summaryrefslogtreecommitdiff
path: root/indra/newview/llselectmgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llselectmgr.cpp')
-rw-r--r--indra/newview/llselectmgr.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 87a2008e2b..f05892d9b0 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -6568,26 +6568,27 @@ bool LLSelectMgr::selectionMove(const LLVector3& displ,
if (update_position)
{
// calculate the distance of the object closest to the camera origin
- F32 min_dist = 1e+30f;
+ F32 min_dist_squared = F32_MAX; // value will be overridden in the loop
+
LLVector3 obj_pos;
for (LLObjectSelection::root_iterator it = getSelection()->root_begin();
it != getSelection()->root_end(); ++it)
{
obj_pos = (*it)->getObject()->getPositionEdit();
- F32 obj_dist = dist_vec(obj_pos, LLViewerCamera::getInstance()->getOrigin());
- if (obj_dist < min_dist)
+ F32 obj_dist_squared = dist_vec_squared(obj_pos, LLViewerCamera::getInstance()->getOrigin());
+ if (obj_dist_squared < min_dist_squared)
{
- min_dist = obj_dist;
+ min_dist_squared = obj_dist_squared;
}
}
- // factor the distance inside the displacement vector. This will get us
+ // factor the distance into the displacement vector. This will get us
// equally visible movements for both close and far away selections.
- min_dist = sqrt(min_dist) / 2;
- displ_global.setVec(displ.mV[0]*min_dist,
- displ.mV[1]*min_dist,
- displ.mV[2]*min_dist);
+ F32 min_dist = sqrt(fsqrtf(min_dist_squared)) / 2;
+ displ_global.setVec(displ.mV[0] * min_dist,
+ displ.mV[1] * min_dist,
+ displ.mV[2] * min_dist);
// equates to: Displ_global = Displ * M_cam_axes_in_global_frame
displ_global = LLViewerCamera::getInstance()->rotateToAbsolute(displ_global);