summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorRicky Curtice <kf6kjg+hg@gmail.com>2011-03-12 23:39:10 -0800
committerRicky Curtice <kf6kjg+hg@gmail.com>2011-03-12 23:39:10 -0800
commit9bac314ba0d8b6bd35c8d2e27ce99a28b924dea6 (patch)
tree313a2608ab5049ac26bc81f0110e47324c8146fb /indra/newview
parentd4d292258e31eee6d639106147758f39deae63e3 (diff)
Switched to using *_SQUARED constants instead of multiplied constants, and cleaned up a few other minor issues noted during review.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llagent.cpp2
-rw-r--r--indra/newview/llhudeffectlookat.cpp4
-rw-r--r--indra/newview/llhudeffectpointat.cpp4
-rw-r--r--indra/newview/llmaniprotate.cpp2
-rw-r--r--indra/newview/llmanipscale.cpp2
-rw-r--r--indra/newview/llnetmap.cpp2
-rw-r--r--indra/newview/llpanelpeople.cpp5
-rw-r--r--indra/newview/llselectmgr.cpp21
-rw-r--r--indra/newview/llspeakers.cpp2
-rw-r--r--indra/newview/llviewermessage.cpp3
-rw-r--r--indra/newview/llviewerparceloverlay.cpp4
11 files changed, 27 insertions, 24 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 4628adee1f..f3f036a0d8 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -1343,7 +1343,7 @@ void LLAgent::stopAutoPilot(BOOL user_cancel)
//NB: auto pilot can terminate for a reason other than reaching the destination
if (mAutoPilotFinishedCallback)
{
- mAutoPilotFinishedCallback(!user_cancel && dist_vec_squared(gAgent.getPositionGlobal(), mAutoPilotTargetGlobal) < mAutoPilotStopDistance * mAutoPilotStopDistance, mAutoPilotCallbackData);
+ mAutoPilotFinishedCallback(!user_cancel && dist_vec_squared(gAgent.getPositionGlobal(), mAutoPilotTargetGlobal) < (mAutoPilotStopDistance * mAutoPilotStopDistance), mAutoPilotCallbackData);
}
mLeaderID = LLUUID::null;
diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp
index 10ee6f1d39..882c0cf2e2 100644
--- a/indra/newview/llhudeffectlookat.cpp
+++ b/indra/newview/llhudeffectlookat.cpp
@@ -56,7 +56,7 @@ const S32 PKT_SIZE = 57;
// throttle
const F32 MAX_SENDS_PER_SEC = 4.f;
-const F32 MIN_DELTAPOS_FOR_UPDATE = 0.05f;
+const F32 MIN_DELTAPOS_FOR_UPDATE_SQUARED = 0.05f * 0.05f;
const F32 MIN_TARGET_OFFSET_SQUARED = 0.0001f;
@@ -416,7 +416,7 @@ BOOL LLHUDEffectLookAt::setLookAt(ELookAtType target_type, LLViewerObject *objec
BOOL lookAtChanged = (target_type != mTargetType) || (object != mTargetObject);
// lookat position has moved a certain amount and we haven't just sent an update
- lookAtChanged = lookAtChanged || ((dist_vec_squared(position, mLastSentOffsetGlobal) > MIN_DELTAPOS_FOR_UPDATE * MIN_DELTAPOS_FOR_UPDATE) &&
+ lookAtChanged = lookAtChanged || ((dist_vec_squared(position, mLastSentOffsetGlobal) > MIN_DELTAPOS_FOR_UPDATE_SQUARED) &&
((current_time - mLastSendTime) > (1.f / MAX_SENDS_PER_SEC)));
if (lookAtChanged)
diff --git a/indra/newview/llhudeffectpointat.cpp b/indra/newview/llhudeffectpointat.cpp
index 562d7cd4ed..28fe8e1c01 100644
--- a/indra/newview/llhudeffectpointat.cpp
+++ b/indra/newview/llhudeffectpointat.cpp
@@ -48,7 +48,7 @@ const S32 PKT_SIZE = 57;
// throttle
const F32 MAX_SENDS_PER_SEC = 4.f;
-const F32 MIN_DELTAPOS_FOR_UPDATE = 0.05f;
+const F32 MIN_DELTAPOS_FOR_UPDATE_SQUARED = 0.05f * 0.05f;
// timeouts
// can't use actual F32_MAX, because we add this to the current frametime
@@ -244,7 +244,7 @@ BOOL LLHUDEffectPointAt::setPointAt(EPointAtType target_type, LLViewerObject *ob
BOOL targetTypeChanged = (target_type != mTargetType) ||
(object != mTargetObject);
- BOOL targetPosChanged = (dist_vec_squared(position, mLastSentOffsetGlobal) > MIN_DELTAPOS_FOR_UPDATE * MIN_DELTAPOS_FOR_UPDATE) &&
+ BOOL targetPosChanged = (dist_vec_squared(position, mLastSentOffsetGlobal) > MIN_DELTAPOS_FOR_UPDATE_SQUARED) &&
((current_time - mLastSendTime) > (1.f / MAX_SENDS_PER_SEC));
if (targetTypeChanged || targetPosChanged)
diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp
index 815b718f33..6ee095475f 100644
--- a/indra/newview/llmaniprotate.cpp
+++ b/indra/newview/llmaniprotate.cpp
@@ -1127,7 +1127,7 @@ BOOL LLManipRotate::updateVisiblity()
if (gSavedSettings.getBOOL("LimitSelectDistance"))
{
F32 max_select_distance = gSavedSettings.getF32("MaxSelectDistance");
- if (dist_vec_squared(gAgent.getPositionAgent(), center) > max_select_distance * max_select_distance)
+ if (dist_vec_squared(gAgent.getPositionAgent(), center) > (max_select_distance * max_select_distance))
{
visible = FALSE;
}
diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp
index 4f8e7e4792..9cdc092257 100644
--- a/indra/newview/llmanipscale.cpp
+++ b/indra/newview/llmanipscale.cpp
@@ -237,7 +237,7 @@ void LLManipScale::render()
}
}
- if (range_squared > 0.00001f)
+ if (range_squared > 0.001f * 0.001f)
{
// range != zero
F32 fraction_of_fov = BOX_HANDLE_BASE_SIZE / (F32) LLViewerCamera::getInstance()->getViewHeightInPixels();
diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp
index 394e0bf1f1..bd4f152ded 100644
--- a/indra/newview/llnetmap.cpp
+++ b/indra/newview/llnetmap.cpp
@@ -334,7 +334,7 @@ void LLNetMap::draw()
//localMouse(&local_mouse_x, &local_mouse_y);
LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
mClosestAgentToCursor.setNull();
- F32 closest_dist_squared = F32_MAX;
+ F32 closest_dist_squared = F32_MAX; // value will be overridden in the loop
F32 min_pick_dist_squared = (mDotRadius * MIN_PICK_SCALE) * (mDotRadius * MIN_PICK_SCALE);
// Draw avatars
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index dbfdf0bdf6..e3a7b749ea 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -158,9 +158,8 @@ protected:
const LLVector3d& me_pos = gAgent.getPositionGlobal();
const LLVector3d& item1_pos = mAvatarsPositions.find(item1->getAvatarId())->second;
const LLVector3d& item2_pos = mAvatarsPositions.find(item2->getAvatarId())->second;
- F32 dist1 = dist_vec_squared(item1_pos, me_pos);
- F32 dist2 = dist_vec_squared(item2_pos, me_pos);
- return dist1 < dist2;
+
+ return dist_vec_squared(item1_pos, me_pos) < dist_vec_squared(item2_pos, me_pos);
}
private:
id_to_pos_map_t mAvatarsPositions;
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 39f3cd4196..262c9a4515 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -6570,7 +6570,8 @@ 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)
@@ -6578,20 +6579,22 @@ bool LLSelectMgr::selectionMove(const LLVector3& displ,
obj_pos = (*it)->getObject()->getPositionEdit();
F32 obj_dist_squared = dist_vec_squared(obj_pos, LLViewerCamera::getInstance()->getOrigin());
- if (obj_dist_squared < min_dist)
+ if (obj_dist_squared < min_dist_squared)
{
- min_dist = obj_dist_squared;
+ min_dist_squared = obj_dist_squared;
}
}
- // since the above uses squared values, take the square root.
- min_dist = sqrt(min_dist);
+
+ // get the non-squared edition for use below
+ // note the use of fsqrtf, this was used in the definition of dist_vec() and is therefore re-used here
+ F32 min_dist = fsqrtf(min_dist_squared);
// factor the distance inside 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_factored = sqrt(min_dist) / 2;
+ displ_global.setVec(displ.mV[0]*min_dist_factored,
+ displ.mV[1]*min_dist_factored,
+ displ.mV[2]*min_dist_factored);
// equates to: Displ_global = Displ * M_cam_axes_in_global_frame
displ_global = LLViewerCamera::getInstance()->rotateToAbsolute(displ_global);
diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp
index 31492e33d9..c588bd8fb4 100644
--- a/indra/newview/llspeakers.cpp
+++ b/indra/newview/llspeakers.cpp
@@ -920,7 +920,7 @@ void LLLocalSpeakerMgr::updateSpeakerList()
if (speakerp->mStatus == LLSpeaker::STATUS_TEXT_ONLY)
{
LLVOAvatar* avatarp = (LLVOAvatar*)gObjectList.findObject(speaker_id);
- if (!avatarp || dist_vec_squared(avatarp->getPositionAgent(), gAgent.getPositionAgent()) > CHAT_NORMAL_RADIUS * CHAT_NORMAL_RADIUS)
+ if (!avatarp || dist_vec_squared(avatarp->getPositionAgent(), gAgent.getPositionAgent()) > CHAT_NORMAL_RADIUS_SQUARED)
{
setSpeakerNotInChannel(speakerp);
}
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 947408f125..4dd5a3f6f1 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -122,6 +122,7 @@
//
const F32 BIRD_AUDIBLE_RADIUS = 32.0f;
const F32 SIT_DISTANCE_FROM_TARGET = 0.25f;
+const F32 CAMERA_POSITION_THRESHOLD_SQUARED = 0.001f * 0.001f;
static const F32 LOGOUT_REPLY_TIME = 3.f; // Wait this long after LogoutReply before quitting.
// Determine how quickly residents' scripts can issue question dialogs
@@ -4748,7 +4749,7 @@ void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data)
BOOL force_mouselook;
mesgsys->getBOOLFast(_PREHASH_SitTransform, _PREHASH_ForceMouselook, force_mouselook);
- if (isAgentAvatarValid() && dist_vec_squared(camera_eye, camera_at) > 0.0001f)
+ if (isAgentAvatarValid() && dist_vec_squared(camera_eye, camera_at) > CAMERA_POSITION_THRESHOLD_SQUARED)
{
gAgentCamera.setSitCamera(sitObjectID, camera_eye, camera_at);
}
diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp
index d07e06f6a7..26765bdd01 100644
--- a/indra/newview/llviewerparceloverlay.cpp
+++ b/indra/newview/llviewerparceloverlay.cpp
@@ -833,7 +833,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines ()
U8* colorp;
bool render_hidden = LLSelectMgr::sRenderHiddenSelections && LLFloaterReg::instanceVisible("build");
- const F32 PROPERTY_LINE_CLIP_DIST = 256.f;
+ const F32 PROPERTY_LINE_CLIP_DIST_SQUARED = 256.f * 256.f;
for (i = 0; i < mVertexCount; i += vertex_per_edge)
{
@@ -844,7 +844,7 @@ S32 LLViewerParcelOverlay::renderPropertyLines ()
vertex.mV[VY] = *(vertexp+1);
vertex.mV[VZ] = *(vertexp+2);
- if (dist_vec_squared2D(vertex, camera_region) > PROPERTY_LINE_CLIP_DIST*PROPERTY_LINE_CLIP_DIST)
+ if (dist_vec_squared2D(vertex, camera_region) > PROPERTY_LINE_CLIP_DIST_SQUARED)
{
continue;
}