MAINT-4158 WIP - track position overrides requested by attachments so they can be undone intelligently
parent
94f945c2c6
commit
8b88633761
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,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<LLJoint::attachment_map_t::value_type>);
|
||||
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()
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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<std::string,AttachmentOverrideRecord> 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 );
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue