summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llappearance/llavatarappearance.cpp1
-rw-r--r--indra/llappearance/llavatarappearance.h2
-rw-r--r--indra/llappearance/llpolyskeletaldistortion.cpp2
-rw-r--r--indra/llcharacter/lljoint.cpp228
-rw-r--r--indra/llcharacter/lljoint.h27
-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
11 files changed, 321 insertions, 73 deletions
diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp
index 2ce43436db..6953599dc4 100644
--- a/indra/llappearance/llavatarappearance.cpp
+++ b/indra/llappearance/llavatarappearance.cpp
@@ -612,6 +612,7 @@ BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent
joint->setRotation(mayaQ(info->mRot.mV[VX], info->mRot.mV[VY],
info->mRot.mV[VZ], LLQuaternion::XYZ));
joint->setScale(info->mScale);
+ joint->setDefaultScale(info->mScale);
joint->setSupport(info->mSupport);
joint->setEnd(info->mEnd);
diff --git a/indra/llappearance/llavatarappearance.h b/indra/llappearance/llavatarappearance.h
index 3865da7098..5f91db0c3c 100644
--- a/indra/llappearance/llavatarappearance.h
+++ b/indra/llappearance/llavatarappearance.h
@@ -161,7 +161,7 @@ protected:
void clearSkeleton();
BOOL mIsBuilt; // state of deferred character building
avatar_joint_list_t mSkeleton;
- LLPosOverrideMap mPelvisFixups;
+ LLVector3OverrideMap mPelvisFixups;
joint_alias_map_t mJointAliasMap;
//--------------------------------------------------------------------
diff --git a/indra/llappearance/llpolyskeletaldistortion.cpp b/indra/llappearance/llpolyskeletaldistortion.cpp
index fdce8d97ce..890292a1f6 100644
--- a/indra/llappearance/llpolyskeletaldistortion.cpp
+++ b/indra/llappearance/llpolyskeletaldistortion.cpp
@@ -225,7 +225,7 @@ void LLPolySkeletalDistortion::apply( ESex avatar_sex )
ostr << "LLPolySkeletalDistortion::apply, id " << getID() << " " << getName() << " effective wt " << effective_weight << " last wt " << mLastWeight << " scaleDelta " << scaleDelta << " offset " << offset;
LLScopedContextString str(ostr.str());
- joint->setScale(newScale);
+ joint->setScale(newScale, true);
}
for (iter = mJointOffsets.begin();
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index c4eda0b432..f764b53ba5 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -44,7 +44,7 @@ bool attachment_map_iter_compare_key(const T& a, const T& b)
return a.first < b.first;
}
-bool LLPosOverrideMap::findActiveOverride(LLUUID& mesh_id, LLVector3& pos) const
+bool LLVector3OverrideMap::findActiveOverride(LLUUID& mesh_id, LLVector3& pos) const
{
pos = LLVector3(0,0,0);
mesh_id = LLUUID();
@@ -62,7 +62,7 @@ bool LLPosOverrideMap::findActiveOverride(LLUUID& mesh_id, LLVector3& pos) const
return found;
}
-void LLPosOverrideMap::showJointPosOverrides( std::ostringstream& os ) const
+void LLVector3OverrideMap::showJointVector3Overrides( std::ostringstream& os ) const
{
map_type::const_iterator max_it = std::max_element(m_map.begin(),
m_map.end(),
@@ -75,23 +75,23 @@ void LLPosOverrideMap::showJointPosOverrides( std::ostringstream& os ) const
}
}
-U32 LLPosOverrideMap::count() const
+U32 LLVector3OverrideMap::count() const
{
return m_map.size();
}
-void LLPosOverrideMap::add(const LLUUID& mesh_id, const LLVector3& pos)
+void LLVector3OverrideMap::add(const LLUUID& mesh_id, const LLVector3& pos)
{
m_map[mesh_id] = pos;
}
-bool LLPosOverrideMap::remove(const LLUUID& mesh_id)
+bool LLVector3OverrideMap::remove(const LLUUID& mesh_id)
{
U32 remove_count = m_map.erase(mesh_id);
return (remove_count > 0);
}
-void LLPosOverrideMap::clear()
+void LLVector3OverrideMap::clear()
{
m_map.clear();
}
@@ -342,7 +342,7 @@ void LLJoint::setPosition( const LLVector3& requested_pos, bool apply_attachment
LLVector3 active_override;
LLUUID mesh_id;
- if (apply_attachment_overrides && m_attachmentOverrides.findActiveOverride(mesh_id,active_override))
+ if (apply_attachment_overrides && m_attachmentPosOverrides.findActiveOverride(mesh_id,active_override))
{
if (pos != active_override && do_debug_joint(getName()))
{
@@ -374,11 +374,30 @@ const LLVector3& LLJoint::getDefaultPosition() const
{
return mDefaultPosition;
}
+
+void LLJoint::setDefaultScale( const LLVector3& scale )
+{
+ mDefaultScale = scale;
+}
+
+const LLVector3& LLJoint::getDefaultScale() const
+{
+ return mDefaultScale;
+}
+
void showJointPosOverrides( const LLJoint& joint, const std::string& note, const std::string& av_info )
{
std::ostringstream os;
os << joint.m_posBeforeOverrides;
- joint.m_attachmentOverrides.showJointPosOverrides(os);
+ joint.m_attachmentPosOverrides.showJointVector3Overrides(os);
+ LL_DEBUGS("Avatar") << av_info << " joint " << joint.getName() << " " << note << " " << os.str() << LL_ENDL;
+}
+
+void showJointScaleOverrides( const LLJoint& joint, const std::string& note, const std::string& av_info )
+{
+ std::ostringstream os;
+ os << joint.m_scaleBeforeOverrides;
+ joint.m_attachmentScaleOverrides.showJointVector3Overrides(os);
LL_DEBUGS("Avatar") << av_info << " joint " << joint.getName() << " " << note << " " << os.str() << LL_ENDL;
}
@@ -389,6 +408,13 @@ bool above_joint_pos_threshold(const LLVector3& diff)
return diff.lengthSquared() > max_joint_pos_offset * max_joint_pos_offset;
}
+bool above_joint_scale_threshold(const LLVector3& diff)
+{
+ //return !diff.isNull();
+ const F32 max_joint_scale_offset = 0.0001f; // 0.1 mm
+ return diff.lengthSquared() > max_joint_scale_offset * max_joint_scale_offset;
+}
+
//--------------------------------------------------------------------
// addAttachmentPosOverride()
//--------------------------------------------------------------------
@@ -407,7 +433,7 @@ void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh
}
return;
}
- if (!m_attachmentOverrides.count())
+ if (!m_attachmentPosOverrides.count())
{
if (do_debug_joint(getName()))
{
@@ -415,7 +441,7 @@ void LLJoint::addAttachmentPosOverride( const LLVector3& pos, const LLUUID& mesh
}
m_posBeforeOverrides = getPosition();
}
- m_attachmentOverrides.add(mesh_id,pos);
+ m_attachmentPosOverrides.add(mesh_id,pos);
if (do_debug_joint(getName()))
{
LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " addAttachmentPosOverride for mesh " << mesh_id << " pos " << pos << LL_ENDL;
@@ -432,7 +458,7 @@ void LLJoint::removeAttachmentPosOverride( const LLUUID& mesh_id, const std::str
{
return;
}
- if (m_attachmentOverrides.remove(mesh_id))
+ if (m_attachmentPosOverrides.remove(mesh_id))
{
if (do_debug_joint(getName()))
{
@@ -449,7 +475,7 @@ void LLJoint::removeAttachmentPosOverride( const LLUUID& mesh_id, const std::str
//--------------------------------------------------------------------
bool LLJoint::hasAttachmentPosOverride( LLVector3& pos, LLUUID& mesh_id ) const
{
- return m_attachmentOverrides.findActiveOverride(mesh_id,pos);
+ return m_attachmentPosOverrides.findActiveOverride(mesh_id,pos);
}
//--------------------------------------------------------------------
@@ -457,9 +483,9 @@ bool LLJoint::hasAttachmentPosOverride( LLVector3& pos, LLUUID& mesh_id ) const
//--------------------------------------------------------------------
void LLJoint::clearAttachmentPosOverrides()
{
- if (m_attachmentOverrides.count())
+ if (m_attachmentPosOverrides.count())
{
- m_attachmentOverrides.clear();
+ m_attachmentPosOverrides.clear();
setPosition(m_posBeforeOverrides);
setId( LLUUID::null );
}
@@ -473,11 +499,11 @@ void LLJoint::showAttachmentPosOverrides(const std::string& av_info) const
LLVector3 active_override;
bool has_active_override;
LLUUID mesh_id;
- has_active_override = m_attachmentOverrides.findActiveOverride(mesh_id,active_override);
- U32 count = m_attachmentOverrides.count();
+ has_active_override = m_attachmentPosOverrides.findActiveOverride(mesh_id,active_override);
+ U32 count = m_attachmentPosOverrides.count();
if (count==1)
{
- LLPosOverrideMap::map_type::const_iterator it = m_attachmentOverrides.getMap().begin();
+ LLVector3OverrideMap::map_type::const_iterator it = m_attachmentPosOverrides.getMap().begin();
std::string highlight = (has_active_override && (it->second == active_override)) ? "*" : "";
LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName()
<< " has single attachment pos override " << highlight << "" << it->second << " default " << mDefaultPosition << LL_ENDL;
@@ -486,8 +512,8 @@ void LLJoint::showAttachmentPosOverrides(const std::string& av_info) const
{
LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " has " << count << " attachment pos overrides" << LL_ENDL;
std::set<LLVector3> distinct_offsets;
- LLPosOverrideMap::map_type::const_iterator it = m_attachmentOverrides.getMap().begin();
- for (; it != m_attachmentOverrides.getMap().end(); ++it)
+ LLVector3OverrideMap::map_type::const_iterator it = m_attachmentPosOverrides.getMap().begin();
+ for (; it != m_attachmentPosOverrides.getMap().end(); ++it)
{
distinct_offsets.insert(it->second);
}
@@ -515,11 +541,11 @@ void LLJoint::updatePos(const std::string& av_info)
{
LLVector3 pos, found_pos;
LLUUID mesh_id;
- if (m_attachmentOverrides.findActiveOverride(mesh_id,found_pos))
+ if (m_attachmentPosOverrides.findActiveOverride(mesh_id,found_pos))
{
if (do_debug_joint(getName()))
{
- LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " updatePos, winner of " << m_attachmentOverrides.count() << " is mesh " << mesh_id << " pos " << found_pos << LL_ENDL;
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " updatePos, winner of " << m_attachmentPosOverrides.count() << " is mesh " << mesh_id << " pos " << found_pos << LL_ENDL;
}
pos = found_pos;
}
@@ -534,6 +560,151 @@ void LLJoint::updatePos(const std::string& av_info)
setPosition(pos);
}
+//--------------------------------------------------------------------
+// updateScale()
+//--------------------------------------------------------------------
+void LLJoint::updateScale(const std::string& av_info)
+{
+ LLVector3 scale, found_scale;
+ LLUUID mesh_id;
+ if (m_attachmentScaleOverrides.findActiveOverride(mesh_id,found_scale))
+ {
+ if (do_debug_joint(getName()))
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " updateScale, winner of " << m_attachmentScaleOverrides.count() << " is mesh " << mesh_id << " scale " << found_scale << LL_ENDL;
+ }
+ scale = found_scale;
+ }
+ else
+ {
+ if (do_debug_joint(getName()))
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " updateScale, winner is scaleBeforeOverrides " << m_scaleBeforeOverrides << LL_ENDL;
+ }
+ scale = m_scaleBeforeOverrides;
+ }
+ setScale(scale);
+}
+
+//--------------------------------------------------------------------
+// addAttachmentScaleOverride()
+//--------------------------------------------------------------------
+void LLJoint::addAttachmentScaleOverride( const LLVector3& scale, const LLUUID& mesh_id, const std::string& av_info )
+{
+ if (mesh_id.isNull())
+ {
+ return;
+ }
+ if (!above_joint_scale_threshold(scale-getDefaultScale()))
+ {
+ if (do_debug_joint(getName()))
+ {
+ LL_DEBUGS("Avatar") << "Attachment scale override ignored for " << getName()
+ << ", scale " << scale << " is same as default scale" << LL_ENDL;
+ }
+ return;
+ }
+ if (!m_attachmentScaleOverrides.count())
+ {
+ if (do_debug_joint(getName()))
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " saving m_scaleBeforeOverrides " << getScale() << LL_ENDL;
+ }
+ m_scaleBeforeOverrides = getScale();
+ }
+ m_attachmentScaleOverrides.add(mesh_id,scale);
+ if (do_debug_joint(getName()))
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " addAttachmentScaleOverride for mesh " << mesh_id << " scale " << scale << LL_ENDL;
+ }
+ updateScale(av_info);
+}
+
+//--------------------------------------------------------------------
+// removeAttachmentScaleOverride()
+//--------------------------------------------------------------------
+void LLJoint::removeAttachmentScaleOverride( const LLUUID& mesh_id, const std::string& av_info )
+{
+ if (mesh_id.isNull())
+ {
+ return;
+ }
+ if (m_attachmentScaleOverrides.remove(mesh_id))
+ {
+ if (do_debug_joint(getName()))
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName()
+ << " removeAttachmentScaleOverride for " << mesh_id << LL_ENDL;
+ showJointScaleOverrides(*this, "remove", av_info);
+ }
+ updateScale(av_info);
+ }
+}
+
+//--------------------------------------------------------------------
+ // hasAttachmentScaleOverride()
+ //--------------------------------------------------------------------
+bool LLJoint::hasAttachmentScaleOverride( LLVector3& scale, LLUUID& mesh_id ) const
+{
+ return m_attachmentScaleOverrides.findActiveOverride(mesh_id,scale);
+}
+
+//--------------------------------------------------------------------
+// clearAttachmentScaleOverrides()
+//--------------------------------------------------------------------
+void LLJoint::clearAttachmentScaleOverrides()
+{
+ if (m_attachmentScaleOverrides.count())
+ {
+ m_attachmentScaleOverrides.clear();
+ setScale(m_scaleBeforeOverrides);
+ setId( LLUUID::null );
+ }
+}
+
+//--------------------------------------------------------------------
+// showAttachmentScaleOverrides()
+//--------------------------------------------------------------------
+void LLJoint::showAttachmentScaleOverrides(const std::string& av_info) const
+{
+ LLVector3 active_override;
+ bool has_active_override;
+ LLUUID mesh_id;
+ has_active_override = m_attachmentScaleOverrides.findActiveOverride(mesh_id,active_override);
+ U32 count = m_attachmentScaleOverrides.count();
+ if (count==1)
+ {
+ LLVector3OverrideMap::map_type::const_iterator it = m_attachmentScaleOverrides.getMap().begin();
+ std::string highlight = (has_active_override && (it->second == active_override)) ? "*" : "";
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName()
+ << " has single attachment scale override " << highlight << "" << it->second << " default " << mDefaultScale << LL_ENDL;
+ }
+ else if (count>1)
+ {
+ LL_DEBUGS("Avatar") << "av " << av_info << " joint " << getName() << " has " << count << " attachment scale overrides" << LL_ENDL;
+ std::set<LLVector3> distinct_offsets;
+ LLVector3OverrideMap::map_type::const_iterator it = m_attachmentScaleOverrides.getMap().begin();
+ for (; it != m_attachmentScaleOverrides.getMap().end(); ++it)
+ {
+ distinct_offsets.insert(it->second);
+ }
+ if (distinct_offsets.size()>1)
+ {
+ LL_DEBUGS("Avatar") << "CONFLICTS, " << distinct_offsets.size() << " different values" << LL_ENDL;
+ }
+ else
+ {
+ LL_DEBUGS("Avatar") << "no conflicts" << LL_ENDL;
+ }
+ std::set<LLVector3>::iterator dit = distinct_offsets.begin();
+ for ( ; dit != distinct_offsets.end(); ++dit)
+ {
+ std::string highlight = (has_active_override && *dit == active_override) ? "*" : "";
+ LL_DEBUGS("Avatar") << " POS " << highlight << "" << (*dit) << " default " << mDefaultScale << LL_ENDL;
+ }
+ }
+}
+
// init static
LLJoint::debug_joint_name_t LLJoint::s_debugJointNames = debug_joint_name_t();
@@ -676,8 +847,21 @@ const LLVector3& LLJoint::getScale()
//--------------------------------------------------------------------
// setScale()
//--------------------------------------------------------------------
-void LLJoint::setScale( const LLVector3& scale )
+void LLJoint::setScale( const LLVector3& requested_scale, bool apply_attachment_overrides )
{
+ LLVector3 scale(requested_scale);
+ LLUUID mesh_id;
+ LLVector3 active_override;
+ if (apply_attachment_overrides && m_attachmentScaleOverrides.findActiveOverride(mesh_id,active_override))
+ {
+ if (scale != active_override && do_debug_joint(getName()))
+ {
+ LLScopedContextString str("setScale");
+ LL_DEBUGS("Avatar") << " joint " << getName() << " requested_scale " << requested_scale
+ << " overriden by attachment " << active_override << LL_ENDL;
+ }
+ scale = active_override;
+ }
if ((mXform.getScale() != scale) && do_debug_joint(getName()))
{
LLScopedContextString str("setScale");
diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h
index d2c573864b..bee968f249 100644
--- a/indra/llcharacter/lljoint.h
+++ b/indra/llcharacter/lljoint.h
@@ -52,12 +52,12 @@ const U32 LL_FACE_JOINT_NUM = (LL_CHARACTER_MAX_ANIMATED_JOINTS-2);
const S32 LL_CHARACTER_MAX_PRIORITY = 7;
const F32 LL_MAX_PELVIS_OFFSET = 5.f;
-class LLPosOverrideMap
+class LLVector3OverrideMap
{
public:
- LLPosOverrideMap() {}
+ LLVector3OverrideMap() {}
bool findActiveOverride(LLUUID& mesh_id, LLVector3& pos) const;
- void showJointPosOverrides(std::ostringstream& os) const;
+ void showJointVector3Overrides(std::ostringstream& os) const;
U32 count() const;
void add(const LLUUID& mesh_id, const LLVector3& pos);
bool remove(const LLUUID& mesh_id);
@@ -114,6 +114,7 @@ protected:
LLUUID mId;
LLVector3 mDefaultPosition;
+ LLVector3 mDefaultScale;
public:
U32 mDirtyFlags;
@@ -140,10 +141,16 @@ public:
static void setDebugJointNames(const debug_joint_name_t& names);
static void setDebugJointNames(const std::string& names_string);
- LLPosOverrideMap m_attachmentOverrides;
+ // Position overrides
+ LLVector3OverrideMap m_attachmentPosOverrides;
LLVector3 m_posBeforeOverrides;
+ // Scale overrides
+ LLVector3OverrideMap m_attachmentScaleOverrides;
+ LLVector3 m_scaleBeforeOverrides;
+
void updatePos(const std::string& av_info);
+ void updateScale(const std::string& av_info);
public:
LLJoint();
@@ -215,6 +222,10 @@ public:
void setDefaultPosition( const LLVector3& pos );
const LLVector3& getDefaultPosition() const;
+ // Tracks the default scale defined by the skeleton
+ void setDefaultScale( const LLVector3& scale );
+ const LLVector3& getDefaultScale() const;
+
// get/set world position
LLVector3 getWorldPosition();
LLVector3 getLastWorldPosition();
@@ -231,7 +242,7 @@ public:
// get/set local scale
const LLVector3& getScale();
- void setScale( const LLVector3& scale );
+ void setScale( const LLVector3& scale, bool apply_attachment_overrides = false );
// get/set world matrix
const LLMatrix4 &getWorldMatrix();
@@ -260,6 +271,12 @@ public:
void clearAttachmentPosOverrides();
void showAttachmentPosOverrides(const std::string& av_info) const;
+ void addAttachmentScaleOverride( const LLVector3& scale, const LLUUID& mesh_id, const std::string& av_info );
+ void removeAttachmentScaleOverride( const LLUUID& mesh_id, const std::string& av_info );
+ bool hasAttachmentScaleOverride( LLVector3& scale, LLUUID& mesh_id ) const;
+ void clearAttachmentScaleOverrides();
+ void showAttachmentScaleOverrides(const std::string& av_info) const;
+
//Accessor for the joint id
LLUUID getId( void ) { return mId; }
//Setter for the joints id
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();
}
}