00001 // Filename: transformTable.I 00002 // Created by: drose (23Mar05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: TransformTable::is_registered 00018 // Access: Published 00019 // Description: Returns true if this table has been registered. 00020 // Once it has been registered, the set of transforms in 00021 // a TransformTable may not be further modified; but 00022 // it must be registered before it can be assigned to a 00023 // Geom. 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE bool TransformTable:: 00026 is_registered() const { 00027 return _is_registered; 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: TransformTable::register_table 00032 // Access: Published, Static 00033 // Description: Registers a TransformTable for use. This is 00034 // similar to GeomVertexFormat::register_format(). Once 00035 // registered, a TransformTable may no longer be 00036 // modified (although the individual VertexTransform 00037 // objects may modify their reported transforms). 00038 // 00039 // This must be called before a table may be used in a 00040 // Geom. After this call, you should discard the 00041 // original pointer you passed in (which may or may not 00042 // now be invalid) and let its reference count decrement 00043 // normally; you should use only the returned value from 00044 // this point on. 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE CPT(TransformTable) TransformTable:: 00047 register_table(const TransformTable *table) { 00048 // We don't actually bother adding the table object to a registry. 00049 // This means there may be multiple copies of identical registered 00050 // TransformTables. Big deal. We can always go back and make a 00051 // registry later if we really need it. 00052 if (table->is_registered()) { 00053 return table; 00054 } 00055 00056 ((TransformTable *)table)->do_register(); 00057 return table; 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: TransformTable::get_num_transforms 00062 // Access: Published 00063 // Description: Returns the number of transforms in the table. 00064 //////////////////////////////////////////////////////////////////// 00065 INLINE int TransformTable:: 00066 get_num_transforms() const { 00067 return _transforms.size(); 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: TransformTable::get_transform 00072 // Access: Published 00073 // Description: Returns the nth transform in the table. 00074 //////////////////////////////////////////////////////////////////// 00075 INLINE const VertexTransform *TransformTable:: 00076 get_transform(int n) const { 00077 nassertr(n >= 0 && n < (int)_transforms.size(), NULL); 00078 return _transforms[n]; 00079 } 00080 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: TransformTable::get_modified 00083 // Access: Published 00084 // Description: Returns a sequence number that's guaranteed to change 00085 // at least when any VertexTransforms in the table 00086 // change. (However, this is only true for a registered 00087 // table. An unregistered table may or may not 00088 // reflect an update here when a VertexTransform 00089 // changes.) 00090 //////////////////////////////////////////////////////////////////// 00091 INLINE UpdateSeq TransformTable:: 00092 get_modified(Thread *current_thread) const { 00093 CDReader cdata(_cycler, current_thread); 00094 return cdata->_modified; 00095 } 00096 00097 //////////////////////////////////////////////////////////////////// 00098 // Function: TransformTable::update_modified 00099 // Access: Private 00100 // Description: Called internally whenever a nested VertexTransform 00101 // reports that it has been modified. 00102 //////////////////////////////////////////////////////////////////// 00103 INLINE void TransformTable:: 00104 update_modified(UpdateSeq modified, Thread *current_thread) { 00105 CDWriter cdata(_cycler, true, current_thread); 00106 cdata->_modified = modified; 00107 } 00108 00109 //////////////////////////////////////////////////////////////////// 00110 // Function: TransformTable::CData::Constructor 00111 // Access: Public 00112 // Description: 00113 //////////////////////////////////////////////////////////////////// 00114 INLINE TransformTable::CData:: 00115 CData() { 00116 } 00117 00118 //////////////////////////////////////////////////////////////////// 00119 // Function: TransformTable::CData::Copy Constructor 00120 // Access: Public 00121 // Description: 00122 //////////////////////////////////////////////////////////////////// 00123 INLINE TransformTable::CData:: 00124 CData(const TransformTable::CData ©) : 00125 _modified(copy._modified) 00126 { 00127 }