From e2442851c61ad645020d78be8ae0c7c851024758 Mon Sep 17 00:00:00 2001
From: andreykproductengine <andreykproductengine@lindenlab.com>
Date: Tue, 27 Nov 2018 20:07:41 +0200
Subject: [PATCH] SL-10080 Limit LOD factor to 4

---
 indra/newview/llappviewer.cpp     | 6 +++---
 indra/newview/llviewercontrol.cpp | 6 +++---
 indra/newview/llvovolume.h        | 2 ++
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index f1af872fb42..bd45f68a5c0 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -568,12 +568,12 @@ static void settings_to_globals()
 	LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO");
 	LLImageGL::sGlobalUseAnisotropic	= gSavedSettings.getBOOL("RenderAnisotropic");
 	LLImageGL::sCompressTextures		= gSavedSettings.getBOOL("RenderCompressTextures");
-	LLVOVolume::sLODFactor				= gSavedSettings.getF32("RenderVolumeLODFactor");
+	LLVOVolume::sLODFactor				= llmin(gSavedSettings.getF32("RenderVolumeLODFactor"), MAX_LOD_FACTOR);
 	LLVOVolume::sDistanceFactor			= 1.f-LLVOVolume::sLODFactor * 0.1f;
 	LLVolumeImplFlexible::sUpdateFactor = gSavedSettings.getF32("RenderFlexTimeFactor");
 	LLVOTree::sTreeFactor				= gSavedSettings.getF32("RenderTreeLODFactor");
-	LLVOAvatar::sLODFactor				= gSavedSettings.getF32("RenderAvatarLODFactor");
-	LLVOAvatar::sPhysicsLODFactor		= gSavedSettings.getF32("RenderAvatarPhysicsLODFactor");
+	LLVOAvatar::sLODFactor				= llmin(gSavedSettings.getF32("RenderAvatarLODFactor"), MAX_LOD_FACTOR);
+	LLVOAvatar::sPhysicsLODFactor		= llmin(gSavedSettings.getF32("RenderAvatarPhysicsLODFactor"), MAX_LOD_FACTOR);
 	LLVOAvatar::updateImpostorRendering(gSavedSettings.getU32("RenderAvatarMaxNonImpostors"));
 	LLVOAvatar::sVisibleInFirstPerson	= gSavedSettings.getBOOL("FirstPersonAvatarVisible");
 	// clamp auto-open time to some minimum usable value
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 88984d518ab..e62d6eb9513 100644
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -219,20 +219,20 @@ static bool handleAnisotropicChanged(const LLSD& newvalue)
 
 static bool handleVolumeLODChanged(const LLSD& newvalue)
 {
-	LLVOVolume::sLODFactor = (F32) newvalue.asReal();
+	LLVOVolume::sLODFactor = llmin((F32) newvalue.asReal(), MAX_LOD_FACTOR);
 	LLVOVolume::sDistanceFactor = 1.f-LLVOVolume::sLODFactor * 0.1f;
 	return true;
 }
 
 static bool handleAvatarLODChanged(const LLSD& newvalue)
 {
-	LLVOAvatar::sLODFactor = (F32) newvalue.asReal();
+	LLVOAvatar::sLODFactor = llmin((F32) newvalue.asReal(), MAX_LOD_FACTOR);
 	return true;
 }
 
 static bool handleAvatarPhysicsLODChanged(const LLSD& newvalue)
 {
-	LLVOAvatar::sPhysicsLODFactor = (F32) newvalue.asReal();
+	LLVOAvatar::sPhysicsLODFactor = llmin((F32) newvalue.asReal(), MAX_LOD_FACTOR);
 	return true;
 }
 
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 0882fc095de..13db9c39b75 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -54,6 +54,8 @@ enum LLVolumeInterfaceType
 	INTERFACE_FLEXIBLE = 1,
 };
 
+const F32 MAX_LOD_FACTOR = 4.0f;
+
 
 class LLRiggedVolume : public LLVolume
 {
-- 
GitLab