From 34ced1aa2cc286db26e2866cfc7a53ef72d828a4 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Fri, 2 Sep 2016 16:44:57 -0400
Subject: SL-395 - partial support for joint scale locking via flag in skin
 info

---
 indra/llprimitive/lldaeloader.cpp | 33 ++++++++++++++++++++-------------
 indra/llprimitive/llmodel.cpp     | 11 +++++++++--
 indra/llprimitive/llmodel.h       |  1 +
 3 files changed, 30 insertions(+), 15 deletions(-)

(limited to 'indra/llprimitive')

diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp
index 37ebdf2cec..c194d677c8 100644
--- a/indra/llprimitive/lldaeloader.cpp
+++ b/indra/llprimitive/lldaeloader.cpp
@@ -1379,6 +1379,16 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
 
 		if ( !missingSkeletonOrScene )
 		{
+            // FIXME: mesh_id is used to determine which mesh gets to
+            // set the joint offset, in the event of a conflict. Since
+            // we don't know the mesh id yet, we can't guarantee that
+            // joint offsets will be applied with the same priority as
+            // in the uploaded model. If the file contains multiple
+            // meshes with conflicting joint offsets, preview may be
+            // incorrect.
+            LLUUID fake_mesh_id;
+            fake_mesh_id.generate();
+
 			//Set the joint translations on the avatar
             JointMap :: const_iterator masterJointIt = mJointMap.begin();
             JointMap :: const_iterator masterJointItEnd = mJointMap.end();
@@ -1393,19 +1403,16 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do
                     LLJoint* pJoint = mJointLookupFunc(lookingForJoint,mOpaqueData);
                     if ( pJoint )
                     {   
-                        // FIXME: mesh_id is used to determine which
-                        // mesh gets to set the joint offset, in the
-                        // event of a conflict. Since we don't know
-                        // the mesh id yet, we can't guarantee that
-                        // joint offsets will be applied with the same
-                        // priority as in the uploaded model. If the
-                        // file contains multiple meshes with
-                        // conflicting joint offsets, preview may be
-                        // incorrect.
-                        LLUUID fake_mesh_id;
-                        fake_mesh_id.generate();
-                        bool dummy; // not used
-                        pJoint->addAttachmentPosOverride( jointTransform.getTranslation(), fake_mesh_id, "", dummy);
+                        const LLVector3& joint_pos = jointTransform.getTranslation();
+                        if (pJoint->aboveJointPosThreshold(joint_pos))
+                        {
+                            bool override_changed; // not used
+                            pJoint->addAttachmentPosOverride(joint_pos, fake_mesh_id, "", override_changed);
+                            if (model->mSkinInfo.mLockScaleIfJointPosition)
+                            {
+                                pJoint->addAttachmentScaleOverride(pJoint->getDefaultScale(), fake_mesh_id, "");
+                            }
+                        }
                     }
                     else
                     {
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index 398f0997f3..cd9e5cfa54 100644
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -50,8 +50,12 @@ std::string model_names[] =
 const int MODEL_NAMES_LENGTH = sizeof(model_names) / sizeof(std::string);
 
 LLModel::LLModel(LLVolumeParams& params, F32 detail)
-	: LLVolume(params, detail), mNormalizedScale(1,1,1), mNormalizedTranslation(0,0,0)
-	, mPelvisOffset( 0.0f ), mStatus(NO_ERRORS), mSubmodelID(0)
+	: LLVolume(params, detail), 
+      mNormalizedScale(1,1,1), 
+      mNormalizedTranslation(0,0,0), 
+      mPelvisOffset( 0.0f ), 
+      mStatus(NO_ERRORS), 
+      mSubmodelID(0)
 {
 	mDecompID = -1;
 	mLocalID = -1;
@@ -1446,6 +1450,9 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin)
 	{
 		mPelvisOffset = skin["pelvis_offset"].asReal();
 	}
+
+    // FIXME BENTO check contents of asset.
+    mLockScaleIfJointPosition = true;
 }
 
 LLSD LLMeshSkinInfo::asLLSD(bool include_joints) const
diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h
index 5f98942340..fe6ce148c4 100644
--- a/indra/llprimitive/llmodel.h
+++ b/indra/llprimitive/llmodel.h
@@ -54,6 +54,7 @@ public:
 	LLSD asLLSD(bool include_joints) const;
 	LLMatrix4 mBindShapeMatrix;
 	float mPelvisOffset;
+    bool mLockScaleIfJointPosition;
 };
 
 class LLModel : public LLVolume
-- 
cgit v1.2.3