transformTable.I 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // Filename: transformTable.I
  2. // Created by: drose (23Mar05)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. ////////////////////////////////////////////////////////////////////
  15. // Function: TransformTable::is_registered
  16. // Access: Published
  17. // Description: Returns true if this table has been registered.
  18. // Once it has been registered, the set of transforms in
  19. // a TransformTable may not be further modified; but
  20. // it must be registered before it can be assigned to a
  21. // Geom.
  22. ////////////////////////////////////////////////////////////////////
  23. INLINE bool TransformTable::
  24. is_registered() const {
  25. return _is_registered;
  26. }
  27. ////////////////////////////////////////////////////////////////////
  28. // Function: TransformTable::register_table
  29. // Access: Published, Static
  30. // Description: Registers a TransformTable for use. This is
  31. // similar to GeomVertexFormat::register_format(). Once
  32. // registered, a TransformTable may no longer be
  33. // modified (although the individual VertexTransform
  34. // objects may modify their reported transforms).
  35. //
  36. // This must be called before a table may be used in a
  37. // Geom. After this call, you should discard the
  38. // original pointer you passed in (which may or may not
  39. // now be invalid) and let its reference count decrement
  40. // normally; you should use only the returned value from
  41. // this point on.
  42. ////////////////////////////////////////////////////////////////////
  43. INLINE CPT(TransformTable) TransformTable::
  44. register_table(const TransformTable *table) {
  45. // We don't actually bother adding the table object to a registry.
  46. // This means there may be multiple copies of identical registered
  47. // TransformTables. Big deal. We can always go back and make a
  48. // registry later if we really need it.
  49. if (table->is_registered()) {
  50. return table;
  51. }
  52. ((TransformTable *)table)->do_register();
  53. return table;
  54. }
  55. ////////////////////////////////////////////////////////////////////
  56. // Function: TransformTable::get_num_transforms
  57. // Access: Published
  58. // Description: Returns the number of transforms in the table.
  59. ////////////////////////////////////////////////////////////////////
  60. INLINE int TransformTable::
  61. get_num_transforms() const {
  62. return _transforms.size();
  63. }
  64. ////////////////////////////////////////////////////////////////////
  65. // Function: TransformTable::get_transform
  66. // Access: Published
  67. // Description: Returns the nth transform in the table.
  68. ////////////////////////////////////////////////////////////////////
  69. INLINE const VertexTransform *TransformTable::
  70. get_transform(int n) const {
  71. nassertr(n >= 0 && n < (int)_transforms.size(), NULL);
  72. return _transforms[n];
  73. }
  74. ////////////////////////////////////////////////////////////////////
  75. // Function: TransformTable::get_modified
  76. // Access: Published
  77. // Description: Returns a sequence number that's guaranteed to change
  78. // at least when any VertexTransforms in the table
  79. // change. (However, this is only true for a registered
  80. // table. An unregistered table may or may not
  81. // reflect an update here when a VertexTransform
  82. // changes.)
  83. ////////////////////////////////////////////////////////////////////
  84. INLINE UpdateSeq TransformTable::
  85. get_modified(Thread *current_thread) const {
  86. CDReader cdata(_cycler, current_thread);
  87. return cdata->_modified;
  88. }
  89. ////////////////////////////////////////////////////////////////////
  90. // Function: TransformTable::update_modified
  91. // Access: Private
  92. // Description: Called internally whenever a nested VertexTransform
  93. // reports that it has been modified.
  94. ////////////////////////////////////////////////////////////////////
  95. INLINE void TransformTable::
  96. update_modified(UpdateSeq modified, Thread *current_thread) {
  97. CDWriter cdata(_cycler, true, current_thread);
  98. cdata->_modified = modified;
  99. }
  100. ////////////////////////////////////////////////////////////////////
  101. // Function: TransformTable::CData::Constructor
  102. // Access: Public
  103. // Description:
  104. ////////////////////////////////////////////////////////////////////
  105. INLINE TransformTable::CData::
  106. CData() {
  107. }
  108. ////////////////////////////////////////////////////////////////////
  109. // Function: TransformTable::CData::Copy Constructor
  110. // Access: Public
  111. // Description:
  112. ////////////////////////////////////////////////////////////////////
  113. INLINE TransformTable::CData::
  114. CData(const TransformTable::CData &copy) :
  115. _modified(copy._modified)
  116. {
  117. }