summaryrefslogtreecommitdiff
path: root/indra/newview/llvoavatar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rw-r--r--indra/newview/llvoavatar.cpp133
1 files changed, 90 insertions, 43 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index e9f00f04fa..7af15fb351 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1860,8 +1860,8 @@ void LLVOAvatar::resetSkeleton()
//LLVector3 pelvis_pos = getJoint("mPelvis")->getPosition();
//LLQuaternion pelvis_rot = getJoint("mPelvis")->getRotation();
- // Clear all attachment pos overrides
- clearAttachmentPosOverrides();
+ // Clear all attachment pos and scale overrides
+ clearAttachmentOverrides();
// Note that we call buildSkeleton twice in this function. The first time is
// just to get the right scale for the collision volumes, because
@@ -1910,7 +1910,7 @@ void LLVOAvatar::resetSkeleton()
updateVisualParams();
// Restore attachment pos overrides
- rebuildAttachmentPosOverrides();
+ rebuildAttachmentOverrides();
LL_DEBUGS("Avatar") << avString() << " reset ends" << LL_ENDL;
}
@@ -5422,9 +5422,9 @@ bool LLVOAvatar::jointIsRiggedTo(const std::string& joint_name, const LLViewerOb
return false;
}
-void LLVOAvatar::clearAttachmentPosOverrides()
+void LLVOAvatar::clearAttachmentOverrides()
{
- LLScopedContextString str("clearAttachmentPosOverrides " + getFullname());
+ LLScopedContextString str("clearAttachmentOverrides " + getFullname());
//Subsequent joints are relative to pelvis
avatar_joint_list_t::iterator iter = mSkeleton.begin();
@@ -5437,6 +5437,10 @@ void LLVOAvatar::clearAttachmentPosOverrides()
{
pJoint->clearAttachmentPosOverrides();
}
+ if (pJoint)
+ {
+ pJoint->clearAttachmentScaleOverrides();
+ }
}
// Attachment points
@@ -5453,11 +5457,11 @@ void LLVOAvatar::clearAttachmentPosOverrides()
}
//-----------------------------------------------------------------------------
-// rebuildAttachmentPosOverrides
+// rebuildAttachmentOverrides
//-----------------------------------------------------------------------------
-void LLVOAvatar::rebuildAttachmentPosOverrides()
+void LLVOAvatar::rebuildAttachmentOverrides()
{
- LLScopedContextString str("rebuildAttachmentPosOverrides " + getFullname());
+ LLScopedContextString str("rebuildAttachmentOverrides " + getFullname());
// Attachment points
for (attachment_map_t::iterator iter = mAttachmentPoints.begin();
@@ -5470,7 +5474,7 @@ void LLVOAvatar::rebuildAttachmentPosOverrides()
for (LLViewerJointAttachment::attachedobjs_vec_t::iterator at_it = attachment_pt->mAttachedObjects.begin();
at_it != attachment_pt->mAttachedObjects.end(); ++at_it)
{
- addAttachmentPosOverridesForObject(*at_it);
+ addAttachmentOverridesForObject(*at_it);
}
}
}
@@ -5478,7 +5482,7 @@ void LLVOAvatar::rebuildAttachmentPosOverrides()
//-----------------------------------------------------------------------------
// addAttachmentPosOverridesForObject
//-----------------------------------------------------------------------------
-void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
+void LLVOAvatar::addAttachmentOverridesForObject(LLViewerObject *vo)
{
LLVOAvatar *av = vo->getAvatarAncestor();
if (!av || (av != this))
@@ -5486,7 +5490,7 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
LL_WARNS("Avatar") << "called with invalid avatar" << LL_ENDL;
}
- LLScopedContextString str("addAttachmentPosOverridesForObject " + av->getFullname());
+ LLScopedContextString str("addAttachmentOverridesForObject " + av->getFullname());
// Process all children
LLViewerObject::const_child_list_t& children = vo->getChildren();
@@ -5494,7 +5498,7 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
it != children.end(); ++it)
{
LLViewerObject *childp = *it;
- addAttachmentPosOverridesForObject(childp);
+ addAttachmentOverridesForObject(childp);
}
LLVOVolume *vobj = dynamic_cast<LLVOVolume*>(vo);
@@ -5535,19 +5539,26 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
{
pJoint->setId( currentId );
const LLVector3& jointPos = pSkinData->mAlternateBindMatrix[i].getTranslation();
-
- bool override_changed;
- pJoint->addAttachmentPosOverride( jointPos, mesh_id, avString(), override_changed );
-
- if (override_changed)
+ if (pJoint->aboveJointPosThreshold(jointPos))
{
- //If joint is a pelvis then handle old/new pelvis to foot values
- if ( lookingForJoint == "mPelvis" )
- {
- pelvisGotSet = true;
- }
- }
+ bool override_changed;
+ pJoint->addAttachmentPosOverride( jointPos, mesh_id, avString(), override_changed );
+ if (override_changed)
+ {
+ //If joint is a pelvis then handle old/new pelvis to foot values
+ if ( lookingForJoint == "mPelvis" )
+ {
+ pelvisGotSet = true;
+ }
+ }
+ if (pSkinData->mLockScaleIfJointPosition)
+ {
+ // Note that unlike positions, there's no threshold check here,
+ // just a lock at the default value.
+ pJoint->addAttachmentScaleOverride(pJoint->getDefaultScale(), mesh_id, avString());
+ }
+ }
}
}
if (pelvisZOffset != 0.0F)
@@ -5577,9 +5588,10 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
//-----------------------------------------------------------------------------
// getAttachmentOverrideNames
//-----------------------------------------------------------------------------
-void LLVOAvatar::getAttachmentOverrideNames(std::set<std::string>& names) const
+void LLVOAvatar::getAttachmentOverrideNames(std::set<std::string>& pos_names, std::set<std::string>& scale_names) const
{
LLVector3 pos;
+ LLVector3 scale;
LLUUID mesh_id;
// Bones
@@ -5589,7 +5601,11 @@ void LLVOAvatar::getAttachmentOverrideNames(std::set<std::string>& names) const
const LLJoint* pJoint = (*iter);
if (pJoint && pJoint->hasAttachmentPosOverride(pos,mesh_id))
{
- names.insert(pJoint->getName());
+ pos_names.insert(pJoint->getName());
+ }
+ if (pJoint && pJoint->hasAttachmentScaleOverride(scale,mesh_id))
+ {
+ scale_names.insert(pJoint->getName());
}
}
@@ -5601,36 +5617,47 @@ void LLVOAvatar::getAttachmentOverrideNames(std::set<std::string>& names) const
const LLViewerJointAttachment *attachment_pt = (*iter).second;
if (attachment_pt && attachment_pt->hasAttachmentPosOverride(pos,mesh_id))
{
- names.insert(attachment_pt->getName());
+ pos_names.insert(attachment_pt->getName());
}
+ // Attachment points don't have scales.
}
}
//-----------------------------------------------------------------------------
-// showAttachmentPosOverrides
+// showAttachmentOverrides
//-----------------------------------------------------------------------------
-void LLVOAvatar::showAttachmentPosOverrides(bool verbose) const
+void LLVOAvatar::showAttachmentOverrides(bool verbose) const
{
- std::set<std::string> joint_names;
- getAttachmentOverrideNames(joint_names);
- if (joint_names.size())
+ std::set<std::string> pos_names, scale_names;
+ getAttachmentOverrideNames(pos_names, scale_names);
+ if (pos_names.size())
{
std::stringstream ss;
- std::copy(joint_names.begin(), joint_names.end(), std::ostream_iterator<std::string>(ss, ","));
- LL_DEBUGS("Avatar") << getFullname() << " attachment positions defined for joints: " << ss.str() << "\n" << LL_ENDL;
+ std::copy(pos_names.begin(), pos_names.end(), std::ostream_iterator<std::string>(ss, ","));
+ LL_INFOS() << getFullname() << " attachment positions defined for joints: " << ss.str() << "\n" << LL_ENDL;
}
else
{
LL_DEBUGS("Avatar") << getFullname() << " no attachment positions defined for any joints" << "\n" << LL_ENDL;
}
+ if (scale_names.size())
+ {
+ std::stringstream ss;
+ std::copy(scale_names.begin(), scale_names.end(), std::ostream_iterator<std::string>(ss, ","));
+ LL_INFOS() << getFullname() << " attachment scales defined for joints: " << ss.str() << "\n" << LL_ENDL;
+ }
+ else
+ {
+ LL_INFOS() << getFullname() << " no attachment scales defined for any joints" << "\n" << LL_ENDL;
+ }
if (!verbose)
{
return;
}
- LLVector3 pos;
+ LLVector3 pos, scale;
LLUUID mesh_id;
S32 count = 0;
@@ -5644,6 +5671,11 @@ void LLVOAvatar::showAttachmentPosOverrides(bool verbose) const
pJoint->showAttachmentPosOverrides(getFullname());
count++;
}
+ if (pJoint && pJoint->hasAttachmentScaleOverride(scale,mesh_id))
+ {
+ pJoint->showAttachmentScaleOverrides(getFullname());
+ count++;
+ }
}
// Attachment points
@@ -5661,15 +5693,15 @@ void LLVOAvatar::showAttachmentPosOverrides(bool verbose) const
if (count)
{
- LL_DEBUGS("Avatar") << avString() << " end of pos overrides" << LL_ENDL;
+ LL_DEBUGS("Avatar") << avString() << " end of pos, scale overrides" << LL_ENDL;
LL_DEBUGS("Avatar") << "=================================" << LL_ENDL;
}
}
//-----------------------------------------------------------------------------
-// resetJointPositionsOnDetach
+// resetJointsOnDetach
//-----------------------------------------------------------------------------
-void LLVOAvatar::resetJointPositionsOnDetach(LLViewerObject *vo)
+void LLVOAvatar::resetJointsOnDetach(LLViewerObject *vo)
{
LLVOAvatar *av = vo->getAvatarAncestor();
if (!av || (av != this))
@@ -5683,21 +5715,21 @@ void LLVOAvatar::resetJointPositionsOnDetach(LLViewerObject *vo)
it != children.end(); ++it)
{
LLViewerObject *childp = *it;
- resetJointPositionsOnDetach(childp);
+ resetJointsOnDetach(childp);
}
// Process self.
LLUUID mesh_id;
if (getRiggedMeshID(vo,mesh_id))
{
- resetJointPositionsOnDetach(mesh_id);
+ resetJointsOnDetach(mesh_id);
}
}
//-----------------------------------------------------------------------------
-// resetJointPositionsOnDetach
+// resetJointsOnDetach
//-----------------------------------------------------------------------------
-void LLVOAvatar::resetJointPositionsOnDetach(const LLUUID& mesh_id)
+void LLVOAvatar::resetJointsOnDetach(const LLUUID& mesh_id)
{
//Subsequent joints are relative to pelvis
avatar_joint_list_t::iterator iter = mSkeleton.begin();
@@ -5713,7 +5745,8 @@ void LLVOAvatar::resetJointPositionsOnDetach(const LLUUID& mesh_id)
{
bool dummy; // unused
pJoint->setId( LLUUID::null );
- pJoint->removeAttachmentPosOverride(mesh_id, avString(), dummy);
+ pJoint->removeAttachmentPosOverride(mesh_id, avString(),dummy);
+ pJoint->removeAttachmentScaleOverride(mesh_id, avString());
}
if ( pJoint && pJoint == pJointPelvis)
{
@@ -6414,7 +6447,7 @@ void LLVOAvatar::cleanupAttachedMesh( LLViewerObject* pVO )
LLUUID mesh_id;
if (getRiggedMeshID(pVO, mesh_id))
{
- resetJointPositionsOnDetach(mesh_id);
+ resetJointsOnDetach(mesh_id);
if ( gAgentCamera.cameraCustomizeAvatar() )
{
gAgent.unpauseAnimation();
@@ -8448,6 +8481,20 @@ void LLVOAvatar::dumpArchetypeXML(const std::string& prefix, bool group_by_weara
pJoint->getName().c_str(), pos[0], pos[1], pos[2], mesh_id.asString().c_str());
}
}
+ // Joint scale overrides
+ for (iter = mSkeleton.begin(); iter != end; ++iter)
+ {
+ LLJoint* pJoint = (*iter);
+
+ LLVector3 scale;
+ LLUUID mesh_id;
+
+ if (pJoint->hasAttachmentScaleOverride(scale,mesh_id))
+ {
+ apr_file_printf( file, "\t\t<joint_scale name=\"%s\" scale=\"%f %f %f\" mesh_id=\"%s\"/>\n",
+ pJoint->getName().c_str(), scale[0], scale[1], scale[2], mesh_id.asString().c_str());
+ }
+ }
F32 pelvis_fixup;
LLUUID mesh_id;
if (hasPelvisFixup(pelvis_fixup, mesh_id))