@@ -147,23 +147,6 @@ void AnimatedMeshSceneNode::OnRegisterSceneNode()
147147 }
148148}
149149
150- IMesh *AnimatedMeshSceneNode::getMeshForCurrentFrame ()
151- {
152- if (Mesh->getMeshType () != EAMT_SKINNED) {
153- return Mesh;
154- }
155-
156- // As multiple scene nodes may be sharing the same skinned mesh, we have to
157- // re-animate it every frame to ensure that this node gets the mesh that it needs.
158-
159- auto *skinnedMesh = static_cast <SkinnedMesh *>(Mesh);
160-
161- // Matrices have already been calculated in OnAnimate
162- // TODO skinnedMesh->skinMesh(PerJoint.GlobalMatrices);
163-
164- return skinnedMesh;
165- }
166-
167150// ! OnAnimate() is called just before rendering the whole scene.
168151void AnimatedMeshSceneNode::OnAnimate (u32 timeMs)
169152{
@@ -213,23 +196,25 @@ void AnimatedMeshSceneNode::render()
213196
214197 ++PassCount;
215198
216- scene::IMesh *m = getMeshForCurrentFrame ();
217- assert (m);
218-
219199 if (auto *sm = dynamic_cast <SkinnedMesh *>(Mesh)) {
220- // TODO check whether there are any weights to make use of these joint transforms
221- driver->setJointTransforms (sm->calculateSkinMatrices (PerJoint.GlobalMatrices ));
222200 sm->rigidAnimation (PerJoint.GlobalMatrices );
201+ // TODO check whether there are any weights to make use of these joint transforms
202+ if (sm->useSoftwareSkinning ()) {
203+ // Perform software skinning; matrices have already been calculated in OnAnimate
204+ sm->skinMesh (PerJoint.GlobalMatrices );
205+ } else {
206+ driver->setJointTransforms (sm->calculateSkinMatrices (PerJoint.GlobalMatrices ));
207+ }
223208 }
224209 driver->setTransform (video::ETS_WORLD, AbsoluteTransformation);
225210
226- for (u32 i = 0 ; i < m ->getMeshBufferCount (); ++i) {
211+ for (u32 i = 0 ; i < Mesh ->getMeshBufferCount (); ++i) {
227212 const bool transparent = driver->needsTransparentRenderPass (Materials[i]);
228213
229214 // only render transparent buffer if this is the transparent render pass
230215 // and solid only in solid pass
231216 if (transparent == isTransparentPass) {
232- scene::IMeshBuffer *mb = m ->getMeshBuffer (i);
217+ scene::IMeshBuffer *mb = Mesh ->getMeshBuffer (i);
233218 const video::SMaterial &material = ReadOnlyMaterials ? mb->getMaterial () : Materials[i];
234219 if (RenderFromIdentity)
235220 driver->setTransform (video::ETS_WORLD, core::IdentityMatrix);
@@ -252,11 +237,11 @@ void AnimatedMeshSceneNode::render()
252237 if (DebugDataVisible & scene::EDS_NORMALS) {
253238 const f32 debugNormalLength = 1 .f ;
254239 const video::SColor debugNormalColor = video::SColor (255 , 34 , 221 , 221 );
255- const u32 count = m ->getMeshBufferCount ();
240+ const u32 count = Mesh ->getMeshBufferCount ();
256241
257242 // draw normals
258243 for (u32 g = 0 ; g < count; ++g) {
259- scene::IMeshBuffer *mb = m ->getMeshBuffer (g);
244+ scene::IMeshBuffer *mb = Mesh ->getMeshBuffer (g);
260245 if (RenderFromIdentity)
261246 driver->setTransform (video::ETS_WORLD, core::IdentityMatrix);
262247 else if (Mesh->getMeshType () == EAMT_SKINNED)
@@ -271,8 +256,8 @@ void AnimatedMeshSceneNode::render()
271256
272257 // show bounding box
273258 if (DebugDataVisible & scene::EDS_BBOX_BUFFERS) {
274- for (u32 g = 0 ; g < m ->getMeshBufferCount (); ++g) {
275- const IMeshBuffer *mb = m ->getMeshBuffer (g);
259+ for (u32 g = 0 ; g < Mesh ->getMeshBufferCount (); ++g) {
260+ const IMeshBuffer *mb = Mesh ->getMeshBuffer (g);
276261
277262 if (Mesh->getMeshType () == EAMT_SKINNED)
278263 driver->setTransform (video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer *)mb)->Transformation );
@@ -305,8 +290,8 @@ void AnimatedMeshSceneNode::render()
305290 debug_mat.ZBuffer = video::ECFN_DISABLED;
306291 driver->setMaterial (debug_mat);
307292
308- for (u32 g = 0 ; g < m ->getMeshBufferCount (); ++g) {
309- const IMeshBuffer *mb = m ->getMeshBuffer (g);
293+ for (u32 g = 0 ; g < Mesh ->getMeshBufferCount (); ++g) {
294+ const IMeshBuffer *mb = Mesh ->getMeshBuffer (g);
310295 if (RenderFromIdentity)
311296 driver->setTransform (video::ETS_WORLD, core::IdentityMatrix);
312297 else if (Mesh->getMeshType () == EAMT_SKINNED)
0 commit comments