From 93675c22ba2d0f0cfeddeb9318433a412bde79fa Mon Sep 17 00:00:00 2001
From: Kitty Barnett <develop@catznip.com>
Date: Sun, 15 Aug 2021 13:28:38 +0200
Subject: [PATCH] Review @setcam_dist after changes to jelly doll rendering

---
 indra/newview/llviewermenu.cpp | 15 ++--------
 indra/newview/llvoavatar.cpp   | 54 +++++++++++++++-------------------
 indra/newview/llvoavatar.h     | 12 ++++----
 3 files changed, 33 insertions(+), 48 deletions(-)

diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 2ddff07b7e4..b381172c19b 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -3201,20 +3201,11 @@ class LLAvatarCheckImpostorMode : public view_listener_t
 		switch (mode) 
 		{
 			case 0:
-// [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
-				return LLRenderMuteList::instance().getSavedVisualMuteSetting(avatar->getID()) == LLVOAvatar::AV_RENDER_NORMALLY;
-// [/RLVa:KB]
-//				return (avatar->getVisualMuteSettings() == LLVOAvatar::AV_RENDER_NORMALLY);
+				return (avatar->getVisualMuteSettings() == LLVOAvatar::AV_RENDER_NORMALLY);
 			case 1:
-// [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
-				return LLRenderMuteList::instance().getSavedVisualMuteSetting(avatar->getID()) == LLVOAvatar::AV_DO_NOT_RENDER;
-// [/RLVa:KB]
-//				return (avatar->getVisualMuteSettings() == LLVOAvatar::AV_DO_NOT_RENDER);
+				return (avatar->getVisualMuteSettings() == LLVOAvatar::AV_DO_NOT_RENDER);
 			case 2:
-// [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
-				return LLRenderMuteList::instance().getSavedVisualMuteSetting(avatar->getID()) == LLVOAvatar::AV_ALWAYS_RENDER;
-// [/RLVa:KB]
-//				return (avatar->getVisualMuteSettings() == LLVOAvatar::AV_ALWAYS_RENDER);
+				return (avatar->getVisualMuteSettings() == LLVOAvatar::AV_ALWAYS_RENDER);
 			default:
 				return false;
 		}
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index f90d3a444d6..08f15a16bfe 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -3679,7 +3679,14 @@ bool LLVOAvatar::isVisuallyMuted()
 	// * check against the render cost and attachment limits
 	if (!isSelf())
 	{
-		if (mVisuallyMuteSetting == AV_ALWAYS_RENDER)
+// [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
+		if (isRlvSilhouette())
+		{
+			muted = true;
+		}
+		else if (mVisuallyMuteSetting == AV_ALWAYS_RENDER)
+// [/RLVa:KB]
+//		if (mVisuallyMuteSetting == AV_ALWAYS_RENDER)
 		{
 			muted = false;
 		}
@@ -3696,12 +3703,6 @@ bool LLVOAvatar::isVisuallyMuted()
         {
             muted = true;
         }
-// [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
-		else if (isRlvSilhouette())
-		{
-			muted = true;
-		}
-// [/RLVa:KB]
 		else 
 		{
 			muted = isTooComplex();
@@ -3731,9 +3732,9 @@ bool LLVOAvatar::isInMuteList() const
 }
 
 // [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
-bool LLVOAvatar::isRlvSilhouette()
+bool LLVOAvatar::isRlvSilhouette() const
 {
-	if (!gRlvHandler.hasBehaviour(RLV_BHVR_SETCAM_AVDIST))
+	if (!RlvActions::hasBehaviour(RLV_BHVR_SETCAM_AVDIST))
 		return false;
 
 	static RlvCachedBehaviourModifier<float> s_nSetCamAvDist(RLV_MODIFIER_SETCAM_AVDIST);
@@ -3741,14 +3742,14 @@ bool LLVOAvatar::isRlvSilhouette()
 	const F64 now = LLFrameTimer::getTotalSeconds();
 	if (now >= mCachedRlvSilhouetteUpdateTime)
 	{
-		const F64 SECONDS_BETWEEN_NEARBY_UPDATES = .5f;
+		const F64 SECONDS_BETWEEN_SILHOUETTE_UPDATES = .5f;
 		bool fIsRlvSilhouette = dist_vec_squared(gAgent.getPositionGlobal(), getPositionGlobal()) > s_nSetCamAvDist() * s_nSetCamAvDist();
 		if (fIsRlvSilhouette != mCachedIsRlvSilhouette)
 		{
 			mCachedIsRlvSilhouette = fIsRlvSilhouette;
 			mNeedsImpostorUpdate = TRUE;
 		}
-		mCachedRlvSilhouetteUpdateTime = now + SECONDS_BETWEEN_NEARBY_UPDATES;
+		mCachedRlvSilhouetteUpdateTime = now + SECONDS_BETWEEN_SILHOUETTE_UPDATES;
 	}
 	return mCachedIsRlvSilhouette;
 }
@@ -11092,23 +11093,19 @@ void LLVOAvatar::calcMutedAVColor()
     std::string change_msg;
     LLUUID av_id(getID());
 
-    if (getVisualMuteSettings() == AV_DO_NOT_RENDER)
-    {
 // [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
-		 if (isRlvSilhouette())
-		 {
-			 new_color = LLColor4::silhouette;
-			 change_msg = " not rendered: color is silhouette";
-		 }
-		 else
-		 {
-// [/RLVa:KB]
-			// explicitly not-rendered avatars are light grey
-			new_color = LLColor4::grey4;
-			change_msg = " not rendered: color is grey4";
-// [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
-		 }
+	if (isRlvSilhouette())
+	{
+		new_color = LLColor4::silhouette;
+		change_msg = " not rendered: color is silhouette";
+	}
+    else if (getVisualMuteSettings() == AV_DO_NOT_RENDER)
 // [/RLVa:KB]
+//    if (getVisualMuteSettings() == AV_DO_NOT_RENDER)
+    {
+        // explicitly not-rendered avatars are light grey
+        new_color = LLColor4::grey4;
+        change_msg = " not rendered: color is grey4";
     }
     else if (LLMuteList::getInstance()->isMuted(av_id)) // the user blocked them
     {
@@ -11122,10 +11119,7 @@ void LLVOAvatar::calcMutedAVColor()
         change_msg = " simple imposter ";
     }
 #ifdef COLORIZE_JELLYDOLLS
-//    else if ( mMutedAVColor == LLColor4::white || mMutedAVColor == LLColor4::grey3 || mMutedAVColor == LLColor4::grey4 )
-// [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
-	else if ( mMutedAVColor == LLColor4::white || mMutedAVColor == LLColor4::grey3 || mMutedAVColor == LLColor4::grey4 || mMutedAVColor == LLColor4::silhouette)
-// [/RLVa:KB]
+    else if ( mMutedAVColor == LLColor4::white || mMutedAVColor == LLColor4::grey3 || mMutedAVColor == LLColor4::grey4 )
 	{
         // select a color based on the first byte of the agents uuid so any muted agent is always the same color
         F32 color_value = (F32) (av_id.mData[0]);
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index d785044c80d..c2fdc0d8f3e 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -438,7 +438,7 @@ class LLVOAvatar :
 	bool		isVisuallyMuted();
 	bool 		isInMuteList() const;
 // [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
-	bool        isRlvSilhouette();
+	bool        isRlvSilhouette() const;
 // [/RLVa:KB]
 	void		forceUpdateVisualMuteSettings();
 
@@ -455,10 +455,7 @@ class LLVOAvatar :
 
 protected:
 	// If you think you need to access this outside LLVOAvatar, you probably want getOverallAppearance()
-// [RLVa:KB] - Checked: RLVa-2.2 (@setcam_avdist)
-	VisualMuteSettings  getVisualMuteSettings()						{ return (!isRlvSilhouette()) ? mVisuallyMuteSetting : AV_DO_NOT_RENDER; };
-// [/RLVa:KB]
-//	VisualMuteSettings  getVisualMuteSettings()						{ return mVisuallyMuteSetting;	};
+	VisualMuteSettings  getVisualMuteSettings()						{ return mVisuallyMuteSetting;	};
 
 public:
 
@@ -581,7 +578,10 @@ class LLVOAvatar :
 	static void	resetImpostors();
 	static void updateImpostors();
 	LLRenderTarget mImpostor;
-	BOOL		mNeedsImpostorUpdate;
+// [RLVa:KB] - Checked: RLVa-2.4 (@setcam_avdist)
+	mutable BOOL mNeedsImpostorUpdate;
+// [/RLVa:KB]
+//	BOOL		mNeedsImpostorUpdate;
 	S32			mLastImpostorUpdateReason;
 	F32SecondsImplicit mLastImpostorUpdateFrameTime;
     const LLVector3*  getLastAnimExtents() const { return mLastAnimExtents; }
-- 
GitLab