From caea7260c73eb606bb8b349debadf6682dbdb3a8 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Tue, 20 Oct 2020 13:51:58 +0100
Subject: SL-14142 - impostor management cleanup

---
 indra/newview/lldrawable.cpp          |  4 ++--
 indra/newview/lldrawpoolavatar.cpp    |  4 ++--
 indra/newview/llfloaterpreference.cpp |  4 ++--
 indra/newview/llvoavatar.cpp          | 32 +++++++++++++++++---------------
 indra/newview/llvoavatar.h            |  6 +++---
 indra/newview/pipeline.cpp            |  5 +----
 indra/newview/pipeline.h              |  1 -
 7 files changed, 27 insertions(+), 29 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index c65cfe91be..5034bd1c5e 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1485,7 +1485,7 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>*
 				LLVOAvatar* avatarp = (LLVOAvatar*) objparent;
 				if (avatarp->isVisible())
 				{
-					impostor = objparent->isAvatar() && !LLPipeline::sImpostorRenderAVVO && ((LLVOAvatar*) objparent)->isImpostor();
+					impostor = objparent->isAvatar() && !LLPipeline::sImpostorRender && ((LLVOAvatar*) objparent)->isImpostor();
 					loaded   = objparent->isAvatar() && ((LLVOAvatar*) objparent)->isFullyLoaded();
 				}
 				else
