From aa96b808981d9453c49d749308a98173ce1864bb Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 15 Aug 2014 10:38:46 -0400 Subject: MAINT-4158 WIP - fix for at least some forms of distortion. I can't repro the drastic height changes, so not positive it addresses that. --- indra/llcharacter/lljoint.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llcharacter') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index dbd6d48a95..c78c38c3a7 100755 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -275,7 +275,7 @@ void LLJoint::storeScaleForReset( const LLVector3& scale ) //-------------------------------------------------------------------- void LLJoint::restoreOldXform( void ) { - mXform = mDefaultXform; + mXform = mOldXform; mResetAfterRestoreOldXform = false; mDirtyFlags = ALL_DIRTY; } @@ -432,7 +432,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], -- cgit v1.2.3 From 33f66ac2344f996a2310b179173232b98c8bd026 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 27 Aug 2014 16:52:52 -0400 Subject: WIP on attachment offset management in joints --- indra/llcharacter/lljoint.cpp | 82 ++++++++++++++++++++++++++++++------------- indra/llcharacter/lljoint.h | 29 +++++++++++---- 2 files changed, 79 insertions(+), 32 deletions(-) (limited to 'indra/llcharacter') 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 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 -- cgit v1.2.3 From 2cb14c7fdcf835816176d6edc0c05b99bcb39873 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 28 Aug 2014 17:32:22 -0400 Subject: MAINT-4158 WIP - track position overrides requested by attachments so they can be undone intelligently --- indra/llcharacter/lljoint.cpp | 56 +++++++++++++++++++------------------------ indra/llcharacter/lljoint.h | 17 ++----------- 2 files changed, 26 insertions(+), 47 deletions(-) (limited to 'indra/llcharacter') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index f6e95fdc8d..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 +bool attachment_map_iter_compare_name(const T& a, const T& b) +{ + return a.second.name < b.second.name; +} + //----------------------------------------------------------------------------- // LLJoint() // Class Constructor @@ -48,8 +62,6 @@ 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; } @@ -242,15 +254,6 @@ void LLJoint::setPosition( const LLVector3& pos ) touch(MATRIX_DIRTY | POSITION_DIRTY); } - -//-------------------------------------------------------------------- -// setDefaultFromCurrentXform() -//-------------------------------------------------------------------- -void LLJoint::setDefaultFromCurrentXform( void ) -{ - mDefaultXform = mXform; -} - //-------------------------------------------------------------------- // addAttachmentPosOverride() //-------------------------------------------------------------------- @@ -262,14 +265,14 @@ void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const std::string& } if (m_attachmentOverrides.empty()) { - LL_WARNS() << "saving m_posBeforeOverrides " << getPosition() << LL_ENDL; + 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_WARNS() << "addAttachmentPosOverride for " << attachment_name << " pos " << pos << LL_ENDL; + LL_DEBUGS("Avatar") << getName() << " addAttachmentPosOverride for " << attachment_name << " pos " << pos << LL_ENDL; updatePos(); } @@ -285,46 +288,35 @@ void LLJoint::removeAttachmentPosOverride( const std::string& attachment_name ) attachment_map_t::iterator it = m_attachmentOverrides.find(attachment_name); if (it != m_attachmentOverrides.end()) { - LL_WARNS() << "removeAttachmentPosOverride for " << attachment_name << LL_ENDL; + LL_DEBUGS("Avatar") << getName() << " removeAttachmentPosOverride for " << attachment_name << LL_ENDL; m_attachmentOverrides.erase(it); } updatePos(); } +//-------------------------------------------------------------------- +// updatePos() +//-------------------------------------------------------------------- void LLJoint::updatePos() { LLVector3 pos; attachment_map_t::iterator it = std::max_element(m_attachmentOverrides.begin(), - m_attachmentOverrides.end()); + m_attachmentOverrides.end(), + attachment_map_iter_compare_name); if (it != m_attachmentOverrides.end()) { AttachmentOverrideRecord& rec = it->second; - LL_WARNS() << "updatePos, winner is attachment " << rec.name << " pos " << rec.pos << LL_ENDL; + LL_DEBUGS("Avatar") << getName() << " updatePos, winner of " << m_attachmentOverrides.size() << " is attachment " << rec.name << " pos " << rec.pos << LL_ENDL; pos = rec.pos; } else { - LL_WARNS() << "updatePos, winner is posBeforeOverrides " << m_posBeforeOverrides << LL_ENDL; + LL_DEBUGS("Avatar") << getName() << " updatePos, winner is posBeforeOverrides " << m_posBeforeOverrides << LL_ENDL; pos = m_posBeforeOverrides; } setPosition(pos); } -//-------------------------------------------------------------------- -// storeScaleForReset() -//-------------------------------------------------------------------- -void LLJoint::storeScaleForReset( const LLVector3& scale ) -{ - mOldXform.setScale( scale ); -} -//-------------------------------------------------------------------- -// restoreOldXform() -//-------------------------------------------------------------------- -void LLJoint::restoreOldXform( void ) -{ - mXform = mOldXform; - mDirtyFlags = ALL_DIRTY; -} //-------------------------------------------------------------------- // getWorldPosition() //-------------------------------------------------------------------- diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index f6f1cd2fe4..0ef054d9c1 100755 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -79,8 +79,6 @@ protected: // explicit transformation members LLXformMatrix mXform; - LLXformMatrix mOldXform; - LLXformMatrix mDefaultXform; LLUUID mId; @@ -103,16 +101,9 @@ public: struct AttachmentOverrideRecord { - AttachmentOverrideRecord() - { - } + AttachmentOverrideRecord(); LLVector3 pos; std::string name; - - bool operator<(const AttachmentOverrideRecord& other) const - { - return name < other.name; - } }; typedef std::map attachment_map_t; attachment_map_t m_attachmentOverrides; @@ -177,7 +168,7 @@ public: // get/set local scale const LLVector3& getScale(); void setScale( const LLVector3& scale ); - void storeScaleForReset( const LLVector3& scale ); + // get/set world matrix const LLMatrix4 &getWorldMatrix(); void setWorldMatrix( const LLMatrix4& mat ); @@ -200,10 +191,6 @@ public: virtual BOOL isAnimatable() const { return TRUE; } S32 getJointNum() const { return mJointNum; } - - void restoreOldXform( void ); - 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 ); -- cgit v1.2.3 From b6ad3bd54dd4d48a0b984bc92a31bab7c9f90e75 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 8 Oct 2014 11:45:12 -0400 Subject: Switched to keying joint offsets by mesh id --- indra/llcharacter/lljoint.cpp | 35 +++++++++++++++++------------------ indra/llcharacter/lljoint.h | 9 ++++----- 2 files changed, 21 insertions(+), 23 deletions(-) (limited to 'indra/llcharacter') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index bad9c198ad..97293bf134 100755 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -45,9 +45,9 @@ LLJoint::AttachmentOverrideRecord::AttachmentOverrideRecord() } template -bool attachment_map_iter_compare_name(const T& a, const T& b) +bool attachment_map_iter_compare_key(const T& a, const T& b) { - return a.second.name < b.second.name; + return a.first < b.first; } //----------------------------------------------------------------------------- @@ -257,61 +257,60 @@ void LLJoint::setPosition( const LLVector3& pos ) //-------------------------------------------------------------------- // addAttachmentPosOverride() //-------------------------------------------------------------------- -void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const std::string& attachment_name ) +void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh_id, const std::string& av_info ) { - if (attachment_name.empty()) + if (mesh_id.isNull()) { return; } if (m_attachmentOverrides.empty()) { - LL_DEBUGS("Avatar") << getName() << " saving m_posBeforeOverrides " << getPosition() << LL_ENDL; + LL_DEBUGS("Avatar") << "av " << av_info << " joint " << 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(); + m_attachmentOverrides[mesh_id] = rec; + LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " addAttachmentPosOverride for mesh " << mesh_id << " pos " << pos << LL_ENDL; + updatePos(av_info); } //-------------------------------------------------------------------- // removeAttachmentPosOverride() //-------------------------------------------------------------------- -void LLJoint::removeAttachmentPosOverride( const std::string& attachment_name ) +void LLJoint::removeAttachmentPosOverride( const LLUUID& mesh_id, const std::string& av_info ) { - if (attachment_name.empty()) + if (mesh_id.isNull()) { return; } - attachment_map_t::iterator it = m_attachmentOverrides.find(attachment_name); + attachment_map_t::iterator it = m_attachmentOverrides.find(mesh_id); if (it != m_attachmentOverrides.end()) { - LL_DEBUGS("Avatar") << getName() << " removeAttachmentPosOverride for " << attachment_name << LL_ENDL; + LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " removeAttachmentPosOverride for " << mesh_id << LL_ENDL; m_attachmentOverrides.erase(it); } - updatePos(); + updatePos(av_info); } //-------------------------------------------------------------------- // updatePos() //-------------------------------------------------------------------- -void LLJoint::updatePos() +void LLJoint::updatePos(const std::string& av_info) { LLVector3 pos; attachment_map_t::iterator it = std::max_element(m_attachmentOverrides.begin(), m_attachmentOverrides.end(), - attachment_map_iter_compare_name); + attachment_map_iter_compare_key); 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; + LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " updatePos, winner of " << m_attachmentOverrides.size() << " is mesh " << it->first << " pos " << rec.pos << LL_ENDL; pos = rec.pos; } else { - LL_DEBUGS("Avatar") << getName() << " updatePos, winner is posBeforeOverrides " << m_posBeforeOverrides << LL_ENDL; + LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " updatePos, winner is posBeforeOverrides " << m_posBeforeOverrides << LL_ENDL; pos = m_posBeforeOverrides; } setPosition(pos); diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index 0ef054d9c1..951cafad94 100755 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -103,13 +103,12 @@ public: { AttachmentOverrideRecord(); LLVector3 pos; - std::string name; }; - typedef std::map attachment_map_t; + typedef std::map attachment_map_t; attachment_map_t m_attachmentOverrides; LLVector3 m_posBeforeOverrides; - void updatePos(); + void updatePos(const std::string& av_info); public: LLJoint(); @@ -192,8 +191,8 @@ public: S32 getJointNum() const { return mJointNum; } - void addAttachmentPosOverride( const LLVector3& pos, const std::string& attachment_name ); - void removeAttachmentPosOverride( const std::string& attachment_name ); + void addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh_id, const std::string& av_info ); + void removeAttachmentPosOverride( const LLUUID& mesh_id, const std::string& av_info ); //Accessor for the joint id LLUUID getId( void ) { return mId; } -- cgit v1.2.3 From dc0abe48c624775f06cfebf1ea4d20222a7b7086 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 29 Oct 2014 13:07:44 -0400 Subject: MAINT-4605 WIP - you can't hide your lion eyes --- indra/llcharacter/lljoint.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llcharacter') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 97293bf134..7c75c4920f 100755 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -289,8 +289,9 @@ void LLJoint::removeAttachmentPosOverride( const LLUUID& mesh_id, const std::str { LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " removeAttachmentPosOverride for " << mesh_id << LL_ENDL; m_attachmentOverrides.erase(it); + updatePos(av_info); } - updatePos(av_info); + } //-------------------------------------------------------------------- -- cgit v1.2.3 From 5c8d902c1bab6f0577750e8e2470384a31880947 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 17 Oct 2014 15:00:18 -0400 Subject: SL-93 WIP - refactoring LLPosOverrideMap for reusability --- indra/llcharacter/lljoint.cpp | 88 ++++++++++++++++++++++++++++++++----------- indra/llcharacter/lljoint.h | 22 +++++++---- 2 files changed, 80 insertions(+), 30 deletions(-) (limited to 'indra/llcharacter') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 7c75c4920f..5e54215739 100755 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -36,18 +36,57 @@ S32 LLJoint::sNumUpdates = 0; S32 LLJoint::sNumTouches = 0; +template +bool attachment_map_iter_compare_key(const T& a, const T& b) +{ + return a.first < b.first; +} -//----------------------------------------------------------------------------- -// LLJoint::AttachmentOverrideRecord::AttachmentOverrideRecord() -//----------------------------------------------------------------------------- -LLJoint::AttachmentOverrideRecord::AttachmentOverrideRecord() +bool LLPosOverrideMap::findActiveOverride(LLUUID& mesh_id, LLVector3& pos) const { + pos = LLVector3(0,0,0); + mesh_id = LLUUID(); + bool found = false; + + map_type::const_iterator it = std::max_element(m_map.begin(), + m_map.end(), + attachment_map_iter_compare_key); + if (it != m_map.end()) + { + found = true; + pos = it->second; + mesh_id = it->first; + } + return found; } -template -bool attachment_map_iter_compare_key(const T& a, const T& b) +void LLPosOverrideMap::showJointPosOverrides( std::ostringstream& os ) const { - return a.first < b.first; + map_type::const_iterator max_it = std::max_element(m_map.begin(), + m_map.end(), + attachment_map_iter_compare_key); + for (map_type::const_iterator it = m_map.begin(); + it != m_map.end(); ++it) + { + const LLVector3& pos = it->second; + os << " " << "[" << it->first <<": " << pos << "]" << ((it==max_it) ? "*" : ""); + } +} + +U32 LLPosOverrideMap::count() const +{ + return m_map.size(); +} + +void LLPosOverrideMap::add(const LLUUID& mesh_id, const LLVector3& pos) +{ + m_map[mesh_id] = pos; +} + +bool LLPosOverrideMap::remove(const LLUUID& mesh_id) +{ + U32 remove_count = m_map.erase(mesh_id); + return (remove_count > 0); } //----------------------------------------------------------------------------- @@ -254,6 +293,14 @@ void LLJoint::setPosition( const LLVector3& pos ) touch(MATRIX_DIRTY | POSITION_DIRTY); } +void showJointPosOverrides( const LLJoint& joint, const std::string& note, const std::string& av_info ) +{ + std::ostringstream os; + os << joint.m_posBeforeOverrides; + joint.m_attachmentOverrides.showJointPosOverrides(os); + LL_DEBUGS("Avatar") << av_info << " joint " << joint.getName() << " " << note << " " << os.str() << LL_ENDL; +} + //-------------------------------------------------------------------- // addAttachmentPosOverride() //-------------------------------------------------------------------- @@ -263,14 +310,12 @@ void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh { return; } - if (m_attachmentOverrides.empty()) + if (!m_attachmentOverrides.count()) { LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " saving m_posBeforeOverrides " << getPosition() << LL_ENDL; m_posBeforeOverrides = getPosition(); } - AttachmentOverrideRecord rec; - rec.pos = pos; - m_attachmentOverrides[mesh_id] = rec; + m_attachmentOverrides.add(mesh_id,pos); LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " addAttachmentPosOverride for mesh " << mesh_id << " pos " << pos << LL_ENDL; updatePos(av_info); } @@ -284,11 +329,11 @@ void LLJoint::removeAttachmentPosOverride( const LLUUID& mesh_id, const std::str { return; } - attachment_map_t::iterator it = m_attachmentOverrides.find(mesh_id); - if (it != m_attachmentOverrides.end()) + if (m_attachmentOverrides.remove(mesh_id)) { - LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " removeAttachmentPosOverride for " << mesh_id << LL_ENDL; - m_attachmentOverrides.erase(it); + LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() + << " removeAttachmentPosOverride for " << mesh_id << LL_ENDL; + showJointPosOverrides(*this, "remove", av_info); updatePos(av_info); } @@ -299,15 +344,12 @@ void LLJoint::removeAttachmentPosOverride( const LLUUID& mesh_id, const std::str //-------------------------------------------------------------------- void LLJoint::updatePos(const std::string& av_info) { - LLVector3 pos; - attachment_map_t::iterator it = std::max_element(m_attachmentOverrides.begin(), - m_attachmentOverrides.end(), - attachment_map_iter_compare_key); - if (it != m_attachmentOverrides.end()) + LLVector3 pos, found_pos; + LLUUID mesh_id; + if (m_attachmentOverrides.findActiveOverride(mesh_id,found_pos)) { - AttachmentOverrideRecord& rec = it->second; - LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " updatePos, winner of " << m_attachmentOverrides.size() << " is mesh " << it->first << " pos " << rec.pos << LL_ENDL; - pos = rec.pos; + LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " updatePos, winner of " << m_attachmentOverrides.count() << " is mesh " << mesh_id << " pos " << found_pos << LL_ENDL; + pos = found_pos; } else { diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index 951cafad94..f8639af3de 100755 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -46,6 +46,20 @@ const U32 LL_FACE_JOINT_NUM = 30; const S32 LL_CHARACTER_MAX_PRIORITY = 7; const F32 LL_MAX_PELVIS_OFFSET = 5.f; +class LLPosOverrideMap +{ +public: + LLPosOverrideMap() {} + bool findActiveOverride(LLUUID& mesh_id, LLVector3& pos) const; + void showJointPosOverrides(std::ostringstream& os) const; + U32 count() const; + void add(const LLUUID& mesh_id, const LLVector3& pos); + bool remove(const LLUUID& mesh_id); +private: + typedef std::map map_type; + map_type m_map; +}; + //----------------------------------------------------------------------------- // class LLJoint //----------------------------------------------------------------------------- @@ -99,13 +113,7 @@ public: static S32 sNumTouches; static S32 sNumUpdates; - struct AttachmentOverrideRecord - { - AttachmentOverrideRecord(); - LLVector3 pos; - }; - typedef std::map attachment_map_t; - attachment_map_t m_attachmentOverrides; + LLPosOverrideMap m_attachmentOverrides; LLVector3 m_posBeforeOverrides; void updatePos(const std::string& av_info); -- cgit v1.2.3 From 7fec81b102e92e1a4e5a36fde077ef9b82cc7123 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Mon, 3 Nov 2014 05:46:31 -0500 Subject: SL-93 WIP - pelvis fixup offsets --- indra/llcharacter/lljoint.cpp | 8 ++++++++ indra/llcharacter/lljoint.h | 1 + 2 files changed, 9 insertions(+) (limited to 'indra/llcharacter') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 5e54215739..af5393ef03 100755 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -339,6 +339,14 @@ void LLJoint::removeAttachmentPosOverride( const LLUUID& mesh_id, const std::str } +//-------------------------------------------------------------------- + // hasAttachmentPosOverride() + //-------------------------------------------------------------------- +bool LLJoint::hasAttachmentPosOverride( LLVector3& pos, LLUUID& mesh_id ) const +{ + return m_attachmentOverrides.findActiveOverride(mesh_id,pos); +} + //-------------------------------------------------------------------- // updatePos() //-------------------------------------------------------------------- diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index f8639af3de..56da8e83b2 100755 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -201,6 +201,7 @@ public: void addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh_id, const std::string& av_info ); void removeAttachmentPosOverride( const LLUUID& mesh_id, const std::string& av_info ); + bool hasAttachmentPosOverride( LLVector3& pos, LLUUID& mesh_id ) const; //Accessor for the joint id LLUUID getId( void ) { return mId; } -- cgit v1.2.3 From 9c4397b6ee6d1a2a2c43d5d886b178753a4833d8 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 14 Nov 2014 15:41:03 -0500 Subject: MAINT-4537 WIP - joint position management during outfit changes --- indra/llcharacter/lljoint.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'indra/llcharacter') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index af5393ef03..cab3a7d619 100755 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -283,12 +283,23 @@ const LLVector3& LLJoint::getPosition() return mXform.getPosition(); } +bool do_debug_joint(const std::string& name) +{ + return true; +} //-------------------------------------------------------------------- // setPosition() //-------------------------------------------------------------------- void LLJoint::setPosition( const LLVector3& pos ) { + if (pos != getPosition()) + { + if (do_debug_joint(getName())) + { + LL_DEBUGS("Avatar") << " joint " << getName() << " set pos " << pos << LL_ENDL; + } + } mXform.setPosition(pos); touch(MATRIX_DIRTY | POSITION_DIRTY); } @@ -312,11 +323,17 @@ void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh } if (!m_attachmentOverrides.count()) { - LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " saving m_posBeforeOverrides " << getPosition() << LL_ENDL; + if (do_debug_joint(getName())) + { + LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " saving m_posBeforeOverrides " << getPosition() << LL_ENDL; + } m_posBeforeOverrides = getPosition(); } m_attachmentOverrides.add(mesh_id,pos); - LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " addAttachmentPosOverride for mesh " << mesh_id << " pos " << pos << LL_ENDL; + if (do_debug_joint(getName())) + { + LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " addAttachmentPosOverride for mesh " << mesh_id << " pos " << pos << LL_ENDL; + } updatePos(av_info); } @@ -331,9 +348,12 @@ void LLJoint::removeAttachmentPosOverride( const LLUUID& mesh_id, const std::str } if (m_attachmentOverrides.remove(mesh_id)) { - LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() - << " removeAttachmentPosOverride for " << mesh_id << LL_ENDL; - showJointPosOverrides(*this, "remove", av_info); + if (do_debug_joint(getName())) + { + LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() + << " removeAttachmentPosOverride for " << mesh_id << LL_ENDL; + showJointPosOverrides(*this, "remove", av_info); + } updatePos(av_info); } -- cgit v1.2.3 From b1884d40f5ba74d1d39be1abad7dc416905c6caf Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Sat, 15 Nov 2014 14:29:39 -0500 Subject: MAINT-4537 WIP - more joint position management during outfit changes --- indra/llcharacter/lljoint.cpp | 17 +++++++++++++++++ indra/llcharacter/lljoint.h | 2 ++ 2 files changed, 19 insertions(+) (limited to 'indra/llcharacter') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index cab3a7d619..6615a430ab 100755 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -89,6 +89,11 @@ bool LLPosOverrideMap::remove(const LLUUID& mesh_id) return (remove_count > 0); } +void LLPosOverrideMap::clear() +{ + m_map.clear(); +} + //----------------------------------------------------------------------------- // LLJoint() // Class Constructor @@ -367,6 +372,18 @@ bool LLJoint::hasAttachmentPosOverride( LLVector3& pos, LLUUID& mesh_id ) const return m_attachmentOverrides.findActiveOverride(mesh_id,pos); } +//-------------------------------------------------------------------- +// clearAttachmentPosOverrides() +//-------------------------------------------------------------------- +void LLJoint::clearAttachmentPosOverrides() +{ + if (m_attachmentOverrides.count()) + { + m_attachmentOverrides.clear(); + setPosition(m_posBeforeOverrides); + } +} + //-------------------------------------------------------------------- // updatePos() //-------------------------------------------------------------------- diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index 56da8e83b2..2abe1d6db1 100755 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -55,6 +55,7 @@ public: U32 count() const; void add(const LLUUID& mesh_id, const LLVector3& pos); bool remove(const LLUUID& mesh_id); + void clear(); private: typedef std::map map_type; map_type m_map; @@ -202,6 +203,7 @@ public: void addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh_id, const std::string& av_info ); void removeAttachmentPosOverride( const LLUUID& mesh_id, const std::string& av_info ); bool hasAttachmentPosOverride( LLVector3& pos, LLUUID& mesh_id ) const; + void clearAttachmentPosOverrides(); //Accessor for the joint id LLUUID getId( void ) { return mId; } -- cgit v1.2.3 From 1135ba80ec569e20187c36a5364debf9eae8aab7 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 19 Nov 2014 09:19:03 -0500 Subject: MAINT-4537, MAINT-4687 WIP --- indra/llcharacter/lljoint.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcharacter') diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 6615a430ab..6f22a7c6b7 100755 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -381,6 +381,7 @@ void LLJoint::clearAttachmentPosOverrides() { m_attachmentOverrides.clear(); setPosition(m_posBeforeOverrides); + setId( LLUUID::null ); } } -- cgit v1.2.3