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