From f040942f190cfdf10ee577a9b4f6a5c83e752e00 Mon Sep 17 00:00:00 2001
From: Leyla Farazha <leyla@lindenlab.com>
Date: Tue, 9 Feb 2010 15:55:33 -0800
Subject: [PATCH] EXT-4449 	 [BSI] Zoom In does not function properly on
 large or linked prim sets reviewed by Richard CC#99

---
 indra/newview/llagent.cpp      |  2 ++
 indra/newview/llviewermenu.cpp | 13 +++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 2354323a66d..a061744f7c4 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -4482,7 +4482,9 @@ void LLAgent::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, const LLV
 	{
 		const F64 ANIM_METERS_PER_SECOND = 10.0;
 		const F64 MIN_ANIM_SECONDS = 0.5;
+		const F64 MAX_ANIM_SECONDS = 10.0;
 		F64 anim_duration = llmax( MIN_ANIM_SECONDS, sqrt(focus_delta_squared) / ANIM_METERS_PER_SECOND );
+		anim_duration = llmin( anim_duration, MAX_ANIM_SECONDS );
 		setAnimationDuration( (F32)anim_duration );
 	}
 
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index a83baf7f9a5..6bf9c993e0d 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -5332,7 +5332,7 @@ class LLWorldCreateLandmark : public view_listener_t
 
 void handle_look_at_selection(const LLSD& param)
 {
-	const F32 PADDING_FACTOR = 2.f;
+	const F32 PADDING_FACTOR = 1.75f;
 	BOOL zoom = (param.asString() == "zoom");
 	if (!LLSelectMgr::getInstance()->getSelection()->isEmpty())
 	{
@@ -5352,14 +5352,19 @@ void handle_look_at_selection(const LLSD& param)
 		}
 		if (zoom)
 		{
+			// Make sure we are not increasing the distance between the camera and object
+			LLVector3d orig_distance = gAgent.getCameraPositionGlobal() - LLSelectMgr::getInstance()->getSelectionCenterGlobal();
+			distance = llmin(distance, (F32) orig_distance.length());
+				
 			gAgent.setCameraPosAndFocusGlobal(LLSelectMgr::getInstance()->getSelectionCenterGlobal() + LLVector3d(obj_to_cam * distance), 
-											LLSelectMgr::getInstance()->getSelectionCenterGlobal(), 
-											object_id );
+										LLSelectMgr::getInstance()->getSelectionCenterGlobal(), 
+										object_id );
+			
 		}
 		else
 		{
 			gAgent.setFocusGlobal( LLSelectMgr::getInstance()->getSelectionCenterGlobal(), object_id );
-		}
+		}	
 	}
 }
 
-- 
GitLab