@@ -1570,7 +1570,7 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)
 	if (mDrawable->getVObj())
 	{
 		// Don't update if we are part of impostor, unles it's an impostor pass
-		if (!LLPipeline::sImpostorRenderAVVO && mDrawable->getVObj()->isAttachment())
+		if (!LLPipeline::sImpostorRender && mDrawable->getVObj()->isAttachment())
 		{
 			LLDrawable* parent = mDrawable->getParent();
 			if (parent && parent->getVObj())
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 8abec252a1..ff036e1934 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -574,7 +574,7 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 		return;
 	}
 	LLVOAvatar::AvatarOverallAppearance oa = avatarp->getOverallAppearance();
-	BOOL impostor = !LLPipeline::sImpostorRenderAVVO && avatarp->isImpostor();
+	BOOL impostor = !LLPipeline::sImpostorRender && avatarp->isImpostor();
 	if (oa == LLVOAvatar::AOA_INVISIBLE ||
 		(impostor && oa == LLVOAvatar::AOA_JELLYDOLL))
 	{
@@ -1511,7 +1511,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 		return;
 	}
 
-	BOOL impostor = !LLPipeline::sImpostorRenderAVVO && avatarp->isImpostor() && !single_avatar;
+	BOOL impostor = !LLPipeline::sImpostorRender && avatarp->isImpostor() && !single_avatar;
 
 	if (( avatarp->isInMuteList() 
 		  || impostor 
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 96094dcf14..c1f1fc5783 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -1473,7 +1473,7 @@ void LLAvatarComplexityControls::setIndirectMaxNonImpostors()
 {
 	U32 max_non_impostors = gSavedSettings.getU32("RenderAvatarMaxNonImpostors");
 	// for this one, we just need to make zero, which means off, the max value of the slider
-	U32 indirect_max_non_impostors = (0 == max_non_impostors) ? LLVOAvatar::IMPOSTORS_OFF : max_non_impostors;
+	U32 indirect_max_non_impostors = (0 == max_non_impostors) ? LLVOAvatar::NON_IMPOSTORS_MAX_SLIDER : max_non_impostors;
 	gSavedSettings.setU32("IndirectMaxNonImpostors", indirect_max_non_impostors);
 }
 
@@ -1973,7 +1973,7 @@ void LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors()
 	LLSliderCtrl* ctrl = getChild<LLSliderCtrl>("IndirectMaxNonImpostors",true);
 	U32 value = ctrl->getValue().asInteger();
 
-	if (0 == value || LLVOAvatar::IMPOSTORS_OFF <= value)
+	if (0 == value || LLVOAvatar::NON_IMPOSTORS_MAX_SLIDER <= value)
 	{
 		value=0;
 	}
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 6ade882258..e2a42a5dd3 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -4029,7 +4029,7 @@ void LLVOAvatar::computeUpdatePeriod()
 			// impostor camera near clip plane
 			mUpdatePeriod = 1;
 		}
-		else if ( shouldImpostor(4) )
+		else if ( shouldImpostor(4.0) )
 		{ //background avatars are REALLY slow updating impostors
 			mUpdatePeriod = 16;
 		}
@@ -4038,7 +4038,7 @@ void LLVOAvatar::computeUpdatePeriod()
 			// Don't update cloud avatars too often
 			mUpdatePeriod = 8;
 		}
-		else if ( shouldImpostor(3) )
+		else if ( shouldImpostor(3.0) )
 		{ //back 25% of max visible avatars are slow updating impostors
 			mUpdatePeriod = 8;
 		}
@@ -4046,7 +4046,7 @@ void LLVOAvatar::computeUpdatePeriod()
 		{  // stuff in between gets an update period based on pixel area
 			mUpdatePeriod = llclamp((S32) sqrtf(impostor_area*4.f/mImpostorPixelArea), 2, 8);
 		}
-		else
+		else // shouldImpostor() at some rank in range (1.0-3.0)
 		{
 			//nearby avatars, update the impostors more frequently.
 			mUpdatePeriod = 4;
@@ -10063,7 +10063,7 @@ BOOL LLVOAvatar::updateLOD()
         return FALSE;
     }
     
-	if (!LLPipeline::sImpostorRenderAVVO && isImpostor() && 0 != mDrawable->getNumFaces() && mDrawable->getFace(0)->hasGeometry())
+	if (!LLPipeline::sImpostorRender && isImpostor() && 0 != mDrawable->getNumFaces() && mDrawable->getFace(0)->hasGeometry())
 	{
 		return TRUE;
 	}
@@ -10253,7 +10253,6 @@ void LLVOAvatar::updateImpostors()
 	for (std::vector<LLCharacter*>::iterator iter = instances_copy.begin();
 		iter != instances_copy.end(); ++iter)
 	{
-		// FIXME state spaghetti! Can we just use shouldImpostor() here?
 		LLVOAvatar* avatar = (LLVOAvatar*) *iter;
 		if (!avatar->isDead()
 			&& avatar->isVisible()
@@ -10271,17 +10270,20 @@ void LLVOAvatar::updateImpostors()
 // virtual
 BOOL LLVOAvatar::isImpostor()
 {
-	// FIXME this doesn't seem to actually mean that the avatar is currently shown as an impostor, or should be.
-	// un-impostored avs have mUpdatePeriod 1. IMPOSTOR_PERIOD is 2.
-	//return sUseImpostors && (isVisuallyMuted() || (mUpdatePeriod >= IMPOSTOR_PERIOD));
-	return (isVisuallyMuted() || (sUseImpostors && (mUpdatePeriod >= IMPOSTOR_PERIOD))) ? TRUE : FALSE;
+	return isVisuallyMuted() || (sUseImpostors && (mUpdatePeriod > 1));
 }
 
-BOOL LLVOAvatar::shouldImpostor(const U32 rank_factor)
+BOOL LLVOAvatar::shouldImpostor(const F32 rank_factor)
 {
-	// FIXME sUseImpostors question
-	//return (!isSelf() && sUseImpostors && mVisibilityRank > (sMaxNonImpostors * rank_factor));
-	return (!isSelf() && (sUseImpostors || isVisuallyMuted()) && mVisibilityRank > (sMaxNonImpostors * rank_factor));
+	if (isSelf())
+	{
+		return false;
+	}
+	if (isVisuallyMuted())
+	{
+		return true;
+	}
+	return sUseImpostors && (mVisibilityRank > (sMaxNonImpostors * rank_factor));
 }
 
 BOOL LLVOAvatar::needsImpostorUpdate() const
@@ -10324,7 +10326,7 @@ void LLVOAvatar::getImpostorValues(LLVector4a* extents, LLVector3& angle, F32& d
 }
 
 // static
-const U32 LLVOAvatar::IMPOSTORS_OFF = 66; /* Must equal the maximum allowed the RenderAvatarMaxNonImpostors
+const U32 LLVOAvatar::NON_IMPOSTORS_MAX_SLIDER = 66; /* Must equal the maximum allowed the RenderAvatarMaxNonImpostors
 										   * slider in panel_preferences_graphics1.xml */
 
 // static
@@ -10333,7 +10335,7 @@ void LLVOAvatar::updateImpostorRendering(U32 newMaxNonImpostorsValue)
 	U32  oldmax = sMaxNonImpostors;
 	bool oldflg = sUseImpostors;
 	
-	if (IMPOSTORS_OFF <= newMaxNonImpostorsValue)
+	if (NON_IMPOSTORS_MAX_SLIDER <= newMaxNonImpostorsValue)
 	{
 		sMaxNonImpostors = 0;
 	}
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 7f816d6a2e..b76d6abacd 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -315,8 +315,8 @@ public:
 public:
 	static S32		sRenderName;
 	static BOOL		sRenderGroupTitles;
-	static const U32 IMPOSTORS_OFF; /* Must equal the maximum allowed the RenderAvatarMaxNonImpostors
-									 * slider in panel_preferences_graphics1.xml */
+	static const U32 NON_IMPOSTORS_MAX_SLIDER; /* Must equal the maximum allowed the RenderAvatarMaxNonImpostors
+												* slider in panel_preferences_graphics1.xml */
 	static U32		sMaxNonImpostors; //(affected by control "RenderAvatarMaxNonImpostors")
 	static F32		sRenderDistance; //distance at which avatars will render.
 	static BOOL		sShowAnimationDebug; // show animation debug info
@@ -554,7 +554,7 @@ private:
 	//--------------------------------------------------------------------
 public:
 	virtual BOOL isImpostor();
-	BOOL 		shouldImpostor(const U32 rank_factor = 1);
+	BOOL 		shouldImpostor(const F32 rank_factor = 1.0);
 	BOOL 	    needsImpostorUpdate() const;
 	const LLVector3& getImpostorOffset() const;
 	const LLVector2& getImpostorDim() const;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 4cbe5a29be..f518a2d466 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -340,7 +340,6 @@ bool	LLPipeline::sRenderGlow = false;
 bool	LLPipeline::sReflectionRender = false;
 bool    LLPipeline::sDistortionRender = false;
 bool	LLPipeline::sImpostorRender = false;
-bool	LLPipeline::sImpostorRenderAVVO = false;
 bool	LLPipeline::sImpostorRenderAlphaDepthPass = false;
 bool	LLPipeline::sUnderWaterRender = false;
 bool	LLPipeline::sTextureBindTest = false;
@@ -3077,7 +3076,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera)
 					{
 						LLVOAvatar* av = vobj->asAvatar();
 						if (av &&
-							((!sImpostorRenderAVVO && av->isImpostor()) //ignore impostor flag during impostor pass
+							((!sImpostorRender && av->isImpostor()) //ignore impostor flag during impostor pass
 							 || av->isInMuteList() 
 							 || (LLVOAvatar::AOA_JELLYDOLL == av->getOverallAppearance() && !av->needsImpostorUpdate()) ))
 						{
@@ -10921,7 +10920,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	{
 		LL_RECORD_BLOCK_TIME(FTM_IMPOSTOR_MARK_VISIBLE);
 		markVisible(avatar->mDrawable, *viewer_camera);
-		sImpostorRenderAVVO = true;
 
 		LLVOAvatar::attachment_map_t::iterator iter;
 		for (iter = avatar->mAttachmentPoints.begin();
@@ -11161,7 +11159,6 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 
 	avatar->setImpostorDim(tdim);
 
-	sImpostorRenderAVVO = false;
 	sUseOcclusion = occlusion;
 	sReflectionRender = false;
 	sImpostorRender = false;
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 397c5ef9ff..600bdd9d06 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -590,7 +590,6 @@ public:
 	static bool				sReflectionRender;
     static bool				sDistortionRender;
 	static bool				sImpostorRender;
-    static bool				sImpostorRenderAVVO;
 	static bool				sImpostorRenderAlphaDepthPass;
 	static bool				sUnderWaterRender;
 	static bool				sRenderGlow;
-- 
cgit v1.2.3