From b45992a7bbdf31a4d2d9fe7f1951884053d76ea3 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Thu, 28 Oct 2021 22:40:59 -0400
Subject: [PATCH] Fast access to various other singletons

---
 indra/newview/llviewerpartsim.cpp   |  4 +-
 indra/newview/llviewershadermgr.cpp |  4 +-
 indra/newview/llvoavatarself.cpp    | 10 ++---
 indra/newview/llvowater.cpp         |  2 +-
 indra/newview/llworld.cpp           |  8 ++--
 indra/newview/pipeline.cpp          | 66 ++++++++++++++---------------
 6 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index b70a28c3091..8c8bd2517b9 100644
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -139,7 +139,7 @@ LLViewerPartGroup::LLViewerPartGroup(const LLVector3 &center_agent, const F32 bo
 	mVOPartGroupp = NULL;
 	mUniformParticles = TRUE;
 
-	mRegionp = LLWorld::getInstance()->getRegionFromPosAgent(center_agent);
+	mRegionp = LLWorld::getInstanceFast()->getRegionFromPosAgent(center_agent);
 	llassert_always(center_agent.isFinite());
 	
 	if (!mRegionp)
@@ -408,7 +408,7 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt)
 			if (!posInGroup(part->mPosAgent, desired_size))
 			{
 				// Transfer particles between groups
-				LLViewerPartSim::getInstance()->put(part) ;
+				LLViewerPartSim::getInstanceFast()->put(part) ;
 				vector_replace_with_last(mParticles, mParticles.begin() + i);
 			}
 			else
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 5bdfd3e4bf8..23f9f67450d 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -1042,7 +1042,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment()
 		return FALSE;
 	}
 	
-	LLWorld::getInstance()->updateWaterObjects();
+	LLWorld::getInstanceFast()->updateWaterObjects();
 	
 	return TRUE;
 }
@@ -1159,7 +1159,7 @@ BOOL LLViewerShaderMgr::loadShadersWater()
 		return loadShadersWater();
 	}
 	
-	LLWorld::getInstance()->updateWaterObjects();
+	LLWorld::getInstanceFast()->updateWaterObjects();
 
 	return TRUE;
 }
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index b9d7c51436e..22f808f54cd 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -981,7 +981,7 @@ void LLVOAvatarSelf::idleUpdateTractorBeam()
 	else if (!mBeam || mBeam->isDead())
 	{
 		// VEFFECT: Tractor Beam
-		mBeam = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM);
+		mBeam = (LLHUDEffectSpiral *)LLHUDManager::getInstanceFast()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM);
 		mBeam->setColor(LLColor4U(gAgent.getEffectColor()));
 		mBeam->setSourceObject(this);
 		mBeamTimer.reset();
