MCPcopy Create free account
hub / github.com/carbonengine/trinity / UpdateBones

Method UpdateBones

trinity/Tr2SkinnedObject.cpp:130–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130void Tr2SkinnedObject::UpdateBones( Be::Time time, Tr2ApexScene* apexScene )
131{
132 CCP_STATS_ZONE( __FUNCTION__ );
133
134 m_hasDynamicBounds = false;
135
136 if( m_visualModel == NULL || m_visualModel->GetSkeleton() == NULL )
137 {
138 return;
139 }
140
141 unsigned numBones = 0;
142 bool isAnimRig = false;
143 const std::string* boneList = NULL;
144 bool rebuildMapping = false;
145 TriGeometryResSkeletonData* skel = m_visualModel->GetSkeleton();
146
147 if( m_animationUpdater != NULL )
148 {
149 boneList = m_animationUpdater->GetAnimationBoneList( numBones );
150
151 if( boneList )
152 {
153 rebuildMapping = ( numBones != m_skinningMatrixCount );
154 isAnimRig = numBones > 0;
155 }
156 }
157
158 if( boneList == NULL && skel != NULL )
159 {
160 CCP_STATS_ZONE( "UpdateBones_BuildRenderRigBoneList" );
161
162 // Either the animationUpdater is NULL or it hasn't been set up fully yet,
163 // so create a new boneList based off the render rig. This allows rendering
164 // of a skinned model without an animation playing - it'll be static in
165 // the bind pose.
166 unsigned int numRenderRigBones = (unsigned int)skel->m_joints.size();
167 if( m_numRenderRigBones != numRenderRigBones )
168 {
169 // Recreate mapping if the number of renderRigBones has changed, this is definitely hacky
170 m_numRenderRigBones = numRenderRigBones;
171 m_renderRigBoneList.resize( numRenderRigBones );
172 for( unsigned int i = 0; i < numRenderRigBones; ++i )
173 {
174 m_renderRigBoneList[i] = skel->m_joints[i].m_name;
175 }
176 rebuildMapping = true;
177 }
178
179 if( m_numRenderRigBones == 0 )
180 {
181 // Guard against an empty skeleton - shouldn't happen but can
182 // if assets are bad.
183 CCP_LOGERR(
184 "Tr2SkinnedObject '%s' has an empty skeleton in visual model from '%s'",
185 m_name.c_str(),
186 m_visualModel->GetGeometryResPath() );
187 m_renderRigBoneList.push_back( "Render_rig_missing" );

Callers

nothing calls this directly

Calls 9

sizeMethod · 0.80
ResetBindingsMethod · 0.80
GetDynamicBoundingBoxMethod · 0.80
GetSkeletonMethod · 0.45
GetAnimationBoneListMethod · 0.45
GetGeometryResPathMethod · 0.45
BindToRigMethod · 0.45
FindJointMethod · 0.45

Tested by

no test coverage detected