Panda3D
transformBlendTable.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 transformBlendTable.I
10  * @author drose
11  * @date 2005-03-24
12  */
13 
14 /**
15  * Returns the total number of different blend combinations in the table.
16  */
17 INLINE size_t TransformBlendTable::
18 get_num_blends() const {
19  return _blends.size();
20 }
21 
22 /**
23  * Returns the nth blend in the table.
24  */
26 get_blend(size_t n) const {
27  nassertr(n < _blends.size(), _blends[0]);
28  return _blends[n];
29 }
30 
31 /**
32  * Returns a counter which is guaranteed to increment at least when any
33  * TransformBlends within the table have changed.
34  */
36 get_modified(Thread *current_thread) const {
37  CDLockedReader cdata(_cycler);
38  if (cdata->_global_modified != VertexTransform::get_global_modified(current_thread)) {
39  CDWriter cdataw(((TransformBlendTable *)this)->_cycler, cdata, false);
40  ((TransformBlendTable *)this)->recompute_modified(cdataw, current_thread);
41  return cdataw->_modified;
42  } else {
43  return cdata->_modified;
44  }
45 }
46 
47 /**
48  * Returns the number of unique VertexTransform objects represented in the
49  * table. This will correspond to the size of the TransformTable object that
50  * would represent the same table. This is also the same limit reflected by
51  * GraphicsStateGuardian::get_max_vertex_transform_indices().
52  */
53 INLINE int TransformBlendTable::
54 get_num_transforms() const {
55  consider_rebuild_index();
56 
57  if (_num_transforms < 0) {
58  // Even if our index is otherwise accurate, we might have recently added a
59  // blend or two, which would necessitate recomputing this value--which
60  // means we need to rebuild the index.
61  ((TransformBlendTable *)this)->rebuild_index();
62  }
63 
64  return _num_transforms;
65 }
66 
67 /**
68  * Returns the maximum number of unique VertexTransform objects that are
69  * applied to any one vertex simultaneously. This is the same limit reflected
70  * by GraphicsStateGuardian::get_max_vertex_transforms().
71  */
72 INLINE int TransformBlendTable::
73 get_max_simultaneous_transforms() const {
74  consider_rebuild_index();
75  return _max_simultaneous_transforms;
76 }
77 
78 /**
79  * Specifies the subset of rows (vertices) in the associated GeomVertexData
80  * that this TransformBlendTable actually affects.
81  */
82 INLINE void TransformBlendTable::
83 set_rows(const SparseArray &rows) {
84  _rows = rows;
85 }
86 
87 /**
88  * Returns the subset of rows (vertices) in the associated GeomVertexData that
89  * this TransformBlendTable actually affects.
90  */
91 INLINE const SparseArray &TransformBlendTable::
92 get_rows() const {
93  return _rows;
94 }
95 
96 /**
97  * Returns a modifiable reference to the SparseArray that specifies the subset
98  * of rows (vertices) in the associated GeomVertexData that this
99  * TransformBlendTable actually affects.
100  */
103  return _rows;
104 }
105 
106 /**
107  * Calls rebuild_index() if the index needs to be rebuilt.
108  */
109 INLINE void TransformBlendTable::
110 consider_rebuild_index() const {
111  if (_blend_index.empty()) {
112  ((TransformBlendTable *)this)->rebuild_index();
113  }
114 }
115 
116 /**
117  *
118  */
119 INLINE TransformBlendTable::CData::
120 CData() {
121 }
122 
123 /**
124  *
125  */
126 INLINE TransformBlendTable::CData::
127 CData(const TransformBlendTable::CData &copy) :
128  _modified(copy._modified),
129  _global_modified(copy._global_modified)
130 {
131 }
get_blend
Returns the nth blend in the table.
This class records a set of integers, where each integer is either present or not present in the set.
Definition: sparseArray.h:42
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 defines a single entry in a TransformBlendTable.
get_modified
Returns a counter which is guaranteed to increment at least when any TransformBlends within the table...
set_rows
Specifies the subset of rows (vertices) in the associated GeomVertexData that this TransformBlendTabl...
A thread; that is, a lightweight process.
Definition: thread.h:46
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:37