From b0e0171b8c524430d24a17c9913500045674f91c Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Fri, 5 Nov 2021 05:12:06 -0400
Subject: [PATCH] Use fast access to LLViewerJoystick singleton

---
 indra/newview/llagentcamera.cpp   | 18 +++++++++---------
 indra/newview/llappviewer.cpp     |  8 ++++----
 indra/newview/lltool.cpp          |  4 ++--
 indra/newview/lltoolmgr.cpp       |  8 ++++----
 indra/newview/llviewercamera.cpp  |  2 +-
 indra/newview/llviewermenu.cpp    |  8 ++++----
 indra/newview/llviewermessage.cpp |  2 +-
 indra/newview/llviewerwindow.cpp  | 14 +++++++-------
 8 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 94035de94ca..9471113e9bf 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -330,7 +330,7 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera)
 	{
 		changeCameraToDefault();
 		
-		if (LLViewerJoystick::getInstance()->getOverrideCamera())
+		if (LLViewerJoystick::getInstanceFast()->getOverrideCamera())
 		{
 			handle_toggle_flycam();
 		}
@@ -338,7 +338,7 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera)
 		// reset avatar mode from eventual residual motion
 		if (LLToolMgr::getInstanceFast()->inBuildMode())
 		{
-			LLViewerJoystick::getInstance()->moveAvatar(true);
+			LLViewerJoystick::getInstanceFast()->moveAvatar(true);
 		}
 
 		//Camera Tool is needed for Free Camera Control Mode
@@ -1377,7 +1377,7 @@ void LLAgentCamera::updateCamera()
 				mFollowCam.copyParams(*current_cam);
 				mFollowCam.setSubjectPositionAndRotation( gAgentAvatarp->getRenderPosition(), avatarRotationForFollowCam );
 				mFollowCam.update();
-				LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true);
+				LLViewerJoystick::getInstanceFast()->setCameraNeedsUpdate(true);
 			}
 			else
 			{
@@ -2334,7 +2334,7 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate)
 		|| ( (RlvActions::isRlvEnabled()) && (!RlvActions::canChangeToMouselook()) )
 // [/RLVa:KB]
 
-		|| LLViewerJoystick::getInstance()->getOverrideCamera())
+		|| LLViewerJoystick::getInstanceFast()->getOverrideCamera())
 	{
 		return;
 	}
