Panda3D
workingNodePath.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file workingNodePath.I
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 /**
15  * Creates a WorkingNodePath that is the same as the indicated NodePath. This
16  * is generally used to begin the traversal of a scene graph with the root
17  * NodePath.
18  */
19 INLINE WorkingNodePath::
20 WorkingNodePath(const NodePath &start) {
21  nassertv(!start.is_empty());
22  _next = nullptr;
23  _start = start._head;
24  _node = start.node();
25 }
26 
27 /**
28  *
29  */
30 INLINE WorkingNodePath::
31 WorkingNodePath(const WorkingNodePath &copy) :
32  _next(copy._next),
33  _start(copy._start),
34  _node(copy._node)
35 {
36  nassertv(_next != nullptr ||
37  _start != nullptr);
38 }
39 
40 /**
41  * Creates a WorkingNodePath that is the same as the indicated
42  * WorkingNodePath, plus one node. This is generally used to continue the
43  * traversal to the next node.
44  */
45 INLINE WorkingNodePath::
46 WorkingNodePath(const WorkingNodePath &parent, PandaNode *child) :
47  _next(&parent),
48  _start(nullptr),
49  _node(child) {
50  nassertv(_node != _next->_node);
51 }
52 
53 /**
54  *
55  */
56 INLINE WorkingNodePath::
57 ~WorkingNodePath() {
58 }
59 
60 /**
61  *
62  */
63 INLINE void WorkingNodePath::
64 operator = (const WorkingNodePath &copy) {
65  _next = copy._next;
66  _start = copy._start;
67  _node = copy._node;
68 
69  nassertv(_next != nullptr ||
70  _start != nullptr);
71 }
72 
73 /**
74  * Constructs and returns an actual NodePath that represents the same path we
75  * have just traversed.
76  */
77 INLINE NodePath WorkingNodePath::
78 get_node_path() const {
79  NodePath result;
80  result._head = r_get_node_path();
81  nassertr(result._head != nullptr, NodePath::fail());
82  return result;
83 }
84 
85 /**
86  * Returns the node traversed to so far.
87  */
89 node() const {
90  return _node;
91 }
92 
93 INLINE std::ostream &
94 operator << (std::ostream &out, const WorkingNodePath &node_path) {
95  node_path.output(out);
96  return out;
97 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PandaNode * node() const
Returns the node traversed to so far.
bool is_empty() const
Returns true if the NodePath contains no nodes.
Definition: nodePath.I:188
WorkingNodePath(const NodePath &start)
Creates a WorkingNodePath that is the same as the indicated NodePath.
This is a class designed to support low-overhead traversals of the complete scene graph,...
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
Definition: nodePath.I:149
PandaNode * node() const
Returns the referenced node of the path.
Definition: nodePath.I:227
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161