From 2f346d6b328bd8367ed1c1e689c0db582be13f35 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 21 Apr 2016 17:00:58 -0400 Subject: SL-314 - show bones now colorizes rigged-to joints a different color. Also removed what I think is some redundancy in calculating attachment pos overrides. If it breaks I'll change it back. --- indra/newview/llvoavatar.cpp | 105 +++++++++++++++++++++++++++++++++---------- indra/newview/llvoavatar.h | 2 + indra/newview/llvovolume.cpp | 18 +++----- 3 files changed, 91 insertions(+), 34 deletions(-) (limited to 'indra') diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index af10af98f2..b5cf9a6ba3 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1426,12 +1426,8 @@ void LLVOAvatar::renderCollisionVolumes() void LLVOAvatar::renderBones() { - LLGLEnable blend(GL_BLEND); - std::ostringstream ostr; - std::ostringstream nullstr; - avatar_joint_list_t::iterator iter = mSkeleton.begin(); avatar_joint_list_t::iterator end = mSkeleton.end(); @@ -1439,6 +1435,8 @@ void LLVOAvatar::renderBones() static LLVector3 BASE_COLOR_VISIBLE(0.5f, 0.5f, 0.5f); static LLVector3 EXTENDED_COLOR_OCCLUDED(0.0f, 1.0f, 0.0f); static LLVector3 EXTENDED_COLOR_VISIBLE(0.5f, 0.5f, 0.5f); + static LLVector3 RIGGED_COLOR_OCCLUDED(0.0f, 1.0f, 1.0f); + static LLVector3 RIGGED_COLOR_VISIBLE(0.5f, 0.5f, 0.5f); static F32 SPHERE_SCALEF = 0.001f; @@ -1450,21 +1448,27 @@ void LLVOAvatar::renderBones() continue; } - ostr << jointp->getName() << ", "; - jointp->updateWorldMatrix(); LLJoint::SupportCategory sc = jointp->getSupport(); LLVector3 occ_color, visible_color; - if (sc == LLJoint::SUPPORT_BASE) + if (jointIsRiggedTo(jointp->getName())) { - occ_color = BASE_COLOR_OCCLUDED; - visible_color = BASE_COLOR_VISIBLE; + occ_color = RIGGED_COLOR_OCCLUDED; + visible_color = RIGGED_COLOR_VISIBLE; } else { - occ_color = EXTENDED_COLOR_OCCLUDED; - visible_color = EXTENDED_COLOR_VISIBLE; + if (sc == LLJoint::SUPPORT_BASE) + { + occ_color = BASE_COLOR_OCCLUDED; + visible_color = BASE_COLOR_VISIBLE; + } + else + { + occ_color = EXTENDED_COLOR_OCCLUDED; + visible_color = EXTENDED_COLOR_VISIBLE; + } } LLVector3 begin_pos(0,0,0); LLVector3 end_pos(jointp->getEnd()); @@ -1478,10 +1482,6 @@ void LLVOAvatar::renderBones() gGL.popMatrix(); } - - mDebugText.clear(); - addDebugText(ostr.str()); - addDebugText(nullstr.str()); } @@ -5241,6 +5241,62 @@ bool LLVOAvatar::getRiggedMeshID(LLViewerObject* pVO, LLUUID& mesh_id) return false; } +bool LLVOAvatar::jointIsRiggedTo(const std::string& joint_name) +{ + for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); + iter != mAttachmentPoints.end(); + ++iter) + { + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + const LLViewerObject* attached_object = (*attachment_iter); + if (attached_object && jointIsRiggedTo(joint_name, attached_object)) + { + return true; + } + } + } + return false; +} + +bool LLVOAvatar::jointIsRiggedTo(const std::string& joint_name, const LLViewerObject *vo) +{ + // Process all children + LLViewerObject::const_child_list_t& children = vo->getChildren(); + for (LLViewerObject::const_child_list_t::const_iterator it = children.begin(); + it != children.end(); ++it) + { + LLViewerObject *childp = *it; + if (jointIsRiggedTo(joint_name,childp)) + { + return true; + } + } + + const LLVOVolume *vobj = dynamic_cast(vo); + if (!vobj) + { + return false; + } + + LLUUID currentId = vobj->getVolume()->getParams().getSculptID(); + const LLMeshSkinInfo* pSkinData = gMeshRepo.getSkinInfo( currentId, vobj ); + + if ( vobj && vobj->isAttachment() && vobj->isMesh() && pSkinData ) + { + if (std::find(pSkinData->mJointNames.begin(), pSkinData->mJointNames.end(), joint_name) != + pSkinData->mJointNames.end()) + { + return true; + } + } + + return false; +} + void LLVOAvatar::clearAttachmentPosOverrides() { LLScopedContextString str("clearAttachmentPosOverrides " + getFullname()); @@ -5319,14 +5375,17 @@ void LLVOAvatar::addAttachmentPosOverridesForObject(LLViewerObject *vo) { pJoint->setId( currentId ); 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" ) - { - pelvisGotSet = true; - } + if (!jointPos.isNull()) + { + //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" ) + { + pelvisGotSet = true; + } + } } } if (pelvisZOffset != 0.0F) diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 0e58d7f626..48c0d0e54b 100755 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -203,6 +203,8 @@ public: void addAttachmentPosOverridesForObject(LLViewerObject *vo); void resetJointPositionsOnDetach(const LLUUID& mesh_id); void resetJointPositionsOnDetach(LLViewerObject *vo); + bool jointIsRiggedTo(const std::string& joint_name); + bool jointIsRiggedTo(const std::string& joint_name, const LLViewerObject *vo); void clearAttachmentPosOverrides(); void showAttachmentPosOverrides() const; diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 4e427289e7..c2550afcac 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4767,13 +4767,18 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) drawablep->clearState(LLDrawable::HAS_ALPHA); bool rigged = vobj->isAttachment() && - vobj->isMesh() && - gMeshRepo.getSkinInfo(vobj->getVolume()->getParams().getSculptID(), vobj); + vobj->isMesh() && + gMeshRepo.getSkinInfo(vobj->getVolume()->getParams().getSculptID(), vobj); bool bake_sunlight = LLPipeline::sBakeSunlight && drawablep->isStatic(); bool is_rigged = false; + if (rigged && pAvatarVO) + { + pAvatarVO->addAttachmentPosOverridesForObject(vobj); + } + //for each face for (S32 i = 0; i < drawablep->getNumFaces(); i++) { @@ -4790,8 +4795,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) //sum up face verts and indices drawablep->updateFaceSize(i); - - if (rigged) { if (!facep->isState(LLFace::RIGGED)) @@ -4805,13 +4808,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) //get drawpool of avatar with rigged face LLDrawPoolAvatar* pool = get_avatar_drawpool(vobj); - // FIXME should this be inside the face loop? - // doesn't seem to depend on any per-face state. - if ( pAvatarVO ) - { - pAvatarVO->addAttachmentPosOverridesForObject(vobj); - } - if (pool) { const LLTextureEntry* te = facep->getTextureEntry(); -- cgit v1.2.3