diff options
Diffstat (limited to 'indra/newview/llskinningutil.cpp')
-rw-r--r-- | indra/newview/llskinningutil.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp index bcbeee6958..5fd2248060 100644 --- a/indra/newview/llskinningutil.cpp +++ b/indra/newview/llskinningutil.cpp @@ -154,6 +154,8 @@ void LLSkinningUtil::remapSkinInfoJoints(LLVOAvatar *avatar, LLMeshSkinInfo* ski return; } + U32 max_joints = getMeshJointCount(skin); + // Compute the remap std::vector<U32> j_proxy(skin->mJointNames.size()); for (U32 j = 0; j < skin->mJointNames.size(); ++j) @@ -163,13 +165,19 @@ void LLSkinningUtil::remapSkinInfoJoints(LLVOAvatar *avatar, LLMeshSkinInfo* ski } S32 top = 0; std::vector<U32> j_remap(skin->mJointNames.size()); - // Fill in j_remap for all joints that will make the cut. + // Fill in j_remap for all joints that will be kept. for (U32 j = 0; j < skin->mJointNames.size(); ++j) { if (j_proxy[j] == j) { // Joint will be included - j_remap[j] = top++; + j_remap[j] = top; + if (top < max_joints-1) + { + top++; + } + + } } // Then use j_proxy to fill in j_remap for the joints that will be discarded @@ -189,7 +197,7 @@ void LLSkinningUtil::remapSkinInfoJoints(LLVOAvatar *avatar, LLMeshSkinInfo* ski for (U32 j = 0; j < skin->mJointNames.size(); ++j) { - if (j_proxy[j] == j) + if (j_proxy[j] == j && new_joint_names.size() < max_joints) { new_joint_names.push_back(skin->mJointNames[j]); new_inv_bind_matrix.push_back(skin->mInvBindMatrix[j]); @@ -199,6 +207,7 @@ void LLSkinningUtil::remapSkinInfoJoints(LLVOAvatar *avatar, LLMeshSkinInfo* ski } } } + llassert(new_joint_names.size() <= max_joints); for (U32 j = 0; j < skin->mJointNames.size(); ++j) { |