workingNodePath.I 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // Filename: workingNodePath.I
  2. // Created by: drose (16Mar02)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: WorkingNodePath::Constructor
  20. // Access: Public
  21. // Description: Creates a WorkingNodePath that is the same as the
  22. // indicated NodePath. This is generally used to begin
  23. // the traversal of a scene graph with the root
  24. // NodePath.
  25. ////////////////////////////////////////////////////////////////////
  26. INLINE WorkingNodePath::
  27. WorkingNodePath(const NodePath &start) {
  28. nassertv(!start.is_empty());
  29. _next = (WorkingNodePath *)NULL;
  30. _start = start._head;
  31. _node = start.node();
  32. }
  33. ////////////////////////////////////////////////////////////////////
  34. // Function: WorkingNodePath::Copy Constructor
  35. // Access: Public
  36. // Description:
  37. ////////////////////////////////////////////////////////////////////
  38. INLINE WorkingNodePath::
  39. WorkingNodePath(const WorkingNodePath &copy) :
  40. _next(copy._next),
  41. _start(copy._start),
  42. _node(copy._node)
  43. {
  44. nassertv(_next != (WorkingNodePath *)NULL ||
  45. _start != (NodePathComponent *)NULL);
  46. }
  47. ////////////////////////////////////////////////////////////////////
  48. // Function: WorkingNodePath::Constructor
  49. // Access: Public
  50. // Description: Creates a WorkingNodePath that is the same as the
  51. // indicated WorkingNodePath, plus one node. This is
  52. // generally used to continue the traversal to the next
  53. // node.
  54. ////////////////////////////////////////////////////////////////////
  55. INLINE WorkingNodePath::
  56. WorkingNodePath(const WorkingNodePath &parent, PandaNode *child) {
  57. _next = &parent;
  58. _start = (NodePathComponent *)NULL;
  59. _node = child;
  60. }
  61. ////////////////////////////////////////////////////////////////////
  62. // Function: WorkingNodePath::Destructor
  63. // Access: Public
  64. // Description:
  65. ////////////////////////////////////////////////////////////////////
  66. INLINE WorkingNodePath::
  67. ~WorkingNodePath() {
  68. }
  69. ////////////////////////////////////////////////////////////////////
  70. // Function: WorkingNodePath::Copy Assignment Operator
  71. // Access: Public
  72. // Description:
  73. ////////////////////////////////////////////////////////////////////
  74. INLINE void WorkingNodePath::
  75. operator = (const WorkingNodePath &copy) {
  76. _next = copy._next;
  77. _start = copy._start;
  78. _node = copy._node;
  79. nassertv(_next != (WorkingNodePath *)NULL ||
  80. _start != (NodePathComponent *)NULL);
  81. }
  82. ////////////////////////////////////////////////////////////////////
  83. // Function: WorkingNodePath::get_node_path
  84. // Access: Public
  85. // Description: Constructs and returns an actual NodePath that
  86. // represents the same path we have just traversed.
  87. ////////////////////////////////////////////////////////////////////
  88. INLINE NodePath WorkingNodePath::
  89. get_node_path() const {
  90. NodePath result;
  91. result._head = r_get_node_path();
  92. nassertr(result._head != (NodePathComponent *)NULL, NodePath::fail());
  93. return result;
  94. }
  95. ////////////////////////////////////////////////////////////////////
  96. // Function: WorkingNodePath::node
  97. // Access: Public
  98. // Description: Returns the node traversed to so far.
  99. ////////////////////////////////////////////////////////////////////
  100. INLINE PandaNode *WorkingNodePath::
  101. node() const {
  102. return _node;
  103. }
  104. INLINE ostream &
  105. operator << (ostream &out, const WorkingNodePath &node_path) {
  106. node_path.output(out);
  107. return out;
  108. }