@@ -989,7 +989,7 @@ void LLVOAvatarSelf::idleUpdateTractorBeam()
 
 	if (!mBeam.isNull())
 	{
-		LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+		LLObjectSelectionHandle selection = LLSelectMgr::getInstanceFast()->getSelection();
 
 		if (gAgentCamera.mPointAt.notNull())
 		{
@@ -1006,7 +1006,7 @@ void LLVOAvatarSelf::idleUpdateTractorBeam()
 		else
 		{
 			mBeam->setTargetObject(NULL);
-			LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
+			LLTool *tool = LLToolMgr::getInstanceFast()->getCurrentTool();
 			if (tool->isEditing())
 			{
 				if (tool->getEditingObject())
@@ -1285,7 +1285,7 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
 		// the simulator should automatically handle permission revocation
 		
 		stopMotionFromSource(attachment_id);
-		LLFollowCamMgr::getInstance()->setCameraActive(viewer_object->getID(), FALSE);
+		LLFollowCamMgr::getInstanceFast()->setCameraActive(viewer_object->getID(), FALSE);
 		
 		LLViewerObject::const_child_list_t& child_list = viewer_object->getChildren();
 		for (LLViewerObject* child_objectp : child_list)
@@ -1294,7 +1294,7 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
 			// permissions revocation
 			
 			stopMotionFromSource(child_objectp->getID());
-			LLFollowCamMgr::getInstance()->setCameraActive(child_objectp->getID(), FALSE);
+			LLFollowCamMgr::getInstanceFast()->setCameraActive(child_objectp->getID(), FALSE);
 		}
 		
 		// Make sure the inventory is in sync with the avatar.
diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp
index 6d5496eada8..9bd588e9d46 100644
--- a/indra/newview/llvowater.cpp
+++ b/indra/newview/llvowater.cpp
@@ -108,7 +108,7 @@ LLDrawable *LLVOWater::createDrawable(LLPipeline *pipeline)
 	}
 	else
 	{
-		mDrawable->setNumFaces(1, pool, LLWorld::getInstance()->getDefaultWaterTexture());
+		mDrawable->setNumFaces(1, pool, LLWorld::getInstanceFast()->getDefaultWaterTexture());
 	}
 
 	return mDrawable;
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 66820743b0d..66d26d35161 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -742,7 +742,7 @@ void LLWorld::clearAllVisibleObjects()
 
 void LLWorld::updateParticles()
 {
-	LLViewerPartSim::getInstance()->updateSimulation();
+	LLViewerPartSim::getInstanceFast()->updateSimulation();
 }
 
 void LLWorld::renderPropertyLines()
@@ -822,7 +822,7 @@ void LLWorld::printPacketsLost()
 
 void LLWorld::processCoarseUpdate(LLMessageSystem* msg, void** user_data)
 {
-	LLViewerRegion* region = LLWorld::getInstance()->getRegion(msg->getSender());
+	LLViewerRegion* region = LLWorld::getInstanceFast()->getRegion(msg->getSender());
 	if( region )
 	{
 		region->updateCoarseLocations(msg);
@@ -1059,7 +1059,7 @@ void LLWorld::shiftRegions(const LLVector3& offset)
 		region->updateRenderMatrix();
 	}
 
-	LLViewerPartSim::getInstance()->shift(offset);
+	LLViewerPartSim::getInstanceFast()->shift(offset);
 }
 
 LLViewerTexture* LLWorld::getDefaultWaterTexture()
@@ -1137,7 +1137,7 @@ void process_enable_simulator(LLMessageSystem *msg, void **user_data)
 
 	// Viewer trusts the simulator.
 	msg->enableCircuit(sim, TRUE);
-	LLWorld::getInstance()->addRegion(handle, sim);
+	LLWorld::getInstanceFast()->addRegion(handle, sim);
 
 	// give the simulator a message it can use to get ip and port
 	LL_INFOS() << "simulator_enable() Enabling " << sim << " with code " << msg->getOurCircuitCode() << LL_ENDL;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 09ea9586088..9cd1ba57acb 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1140,7 +1140,7 @@ void LLPipeline::updateRenderDeferred()
                       LLPipeline::sRenderTransparentWater &&
                       RenderAvatarVP &&
                       WindLightUseAtmosShaders &&
-                      (bool) LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred");
+                      (bool) LLFeatureManager::getInstanceFast()->isFeatureAvailable("RenderDeferred");
 // [RLVa:KB] - @setsphere
 	if (!sRenderDeferred && RlvActions::hasBehaviour(RLV_BHVR_SETSPHERE) && WindLightUseAtmosShaders)
 	{
@@ -1163,7 +1163,7 @@ void LLPipeline::refreshCachedSettings()
 	LLPipeline::sUseOcclusion = 
 			(!gUseWireframe
 			&& LLGLSLShader::sNoFixedFunction
-			&& LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") 
+			&& LLFeatureManager::getInstanceFast()->isFeatureAvailable("UseOcclusion")
 			&& gSavedSettings.getBOOL("UseOcclusion") 
 			&& gGLManager.mHasOcclusionQuery) ? 2 : 0;
 	
@@ -1571,7 +1571,7 @@ void LLPipeline::restoreGL()
 		LLViewerShaderMgr::instance()->setShaders();
 	}
 
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 		{
@@ -1722,7 +1722,7 @@ void LLPipeline::dirtyPoolObjectTextures(const std::set<LLViewerFetchedTexture*>
 	}
 	
 	LLOctreeDirtyTexture dirty(textures);
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 		{
@@ -2245,7 +2245,7 @@ void LLPipeline::updateMove()
 	{
  		LL_RECORD_BLOCK_TIME(FTM_OCTREE_BALANCE);
 
-		for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+		for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 		{
 			for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 			{
@@ -2506,7 +2506,7 @@ void LLPipeline::checkReferences(LLSpatialGroup* group)
 
 bool LLPipeline::visibleObjectsInFrustum(LLCamera& camera)
 {
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 		{
@@ -2539,7 +2539,7 @@ bool LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3&
 
 	bool res = true;
 
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 		{
@@ -2568,7 +2568,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 {
 	static LLCachedControl<bool> use_occlusion(gSavedSettings,"UseOcclusion");
 	static bool can_use_occlusion = LLGLSLShader::sNoFixedFunction
-									&& LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") 
+									&& LLFeatureManager::getInstanceFast()->isFeatureAvailable("UseOcclusion")
 									&& gGLManager.mHasOcclusionQuery;
 
 	LL_RECORD_BLOCK_TIME(FTM_CULL);
@@ -2632,7 +2632,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
         camera.disableUserClipPlane();
     }
 
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 		{
@@ -2695,7 +2695,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 
     if (render_water)
     {
-        LLWorld::getInstance()->precullWaterObjects(camera, sCull, render_water);
+        LLWorld::getInstanceFast()->precullWaterObjects(camera, sCull, render_water);
     }
 	
 	gGL.matrixMode(LLRender::MM_PROJECTION);
@@ -2898,7 +2898,7 @@ void LLPipeline::doOcclusion(LLCamera& camera)
 		}
 	
 		//apply occlusion culling to object cache tree
-		for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+		for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 		{
 			LLVOCachePartition* vo_part = region->getVOCachePartition();
 			if(vo_part)
@@ -3357,7 +3357,7 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
 	
 	{
 		LL_RECORD_BLOCK_TIME(FTM_SHIFT_OCTREE);
-		for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+		for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 		{
 			for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 			{
@@ -3561,7 +3561,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 	if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
 	{
 		LLSpatialGroup* last_group = NULL;
-		BOOL fov_changed = LLViewerCamera::getInstance()->isDefaultFOVChanged();
+		BOOL fov_changed = LLViewerCamera::getInstanceFast()->isDefaultFOVChanged();
 		for (LLCullResult::bridge_iterator i = sCull->beginVisibleBridge(), i_end = sCull->endVisibleBridge(); i != i_end; ++i)
 		{
 			LLCullResult::bridge_iterator cur_iter = i;
@@ -3674,7 +3674,7 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera)
         return;
     }
 
-	if (LLSelectMgr::getInstance()->mHideSelectedObjects)
+	if (LLSelectMgr::getInstanceFast()->mHideSelectedObjects)
 	{
 //		if (drawablep->getVObj().notNull() &&
 //			drawablep->getVObj()->isSelected())
@@ -4141,7 +4141,7 @@ void LLPipeline::postSort(LLCamera& camera)
 		mSelectedFaces.clear();
 
 		// Draw face highlights for selected faces.
-		if (LLSelectMgr::getInstance()->getTEMode())
+		if (LLSelectMgr::getInstanceFast()->getTEMode())
 		{
 			LLPipeline::setRenderHighlightTextureChannel(gFloaterTools->getPanelFace()->getTextureChannelToEdit());
 
@@ -4160,7 +4160,7 @@ void LLPipeline::postSort(LLCamera& camera)
 					return true;
 				}
 			} func;
-			LLSelectMgr::getInstance()->getSelection()->applyToTEs(&func);
+			LLSelectMgr::getInstanceFast()->getSelection()->applyToTEs(&func);
 		}
 	}
 
@@ -4199,9 +4199,9 @@ void render_hud_elements()
 		LLTracker::render3D();
 		
 		// Show the property lines
-		LLWorld::getInstance()->renderPropertyLines();
-		LLViewerParcelMgr::getInstance()->render();
-		LLViewerParcelMgr::getInstance()->renderParcelCollision();
+		LLWorld::getInstanceFast()->renderPropertyLines();
+		LLViewerParcelMgr::getInstanceFast()->render();
+		LLViewerParcelMgr::getInstanceFast()->renderParcelCollision();
 	
 		// Render name tags.
 		LLHUDObject::renderAll();
@@ -4209,7 +4209,7 @@ void render_hud_elements()
 	else if (gForceRenderLandFence)
 	{
 		// This is only set when not rendering the UI, for parcel snapshots
-		LLViewerParcelMgr::getInstance()->render();
+		LLViewerParcelMgr::getInstanceFast()->render();
 	}
 	else if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD))
 	{
@@ -5012,7 +5012,7 @@ void LLPipeline::renderPhysicsDisplay()
 		gDebugProgram.bind();
 	}
 
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 		{
@@ -5418,7 +5418,7 @@ void LLPipeline::renderDebug()
 
 
 	// Debug stuff.
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 		{
@@ -7240,7 +7240,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start,
 
 	LLDrawable* drawable = NULL;
 
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_PARTICLE);
 		if (part && hasRenderType(part->mDrawableType))
@@ -7289,7 +7289,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start,
 
 	sPickAvatar = false; //! LLToolMgr::getInstance()->inBuildMode();
 	
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		for (U32 j = 0; j < LLViewerRegion::NUM_PARTITIONS; j++)
 		{
@@ -7352,7 +7352,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start,
 
 		//check against avatars
 		sPickAvatar = true;
-		for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+		for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 		{
 			LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_AVATAR);
 			if (part && hasRenderType(part->mDrawableType))
@@ -7430,7 +7430,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector4a& start, c
 {
 	LLDrawable* drawable = NULL;
 
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		bool toggle = false;
 		if (!hasRenderType(LLPipeline::RENDER_TYPE_HUD))
@@ -7528,7 +7528,7 @@ void LLPipeline::doResetVertexBuffers(bool forced)
 
 	mALRenderUtil->resetVertexBuffers();
 
-	for (LLViewerRegion* region : LLWorld::getInstance()->getRegionList())
+	for (LLViewerRegion* region : LLWorld::getInstanceFast()->getRegionList())
 	{
 		for (U32 i = 0; i < LLViewerRegion::NUM_PARTITIONS; i++)
 		{
@@ -7543,7 +7543,7 @@ void LLPipeline::doResetVertexBuffers(bool forced)
 	{
 		LLSpatialPartition::sTeleportRequested = FALSE;
 
-		LLWorld::getInstance()->clearAllVisibleObjects();
+		LLWorld::getInstanceFast()->clearAllVisibleObjects();
 		clearRebuildDrawables();
 	}
 
@@ -7863,7 +7863,7 @@ void LLPipeline::renderFinalize()
     if (LLPipeline::sRenderDeferred)
     {
 		auto& viewerCamera = LLViewerCamera::instanceFast();
-		bool dof_enabled = (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) &&
+		bool dof_enabled = (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstanceFast()->inBuildMode()) &&
                            RenderDepthOfField;
 
         bool multisample = RenderFSAASamples > 1 && (mFXAABuffer.isComplete() || (mSMAAEdgeBuffer.isComplete() && mSMAABlendBuffer.isComplete()));
@@ -7888,10 +7888,10 @@ void LLPipeline::renderFinalize()
 
             LLVector3 focus_point;
 
-            LLViewerObject *obj = LLViewerMediaFocus::getInstance()->getFocusedObject();
+            LLViewerObject *obj = LLViewerMediaFocus::getInstanceFast()->getFocusedObject();
             if (obj && obj->mDrawable && obj->isSelected())
             { // focus on selected media object
-                S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace();
+                S32 face_idx = LLViewerMediaFocus::getInstanceFast()->getFocusedFace();
                 if (obj && obj->mDrawable)
                 {
                     LLFace *face = obj->mDrawable->getFace(face_idx);
@@ -7904,7 +7904,7 @@ void LLPipeline::renderFinalize()
 
             if (focus_point.isExactlyZero())
             {
-                if (LLViewerJoystick::getInstance()->getOverrideCamera())
+                if (LLViewerJoystick::getInstanceFast()->getOverrideCamera())
                 { // focus on point under cursor
                     focus_point.set(gDebugRaycastIntersection.getF32ptr());
                 }
@@ -9796,7 +9796,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
                     gUIProgram.bind();
                 }
 
-                LLWorld::getInstance()->renderPropertyLines();
+                LLWorld::getInstanceFast()->renderPropertyLines();
 
                 if (LLGLSLShader::sNoFixedFunction)
                 {
-- 
GitLab