summaryrefslogtreecommitdiff
path: root/indra/newview/llskinningutil.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2016-11-30 14:03:54 -0500
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2016-11-30 14:03:54 -0500
commit93db7eacbd1e46c78f8f5d0071578b9bed3202ac (patch)
treee0394c9a47876759aafc92461d3226b0184340e1 /indra/newview/llskinningutil.cpp
parent4c2144e1153fb71544140bb51630b13e17ead6d3 (diff)
SL-540 - fix for regression in handling of out-of-range joint indices in skin weights
Diffstat (limited to 'indra/newview/llskinningutil.cpp')
-rw-r--r--indra/newview/llskinningutil.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp
index b2fd1744bc..cf09f6f978 100644
--- a/indra/newview/llskinningutil.cpp
+++ b/indra/newview/llskinningutil.cpp
@@ -64,6 +64,7 @@ void LLSkinningUtil::scrubInvalidJoints(LLVOAvatar *avatar, LLMeshSkinInfo* skin
// needed for handling of any legacy bad data.
if (!avatar->getJoint(skin->mJointNames[j]))
{
+ LL_DEBUGS("Avatar") << "Mesh rigged to invalid joint" << skin->mJointNames[j] << LL_ENDL;
skin->mJointNames[j] = "mPelvis";
}
}
@@ -140,6 +141,24 @@ void LLSkinningUtil::checkSkinWeights(LLVector4a* weights, U32 num_vertices, con
#endif
}
+void LLSkinningUtil::scrubSkinWeights(LLVector4a* weights, U32 num_vertices, const LLMeshSkinInfo* skin)
+{
+ const S32 max_joints = skin->mJointNames.size();
+ for (U32 j=0; j<num_vertices; j++)
+ {
+ F32 *w = weights[j].getF32ptr();
+
+ for (U32 k=0; k<4; ++k)
+ {
+ S32 i = llfloor(w[k]);
+ F32 f = w[k]-i;
+ i = llclamp(i,0,max_joints-1);
+ w[k] = i + f;
+ }
+ }
+ checkSkinWeights(weights, num_vertices, skin);
+}
+
// static
void LLSkinningUtil::getPerVertexSkinMatrix(
F32* weights,