Switched to keying joint offsets by mesh id
parent
1355578332
commit
2be54fbe6f
|
|
@ -45,9 +45,9 @@ LLJoint::AttachmentOverrideRecord::AttachmentOverrideRecord()
|
|||
}
|
||||
|
||||
template <class T>
|
||||
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<LLJoint::attachment_map_t::value_type>);
|
||||
attachment_map_iter_compare_key<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;
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -103,13 +103,12 @@ public:
|
|||
{
|
||||
AttachmentOverrideRecord();
|
||||
LLVector3 pos;
|
||||
std::string name;
|
||||
};
|
||||
typedef std::map<std::string,AttachmentOverrideRecord> attachment_map_t;
|
||||
typedef std::map<LLUUID,AttachmentOverrideRecord> 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; }
|
||||
|
|
|
|||
|
|
@ -1935,7 +1935,9 @@ bool LLModelLoader::doLoadModel()
|
|||
LLJoint* pJoint = mPreview->getPreviewAvatar()->getJoint( lookingForJoint );
|
||||
if ( pJoint )
|
||||
{
|
||||
pJoint->addAttachmentPosOverride( jointTransform.getTranslation(), mFilename);
|
||||
LLUUID fake_mesh_id;
|
||||
fake_mesh_id.generate();
|
||||
pJoint->addAttachmentPosOverride( jointTransform.getTranslation(), fake_mesh_id, gAgentAvatarp->avString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5076,7 +5076,7 @@ LLJoint *LLVOAvatar::getJoint( const std::string &name )
|
|||
//-----------------------------------------------------------------------------
|
||||
// resetJointPositionsOnDetach
|
||||
//-----------------------------------------------------------------------------
|
||||
void LLVOAvatar::resetJointPositionsOnDetach(const std::string& attachment_name)
|
||||
void LLVOAvatar::resetJointPositionsOnDetach(const LLUUID& mesh_id)
|
||||
{
|
||||
//Subsequent joints are relative to pelvis
|
||||
avatar_joint_list_t::iterator iter = mSkeleton.begin();
|
||||
|
|
@ -5091,7 +5091,7 @@ void LLVOAvatar::resetJointPositionsOnDetach(const std::string& attachment_name)
|
|||
if ( pJoint && pJoint != pJointPelvis)
|
||||
{
|
||||
pJoint->setId( LLUUID::null );
|
||||
pJoint->removeAttachmentPosOverride(attachment_name);
|
||||
pJoint->removeAttachmentPosOverride(mesh_id, avString());
|
||||
}
|
||||
else
|
||||
if ( pJoint && pJoint == pJointPelvis)
|
||||
|
|
@ -5761,8 +5761,8 @@ void LLVOAvatar::cleanupAttachedMesh( LLViewerObject* pVO )
|
|||
&& pSkinData->mJointNames.size() > JOINT_COUNT_REQUIRED_FOR_FULLRIG // full rig
|
||||
&& pSkinData->mAlternateBindMatrix.size() > 0 )
|
||||
{
|
||||
const std::string& attachment_name = pVO->getAttachmentItemName();
|
||||
LLVOAvatar::resetJointPositionsOnDetach(attachment_name);
|
||||
const LLUUID& mesh_id = pSkinData->mMeshID;
|
||||
LLVOAvatar::resetJointPositionsOnDetach(mesh_id);
|
||||
//Need to handle the repositioning of the cam, updating rig data etc during outfit editing
|
||||
//This handles the case where we detach a replacement rig.
|
||||
if ( gAgentCamera.cameraCustomizeAvatar() )
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public:
|
|||
|
||||
virtual LLJoint* getJoint(const std::string &name);
|
||||
|
||||
void resetJointPositionsOnDetach(const std::string& attachment_name);
|
||||
void resetJointPositionsOnDetach(const LLUUID& mesh_id);
|
||||
|
||||
/*virtual*/ const LLUUID& getID() const;
|
||||
/*virtual*/ void addDebugText(const std::string& text);
|
||||
|
|
|
|||
|
|
@ -4637,8 +4637,8 @@ 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->addAttachmentPosOverride( jointPos, attachment_name );
|
||||
const LLUUID& mesh_id = pSkinData->mMeshID;
|
||||
pJoint->addAttachmentPosOverride( jointPos, mesh_id, pAvatarVO->avString() );
|
||||
|
||||
//If joint is a pelvis then handle old/new pelvis to foot values
|
||||
if ( lookingForJoint == "mPelvis" )
|
||||
|
|
|
|||
Loading…
Reference in New Issue