summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2016-06-07 10:39:32 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2016-06-07 10:39:32 -0400
commit3a53109152b961c9d0e7d6dd4f66b02d7531fb2a (patch)
tree637edbe67399e3c299ca5527fb1b41f945feaa7b /indra/newview
parentbd09297b8ec465a52f294092998812745ec6c566 (diff)
SL-395 - support scale overrides (currently no way to get these into a dae, so the actual scale values are fabricated at run-time based on the joint name)
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llappearancemgr.cpp4
-rw-r--r--indra/newview/llfloatermodelpreview.cpp2
-rw-r--r--indra/newview/llviewerobject.cpp2
-rw-r--r--indra/newview/llvoavatar.cpp107
-rw-r--r--indra/newview/llvoavatar.h15
-rw-r--r--indra/newview/llvovolume.cpp4
6 files changed, 90 insertions, 44 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index cc676550ab..b1a6edad35 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -854,7 +854,7 @@ void LLWearableHoldingPattern::onAllComplete()
// attachments, even those that are not being removed. This is
// needed to get joint positions all slammed down to their
// pre-attachment states.
- gAgentAvatarp->clearAttachmentPosOverrides();
+ gAgentAvatarp->clearAttachmentOverrides();
if (objects_to_remove.size() || items_to_add.size())
{
@@ -877,7 +877,7 @@ void LLWearableHoldingPattern::onAllComplete()
++it)
{
LLViewerObject *objectp = *it;
- gAgentAvatarp->addAttachmentPosOverridesForObject(objectp);
+ gAgentAvatarp->addAttachmentOverridesForObject(objectp);
}
// Add new attachments to match those requested.
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 0f0fafcce6..d7a773673f 100644
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -493,7 +493,7 @@ void LLFloaterModelPreview::onClickCalculateBtn()
{
// Diagnostic message showing list of joints for which joint offsets are defined.
// FIXME - given time, would be much better to put this in the UI, in updateStatusMessages().
- mModelPreview->getPreviewAvatar()->showAttachmentPosOverrides();
+ mModelPreview->getPreviewAvatar()->showAttachmentOverrides();
}
mUploadModelUrl.clear();
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 5edc3c9745..db0adad3c0 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -370,7 +370,7 @@ void LLViewerObject::markDead()
if (av && LLVOAvatar::getRiggedMeshID(this,mesh_id))
{
// This case is needed for indirectly attached mesh objects.
- av->resetJointPositionsOnDetach(mesh_id);
+ av->resetJointsOnDetach(mesh_id);
}
// Mark itself as dead
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();
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 32a30c3aa8..f456b66a8d 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -200,15 +200,16 @@ public:
virtual LLJoint* getJoint(const std::string &name);
- void addAttachmentPosOverridesForObject(LLViewerObject *vo);
- void resetJointPositionsOnDetach(const LLUUID& mesh_id);
- void resetJointPositionsOnDetach(LLViewerObject *vo);
+ void addAttachmentOverridesForObject(LLViewerObject *vo);
+ void resetJointsOnDetach(const LLUUID& mesh_id);
+ void resetJointsOnDetach(LLViewerObject *vo);
bool jointIsRiggedTo(const std::string& joint_name);
bool jointIsRiggedTo(const std::string& joint_name, const LLViewerObject *vo);
- void clearAttachmentPosOverrides();
- void rebuildAttachmentPosOverrides();
- void showAttachmentPosOverrides(bool verbose = false) const;
- void getAttachmentOverrideNames(std::set<std::string>& names) const;
+ void clearAttachmentOverrides();
+ void rebuildAttachmentOverrides();
+ void showAttachmentOverrides(bool verbose = false) const;
+ void getAttachmentOverrideNames(std::set<std::string>& pos_names,
+ std::set<std::string>& scale_names) const;
/*virtual*/ const LLUUID& getID() const;
/*virtual*/ void addDebugText(const std::string& text);
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 465f8fe0d6..8e6a15b67f 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4780,10 +4780,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
if (rigged && pAvatarVO)
{
- pAvatarVO->addAttachmentPosOverridesForObject(vobj);
+ pAvatarVO->addAttachmentOverridesForObject(vobj);
if (pAvatarVO->isSelf())
{
- //pAvatarVO->showAttachmentPosOverrides();
+ //pAvatarVO->showAttachmentOverrides();
}
}