]> git.lizzy.rs Git - irrlicht.git/blobdiff - source/Irrlicht/CAnimatedMeshSceneNode.cpp
Avoid reskinning joints for animated meshes twice for each frame.
[irrlicht.git] / source / Irrlicht / CAnimatedMeshSceneNode.cpp
index 21733a0ecfb643fd35c239d7f315378bc4c8659b..9d92e03875c54c5eb31f7988b7e2370a64c2948f 100644 (file)
@@ -192,7 +192,7 @@ IMesh * CAnimatedMeshSceneNode::getMeshForCurrentFrame()
                // As multiple scene nodes may be sharing the same skinned mesh, we have to\r
                // re-animate it every frame to ensure that this node gets the mesh that it needs.\r
 \r
-               CSkinnedMesh* skinnedMesh = reinterpret_cast<CSkinnedMesh*>(Mesh);\r
+               CSkinnedMesh* skinnedMesh = static_cast<CSkinnedMesh*>(Mesh);\r
 \r
                if (JointMode == EJUOR_CONTROL)//write to mesh\r
                        skinnedMesh->transferJointsToMesh(JointChildSceneNodes);\r
@@ -236,15 +236,6 @@ void CAnimatedMeshSceneNode::OnAnimate(u32 timeMs)
 \r
        // set CurrentFrameNr\r
        buildFrameNr(timeMs-LastTimeMs);\r
-\r
-       // update bbox\r
-       if (Mesh)\r
-       {\r
-               scene::IMesh * mesh = getMeshForCurrentFrame();\r
-\r
-               if (mesh)\r
-                       Box = mesh->getBoundingBox();\r
-       }\r
        LastTimeMs = timeMs;\r
 \r
        IAnimatedMeshSceneNode::OnAnimate(timeMs);\r
@@ -276,6 +267,7 @@ void CAnimatedMeshSceneNode::render()
                #ifdef _DEBUG\r
                        os::Printer::log("Animated Mesh returned no mesh to render.", Mesh->getDebugName(), ELL_WARNING);\r
                #endif\r
+               return;\r
        }\r
 \r
        driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);\r
@@ -343,8 +335,8 @@ void CAnimatedMeshSceneNode::render()
                // show normals\r
                if (DebugDataVisible & scene::EDS_NORMALS)\r
                {\r
-                       const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);\r
-                       const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);\r
+                       const f32 debugNormalLength = 1.f;\r
+                       const video::SColor debugNormalColor = video::SColor(255, 34, 221, 221);\r
                        const u32 count = m->getMeshBufferCount();\r
 \r
                        // draw normals\r
@@ -652,54 +644,6 @@ bool CAnimatedMeshSceneNode::isReadOnlyMaterials() const
 }\r
 \r
 \r
-//! Writes attributes of the scene node.\r
-void CAnimatedMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const\r
-{\r
-       IAnimatedMeshSceneNode::serializeAttributes(out, options);\r
-\r
-       if (options && (options->Flags&io::EARWF_USE_RELATIVE_PATHS) && options->Filename)\r
-       {\r
-               const io::path path = SceneManager->getFileSystem()->getRelativeFilename(\r
-                               SceneManager->getFileSystem()->getAbsolutePath(SceneManager->getMeshCache()->getMeshName(Mesh).getPath()),\r
-                               options->Filename);\r
-               out->addString("Mesh", path.c_str());\r
-       }\r
-       else\r
-               out->addString("Mesh", SceneManager->getMeshCache()->getMeshName(Mesh).getPath().c_str());\r
-       out->addBool("Looping", Looping);\r
-       out->addBool("ReadOnlyMaterials", ReadOnlyMaterials);\r
-       out->addFloat("FramesPerSecond", FramesPerSecond);\r
-       out->addInt("StartFrame", StartFrame);\r
-       out->addInt("EndFrame", EndFrame);\r
-}\r
-\r
-\r
-//! Reads attributes of the scene node.\r
-void CAnimatedMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)\r
-{\r
-       IAnimatedMeshSceneNode::deserializeAttributes(in, options);\r
-\r
-       io::path oldMeshStr = SceneManager->getMeshCache()->getMeshName(Mesh);\r
-       io::path newMeshStr = in->getAttributeAsString("Mesh");\r
-\r
-       Looping = in->getAttributeAsBool("Looping");\r
-       ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials");\r
-       FramesPerSecond = in->getAttributeAsFloat("FramesPerSecond");\r
-       StartFrame = in->getAttributeAsInt("StartFrame");\r
-       EndFrame = in->getAttributeAsInt("EndFrame");\r
-\r
-       if (newMeshStr != "" && oldMeshStr != newMeshStr)\r
-       {\r
-               IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str());\r
-\r
-               if (newAnimatedMesh)\r
-                       setMesh(newAnimatedMesh);\r
-       }\r
-\r
-       // TODO: read animation names instead of frame begin and ends\r
-}\r
-\r
-\r
 //! Sets a new mesh\r
 void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh)\r
 {\r
@@ -795,7 +739,7 @@ void CAnimatedMeshSceneNode::animateJoints(bool CalculateAbsolutePositions)
                checkJoints();\r
                const f32 frame = getFrameNr(); //old?\r
 \r
-               CSkinnedMesh* skinnedMesh=reinterpret_cast<CSkinnedMesh*>(Mesh);\r
+               CSkinnedMesh* skinnedMesh=static_cast<CSkinnedMesh*>(Mesh);\r
 \r
                skinnedMesh->transferOnlyJointsHintsToMesh( JointChildSceneNodes );\r
                skinnedMesh->animateMesh(frame, 1.0f);\r