From c5dc0ee36e8d17fd0cf25f5a1fbdfb8609a64ee0 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Fri, 9 Jun 2017 21:13:54 +0100
Subject: [PATCH] SL-704 - code cleanup

---
 indra/newview/llcontrolavatar.cpp  |  5 +--
 indra/newview/lldrawpoolavatar.cpp |  2 +-
 indra/newview/llpanelvolume.cpp    |  4 +--
 indra/newview/llviewermessage.cpp  |  2 +-
 indra/newview/llvoavatar.cpp       | 54 ++++++++++++++++--------------
 indra/newview/llvograss.cpp        |  2 +-
 indra/newview/llvovolume.cpp       | 10 +++---
 indra/newview/llvovolume.h         |  4 +--
 8 files changed, 42 insertions(+), 41 deletions(-)

diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp
index 1ecd3305ed8..a8caba08afe 100644
--- a/indra/newview/llcontrolavatar.cpp
+++ b/indra/newview/llcontrolavatar.cpp
@@ -92,14 +92,11 @@ void LLControlAvatar::updateGeom(LLVOVolume *obj)
 
 LLControlAvatar *LLControlAvatar::createControlAvatar(LLVOVolume *obj)
 {
-    // TRIF Lifted from LLPreviewAnimation
+    // AXON Lifted from LLPreviewAnimation
 	LLControlAvatar *cav = (LLControlAvatar*)gObjectList.createObjectViewer(LL_PCODE_LEGACY_AVATAR, gAgent.getRegion(), CO_FLAG_CONTROL_AVATAR);
 	cav->createDrawable(&gPipeline);
 	cav->mIsDummy = TRUE;
 	cav->mSpecialRenderMode = 1;
-	//cav->setPositionAgent(obj->getRenderPosition());
-	//cav->slamPosition();
-	//cav->setRotation(obj->getRotation());
 	cav->updateJointLODs();
 	cav->updateGeometry(cav->mDrawable);
 	cav->startMotion(ANIM_AGENT_STAND, 5.0f);
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index fa4fd7c5333..869e37e08c3 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -468,7 +468,7 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 	LLVOAvatar *avatarp = (LLVOAvatar *)facep->getDrawable()->getVObj().get();
 
 // AXON fix
-	if (avatarp->isDead() || /*avatarp->mIsDummy ||*/ avatarp->mDrawable.isNull())
+	if (avatarp->isDead() || avatarp->mIsDummy || avatarp->mDrawable.isNull())
 	{
 		return;
 	}
diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp
index 58cbede57ba..f34194db19d 100644
--- a/indra/newview/llpanelvolume.cpp
+++ b/indra/newview/llpanelvolume.cpp
@@ -355,8 +355,8 @@ void LLPanelVolume::getState( )
     // AXON FIXME CHECK FOR SKIN INFO ALSO
     // WHAT ABOUT isPermanentEnforced?
     // What about linksets with some skinned objects?
-    BOOL can_be_animated_mesh = volobjp && volobjp->canBeAnimatedMesh() && editable;
-    getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(can_be_animated_mesh);
+    BOOL can_be_animated_object = volobjp && volobjp->canBeAnimatedObject() && editable;
+    getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(can_be_animated_object);
 
 	// Flexible properties
 	BOOL is_flexible = volobjp && volobjp->isFlexible();
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 7fd87f99d36..db237d30ea6 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -5091,7 +5091,7 @@ void process_object_animation(LLMessageSystem *mesgsys, void **user_data)
         return;
     }
 
