From 6837ca5cd899d0aba71f856f540b535a7fc78595 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Tue, 18 Jul 2017 19:33:14 +0100
Subject: [PATCH] SL-727 - right-click menus and hover info ignore control
 avatars.

---
 indra/newview/llcontrolavatar.cpp | 46 +++++++++++++++++++++++++++++++
 indra/newview/llcontrolavatar.h   | 11 ++++++++
 indra/newview/llvoavatar.cpp      |  1 +
 indra/newview/llvoavatar.h        |  3 +-
 indra/newview/llvovolume.cpp      | 16 +++++++++++
 indra/newview/llvovolume.h        |  2 ++
 6 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp
index 4aee5819aa1..94e5666a70b 100644
--- a/indra/newview/llcontrolavatar.cpp
+++ b/indra/newview/llcontrolavatar.cpp
@@ -195,6 +195,18 @@ void LLControlAvatar::updateDebugText()
     getAnimatedVolumes(volumes);
     S32 animated_volume_count = volumes.size();
     addDebugText(llformat("CAV obj %d anim %d", total_linkset_count, animated_volume_count));
+#if 0
+    // AXON - detailed rigged mesh info
+    for (std::vector<LLVOVolume*>::iterator it = volumes.begin();
+         it != volumes.end(); ++it)
+    {
+        LLRiggedVolume *rig_vol = (*it)->getRiggedVolume();
+        if (rig_vol)
+        {
+            addDebugText(rig_vol->mExtraDebugText);
+        }
+    }
+#endif
 
     LLVOAvatar::updateDebugText();
 }
@@ -262,3 +274,37 @@ void LLControlAvatar::updateAnimations()
     LL_DEBUGS("AXON") << "process animation state changes here" << LL_ENDL;
     processAnimationStateChanges();
 }
+
+// virtual
+LLViewerObject* LLControlAvatar::lineSegmentIntersectRiggedAttachments(const LLVector4a& start, const LLVector4a& end,
+									  S32 face,
+									  BOOL pick_transparent,
+									  BOOL pick_rigged,
+									  S32* face_hit,
+									  LLVector4a* intersection,
+									  LLVector2* tex_coord,
+									  LLVector4a* normal,
+									  LLVector4a* tangent)
+{
+	LLViewerObject* hit = NULL;
+
+	if (lineSegmentBoundingBox(start, end))
+	{
+		LLVector4a local_end = end;
+		LLVector4a local_intersection;
+
+        if (mRootVolp &&
+            mRootVolp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent))
+        {
+            local_end = local_intersection;
+            if (intersection)
+            {
+                *intersection = local_intersection;
+            }
+			
+            hit = mRootVolp;
+        }
+	}
+		
+	return hit;
+}
diff --git a/indra/newview/llcontrolavatar.h b/indra/newview/llcontrolavatar.h
index 1be2d584416..a6b77b73bab 100644
--- a/indra/newview/llcontrolavatar.h
+++ b/indra/newview/llcontrolavatar.h
@@ -55,6 +55,17 @@ class LLControlAvatar:
     void getAnimatedVolumes(std::vector<LLVOVolume*>& volumes);
     void updateAnimations();  
     
+	virtual LLViewerObject*	lineSegmentIntersectRiggedAttachments(
+        const LLVector4a& start, const LLVector4a& end,
+        S32 face = -1,                    // which face to check, -1 = ALL_SIDES
+        BOOL pick_transparent = FALSE,
+        BOOL pick_rigged = FALSE,
+        S32* face_hit = NULL,             // which face was hit
+        LLVector4a* intersection = NULL,   // return the intersection point
+        LLVector2* tex_coord = NULL,      // return the texture coordinates of the intersection point
+        LLVector4a* normal = NULL,         // return the surface normal at the intersection point
+        LLVector4a* tangent = NULL);     // return the surface tangent at the intersection point
+
 	virtual void	updateDebugText();
 
     bool mPlaying;
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index ee570c83456..eab5206828e 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1704,6 +1704,7 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a&
 	return FALSE;
 }
 
+// virtual
 LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector4a& start, const LLVector4a& end,
 									  S32 face,
 									  BOOL pick_transparent,
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 406b9d8a22f..8b22024e0a4 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -169,7 +169,8 @@ class LLVOAvatar :
 												 LLVector2* tex_coord = NULL,      // return the texture coordinates of the intersection point
 												 LLVector4a* normal = NULL,         // return the surface normal at the intersection point
 												 LLVector4a* tangent = NULL);     // return the surface tangent at the intersection point
-	LLViewerObject*	lineSegmentIntersectRiggedAttachments(const LLVector4a& start, const LLVector4a& end,
+	virtual LLViewerObject*	lineSegmentIntersectRiggedAttachments(
+                                                 const LLVector4a& start, const LLVector4a& end,
 												 S32 face = -1,                    // which face to check, -1 = ALL_SIDES
 												 BOOL pick_transparent = FALSE,
 												 BOOL pick_rigged = FALSE,
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index d661837dddf..bdd0cb09848 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4364,6 +4364,9 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
 	U32 maxJoints = LLSkinningUtil::getMeshJointCount(skin);
     LLSkinningUtil::initSkinningMatrixPalette((LLMatrix4*)mat, maxJoints, skin, avatar);
 
+    S32 rigged_vert_count = 0;
+    S32 rigged_face_count = 0;
+    LLVector4a box_min, box_max;
 	for (S32 i = 0; i < volume->getNumVolumeFaces(); ++i)
 	{
 		const LLVolumeFace& vol_face = volume->getVolumeFace(i);
@@ -4385,6 +4388,8 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
 				LL_RECORD_BLOCK_TIME(FTM_SKIN_RIGGED);
 
                 U32 max_joints = LLSkinningUtil::getMaxJointCount();
+                rigged_vert_count += dst_face.mNumVertices;
+                rigged_face_count++;
 				for (U32 j = 0; j < dst_face.mNumVertices; ++j)
 				{
 					LLMatrix4a final_mat;
@@ -4404,12 +4409,19 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
 
 				min = pos[0];
 				max = pos[1];
+                if (i==0)
+                {
+                    box_min = min;
+                    box_max = max;
+                }
 
 				for (U32 j = 1; j < dst_face.mNumVertices; ++j)
 				{
 					min.setMin(min, pos[j]);
 					max.setMax(max, pos[j]);
 				}
+                box_min.setMin(min,box_min);
+                box_max.setMax(max,box_max);
 
 				dst_face.mCenter->setAdd(dst_face.mExtents[0], dst_face.mExtents[1]);
 				dst_face.mCenter->mul(0.5f);
@@ -4429,6 +4441,10 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
 			}
 		}
 	}
+    mExtraDebugText = llformat("rigged %d/%d - box (%f %f %f) (%f %f %f)",
+                               rigged_face_count, rigged_vert_count,
+                               box_min[0], box_min[1], box_min[2],
+                               box_max[0], box_max[1], box_max[2]);
 }
 
 U32 LLVOVolume::getPartitionType() const
diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h
index 3c0c9facb1c..44d9c65b4bf 100644
--- a/indra/newview/llvovolume.h
+++ b/indra/newview/llvovolume.h
@@ -62,6 +62,8 @@ class LLRiggedVolume : public LLVolume
 	}
 
 	void update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, const LLVolume* src_volume);
+
+    std::string mExtraDebugText;
 };
 
 // Base class for implementations of the volume - Primitive, Flexible Object, etc.
-- 
GitLab