diff options
| author | Loren Shih <seraph@lindenlab.com> | 2011-01-04 11:00:14 -0500 |
|---|---|---|
| committer | Loren Shih <seraph@lindenlab.com> | 2011-01-04 11:00:14 -0500 |
| commit | 5fe826945cd4ce22ffacd97894ab5e7f7d22719a (patch) | |
| tree | 072fd3052ccc57b426e248c0713a391df0177022 /indra/llprimitive | |
| parent | e68b03260ffdf786f609ace72ba1f63ce0913b2c (diff) | |
| parent | 350a736d37de282e1e3c22627400d957f0e00dc5 (diff) | |
Automated merge from mesh-development
Diffstat (limited to 'indra/llprimitive')
| -rwxr-xr-x | indra/llprimitive/llmodel.cpp | 54 |
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; } } |
