summaryrefslogtreecommitdiff
path: root/indra/llcharacter
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2014-08-27 16:52:52 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2014-08-27 16:52:52 -0400
commit94f945c2c65fcd791bf86c58168fd457837e2acd (patch)
tree715d8f810c5f5ae7e69130c692e37ac5a199b3cc /indra/llcharacter
parent892f99af3b51ea08e6e77d5945e6e9ca24d4223d (diff)
WIP on attachment offset management in joints
Diffstat (limited to 'indra/llcharacter')
-rwxr-xr-xindra/llcharacter/lljoint.cpp82
-rwxr-xr-xindra/llcharacter/lljoint.h29
2 files changed, 79 insertions, 32 deletions
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index c78c38c3a7..f6e95fdc8d 100755
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -52,7 +52,6 @@ void LLJoint::init()
mOldXform.setScale(LLVector3(1.0f, 1.0f, 1.0f));
mDirtyFlags = MATRIX_DIRTY | ROTATION_DIRTY | POSITION_DIRTY;
mUpdateXform = TRUE;
- mResetAfterRestoreOldXform = false;
}
LLJoint::LLJoint() :
@@ -245,7 +244,7 @@ void LLJoint::setPosition( const LLVector3& pos )
//--------------------------------------------------------------------
-// setPosition()
+// setDefaultFromCurrentXform()
//--------------------------------------------------------------------
void LLJoint::setDefaultFromCurrentXform( void )
{
@@ -253,14 +252,62 @@ void LLJoint::setDefaultFromCurrentXform( void )
}
//--------------------------------------------------------------------
-// storeCurrentXform()
+// addAttachmentPosOverride()
//--------------------------------------------------------------------
-void LLJoint::storeCurrentXform( const LLVector3& pos )
-{
- mOldXform = mXform;
- mResetAfterRestoreOldXform = true;
- setPosition( pos );
- touch(ALL_DIRTY);
+void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const std::string& attachment_name )
+{
+ if (attachment_name.empty())
+ {
+ return;
+ }
+ if (m_attachmentOverrides.empty())
+ {
+ LL_WARNS() << "saving m_posBeforeOverrides " << getPosition() << LL_ENDL;
+ m_posBeforeOverrides = getPosition();
+ }
+ AttachmentOverrideRecord rec;
+ rec.name = attachment_name;
+ rec.pos = pos;
+ m_attachmentOverrides[attachment_name] = rec;
+ LL_WARNS() << "addAttachmentPosOverride for " << attachment_name << " pos " << pos << LL_ENDL;
+ updatePos();
+}
+
+//--------------------------------------------------------------------
+// removeAttachmentPosOverride()
+//--------------------------------------------------------------------
+void LLJoint::removeAttachmentPosOverride( const std::string& attachment_name )
+{
+ if (attachment_name.empty())
+ {
+ return;
+ }
+ attachment_map_t::iterator it = m_attachmentOverrides.find(attachment_name);
+ if (it != m_attachmentOverrides.end())
+ {
+ LL_WARNS() << "removeAttachmentPosOverride for " << attachment_name << LL_ENDL;
+ m_attachmentOverrides.erase(it);
+ }
+ updatePos();
+}
+
+void LLJoint::updatePos()
+{
+ LLVector3 pos;
+ attachment_map_t::iterator it = std::max_element(m_attachmentOverrides.begin(),
+ m_attachmentOverrides.end());
+ if (it != m_attachmentOverrides.end())
+ {
+ AttachmentOverrideRecord& rec = it->second;
+ LL_WARNS() << "updatePos, winner is attachment " << rec.name << " pos " << rec.pos << LL_ENDL;
+ pos = rec.pos;
+ }
+ else
+ {
+ LL_WARNS() << "updatePos, winner is posBeforeOverrides " << m_posBeforeOverrides << LL_ENDL;
+ pos = m_posBeforeOverrides;
+ }
+ setPosition(pos);
}
//--------------------------------------------------------------------
@@ -276,7 +323,6 @@ void LLJoint::storeScaleForReset( const LLVector3& scale )
void LLJoint::restoreOldXform( void )
{
mXform = mOldXform;
- mResetAfterRestoreOldXform = false;
mDirtyFlags = ALL_DIRTY;
}
//--------------------------------------------------------------------
@@ -325,7 +371,7 @@ void LLJoint::setWorldPosition( const LLVector3& pos )
//--------------------------------------------------------------------
-// mXform.getRotation()
+// getRotation()
//--------------------------------------------------------------------
const LLQuaternion& LLJoint::getRotation()
{
@@ -548,20 +594,6 @@ void LLJoint::clampRotation(LLQuaternion old_rot, LLQuaternion new_rot)
break;
}
}
-
- // 2003.03.26 - This code was just using up cpu cycles. AB
-
-// LLVector3 old_axis = main_axis * old_rot;
-// LLVector3 new_axis = main_axis * new_rot;
-
-// for (S32 i = 0; i < mConstraintSilhouette.size() - 1; i++)
-// {
-// LLVector3 vert1 = mConstraintSilhouette[i];
-// LLVector3 vert2 = mConstraintSilhouette[i + 1];
-
- // figure out how to clamp rotation to line on 3-sphere
-
-// }
}
// End
diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h
index b65d6979d4..f6f1cd2fe4 100755
--- a/indra/llcharacter/lljoint.h
+++ b/indra/llcharacter/lljoint.h
@@ -88,8 +88,6 @@ public:
U32 mDirtyFlags;
BOOL mUpdateXform;
- BOOL mResetAfterRestoreOldXform;
-
// describes the skin binding pose
LLVector3 mSkinOffset;
@@ -103,6 +101,25 @@ public:
static S32 sNumTouches;
static S32 sNumUpdates;
+ struct AttachmentOverrideRecord
+ {
+ AttachmentOverrideRecord()
+ {
+ }
+ LLVector3 pos;
+ std::string name;
+
+ bool operator<(const AttachmentOverrideRecord& other) const
+ {
+ return name < other.name;
+ }
+ };
+ typedef std::map<std::string,AttachmentOverrideRecord> attachment_map_t;
+ attachment_map_t m_attachmentOverrides;
+ LLVector3 m_posBeforeOverrides;
+
+ void updatePos();
+
public:
LLJoint();
LLJoint(S32 joint_num);
@@ -188,15 +205,13 @@ public:
void setDefaultFromCurrentXform( void );
void storeCurrentXform( const LLVector3& pos );
+ void addAttachmentPosOverride( const LLVector3& pos, const std::string& attachment_name );
+ void removeAttachmentPosOverride( const std::string& attachment_name );
+
//Accessor for the joint id
LLUUID getId( void ) { return mId; }
//Setter for the joints id
void setId( const LLUUID& id ) { mId = id;}
-
- //If the old transform flag has been set, then the reset logic in avatar needs to be aware(test) of it
- const BOOL doesJointNeedToBeReset( void ) const { return mResetAfterRestoreOldXform; }
- void setJointResetFlag( bool val ) { mResetAfterRestoreOldXform = val; }
-
};
#endif // LL_LLJOINT_H