From df94d0c778e63ce053cfd1fa4423b180bab6adfb Mon Sep 17 00:00:00 2001 From: prep Date: Wed, 3 Aug 2011 17:01:34 -0400 Subject: Fixes for sh-2039, sh-1336, and sh-2044. Vertices were having incorrect weights assigned. --- indra/llprimitive/llmodel.cpp | 13 +++++++++++++ indra/llprimitive/llmodel.h | 23 ++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index def276c808..d8e4d4a173 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1679,6 +1679,19 @@ LLSD LLModel::writeModelToStream(std::ostream& ostr, LLSD& mdl, BOOL nowrite, BO LLModel::weight_list& LLModel::getJointInfluences(const LLVector3& pos) { + //1. If a vertex has been weighted then we'll find it via pos and return it's weight list + weight_map::iterator iterPos = mSkinWeights.begin(); + weight_map::iterator iterEnd = mSkinWeights.end(); + + for ( ; iterPos!=iterEnd; ++iterPos ) + { + if ( jointPositionalLookup( iterPos->first, pos ) ) + { + return iterPos->second; + } + } + + //2. Otherwise we'll use the older implementation weight_map::iterator iter = mSkinWeights.find(pos); if (iter != mSkinWeights.end()) diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index b5dd9bf87d..9a7b9fa271 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -219,20 +219,17 @@ public: }; - struct JointPositionalCompare + //Are the doubles the same w/in epsilon specified tolerance + bool areEqual( double a, double b ) { - //Are the doubles the same w/in epsilon specified tolerance - bool areEqual( double a, double b ) - { - const float epsilon = 1e-5f; - return (abs((int)(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; - } - }; + const float epsilon = 1e-5f; + return (fabs((a - b)) < epsilon) ? true : false ; + } + //Make sure that we return false for any values that are within the tolerance for equivalence + bool jointPositionalLookup( const LLVector3& a, const LLVector3& b ) + { + return ( areEqual( a[0],b[0]) && areEqual( a[1],b[1] ) && areEqual( a[2],b[2]) ) ? true : false; + } //copy of position array for this model -- mPosition[idx].mV[X,Y,Z] std::vector mPosition; -- cgit v1.2.3