summaryrefslogtreecommitdiff
path: root/indra/llprimitive/llmodel.cpp
diff options
context:
space:
mode:
authorleyla_linden <none@none>2010-12-31 12:55:04 -0800
committerleyla_linden <none@none>2010-12-31 12:55:04 -0800
commit350a736d37de282e1e3c22627400d957f0e00dc5 (patch)
tree7427e593ce39ad2c50e1f217bad5b211a9eb3928 /indra/llprimitive/llmodel.cpp
parentd196348d0f4bd542eee3702329dab28952b8a5e5 (diff)
parente3204165b9bb9b36cb11a8d0a4a4040634e707fc (diff)
Merge
Diffstat (limited to 'indra/llprimitive/llmodel.cpp')
-rwxr-xr-xindra/llprimitive/llmodel.cpp54
1 files changed, 45 insertions, 9 deletions
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index 28f152f49c..1869e1dd47 100755
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -1878,21 +1878,57 @@ LLModel::weight_list& LLModel::getJointInfluences(const LLVector3& pos)
}
else
{ //no exact match found, get closest point
- iter = mSkinWeights.begin();
- weight_map::iterator best = iter;
+ const F32 epsilon = 2.f/65536;
+ 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();
- while (++iter != mSkinWeights.end())
- {
- F32 dist = (iter->first - pos).magVecSquared();
- if (dist < min_dist)
+ bool done = false;
+ while (!done)
+ { //search up and down mSkinWeights from lower bound of pos until a
+ //match is found within epsilon. If no match is found within epsilon,
+ //return closest match
+ done = true;
+ if (iter_up != mSkinWeights.end() && ++iter_up != mSkinWeights.end())
{
- best = iter;
- min_dist = dist;
+ done = false;
+ F32 dist = (iter_up->first - pos).magVecSquared();
+
+ if (dist < epsilon)
+ {
+ return iter_up->second;
+ }
+
+ if (dist < min_dist)
+ {
+ best = iter_up;
+ min_dist = dist;
+ }
}
- }
+ if (iter_down != mSkinWeights.begin() && --iter_down != mSkinWeights.begin())
+ {
+ done = false;
+
+ F32 dist = (iter_down->first - pos).magVecSquared();
+
+ if (dist < epsilon)
+ {
+ return iter_down->second;
+ }
+
+ if (dist < min_dist)
+ {
+ best = iter_down;
+ min_dist = dist;
+ }
+
+ }
+ }
+
return best->second;
}
}