Panda3D
 All Classes Functions Variables Enumerations
transformTable.I
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: TransformTable::is_registered
18 // Access: Published
19 // Description: Returns true if this table has been registered.
20 // Once it has been registered, the set of transforms in
21 // a TransformTable may not be further modified; but
22 // it must be registered before it can be assigned to a
23 // Geom.
24 ////////////////////////////////////////////////////////////////////
25 INLINE bool TransformTable::
26 is_registered() const {
27  return _is_registered;
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: TransformTable::register_table
32 // Access: Published, Static
33 // Description: Registers a TransformTable for use. This is
34 // similar to GeomVertexFormat::register_format(). Once
35 // registered, a TransformTable may no longer be
36 // modified (although the individual VertexTransform
37 // objects may modify their reported transforms).
38 //
39 // This must be called before a table may be used in a
40 // Geom. After this call, you should discard the
41 // original pointer you passed in (which may or may not
42 // now be invalid) and let its reference count decrement
43 // normally; you should use only the returned value from
44 // this point on.
45 ////////////////////////////////////////////////////////////////////
46 INLINE CPT(TransformTable) TransformTable::
47 register_table(const TransformTable *table) {
48  // We don't actually bother adding the table object to a registry.
49  // This means there may be multiple copies of identical registered
50  // TransformTables. Big deal. We can always go back and make a
51  // registry later if we really need it.
52  if (table->is_registered()) {
53  return table;
54  }
55 
56  ((TransformTable *)table)->do_register();
57  return table;
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: TransformTable::get_num_transforms
62 // Access: Published
63 // Description: Returns the number of transforms in the table.
64 ////////////////////////////////////////////////////////////////////
65 INLINE int TransformTable::
67  return _transforms.size();
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function: TransformTable::get_transform
72 // Access: Published
73 // Description: Returns the nth transform in the table.
74 ////////////////////////////////////////////////////////////////////
76 get_transform(int n) const {
77  nassertr(n >= 0 && n < (int)_transforms.size(), NULL);
78  return _transforms[n];
79 }
80 
81 ////////////////////////////////////////////////////////////////////
82 // Function: TransformTable::get_modified
83 // Access: Published
84 // Description: Returns a sequence number that's guaranteed to change
85 // at least when any VertexTransforms in the table
86 // change. (However, this is only true for a registered
87 // table. An unregistered table may or may not
88 // reflect an update here when a VertexTransform
89 // changes.)
90 ////////////////////////////////////////////////////////////////////
92 get_modified(Thread *current_thread) const {
93  CDReader cdata(_cycler, current_thread);
94  return cdata->_modified;
95 }
96 
97 ////////////////////////////////////////////////////////////////////
98 // Function: TransformTable::update_modified
99 // Access: Private
100 // Description: Called internally whenever a nested VertexTransform
101 // reports that it has been modified.
102 ////////////////////////////////////////////////////////////////////
103 INLINE void TransformTable::
104 update_modified(UpdateSeq modified, Thread *current_thread) {
105  CDWriter cdata(_cycler, true, current_thread);
106  cdata->_modified = modified;
107 }
108 
109 ////////////////////////////////////////////////////////////////////
110 // Function: TransformTable::CData::Constructor
111 // Access: Public
112 // Description:
113 ////////////////////////////////////////////////////////////////////
114 INLINE TransformTable::CData::
115 CData() {
116 }
117 
118 ////////////////////////////////////////////////////////////////////
119 // Function: TransformTable::CData::Copy Constructor
120 // Access: Public
121 // Description:
122 ////////////////////////////////////////////////////////////////////
123 INLINE TransformTable::CData::
124 CData(const TransformTable::CData &copy) :
125  _modified(copy._modified)
126 {
127 }
bool is_registered() const
Returns true if this table has been registered.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This is an abstract base class that holds a pointer to some transform, computed in some arbitrary way...
UpdateSeq get_modified(Thread *current_thread) const
Returns a sequence number that&#39;s guaranteed to change at least when any VertexTransforms in the table...
const VertexTransform * get_transform(int n) const
Returns the nth transform in the table.
Stores the total set of VertexTransforms that the vertices in a particular GeomVertexData object migh...
A thread; that is, a lightweight process.
Definition: thread.h:51
int get_num_transforms() const
Returns the number of transforms in the table.
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43