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/llappearance/llavatarappearance.cpp | 2 +- indra/llappearance/llpolyskeletaldistortion.cpp | 2 +- indra/llcharacter/lljoint.cpp | 56 +++++++++++-------------- indra/llcharacter/lljoint.h | 17 +------- indra/newview/llfloatermodelpreview.cpp | 3 +- indra/newview/llvovolume.cpp | 3 +- 6 files changed, 31 insertions(+), 52 deletions(-) (limited to 'indra') diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp index c1107f674e..9904f454d6 100755 --- a/indra/llappearance/llavatarappearance.cpp +++ b/indra/llappearance/llavatarappearance.cpp @@ -605,7 +605,7 @@ BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent info->mRot.mV[VZ], LLQuaternion::XYZ)); joint->setScale(info->mScale); - joint->setDefaultFromCurrentXform(); + //joint->setDefaultFromCurrentXform(); if (info->mIsJoint) { diff --git a/indra/llappearance/llpolyskeletaldistortion.cpp b/indra/llappearance/llpolyskeletaldistortion.cpp index ea29cbd451..fbc312c426 100644 --- a/indra/llappearance/llpolyskeletaldistortion.cpp +++ b/indra/llappearance/llpolyskeletaldistortion.cpp @@ -213,7 +213,7 @@ void LLPolySkeletalDistortion::apply( ESex avatar_sex ) LLVector3 scaleDelta = iter->second; newScale = newScale + (effective_weight * scaleDelta) - (mLastWeight * scaleDelta); //An aspect of attached mesh objects (which contain joint offsets) that need to be cleaned up when detached - joint->storeScaleForReset( newScale ); + // needed? // joint->storeScaleForReset( newScale ); joint->setScale(newScale); } 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 ); diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 039ff848cb..93c18c5c8b 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -1935,7 +1935,8 @@ bool LLModelLoader::doLoadModel() LLJoint* pJoint = mPreview->getPreviewAvatar()->getJoint( lookingForJoint ); if ( pJoint ) { - LL_WARNS() << "Aieee, now what!" << LL_ENDL; + pJoint->addAttachmentPosOverride( jointTransform.getTranslation(), mFilename); + //LL_WARNS() << "Aieee, now what!" << LL_ENDL; //pJoint->storeCurrentXform( jointTransform.getTranslation() ); } else diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 0ef48c4c70..0dc5ae5058 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4626,8 +4626,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) const LLVector3& jointPos = pSkinData->mAlternateBindMatrix[i].getTranslation(); //Set the joint position - const std::string& attachment_name = drawablep->getVObj()->getAttachmentItemName(); - //pJoint->storeCurrentXform( jointPos ); + const std::string& attachment_name = drawablep->getVObj()->getAttachmentItemName(); pJoint->addAttachmentPosOverride( jointPos, attachment_name ); //If joint is a pelvis then handle old/new pelvis to foot values -- cgit v1.2.3