summaryrefslogtreecommitdiff
path: root/indra/llcharacter/lljoint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcharacter/lljoint.cpp')
-rwxr-xr-xindra/llcharacter/lljoint.cpp110
1 files changed, 67 insertions, 43 deletions
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index dbd6d48a95..bad9c198ad 100755
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -36,6 +36,20 @@
S32 LLJoint::sNumUpdates = 0;
S32 LLJoint::sNumTouches = 0;
+
+//-----------------------------------------------------------------------------
+// LLJoint::AttachmentOverrideRecord::AttachmentOverrideRecord()
+//-----------------------------------------------------------------------------
+LLJoint::AttachmentOverrideRecord::AttachmentOverrideRecord()
+{
+}
+
+template <class T>
+bool attachment_map_iter_compare_name(const T& a, const T& b)
+{
+ return a.second.name < b.second.name;
+}
+
//-----------------------------------------------------------------------------
// LLJoint()
// Class Constructor
@@ -48,11 +62,8 @@ void LLJoint::init()
mParent = NULL;
mXform.setScaleChildOffset(TRUE);
mXform.setScale(LLVector3(1.0f, 1.0f, 1.0f));
- mOldXform.setScaleChildOffset(TRUE);
- mOldXform.setScale(LLVector3(1.0f, 1.0f, 1.0f));
mDirtyFlags = MATRIX_DIRTY | ROTATION_DIRTY | POSITION_DIRTY;
mUpdateXform = TRUE;
- mResetAfterRestoreOldXform = false;
}
LLJoint::LLJoint() :
@@ -243,42 +254,69 @@ void LLJoint::setPosition( const LLVector3& pos )
touch(MATRIX_DIRTY | POSITION_DIRTY);
}
-
//--------------------------------------------------------------------
-// setPosition()
+// addAttachmentPosOverride()
//--------------------------------------------------------------------
-void LLJoint::setDefaultFromCurrentXform( void )
-{
- mDefaultXform = mXform;
+void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const std::string& attachment_name )
+{
+ if (attachment_name.empty())
+ {
+ return;
+ }
+ if (m_attachmentOverrides.empty())
+ {
+ LL_DEBUGS("Avatar") << getName() << " saving m_posBeforeOverrides " << getPosition() << LL_ENDL;
+ m_posBeforeOverrides = getPosition();
+ }
+ AttachmentOverrideRecord rec;
+ rec.name = attachment_name;
+ rec.pos = pos;
+ m_attachmentOverrides[attachment_name] = rec;
+ LL_DEBUGS("Avatar") << getName() << " addAttachmentPosOverride for " << attachment_name << " pos " << pos << LL_ENDL;
+ updatePos();
}
//--------------------------------------------------------------------
-// storeCurrentXform()
+// removeAttachmentPosOverride()
//--------------------------------------------------------------------
-void LLJoint::storeCurrentXform( const LLVector3& pos )
-{
- mOldXform = mXform;
- mResetAfterRestoreOldXform = true;
- setPosition( pos );
- touch(ALL_DIRTY);
+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_DEBUGS("Avatar") << getName() << " removeAttachmentPosOverride for " << attachment_name << LL_ENDL;
+ m_attachmentOverrides.erase(it);
+ }
+ updatePos();
}
//--------------------------------------------------------------------
-// storeScaleForReset()
+// updatePos()
//--------------------------------------------------------------------
-void LLJoint::storeScaleForReset( const LLVector3& scale )
+void LLJoint::updatePos()
{
- mOldXform.setScale( scale );
-}
-//--------------------------------------------------------------------
-// restoreOldXform()
-//--------------------------------------------------------------------
-void LLJoint::restoreOldXform( void )
-{
- mXform = mDefaultXform;
- mResetAfterRestoreOldXform = false;
- mDirtyFlags = ALL_DIRTY;
+ LLVector3 pos;
+ attachment_map_t::iterator it = std::max_element(m_attachmentOverrides.begin(),
+ m_attachmentOverrides.end(),
+ attachment_map_iter_compare_name<LLJoint::attachment_map_t::value_type>);
+ if (it != m_attachmentOverrides.end())
+ {
+ AttachmentOverrideRecord& rec = it->second;
+ LL_DEBUGS("Avatar") << getName() << " updatePos, winner of " << m_attachmentOverrides.size() << " is attachment " << rec.name << " pos " << rec.pos << LL_ENDL;
+ pos = rec.pos;
+ }
+ else
+ {
+ LL_DEBUGS("Avatar") << getName() << " updatePos, winner is posBeforeOverrides " << m_posBeforeOverrides << LL_ENDL;
+ pos = m_posBeforeOverrides;
+ }
+ setPosition(pos);
}
+
//--------------------------------------------------------------------
// getWorldPosition()
//--------------------------------------------------------------------
@@ -325,7 +363,7 @@ void LLJoint::setWorldPosition( const LLVector3& pos )
//--------------------------------------------------------------------
-// mXform.getRotation()
+// getRotation()
//--------------------------------------------------------------------
const LLQuaternion& LLJoint::getRotation()
{
@@ -432,7 +470,7 @@ const LLMatrix4 &LLJoint::getWorldMatrix()
//--------------------------------------------------------------------
void LLJoint::setWorldMatrix( const LLMatrix4& mat )
{
-LL_INFOS() << "WARNING: LLJoint::setWorldMatrix() not correctly implemented yet" << LL_ENDL;
+ LL_INFOS() << "WARNING: LLJoint::setWorldMatrix() not correctly implemented yet" << LL_ENDL;
// extract global translation
LLVector3 trans( mat.mMatrix[VW][VX],
mat.mMatrix[VW][VY],
@@ -548,20 +586,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