From 81bc59321f9f8acaa37a57b5ce7521ff1f7f9ed3 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 27 Dec 2004 03:12:14 +0000 Subject: [PATCH] fix broken bone optimization if some verts in a mesh aren't associated with a bone --- stepmania/src/RageModelGeometry.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/stepmania/src/RageModelGeometry.cpp b/stepmania/src/RageModelGeometry.cpp index 352a978736..6918094bca 100644 --- a/stepmania/src/RageModelGeometry.cpp +++ b/stepmania/src/RageModelGeometry.cpp @@ -23,26 +23,23 @@ void RageModelGeometry::OptimizeBones() { msMesh& mesh = m_Meshes[i]; + if( mesh.Vertices.empty() ) + continue; // nothing to optimize + // check to see if all vertices have the same bone index bool bAllVertsUseSameBone = true; - char nBoneIndex; - if( !mesh.Vertices.empty() ) - nBoneIndex = mesh.Vertices[0].bone; - else - nBoneIndex = (char)-1; + char nBoneIndex = mesh.Vertices[0].bone; - if( nBoneIndex != -1 ) + for (unsigned j = 1; j < mesh.Vertices.size(); j++) { - for (unsigned j = 1; j < mesh.Vertices.size(); j++) + if( mesh.Vertices[j].bone != nBoneIndex ) { - if( mesh.Vertices[j].bone != nBoneIndex ) - { - bAllVertsUseSameBone = false; - break; - } + bAllVertsUseSameBone = false; + break; } } + if( bAllVertsUseSameBone ) { mesh.nBoneIndex = nBoneIndex;