@@ -2394,12 +2394,12 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToDefault()
 {
-	if (LLViewerJoystick::getInstance()->getOverrideCamera())
+	if (LLViewerJoystick::getInstanceFast()->getOverrideCamera())
 	{
 		return;
 	}
 
-	if (LLFollowCamMgr::getInstance()->getActiveFollowCamParams())
+	if (LLFollowCamMgr::getInstanceFast()->getActiveFollowCamParams())
 	{
 		changeCameraToFollow();
 	}
@@ -2420,7 +2420,7 @@ void LLAgentCamera::changeCameraToDefault()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToFollow(BOOL animate)
 {
-	if (LLViewerJoystick::getInstance()->getOverrideCamera())
+	if (LLViewerJoystick::getInstanceFast()->getOverrideCamera())
 	{
 		return;
 	}
@@ -2475,7 +2475,7 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
 {
-	if (LLViewerJoystick::getInstance()->getOverrideCamera())
+	if (LLViewerJoystick::getInstanceFast()->getOverrideCamera())
 	{
 		return;
 	}
@@ -2546,7 +2546,7 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToCustomizeAvatar()
 {
-	if (LLViewerJoystick::getInstance()->getOverrideCamera() || !isAgentAvatarValid())
+	if (LLViewerJoystick::getInstanceFast()->getOverrideCamera() || !isAgentAvatarValid())
 	{
 		return;
 	}
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 2ede599d4dc..4a0cf403232 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4958,22 +4958,22 @@ void LLAppViewer::idle()
 	{
 		gAgentPilot.moveCamera();
 	}
-	else if (LLViewerJoystick::getInstance()->getOverrideCamera())
+	else if (LLViewerJoystick::getInstanceFast()->getOverrideCamera())
 	{
-		LLViewerJoystick::getInstance()->moveFlycam();
+		LLViewerJoystick::getInstanceFast()->moveFlycam();
 	}
 	else
 	{
 		if (LLToolMgr::getInstanceFast()->inBuildMode())
 		{
-			LLViewerJoystick::getInstance()->moveObjects();
+			LLViewerJoystick::getInstanceFast()->moveObjects();
 		}
 
 		gAgentCamera.updateCamera();
 	}
 
 	// update media focus
-	LLViewerMediaFocus::getInstance()->update();
+	LLViewerMediaFocus::getInstanceFast()->update();
 
 	// Update marketplace
 	LLMarketplaceInventoryImporter::update();
diff --git a/indra/newview/lltool.cpp b/indra/newview/lltool.cpp
index 9bf94868c18..12630da2a01 100644
--- a/indra/newview/lltool.cpp
+++ b/indra/newview/lltool.cpp
@@ -195,7 +195,7 @@ BOOL LLTool::handleKey(KEY key, MASK mask)
 LLTool* LLTool::getOverrideTool(MASK mask)
 {
 	// NOTE: if in flycam mode, ALT-ZOOM camera should be disabled
-	if (LLViewerJoystick::getInstance()->getOverrideCamera())
+	if (LLViewerJoystick::getInstanceFast()->getOverrideCamera())
 	{
 		return NULL;
 	}
@@ -205,7 +205,7 @@ LLTool* LLTool::getOverrideTool(MASK mask)
 	{
 		if (mask & MASK_ALT)
 		{
-			return LLToolCamera::getInstance();
+			return LLToolCamera::getInstanceFast();
 		}
 	}
 	return NULL;
diff --git a/indra/newview/lltoolmgr.cpp b/indra/newview/lltoolmgr.cpp
index 39e588d9e0c..8cb024140d4 100644
--- a/indra/newview/lltoolmgr.cpp
+++ b/indra/newview/lltoolmgr.cpp
@@ -325,7 +325,7 @@ void LLToolMgr::enterBuildMode(bool verify_canedit /*=false*/)
 		if (gSavedSettings.getBOOL("EditCameraMovement"))
 		{
 			// camera should be set
-			if (LLViewerJoystick::getInstance()->getOverrideCamera())
+			if (LLViewerJoystick::getInstanceFast()->getOverrideCamera())
 			{
 				handle_toggle_flycam();
 			}
@@ -342,7 +342,7 @@ void LLToolMgr::enterBuildMode(bool verify_canedit /*=false*/)
 
 
 		setCurrentToolset(gBasicToolset);
-		getCurrentToolset()->selectTool( LLToolCompCreate::getInstance() );
+		getCurrentToolset()->selectTool( LLToolCompCreate::getInstanceFast() );
 
 		// Could be first use
 		//LLFirstUse::useBuild();
@@ -350,7 +350,7 @@ void LLToolMgr::enterBuildMode(bool verify_canedit /*=false*/)
 		gAgentCamera.resetView(false);
 
 		// avoid spurious avatar movements
-		LLViewerJoystick::getInstance()->setNeedsReset();
+		LLViewerJoystick::getInstanceFast()->setNeedsReset();
 
 	}
 // [RLVa:KB] - Checked: RLVa-2.1.0
@@ -381,7 +381,7 @@ void LLToolMgr::leaveBuildMode()
 			gViewerWindow->showCursor();			
 		}
 		// avoid spurious avatar movements pulling out of edit mode
-		LLViewerJoystick::getInstance()->setNeedsReset();
+		LLViewerJoystick::getInstanceFast()->setNeedsReset();
 	}
 
 }
diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index 0ef30917aa7..8b4521ae2bf 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -109,7 +109,7 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 &center,
 											const LLVector3 &point_of_interest)
 {
 	// do not update if avatar didn't move
-	if (!LLViewerJoystick::getInstance()->getCameraNeedsUpdate())
+	if (!LLViewerJoystick::getInstanceFast()->getCameraNeedsUpdate())
 	{
 		return;
 	}
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 49bc105bf0b..f259e5a5cd1 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -2818,14 +2818,14 @@ class LLViewCheckJoystickFlycam : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
 	{
-		bool new_value = LLViewerJoystick::getInstance()->getOverrideCamera();
+		bool new_value = LLViewerJoystick::getInstanceFast()->getOverrideCamera();
 		return new_value;
 	}
 };
 
 void handle_toggle_flycam()
 {
-	LLViewerJoystick::getInstance()->toggleFlycam();
+	LLViewerJoystick::getInstanceFast()->toggleFlycam();
 }
 
 class LLObjectBuild : public view_listener_t
@@ -2892,8 +2892,8 @@ void handle_object_edit()
 	LLToolMgr::getInstanceFast()->setCurrentToolset(gBasicToolset);
 	gFloaterTools->setEditTool( LLToolCompTranslate::getInstanceFast() );
 	
-	LLViewerJoystick::getInstance()->moveObjects(true);
-	LLViewerJoystick::getInstance()->setNeedsReset(true);
+	LLViewerJoystick::getInstanceFast()->moveObjects(true);
+	LLViewerJoystick::getInstanceFast()->setNeedsReset(true);
 	
 	// Could be first use
 	//LLFirstUse::useBuild();
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 9d4cd26a0b3..35996663f5f 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -6524,7 +6524,7 @@ void process_teleport_local(LLMessageSystem *msg,void**)
 	gAgent.setPositionAgent(pos);
 	gAgentCamera.slamLookAt(look_at);
 
-	if ( !(gAgent.getTeleportKeepsLookAt() && LLViewerJoystick::getInstance()->getOverrideCamera()) )
+	if ( !(gAgent.getTeleportKeepsLookAt() && LLViewerJoystick::getInstanceFast()->getOverrideCamera()) )
 	{
 		gAgentCamera.resetView(TRUE, TRUE);
 	}
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 71aa7437a66..c23b4ab240e 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1657,7 +1657,7 @@ BOOL LLViewerWindow::handleTranslatedKeyUp(KEY key,  MASK mask)
 
 void LLViewerWindow::handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level)
 {
-	LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true);
+	LLViewerJoystick::getInstanceFast()->setCameraNeedsUpdate(true);
 	gViewerInput.scanKey(key, key_down, key_up, key_level);
 	return; // Be clear this function returns nothing
 }
