From a44d26bfbf9092656386cf431de7988273855094 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 22 Oct 2022 17:03:30 +0200 Subject: [PATCH] pgraph: Allow moving a NodePath into a WorkingNodePath efficiently --- panda/src/pgraph/workingNodePath.I | 15 ++++++++++++++- panda/src/pgraph/workingNodePath.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/panda/src/pgraph/workingNodePath.I b/panda/src/pgraph/workingNodePath.I index 1b545c29b8..e4747906c0 100644 --- a/panda/src/pgraph/workingNodePath.I +++ b/panda/src/pgraph/workingNodePath.I @@ -21,7 +21,20 @@ WorkingNodePath(const NodePath &start) { nassertv(!start.is_empty()); _next = nullptr; _start = start._head; - _node = start.node(); + _node = _start->get_node(); +} + +/** + * Creates a WorkingNodePath that is the same as the indicated NodePath. This + * is generally used to begin the traversal of a scene graph with the root + * NodePath. + */ +INLINE WorkingNodePath:: +WorkingNodePath(NodePath &&start) { + nassertv(!start.is_empty()); + _next = nullptr; + _start = std::move(start._head); + _node = _start->get_node(); } /** diff --git a/panda/src/pgraph/workingNodePath.h b/panda/src/pgraph/workingNodePath.h index 9e698897f5..66f44b4ccb 100644 --- a/panda/src/pgraph/workingNodePath.h +++ b/panda/src/pgraph/workingNodePath.h @@ -39,6 +39,7 @@ class EXPCL_PANDA_PGRAPH WorkingNodePath { public: INLINE WorkingNodePath(const NodePath &start); + INLINE WorkingNodePath(NodePath &&start); INLINE WorkingNodePath(const WorkingNodePath ©); INLINE WorkingNodePath(const WorkingNodePath &parent, PandaNode *child); INLINE ~WorkingNodePath();