qpnodePathComponent.I 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // Filename: qpnodePathComponent.I
  2. // Created by: drose (25Feb02)
  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: qpNodePathComponent::CData::Constructor
  20. // Access: Public
  21. // Description:
  22. ////////////////////////////////////////////////////////////////////
  23. INLINE qpNodePathComponent::CData::
  24. CData() {
  25. _length = 1;
  26. }
  27. ////////////////////////////////////////////////////////////////////
  28. // Function: qpNodePathComponent::CData::Copy Constructor
  29. // Access: Public
  30. // Description:
  31. ////////////////////////////////////////////////////////////////////
  32. INLINE qpNodePathComponent::CData::
  33. CData(const qpNodePathComponent::CData &copy) :
  34. _next(copy._next),
  35. _length(copy._length)
  36. {
  37. }
  38. ////////////////////////////////////////////////////////////////////
  39. // Function: qpNodePathComponent::Constructor
  40. // Access: Private
  41. // Description: Constructs a new qpNodePathComponent from the
  42. // indicated node. Don't try to call this directly; ask
  43. // the PandaNode to do it for you.
  44. ////////////////////////////////////////////////////////////////////
  45. INLINE qpNodePathComponent::
  46. qpNodePathComponent(PandaNode *node, qpNodePathComponent *next) :
  47. _node(node),
  48. _key(0)
  49. {
  50. #ifdef DO_MEMORY_USAGE
  51. MemoryUsage::update_type(this, get_class_type());
  52. #endif
  53. CDWriter cdata(_cycler);
  54. cdata->_next = next;
  55. if (next != (qpNodePathComponent *)NULL) {
  56. cdata->_length = next->get_length() + 1;
  57. }
  58. }
  59. ////////////////////////////////////////////////////////////////////
  60. // Function: qpNodePathComponent::Copy Constructor
  61. // Access: Private
  62. // Description: qpNodePathComponents should not be copied.
  63. ////////////////////////////////////////////////////////////////////
  64. INLINE qpNodePathComponent::
  65. qpNodePathComponent(const qpNodePathComponent &copy) {
  66. nassertv(false);
  67. }
  68. ////////////////////////////////////////////////////////////////////
  69. // Function: qpNodePathComponent::Copy Assignment Operator
  70. // Access: Private
  71. // Description: qpNodePathComponents should not be copied.
  72. ////////////////////////////////////////////////////////////////////
  73. INLINE void qpNodePathComponent::
  74. operator = (const qpNodePathComponent &copy) {
  75. nassertv(false);
  76. }
  77. ////////////////////////////////////////////////////////////////////
  78. // Function: qpNodePathComponent::Destructor
  79. // Access: Public
  80. // Description:
  81. ////////////////////////////////////////////////////////////////////
  82. INLINE qpNodePathComponent::
  83. ~qpNodePathComponent() {
  84. nassertv(_node != (PandaNode *)NULL);
  85. _node->delete_component(this);
  86. }
  87. ////////////////////////////////////////////////////////////////////
  88. // Function: qpNodePathComponent::get_node
  89. // Access: Public
  90. // Description: Returns the node referenced by this component.
  91. ////////////////////////////////////////////////////////////////////
  92. INLINE PandaNode *qpNodePathComponent::
  93. get_node() const {
  94. // We don't have to bother checking if the component has been
  95. // collapsed here, since the _node pointer will still be the same
  96. // even if it has.
  97. nassertr(_node != (PandaNode *)NULL, _node);
  98. return _node;
  99. }
  100. ////////////////////////////////////////////////////////////////////
  101. // Function: qpNodePathComponent::is_collapsed
  102. // Access: Public
  103. // Description: Returns true if this component has been collapsed
  104. // with another component. In this case, the component
  105. // itself is invalid, and the collapsed component should
  106. // be used instead.
  107. ////////////////////////////////////////////////////////////////////
  108. INLINE bool qpNodePathComponent::
  109. is_collapsed() const {
  110. CDReader cdata(_cycler);
  111. return (cdata->_length == 0);
  112. }
  113. ////////////////////////////////////////////////////////////////////
  114. // Function: qpNodePathComponent::get_collapsed
  115. // Access: Public
  116. // Description: If is_collapsed() returns true, this is the component
  117. // that this one has been collapsed with, and should be
  118. // replaced with.
  119. ////////////////////////////////////////////////////////////////////
  120. INLINE qpNodePathComponent *qpNodePathComponent::
  121. get_collapsed() const {
  122. nassertr(is_collapsed(), (qpNodePathComponent *)NULL);
  123. CDReader cdata(_cycler);
  124. return cdata->_next;
  125. }