@@ -1704,7 +1704,7 @@ BOOL LLViewerWindow::handleActivateApp(LLWindow *window, BOOL activating)
 {
 	//if (!activating) gAgentCamera.changeCameraToDefault();
 
-	LLViewerJoystick::getInstance()->setNeedsReset(true);
+	LLViewerJoystick::getInstanceFast()->setNeedsReset(true);
 	return FALSE;
 }
 
@@ -1800,9 +1800,9 @@ void LLViewerWindow::handleDataCopy(LLWindow *window, S32 data_type, void *data)
 
 BOOL LLViewerWindow::handleTimerEvent(LLWindow *window)
 {
-	if (LLViewerJoystick::getInstance()->getOverrideCamera())
+	if (LLViewerJoystick::getInstanceFast()->getOverrideCamera())
 	{
-		LLViewerJoystick::getInstance()->updateStatus();
+		LLViewerJoystick::getInstanceFast()->updateStatus();
 		return TRUE;
 	}
 	return FALSE;
@@ -1811,9 +1811,9 @@ BOOL LLViewerWindow::handleTimerEvent(LLWindow *window)
 BOOL LLViewerWindow::handleDeviceChange(LLWindow *window)
 {
 	// give a chance to use a joystick after startup (hot-plugging)
-	if (!LLViewerJoystick::getInstance()->isJoystickInitialized() )
+	if (!LLViewerJoystick::getInstanceFast()->isJoystickInitialized() )
 	{
-		LLViewerJoystick::getInstance()->init(true);
+		LLViewerJoystick::getInstanceFast()->init(true);
 		return TRUE;
 	}
 	return FALSE;
@@ -4488,7 +4488,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
 	LLVector3 mouse_world_start = mouse_point_global;
 	LLVector3 mouse_world_end   = mouse_point_global + mouse_direction_global * depth;
 
-	if (!LLViewerJoystick::getInstance()->getOverrideCamera())
+	if (!LLViewerJoystick::getInstanceFast()->getOverrideCamera())
 	{ //always set raycast intersection to mouse_world_end unless
 		//flycam is on (for DoF effect)
 		gDebugRaycastIntersection.load3(mouse_world_end.mV);
-- 
GitLab