00001 // Filename: workingNodePath.I 00002 // Created by: drose (16Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: WorkingNodePath::Constructor 00022 // Access: Public 00023 // Description: Creates a WorkingNodePath that is the same as the 00024 // indicated NodePath. This is generally used to begin 00025 // the traversal of a scene graph with the root 00026 // NodePath. 00027 //////////////////////////////////////////////////////////////////// 00028 INLINE WorkingNodePath:: 00029 WorkingNodePath(const NodePath &start) { 00030 nassertv(!start.is_empty()); 00031 _next = (WorkingNodePath *)NULL; 00032 _start = start._head; 00033 _node = start.node(); 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: WorkingNodePath::Copy Constructor 00038 // Access: Public 00039 // Description: 00040 //////////////////////////////////////////////////////////////////// 00041 INLINE WorkingNodePath:: 00042 WorkingNodePath(const WorkingNodePath ©) : 00043 _next(copy._next), 00044 _start(copy._start), 00045 _node(copy._node) 00046 { 00047 nassertv(_next != (WorkingNodePath *)NULL || 00048 _start != (NodePathComponent *)NULL); 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: WorkingNodePath::Constructor 00053 // Access: Public 00054 // Description: Creates a WorkingNodePath that is the same as the 00055 // indicated WorkingNodePath, plus one node. This is 00056 // generally used to continue the traversal to the next 00057 // node. 00058 //////////////////////////////////////////////////////////////////// 00059 INLINE WorkingNodePath:: 00060 WorkingNodePath(const WorkingNodePath &parent, PandaNode *child) { 00061 _next = &parent; 00062 _start = (NodePathComponent *)NULL; 00063 _node = child; 00064 } 00065 00066 //////////////////////////////////////////////////////////////////// 00067 // Function: WorkingNodePath::Destructor 00068 // Access: Public 00069 // Description: 00070 //////////////////////////////////////////////////////////////////// 00071 INLINE WorkingNodePath:: 00072 ~WorkingNodePath() { 00073 } 00074 00075 //////////////////////////////////////////////////////////////////// 00076 // Function: WorkingNodePath::Copy Assignment Operator 00077 // Access: Public 00078 // Description: 00079 //////////////////////////////////////////////////////////////////// 00080 INLINE void WorkingNodePath:: 00081 operator = (const WorkingNodePath ©) { 00082 _next = copy._next; 00083 _start = copy._start; 00084 _node = copy._node; 00085 00086 nassertv(_next != (WorkingNodePath *)NULL || 00087 _start != (NodePathComponent *)NULL); 00088 } 00089 00090 //////////////////////////////////////////////////////////////////// 00091 // Function: WorkingNodePath::get_node_path 00092 // Access: Public 00093 // Description: Constructs and returns an actual NodePath that 00094 // represents the same path we have just traversed. 00095 //////////////////////////////////////////////////////////////////// 00096 INLINE NodePath WorkingNodePath:: 00097 get_node_path() const { 00098 NodePath result; 00099 result._head = r_get_node_path(); 00100 nassertr(result._head != (NodePathComponent *)NULL, NodePath::fail()); 00101 return result; 00102 } 00103 00104 //////////////////////////////////////////////////////////////////// 00105 // Function: WorkingNodePath::node 00106 // Access: Public 00107 // Description: Returns the node traversed to so far. 00108 //////////////////////////////////////////////////////////////////// 00109 INLINE PandaNode *WorkingNodePath:: 00110 node() const { 00111 return _node; 00112 } 00113 00114 INLINE ostream & 00115 operator << (ostream &out, const WorkingNodePath &node_path) { 00116 node_path.output(out); 00117 return out; 00118 }