diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2016-04-06 16:12:39 -0400 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2016-04-06 16:12:39 -0400 |
commit | b138ca8aeec421f6e5b1412e7c7fbcefd87570d0 (patch) | |
tree | ee32893aba4b9dd466ca409f41c32cef362467b3 /indra/newview | |
parent | 129702eef3ab7d6046da1bd2f1a5b460912bdb0e (diff) |
SL-366 - more cases where skinned weights can go awry, and a bunch more asserts to verify.
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/llfloatermodelpreview.cpp | 5 | ||||
-rw-r--r-- | indra/newview/llskinningutil.cpp | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index ceb3566d95..cda704f47b 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -3317,14 +3317,17 @@ void LLModelPreview::genBuffers(S32 lod, bool include_skin_weights) LLVector3 pos(vf.mPositions[i].getF32ptr()); const LLModel::weight_list& weight_list = base_mdl->getJointInfluences(pos); + llassert(weight_list.size()>0 && weight_list.size() <= 4); // LLModel::loadModel() should guarantee this LLVector4 w(0,0,0,0); for (U32 i = 0; i < weight_list.size(); ++i) { - F32 wght = llmin(weight_list[i].mWeight, 0.999999f); + F32 wght = llclamp(weight_list[i].mWeight, 0.001f, 0.999f); F32 joint = (F32) weight_list[i].mJointIdx; w.mV[i] = joint + wght; + llassert(w.mV[i]-(S32)w.mV[i]>0.0f); // because weights are non-zero, and range of wt values + //should not cause floating point precision issues. } *(weights_strider++) = w; diff --git a/indra/newview/llskinningutil.cpp b/indra/newview/llskinningutil.cpp index fbe45c8ea6..732afdfa9a 100644 --- a/indra/newview/llskinningutil.cpp +++ b/indra/newview/llskinningutil.cpp @@ -291,12 +291,15 @@ void LLSkinningUtil::checkSkinWeights(LLVector4a* weights, U32 num_vertices, con { F32 *w = weights[j].getF32ptr(); + F32 wsum = 0.0; for (U32 k=0; k<4; ++k) { S32 i = llfloor(w[k]); llassert(i>=0); llassert(i<max_joints); + wsum += w[k]-i; } + llassert(wsum > 0.0f); } } #endif @@ -310,7 +313,7 @@ void LLSkinningUtil::getPerVertexSkinMatrix( LLMatrix4a& final_mat, U32 max_joints) { - + bool valid_weights = true; final_mat.clear(); S32 idx[4]; @@ -336,6 +339,7 @@ void LLSkinningUtil::getPerVertexSkinMatrix( if (handle_bad_scale && scale <= 0.f) { wght = LLVector4(1.0f, 0.0f, 0.0f, 0.0f); + valid_weights = false; } else { @@ -353,5 +357,8 @@ void LLSkinningUtil::getPerVertexSkinMatrix( final_mat.add(src); } + // SL-366 - with weight validation/cleanup code, it should no longer be + // possible to hit the bad scale case. + llassert(valid_weights); } |