Panda3D
 All Classes Functions Variables Enumerations
transformBlendTable.I
1 // Filename: transformBlendTable.I
2 // Created by: drose (24Mar05)
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: TransformBlendTable::get_num_blends
18 // Access: Published
19 // Description: Returns the total number of different blend
20 // combinations in the table.
21 ////////////////////////////////////////////////////////////////////
22 INLINE int TransformBlendTable::
23 get_num_blends() const {
24  return _blends.size();
25 }
26 
27 ////////////////////////////////////////////////////////////////////
28 // Function: TransformBlendTable::get_blend
29 // Access: Published
30 // Description: Returns the nth blend in the table.
31 ////////////////////////////////////////////////////////////////////
33 get_blend(int n) const {
34  nassertr(n >= 0 && n < (int)_blends.size(), _blends[0]);
35  return _blends[n];
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: TransformBlendTable::get_modified
40 // Access: Published
41 // Description: Returns a counter which is guaranteed to increment at
42 // least when any TransformBlends within the table
43 // have changed.
44 ////////////////////////////////////////////////////////////////////
46 get_modified(Thread *current_thread) const {
47  CDLockedReader cdata(_cycler);
48  if (cdata->_global_modified != VertexTransform::get_global_modified(current_thread)) {
49  CDWriter cdataw(((TransformBlendTable *)this)->_cycler, cdata, false);
50  ((TransformBlendTable *)this)->recompute_modified(cdataw, current_thread);
51  return cdataw->_modified;
52  } else {
53  return cdata->_modified;
54  }
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: TransformBlendTable::get_num_transforms
59 // Access: Published
60 // Description: Returns the number of unique VertexTransform objects
61 // represented in the table. This will correspond to
62 // the size of the TransformTable object that would
63 // represent the same table. This is also the same
64 // limit reflected by
65 // GraphicsStateGuardian::get_max_vertex_transform_indices().
66 ////////////////////////////////////////////////////////////////////
67 INLINE int TransformBlendTable::
69  consider_rebuild_index();
70 
71  if (_num_transforms < 0) {
72  // Even if our index is otherwise accurate, we might have recently
73  // added a blend or two, which would necessitate recomputing this
74  // value--which means we need to rebuild the index.
75  ((TransformBlendTable *)this)->rebuild_index();
76  }
77 
78  return _num_transforms;
79 }
80 
81 ////////////////////////////////////////////////////////////////////
82 // Function: TransformBlendTable::get_max_simultaneous_transforms
83 // Access: Published
84 // Description: Returns the maximum number of unique VertexTransform
85 // objects that are applied to any one vertex
86 // simultaneously. This is the same limit reflected by
87 // GraphicsStateGuardian::get_max_vertex_transforms().
88 ////////////////////////////////////////////////////////////////////
89 INLINE int TransformBlendTable::
91  consider_rebuild_index();
92  return _max_simultaneous_transforms;
93 }
94 
95 ////////////////////////////////////////////////////////////////////
96 // Function: TransformBlendTable::set_rows
97 // Access: Published
98 // Description: Specifies the subset of rows (vertices) in the
99 // associated GeomVertexData that this
100 // TransformBlendTable actually affects.
101 ////////////////////////////////////////////////////////////////////
102 INLINE void TransformBlendTable::
103 set_rows(const SparseArray &rows) {
104  _rows = rows;
105 }
106 
107 ////////////////////////////////////////////////////////////////////
108 // Function: TransformBlendTable::get_rows
109 // Access: Published
110 // Description: Returns the subset of rows (vertices) in the
111 // associated GeomVertexData that this
112 // TransformBlendTable actually affects.
113 ////////////////////////////////////////////////////////////////////
115 get_rows() const {
116  return _rows;
117 }
118 
119 ////////////////////////////////////////////////////////////////////
120 // Function: TransformBlendTable::modify_rows
121 // Access: Published
122 // Description: Returns a modifiable reference to the SparseArray
123 // that specifies the subset of rows (vertices) in the
124 // associated GeomVertexData that this
125 // TransformBlendTable actually affects.
126 ////////////////////////////////////////////////////////////////////
129  return _rows;
130 }
131 
132 ////////////////////////////////////////////////////////////////////
133 // Function: TransformBlendTable::consider_rebuild_index
134 // Access: Private
135 // Description: Calls rebuild_index() if the index needs to be
136 // rebuilt.
137 ////////////////////////////////////////////////////////////////////
138 INLINE void TransformBlendTable::
139 consider_rebuild_index() const {
140  if (_blend_index.empty()) {
141  ((TransformBlendTable *)this)->rebuild_index();
142  }
143 }
144 
145 ////////////////////////////////////////////////////////////////////
146 // Function: TransformBlendTable::CData::Constructor
147 // Access: Public
148 // Description:
149 ////////////////////////////////////////////////////////////////////
150 INLINE TransformBlendTable::CData::
151 CData() {
152 }
153 
154 ////////////////////////////////////////////////////////////////////
155 // Function: TransformBlendTable::CData::Copy Constructor
156 // Access: Public
157 // Description:
158 ////////////////////////////////////////////////////////////////////
159 INLINE TransformBlendTable::CData::
160 CData(const TransformBlendTable::CData &copy) :
161  _modified(copy._modified),
162  _global_modified(copy._global_modified)
163 {
164 }
This class records a set of integers, where each integer is either present or not present in the set...
Definition: sparseArray.h:49
UpdateSeq get_modified(Thread *current_thread) const
Returns a counter which is guaranteed to increment at least when any TransformBlends within the table...
void set_rows(const SparseArray &rows)
Specifies the subset of rows (vertices) in the associated GeomVertexData that this TransformBlendTabl...
SparseArray & modify_rows()
Returns a modifiable reference to the SparseArray that specifies the subset of rows (vertices) in the...
static UpdateSeq get_global_modified(Thread *current_thread)
Returns the currently highest VertexTransform::get_modified() value in the world. ...
This template class calls PipelineCycler::read() in the constructor and PipelineCycler::release_read(...
const SparseArray & get_rows() const
Returns the subset of rows (vertices) in the associated GeomVertexData that this TransformBlendTable ...
int get_max_simultaneous_transforms() const
Returns the maximum number of unique VertexTransform objects that are applied to any one vertex simul...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
This defines a single entry in a TransformBlendTable.
int get_num_blends() const
Returns the total number of different blend combinations in the table.
A thread; that is, a lightweight process.
Definition: thread.h:51
const TransformBlend & get_blend(int n) const
Returns the nth blend in the table.
int get_num_transforms() const
Returns the number of unique VertexTransform objects represented in the table.
This structure collects together the different combinations of transforms and blend amounts used by a...
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43