Panda3D
 All Classes Functions Variables Enumerations
transformBlendTable.I
00001 // Filename: transformBlendTable.I
00002 // Created by:  drose (24Mar05)
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: TransformBlendTable::get_num_blends
00018 //       Access: Published
00019 //  Description: Returns the total number of different blend
00020 //               combinations in the table.
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE int TransformBlendTable::
00023 get_num_blends() const {
00024   return _blends.size();
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: TransformBlendTable::get_blend
00029 //       Access: Published
00030 //  Description: Returns the nth blend in the table.
00031 ////////////////////////////////////////////////////////////////////
00032 INLINE const TransformBlend &TransformBlendTable::
00033 get_blend(int n) const {
00034   nassertr(n >= 0 && n < (int)_blends.size(), _blends[0]);
00035   return _blends[n];
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: TransformBlendTable::get_modified
00040 //       Access: Published
00041 //  Description: Returns a counter which is guaranteed to increment at
00042 //               least when any TransformBlends within the table
00043 //               have changed.
00044 ////////////////////////////////////////////////////////////////////
00045 INLINE UpdateSeq TransformBlendTable::
00046 get_modified(Thread *current_thread) const {
00047   CDLockedReader cdata(_cycler);
00048   if (cdata->_global_modified != VertexTransform::get_global_modified(current_thread)) {
00049     CDWriter cdataw(((TransformBlendTable *)this)->_cycler, cdata, false);
00050     ((TransformBlendTable *)this)->recompute_modified(cdataw, current_thread);
00051     return cdataw->_modified;
00052   } else {
00053     return cdata->_modified;
00054   }
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: TransformBlendTable::get_num_transforms
00059 //       Access: Published
00060 //  Description: Returns the number of unique VertexTransform objects
00061 //               represented in the table.  This will correspond to
00062 //               the size of the TransformTable object that would
00063 //               represent the same table.  This is also the same
00064 //               limit reflected by
00065 //               GraphicsStateGuardian::get_max_vertex_transform_indices().
00066 ////////////////////////////////////////////////////////////////////
00067 INLINE int TransformBlendTable::
00068 get_num_transforms() const {
00069   consider_rebuild_index();
00070 
00071   if (_num_transforms < 0) {
00072     // Even if our index is otherwise accurate, we might have recently
00073     // added a blend or two, which would necessitate recomputing this
00074     // value--which means we need to rebuild the index.
00075     ((TransformBlendTable *)this)->rebuild_index();
00076   }
00077 
00078   return _num_transforms;
00079 }
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: TransformBlendTable::get_max_simultaneous_transforms
00083 //       Access: Published
00084 //  Description: Returns the maximum number of unique VertexTransform
00085 //               objects that are applied to any one vertex
00086 //               simultaneously.  This is the same limit reflected by
00087 //               GraphicsStateGuardian::get_max_vertex_transforms().
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE int TransformBlendTable::
00090 get_max_simultaneous_transforms() const {
00091   consider_rebuild_index();
00092   return _max_simultaneous_transforms;
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: TransformBlendTable::set_rows
00097 //       Access: Published
00098 //  Description: Specifies the subset of rows (vertices) in the
00099 //               associated GeomVertexData that this
00100 //               TransformBlendTable actually affects.
00101 ////////////////////////////////////////////////////////////////////
00102 INLINE void TransformBlendTable::
00103 set_rows(const SparseArray &rows) {
00104   _rows = rows;
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //     Function: TransformBlendTable::get_rows
00109 //       Access: Published
00110 //  Description: Returns the subset of rows (vertices) in the
00111 //               associated GeomVertexData that this
00112 //               TransformBlendTable actually affects.
00113 ////////////////////////////////////////////////////////////////////
00114 INLINE const SparseArray &TransformBlendTable::
00115 get_rows() const {
00116   return _rows;
00117 }
00118 
00119 ////////////////////////////////////////////////////////////////////
00120 //     Function: TransformBlendTable::modify_rows
00121 //       Access: Published
00122 //  Description: Returns a modifiable reference to the SparseArray
00123 //               that specifies the subset of rows (vertices) in the
00124 //               associated GeomVertexData that this
00125 //               TransformBlendTable actually affects.
00126 ////////////////////////////////////////////////////////////////////
00127 INLINE SparseArray &TransformBlendTable::
00128 modify_rows() {
00129   return _rows;
00130 }
00131 
00132 ////////////////////////////////////////////////////////////////////
00133 //     Function: TransformBlendTable::consider_rebuild_index
00134 //       Access: Private
00135 //  Description: Calls rebuild_index() if the index needs to be
00136 //               rebuilt.
00137 ////////////////////////////////////////////////////////////////////
00138 INLINE void TransformBlendTable::
00139 consider_rebuild_index() const {
00140   if (_blend_index.empty()) {
00141     ((TransformBlendTable *)this)->rebuild_index();
00142   }
00143 }
00144 
00145 ////////////////////////////////////////////////////////////////////
00146 //     Function: TransformBlendTable::CData::Constructor
00147 //       Access: Public
00148 //  Description:
00149 ////////////////////////////////////////////////////////////////////
00150 INLINE TransformBlendTable::CData::
00151 CData() {
00152 }
00153 
00154 ////////////////////////////////////////////////////////////////////
00155 //     Function: TransformBlendTable::CData::Copy Constructor
00156 //       Access: Public
00157 //  Description:
00158 ////////////////////////////////////////////////////////////////////
00159 INLINE TransformBlendTable::CData::
00160 CData(const TransformBlendTable::CData &copy) :
00161   _modified(copy._modified),
00162   _global_modified(copy._global_modified)
00163 {
00164 }
 All Classes Functions Variables Enumerations