From 7ecaf74dd33cdbf2328b1a63ca292a1976cf49b9 Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 5 Jan 2023 11:15:50 +0800 Subject: [PATCH] Remove incorrect animation data in some b3d models, see #4829 --- src/graphics/b3d_mesh_loader.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/graphics/b3d_mesh_loader.cpp b/src/graphics/b3d_mesh_loader.cpp index 81243f486..38a50ae6e 100644 --- a/src/graphics/b3d_mesh_loader.cpp +++ b/src/graphics/b3d_mesh_loader.cpp @@ -142,13 +142,20 @@ SP::SPMesh* B3DMeshLoader::toSPM(scene::CSkinnedMesh* mesh) wi[b].push_back(core::array()); } - const bool skinned_mesh = !mesh->RootJoints.empty() && + bool skinned_mesh = !mesh->RootJoints.empty() && mesh->getFrameCount() > 0; + unsigned idx = 0; if (skinned_mesh) { - unsigned idx = 0; for (unsigned i = 0; i < mesh->RootJoints.size(); i++) computeWeightInfluence(mesh->RootJoints[i], idx, wi); + } + // Some b3d models has incorrect animation data, remove it and treat them + // as static mesh + if (idx == 0) + skinned_mesh = false; + if (skinned_mesh) + { spm->m_total_joints = idx; spm->m_joint_using = idx; spm->m_bind_frame = m_straight_frame;