diff options
Diffstat (limited to 'indra/llprimitive')
-rw-r--r-- | indra/llprimitive/llmodel.cpp | 8 | ||||
-rw-r--r-- | indra/llprimitive/llmodel.h | 18 |
2 files changed, 21 insertions, 5 deletions
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index ea0ea931af..def276c808 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1692,13 +1692,13 @@ LLModel::weight_list& LLModel::getJointInfluences(const LLVector3& pos) } else { //no exact match found, get closest point - const F32 epsilon = 2.f/65536; + const F32 epsilon = 1e-5f; weight_map::iterator iter_up = mSkinWeights.lower_bound(pos); weight_map::iterator iter_down = ++iter_up; weight_map::iterator best = iter_up; - F32 min_dist = (iter->first - pos).magVecSquared(); + F32 min_dist = (iter->first - pos).magVec(); bool done = false; while (!done) @@ -1709,7 +1709,7 @@ LLModel::weight_list& LLModel::getJointInfluences(const LLVector3& pos) if (iter_up != mSkinWeights.end() && ++iter_up != mSkinWeights.end()) { done = false; - F32 dist = (iter_up->first - pos).magVecSquared(); + F32 dist = (iter_up->first - pos).magVec(); if (dist < epsilon) { @@ -1727,7 +1727,7 @@ LLModel::weight_list& LLModel::getJointInfluences(const LLVector3& pos) { done = false; - F32 dist = (iter_down->first - pos).magVecSquared(); + F32 dist = (iter_down->first - pos).magVec(); if (dist < epsilon) { diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index 3f58eba07d..9dab3a0400 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -217,13 +217,29 @@ public: } }; + + struct JointPositionalCompare + { + //Are the doubles the same w/in epsilon specified tolerance + bool areEqual( double a, double b ) + { + const float epsilon = 1e-5f; + return (abs(a - b) > epsilon) && (a < b); + } + //Make sure that we return false for any values that are within the tolerance for equivalence + bool operator() ( const LLVector3& a, const LLVector3& b ) + { + return ( areEqual( a[0],b[0]) && areEqual( a[1],b[1] ) && areEqual( a[2],b[2]) ) ? false : true; + } + }; + //copy of position array for this model -- mPosition[idx].mV[X,Y,Z] std::vector<LLVector3> mPosition; //map of positions to skin weights --- mSkinWeights[pos].mV[0..4] == <joint_index>.<weight> //joint_index corresponds to mJointList typedef std::vector<JointWeight> weight_list; - typedef std::map<LLVector3, weight_list > weight_map; + typedef std::map<LLVector3, weight_list, JointPositionalCompare > weight_map; weight_map mSkinWeights; //get list of weight influences closest to given position |