From aacb7eb25fd4caceaafb145ed550e14cebeef665 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Mon, 1 Oct 2018 16:11:09 +0100
Subject: SL-9773 - treat animated object attachments the same as other rigged
 attachments for purposes of visibility in mouselook.

---
 indra/newview/llcontrolavatar.cpp  | 14 ++++++++++++++
 indra/newview/llcontrolavatar.h    |  2 ++
 indra/newview/lldrawpoolavatar.cpp |  2 +-
 indra/newview/llvoavatar.cpp       |  6 ++++++
 indra/newview/llvoavatar.h         |  1 +
 indra/newview/llvoavatarself.cpp   |  6 ++++++
 indra/newview/llvoavatarself.h     |  3 +++
 7 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp
index a620f2abe9..28c02b0434 100644
--- a/indra/newview/llcontrolavatar.cpp
+++ b/indra/newview/llcontrolavatar.cpp
@@ -574,3 +574,17 @@ std::string LLControlAvatar::getFullname() const
         return "AO_no_root_vol";
     }
 }
+
+// virtual
+bool LLControlAvatar::shouldRenderRigged() const
+{
+    if (mRootVolp && mRootVolp->isAttachment())
+    {
+        LLVOAvatar *attached_av = mRootVolp->getAvatarAncestor();
+        if (attached_av)
+        {
+            return attached_av->shouldRenderRigged();
+        }
+    }
+    return true;
+}
diff --git a/indra/newview/llcontrolavatar.h b/indra/newview/llcontrolavatar.h
index 9924697938..f7f8db2717 100644
--- a/indra/newview/llcontrolavatar.h
+++ b/indra/newview/llcontrolavatar.h
@@ -73,6 +73,8 @@ public:
 
     virtual std::string getFullname() const;
 
+    /* virtual */ bool shouldRenderRigged() const;
+    
     bool mPlaying;
 
     F32 mGlobalScale;
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 905428b090..d5e86143f1 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -1709,7 +1709,7 @@ void LLDrawPoolAvatar::updateRiggedFaceVertexBuffer(
 
 void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
 {
-	if (avatar->isSelf() && !gAgent.needsRenderAvatar())
+	if (!avatar->shouldRenderRigged())
 	{
 		return;
 	}
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 1f72aed5b4..93885a4472 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -7464,6 +7464,12 @@ void LLVOAvatar::onGlobalColorChanged(const LLTexGlobalColor* global_color)
 	updateMeshTextures();
 }
 
+// virtual
+bool LLVOAvatar::shouldRenderRigged() const
+{
+    return true;
+}
+
 // FIXME: We have an mVisible member, set in updateVisibility(), but this
 // function doesn't return it! isVisible() and mVisible are used
 // different places for different purposes. mVisible seems to be more
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 25c89f96d7..985559f2d6 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -756,6 +756,7 @@ private:
 	//--------------------------------------------------------------------
 public:
 	BOOL			isVisible() const;
+    virtual bool    shouldRenderRigged() const;
 	void			setVisibilityRank(U32 rank);
     U32				getVisibilityRank() const { return mVisibilityRank; }
 	static S32 		sNumVisibleAvatars; // Number of instances of this class
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index b3a2d7951c..dcaade55a6 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -2701,6 +2701,12 @@ void LLVOAvatarSelf::onCustomizeEnd(bool disable_camera_switch)
 	}
 }
 
+// virtual
+bool LLVOAvatarSelf::shouldRenderRigged() const
+{
+    return gAgent.needsRenderAvatar(); 
+}
+
 // HACK: this will null out the avatar's local texture IDs before the TE message is sent
 //       to ensure local texture IDs are not sent to other clients in the area.
 //       this is a short-term solution. The long term solution will be to not set the texture
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index f9f90bb323..b0fdae9bf0 100644
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -312,6 +312,9 @@ public:
 	//--------------------------------------------------------------------
 	// Visibility
 	//--------------------------------------------------------------------
+
+    /* virtual */ bool shouldRenderRigged() const;
+    
 public:
 	bool			sendAppearanceMessage(LLMessageSystem *mesgsys) const;
 
-- 
cgit v1.2.3