diff options
Diffstat (limited to 'indra/newview/llvoavatar.cpp')
-rw-r--r-- | indra/newview/llvoavatar.cpp | 111 |
1 files changed, 77 insertions, 34 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index e9f00f04fa..3354678af9 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,7 +5539,6 @@ 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 ); @@ -5547,7 +5550,6 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo) pelvisGotSet = true; } } - } } if (pelvisZOffset != 0.0F) @@ -5565,6 +5567,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 @@ -5577,9 +5598,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 +5611,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 +5627,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 +5681,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 +5703,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 +5725,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 +5755,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 +6457,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(); |