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.cpp107
1 files changed, 76 insertions, 31 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 0423f0e380..94d54a0660 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1855,8 +1855,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
@@ -1905,7 +1905,7 @@ void LLVOAvatar::resetSkeleton()
updateVisualParams();
// Restore attachment pos overrides
- rebuildAttachmentPosOverrides();
+ rebuildAttachmentOverrides();
// Restore mPelvis state
//getJoint("mPelvis")->setRotation(pelvis_rot);
@@ -5338,9 +5338,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();
@@ -5353,6 +5353,10 @@ void LLVOAvatar::clearAttachmentPosOverrides()
{
pJoint->clearAttachmentPosOverrides();
}
+ if (pJoint)
+ {
+ pJoint->clearAttachmentScaleOverrides();
+ }
}
// Attachment points
@@ -5369,11 +5373,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();
@@ -5386,7 +5390,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);
}
}
}
@@ -5394,7 +5398,7 @@ void LLVOAvatar::rebuildAttachmentPosOverrides()
//-----------------------------------------------------------------------------
// addAttachmentPosOverridesForObject
//-----------------------------------------------------------------------------
-void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
+void LLVOAvatar::addAttachmentOverridesForObject(LLViewerObject *vo)
{
LLVOAvatar *av = vo->getAvatarAncestor();
if (!av || (av != this))
@@ -5402,7 +5406,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();
@@ -5410,7 +5414,7 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
it != children.end(); ++it)
{
LLViewerObject *childp = *it;
- addAttachmentPosOverridesForObject(childp);
+ addAttachmentOverridesForObject(childp);
}
LLVOVolume *vobj = dynamic_cast<LLVOVolume*>(vo);
@@ -5453,7 +5457,7 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
const LLVector3& jointPos = pSkinData->mAlternateBindMatrix[i].getTranslation();
//Set the joint position
pJoint->addAttachmentPosOverride( jointPos, mesh_id, avString() );
-
+
//If joint is a pelvis then handle old/new pelvis to foot values
if ( lookingForJoint == "mPelvis" )
{
@@ -5468,6 +5472,25 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo)
}
}
}
+ // Set the joint scales
+ // FIXME replace with real logic for finding scale, probably inside the bindcnt loop above
+ const LLUUID& mesh_id = pSkinData->mMeshID;
+ for (int i = 0; i < jointCnt; ++i)
+ {
+ std::string lookingForJoint = pSkinData->mJointNames[i].c_str();
+ LLJoint* pJoint = getJoint(lookingForJoint);
+ if (pJoint)
+ {
+ if (pJoint->getName() == "mCollarRight" ||
+ pJoint->getName() == "mShoulderRight" ||
+ pJoint->getName() == "mElbowRight" ||
+ pJoint->getName() == "mHandRight")
+ {
+ LLVector3 jointScale(2.0f, 2.0f, 2.0f);
+ pJoint->addAttachmentScaleOverride(jointScale, mesh_id, avString());
+ }
+ }
+ }
}
//Rebuild body data if we altered joints/pelvis
@@ -5480,9 +5503,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
@@ -5492,7 +5516,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());
}
}
@@ -5504,36 +5532,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, ","));
+ 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_INFOS() << 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;
@@ -5547,6 +5586,11 @@ void LLVOAvatar::showAttachmentPosOverrides(bool verbose) const
pJoint->showAttachmentPosOverrides(getFullname());
count++;
}
+ if (pJoint && pJoint->hasAttachmentScaleOverride(scale,mesh_id))
+ {
+ pJoint->showAttachmentScaleOverrides(getFullname());
+ count++;
+ }
}
// Attachment points
@@ -5564,15 +5608,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))
@@ -5586,21 +5630,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();
@@ -5616,6 +5660,7 @@ void LLVOAvatar::resetJointPositionsOnDetach(const LLUUID& mesh_id)
{
pJoint->setId( LLUUID::null );
pJoint->removeAttachmentPosOverride(mesh_id, avString());
+ pJoint->removeAttachmentScaleOverride(mesh_id, avString());
}
if ( pJoint && pJoint == pJointPelvis)
{
@@ -6316,7 +6361,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();