-    if (!volp->isAnimatedMesh())
+    if (!volp->isAnimatedObject())
     {
 		LL_WARNS("Messaging") << "AXON Received animation state for non-animated object" << uuid << LL_ENDL;
         return;
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 7ba264f35ad..1c9f79b2009 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1944,7 +1944,9 @@ void LLVOAvatar::resetSkeleton(bool reset_animations)
 //-----------------------------------------------------------------------------
 void LLVOAvatar::releaseMeshData()
 {
-	if (sInstances.size() < AVATAR_RELEASE_THRESHOLD)// || mIsDummy)
+    // AXON what should we be doing here for control avs? Why are
+    // dummies treated differently in the first place?
+	if (sInstances.size() < AVATAR_RELEASE_THRESHOLD || mIsDummy)
 	{
 		return;
 	}
@@ -2740,7 +2742,7 @@ void LLVOAvatar::idleUpdateLoadingEffect()
 																 LLPartData::LL_PART_EMISSIVE_MASK | // LLPartData::LL_PART_FOLLOW_SRC_MASK |
 																 LLPartData::LL_PART_TARGET_POS_MASK );
 			
-            // TRIF skip cloud effects for dummy avs as well
+            // AXON skip cloud effects for dummy avs as well
 			if (!mIsDummy && !isTooComplex()) // do not generate particles for overly-complex avatars
 			{
 				setParticleSource(particle_parameters, getID());
@@ -3533,7 +3535,9 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
 	}
 
 	// change animation time quanta based on avatar render load
-	if (!isSelf())// && !mIsDummy)
+    // AXON how should control avs be handled here?
+    bool is_pure_dummy = mIsDummy && !isControlAvatar();
+	if (!isSelf() && !is_pure_dummy)
 	{
 		F32 time_quantum = clamp_rescale((F32)sInstances.size(), 10.f, 35.f, 0.f, 0.25f);
 		F32 pixel_area_scale = clamp_rescale(mPixelArea, 100, 5000, 1.f, 0.f);
@@ -3655,8 +3659,8 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
 		//--------------------------------------------------------------------
 		// Propagate viewer object rotation to root of avatar
 		//--------------------------------------------------------------------
-        // FIXME TRIF - just skipping this for now for all dummy avs
-		if (!mIsDummy && !isAnyAnimationSignaled(AGENT_NO_ROTATE_ANIMS, NUM_AGENT_NO_ROTATE_ANIMS))
+        // AXON - also skip for control avatars
+		if (!isControlAvatar() && !isAnyAnimationSignaled(AGENT_NO_ROTATE_ANIMS, NUM_AGENT_NO_ROTATE_ANIMS))
 		{
 			LLQuaternion iQ;
 			LLVector3 upDir( 0.0f, 0.0f, 1.0f );
@@ -4356,11 +4360,12 @@ U32 LLVOAvatar::renderSkinned()
 		}
 		
 		BOOL first_pass = TRUE;
+        bool is_pure_dummy = mIsDummy && !isControlAvatar();
 		if (!LLDrawPoolAvatar::sSkipOpaque)
 		{
 			if (!isSelf() || gAgent.needsRenderHead() || LLPipeline::sShadowRender)
 			{
-				if (isTextureVisible(TEX_HEAD_BAKED))// || mIsDummy)
+				if (isTextureVisible(TEX_HEAD_BAKED) || is_pure_dummy)
 				{
 					LLViewerJoint* head_mesh = getViewerJoint(MESH_ID_HEAD);
 					if (head_mesh)
@@ -4370,7 +4375,7 @@ U32 LLVOAvatar::renderSkinned()
 					first_pass = FALSE;
 				}
 			}
-			if (isTextureVisible(TEX_UPPER_BAKED))// || mIsDummy)
+			if (isTextureVisible(TEX_UPPER_BAKED) || is_pure_dummy)
 			{
 				LLViewerJoint* upper_mesh = getViewerJoint(MESH_ID_UPPER_BODY);
 				if (upper_mesh)
@@ -4380,7 +4385,7 @@ U32 LLVOAvatar::renderSkinned()
 				first_pass = FALSE;
 			}
 			
-			if (isTextureVisible(TEX_LOWER_BAKED))// || mIsDummy)
+			if (isTextureVisible(TEX_LOWER_BAKED) || is_pure_dummy)
 			{
 				LLViewerJoint* lower_mesh = getViewerJoint(MESH_ID_LOWER_BODY);
 				if (lower_mesh)
@@ -4437,20 +4442,14 @@ U32 LLVOAvatar::renderTransparent(BOOL first_pass)
 			}
 			first_pass = FALSE;
 		}
-		// Can't test for baked hair being defined, since that won't always be the case (not all viewers send baked hair)
-		// TODO: 1.25 will be able to switch this logic back to calling isTextureVisible();
-        if (!mIsDummy)
+		if (isTextureVisible(TEX_HAIR_BAKED))
         {
-		if ( (getImage(TEX_HAIR_BAKED, 0) && getImage(TEX_HAIR_BAKED, 0)->getID() != IMG_INVISIBLE)
-			|| LLDrawPoolAlpha::sShowDebugAlpha)		
-		{
-			LLViewerJoint* hair_mesh = getViewerJoint(MESH_ID_HAIR);
-			if (hair_mesh)
-			{
-				num_indices += hair_mesh->render(mAdjustedPixelArea, first_pass, mIsDummy);
-			}
-			first_pass = FALSE;
-		}
+            LLViewerJoint* hair_mesh = getViewerJoint(MESH_ID_HAIR);
+            if (hair_mesh)
+            {
+                num_indices += hair_mesh->render(mAdjustedPixelArea, first_pass, mIsDummy);
+            }
+            first_pass = FALSE;
         }
 		if (LLPipeline::sImpostorRender)
 		{
@@ -4491,7 +4490,9 @@ U32 LLVOAvatar::renderRigid()
 		gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f);
 	}
 
-	if (isTextureVisible(TEX_EYES_BAKED)  || mIsDummy)
+    bool is_pure_dummy = mIsDummy && !isControlAvatar();
+
+	if (isTextureVisible(TEX_EYES_BAKED)  || is_pure_dummy)
 	{
 		LLViewerJoint* eyeball_left = getViewerJoint(MESH_ID_EYEBALL_LEFT);
 		LLViewerJoint* eyeball_right = getViewerJoint(MESH_ID_EYEBALL_RIGHT);
@@ -5529,7 +5530,7 @@ void LLVOAvatar::rebuildAttachmentOverrides()
 void LLVOAvatar::addAttachmentOverridesForObject(LLViewerObject *vo)
 {
     bool non_attached_case = false;
-    // FIXME TRIF - will this work if vo has child objects?
+    // FIXME AXON - will this work if vo has child objects?
     if (vo->mControlAvatar)
     {
         non_attached_case = true;
@@ -5759,7 +5760,7 @@ void LLVOAvatar::showAttachmentOverrides(bool verbose) const
 //-----------------------------------------------------------------------------
 // resetJointsOnDetach
 //-----------------------------------------------------------------------------
-// TRIF handle NPC case
+// AXON handle NPC case
 void LLVOAvatar::resetJointsOnDetach(LLViewerObject *vo)
 {
 	LLVOAvatar *av = vo->getAvatarAncestor();
@@ -5788,7 +5789,7 @@ void LLVOAvatar::resetJointsOnDetach(LLViewerObject *vo)
 //-----------------------------------------------------------------------------
 // resetJointsOnDetach
 //-----------------------------------------------------------------------------
-// TRIF handle NPC case
+// AXON handle NPC case
 void LLVOAvatar::resetJointsOnDetach(const LLUUID& mesh_id)
 {	
 	//Subsequent joints are relative to pelvis
@@ -5867,6 +5868,7 @@ void LLVOAvatar::getGround(const LLVector3 &in_pos_agent, LLVector3 &out_pos_age
 	LLVector3d z_vec(0.0f, 0.0f, 1.0f);
 	LLVector3d p0_global, p1_global;
 
+    // AXON update for control avs?
 	if (mIsDummy)
 	{
 		outNorm.setVec(z_vec);
@@ -5896,6 +5898,7 @@ F32 LLVOAvatar::getTimeDilation()
 //-----------------------------------------------------------------------------
 F32 LLVOAvatar::getPixelArea() const
 {
+    // AXON update for control avatars
 	if (mIsDummy)
 	{
 		return 100000.f;
@@ -6827,6 +6830,7 @@ void LLVOAvatar::onGlobalColorChanged(const LLTexGlobalColor* global_color)
 
 BOOL LLVOAvatar::isVisible() const
 {
+    // AXON should we flag control avs as invisible?
 	return mDrawable.notNull()
 		&& (!mOrphaned || isSelf())
 		&& (mDrawable->isVisible() || mIsDummy);
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index e7e4e6f2286..337f969f3d0 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -92,7 +92,7 @@ LLVOGrass::~LLVOGrass()
 
 void LLVOGrass::updateSpecies()
 {
-	// TRIF is grass still even supported? This use of state seems odd.
+	// AXON is grass still even supported? This use of state seems odd.
 	mSpecies = getAttachmentState();
 	
 	if (!sSpeciesTable.count(mSpecies))
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index a2f417a5cca..59e1895bc6d 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3308,7 +3308,7 @@ void LLVOVolume::setExtendedMeshFlags(U32 flags)
     }
 }
 
-bool LLVOVolume::canBeAnimatedMesh() const
+bool LLVOVolume::canBeAnimatedObject() const
 {
     if (!isMesh())
     {
@@ -3322,9 +3322,9 @@ bool LLVOVolume::canBeAnimatedMesh() const
     return true;
 }
 
-bool LLVOVolume::isAnimatedMesh() const
+bool LLVOVolume::isAnimatedObject() const
 {
-    return canBeAnimatedMesh() && (getExtendedMeshFlags() & LLExtendedMeshParams::ANIMATED_MESH_ENABLED_FLAG);
+    return canBeAnimatedObject() && (getExtendedMeshFlags() & LLExtendedMeshParams::ANIMATED_MESH_ENABLED_FLAG);
 }
 
 //----------------------------------------------------------------------------
@@ -4850,11 +4850,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
 			bool bake_sunlight = LLPipeline::sBakeSunlight && drawablep->isStatic();
 
-            // TRIF why this variable? Only different from rigged if
+            // AXON why this variable? Only different from rigged if
             // there are no LLFaces associated with the drawable.
 			bool is_rigged = false;
 
-            // TRIF handle NPC case
+            // AXON handle NPC case
             if (rigged && pAvatarVO)
             {
                 pAvatarVO->addAttachmentOverridesForObject(vobj);
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 5918166aff4..75dabd961a5 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -269,8 +269,8 @@ class LLVOVolume : public LLViewerObject
     // Extended Mesh Properties
     U32 getExtendedMeshFlags() const;
     void setExtendedMeshFlags(U32 flags);
-    bool canBeAnimatedMesh() const;
-    bool isAnimatedMesh() const;
+    bool canBeAnimatedObject() const;
+    bool isAnimatedObject() const;
 
     // Functions that deal with media, or media navigation
     
-- 
GitLab