]> git.lizzy.rs Git - minetest.git/commitdiff
Recalculate normals before adding mesh to the scene
authorx2048 <codeforsmile@gmail.com>
Sun, 2 Jan 2022 13:32:13 +0000 (14:32 +0100)
committerGitHub <noreply@github.com>
Sun, 2 Jan 2022 13:32:13 +0000 (14:32 +0100)
src/client/content_cao.cpp

index a80a3ce4ee15f2d6e15b1fe855855e203f7efc4b..db01945eb565fa28e92e9a76e1df33ea7ea65150 100644 (file)
@@ -764,10 +764,6 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
                grabMatrixNode();
                scene::IAnimatedMesh *mesh = m_client->getMesh(m_prop.mesh, true);
                if (mesh) {
-                       m_animated_meshnode = m_smgr->addAnimatedMeshSceneNode(mesh, m_matrixnode);
-                       m_animated_meshnode->grab();
-                       mesh->drop(); // The scene node took hold of it
-
                        if (!checkMeshNormals(mesh)) {
                                infostream << "GenericCAO: recalculating normals for mesh "
                                        << m_prop.mesh << std::endl;
@@ -775,6 +771,9 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
                                                recalculateNormals(mesh, true, false);
                        }
 
+                       m_animated_meshnode = m_smgr->addAnimatedMeshSceneNode(mesh, m_matrixnode);
+                       m_animated_meshnode->grab();
+                       mesh->drop(); // The scene node took hold of it
                        m_animated_meshnode->animateJoints(); // Needed for some animations
                        m_animated_meshnode->setScale(m_prop.visual_size);