From 62d14e1a33edf2df88761969f81e70ecd0081dab Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 12 Feb 2016 15:40:46 -0500 Subject: [PATCH 1/5] SL-333 WIP - added back some unused constructors to make the appearance utility happier --- indra/llappearance/llavatarappearance.h | 1 + indra/llappearance/llavatarjoint.cpp | 6 ++++++ indra/llappearance/llavatarjoint.h | 1 + indra/llcharacter/lljoint.cpp | 7 +++++++ indra/llcharacter/lljoint.h | 15 +++++++++++++++ indra/newview/llviewerjoint.cpp | 4 ++++ indra/newview/llviewerjoint.h | 2 ++ indra/newview/llvoavatar.cpp | 6 ++++++ indra/newview/llvoavatar.h | 1 + 9 files changed, 43 insertions(+) diff --git a/indra/llappearance/llavatarappearance.h b/indra/llappearance/llavatarappearance.h index 39271aeadb..3865da7098 100755 --- a/indra/llappearance/llavatarappearance.h +++ b/indra/llappearance/llavatarappearance.h @@ -125,6 +125,7 @@ public: protected: virtual LLAvatarJoint* createAvatarJoint() = 0; + virtual LLAvatarJoint* createAvatarJoint(S32 joint_num) = 0; virtual LLAvatarJointMesh* createAvatarJointMesh() = 0; void makeJointAliases(LLAvatarBoneInfo *bone_info); diff --git a/indra/llappearance/llavatarjoint.cpp b/indra/llappearance/llavatarjoint.cpp index 8133d4405a..29642be099 100644 --- a/indra/llappearance/llavatarjoint.cpp +++ b/indra/llappearance/llavatarjoint.cpp @@ -52,6 +52,12 @@ LLAvatarJoint::LLAvatarJoint() : init(); } +LLAvatarJoint::LLAvatarJoint(S32 joint_num) : + LLJoint(joint_num) +{ + init(); +} + LLAvatarJoint::LLAvatarJoint(const std::string &name, LLJoint *parent) : LLJoint(name, parent) { diff --git a/indra/llappearance/llavatarjoint.h b/indra/llappearance/llavatarjoint.h index 4510007856..fec91503c7 100644 --- a/indra/llappearance/llavatarjoint.h +++ b/indra/llappearance/llavatarjoint.h @@ -46,6 +46,7 @@ class LLAvatarJoint : { public: LLAvatarJoint(); + LLAvatarJoint(S32 joint_num); // *TODO: Only used for LLVOAvatarSelf::mScreenp. *DOES NOT INITIALIZE mResetAfterRestoreOldXform* LLAvatarJoint(const std::string &name, LLJoint *parent = NULL); virtual ~LLAvatarJoint(); diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index af50a3f574..264ec44c02 100755 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -121,6 +121,13 @@ LLJoint::LLJoint() : touch(); } +LLJoint::LLJoint(S32 joint_num) : + mJointNum(joint_num) +{ + init(); + touch(); +} + //----------------------------------------------------------------------------- // LLJoint() // Class Constructor diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index f5007a3f06..e666f177e7 100755 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -143,6 +143,21 @@ public: public: LLJoint(); + + // Note: these joint_num constructors are a bad idea because there + // are only a couple of places in the code where it is useful to + // have a joint num for a joint (for joints that are used in + // animations), and including them as part of the constructor then + // forces us to maintain an alternate path through the entire + // large-ish class hierarchy of joint types. The only reason they + // are still here now is to avoid breaking the baking service + // (appearanceutility) builds; these constructors are not used in + // the viewer. Once the appearance utility is updated to remove + // these joint num references, which it shouldn't ever need, from + // its own classes, we can also remove all the joint_num + // constructors from LLJoint, LLViewerJoint, LLAvatarJoint, and + // createAvatarJoint. + LLJoint(S32 joint_num); // *TODO: Only used for LLVOAvatarSelf::mScreenp. *DOES NOT INITIALIZE mResetAfterRestoreOldXform* LLJoint( const std::string &name, LLJoint *parent=NULL ); diff --git a/indra/newview/llviewerjoint.cpp b/indra/newview/llviewerjoint.cpp index 7bd93942b3..b7bd131246 100755 --- a/indra/newview/llviewerjoint.cpp +++ b/indra/newview/llviewerjoint.cpp @@ -48,6 +48,10 @@ LLViewerJoint::LLViewerJoint() : LLAvatarJoint() { } +LLViewerJoint::LLViewerJoint(S32 joint_num) : + LLAvatarJoint(joint_num) +{ } + LLViewerJoint::LLViewerJoint(const std::string &name, LLJoint *parent) : LLAvatarJoint(name, parent) { } diff --git a/indra/newview/llviewerjoint.h b/indra/newview/llviewerjoint.h index 75efafd138..abe11bbf5c 100755 --- a/indra/newview/llviewerjoint.h +++ b/indra/newview/llviewerjoint.h @@ -44,6 +44,8 @@ class LLViewerJoint : { public: LLViewerJoint(); + LLViewerJoint(S32 joint_num); + // *TODO: Only used for LLVOAvatarSelf::mScreenp. *DOES NOT INITIALIZE mResetAfterRestoreOldXform* LLViewerJoint(const std::string &name, LLJoint *parent = NULL); virtual ~LLViewerJoint(); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 15e1f88d76..762ff95840 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1174,6 +1174,12 @@ LLAvatarJoint* LLVOAvatar::createAvatarJoint() return new LLViewerJoint(); } +// virtual +LLAvatarJoint* LLVOAvatar::createAvatarJoint(S32 joint_num) +{ + return new LLViewerJoint(joint_num); +} + // virtual LLAvatarJointMesh* LLVOAvatar::createAvatarJointMesh() { diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 31c69bf88d..e1b4885bbb 100755 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -356,6 +356,7 @@ protected: protected: /*virtual*/ LLAvatarJoint* createAvatarJoint(); // Returns LLViewerJoint + /*virtual*/ LLAvatarJoint* createAvatarJoint(S32 joint_num); // Returns LLViewerJoint /*virtual*/ LLAvatarJointMesh* createAvatarJointMesh(); // Returns LLViewerJointMesh public: void updateHeadOffset(); From 4282de6e8572c4b6a9209bbea601c804406a49b8 Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Wed, 17 Feb 2016 17:02:27 -0800 Subject: [PATCH 2/5] SL-318 allow joint offset changes in BVH animations up to 5m. --- indra/llcharacter/llbvhloader.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp index 8985dc9521..a6ab801cef 100755 --- a/indra/llcharacter/llbvhloader.cpp +++ b/indra/llcharacter/llbvhloader.cpp @@ -487,7 +487,7 @@ void LLBVHLoader::makeTranslation(std::string alias_name, std::string joint_name newTrans.mFrameMatrix = fm; - if (joint_name == "mPelvis") +if (joint_name == "mPelvis") { newTrans.mRelativePositionKey = TRUE; newTrans.mRelativeRotationKey = TRUE; @@ -960,7 +960,7 @@ void LLBVHLoader::applyTranslations() //---------------------------------------------------------------- if ( trans.mIgnore ) { - //LL_INFOS() << "NOTE: Ignoring " << joint->mName.c_str() << LL_ENDL; + //LL_INFOS() << "NOTE: Ignoring " << joint->mName.c_str() << LL_ENDL; joint->mIgnore = TRUE; continue; } @@ -974,13 +974,8 @@ void LLBVHLoader::applyTranslations() joint->mOutName = trans.mOutName; } - //---------------------------------------------------------------- - // Set the ignorepos flag if necessary - //---------------------------------------------------------------- - if ( joint->mOutName == std::string("mPelvis") ) - { - joint->mIgnorePositions = FALSE; - } + //Allow joint position changes as of SL-318 + joint->mIgnorePositions = FALSE; //---------------------------------------------------------------- // Set the relativepos flags if necessary @@ -1426,8 +1421,8 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp) frame++; } - // output position keys (only for 1st joint) - if ( ji == mJoints.begin() && !joint->mIgnorePositions ) + // output position keys if joint has motion. + if ( !joint->mIgnorePositions ) { dp.packS32(joint->mNumPosKeys, "num_pos_keys"); @@ -1457,6 +1452,7 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp) outPos *= INCHES_TO_METERS; + //SL-318 Pelvis position can only move 5m. Limiting all joint position offsets to this dist. outPos -= relPos; outPos.clamp(-LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); From f1e6f5c72a1df374252698f68de51de4d4238cc4 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Tue, 23 Feb 2016 09:34:40 -0500 Subject: [PATCH 3/5] SL-287 WIP - fixed default avatar crash caused by added spine joints. Still renders distorted. --- indra/llappearance/llavatarjointmesh.cpp | 60 ++++-- indra/llcharacter/lljoint.h | 2 +- indra/llcommon/StackWalker.h | 2 +- .../avatar_skeleton_spine_joints.xml | 198 ++++++++++++++++++ indra/newview/llviewerjointmesh.cpp | 2 +- 5 files changed, 241 insertions(+), 23 deletions(-) create mode 100644 indra/newview/character/avatar_skeleton_spine_joints.xml diff --git a/indra/llappearance/llavatarjointmesh.cpp b/indra/llappearance/llavatarjointmesh.cpp index 747579fca2..8b052ac198 100644 --- a/indra/llappearance/llavatarjointmesh.cpp +++ b/indra/llappearance/llavatarjointmesh.cpp @@ -79,6 +79,28 @@ LLSkinJoint::~LLSkinJoint() } +LLAvatarJoint *getBaseSkeletonAncestor(LLAvatarJoint* joint) +{ + LLJoint *ancestor = joint->getParent(); + while (ancestor->getParent() && (ancestor->getSupport() != LLJoint::SUPPORT_BASE)) + { + LL_DEBUGS("Avatar") << "skipping non-base ancestor " << ancestor->getName() << LL_ENDL; + ancestor = ancestor->getParent(); + } + return (LLAvatarJoint*) ancestor; +} + +LLVector3 totalSkinOffset(LLAvatarJoint *joint) +{ + LLVector3 totalOffset; + while (joint) + { + totalOffset += joint->getSkinOffset(); + joint = (LLAvatarJoint*)joint->getParent(); + } + return totalOffset; +} + //----------------------------------------------------------------------------- // LLSkinJoint::setupSkinJoint() //----------------------------------------------------------------------------- @@ -92,18 +114,12 @@ BOOL LLSkinJoint::setupSkinJoint( LLAvatarJoint *joint) } // compute the inverse root skin matrix - mRootToJointSkinOffset.clearVec(); + mRootToJointSkinOffset = totalSkinOffset(joint); + mRootToJointSkinOffset = -mRootToJointSkinOffset; - LLVector3 rootSkinOffset; - while (joint) - { - rootSkinOffset += joint->getSkinOffset(); - joint = (LLAvatarJoint*)joint->getParent(); - } - - mRootToJointSkinOffset = -rootSkinOffset; - mRootToParentJointSkinOffset = mRootToJointSkinOffset; - mRootToParentJointSkinOffset += mJoint->getSkinOffset(); + //mRootToParentJointSkinOffset = totalSkinOffset((LLAvatarJoint*)joint->getParent()); + mRootToParentJointSkinOffset = totalSkinOffset(getBaseSkeletonAncestor(joint)); + mRootToParentJointSkinOffset = -mRootToParentJointSkinOffset; return TRUE; } @@ -315,9 +331,9 @@ void LLAvatarJointMesh::setMesh( LLPolyMesh *mesh ) if (!mMesh->isLOD()) { setupJoint((LLAvatarJoint*)getRoot()); + LL_DEBUGS("Avatar") << getName() << " joint render entries: " << mMesh->mJointRenderData.size() << LL_ENDL; } - LL_DEBUGS() << "joint render entries: " << mMesh->mJointRenderData.size() << LL_ENDL; } //----------------------------------------------------------------------------- @@ -325,8 +341,6 @@ void LLAvatarJointMesh::setMesh( LLPolyMesh *mesh ) //----------------------------------------------------------------------------- void LLAvatarJointMesh::setupJoint(LLAvatarJoint* current_joint) { - LL_DEBUGS() << "Mesh: " << getName() << LL_ENDL; - S32 joint_count = 0; U32 sj; @@ -340,22 +354,28 @@ void LLAvatarJointMesh::setupJoint(LLAvatarJoint* current_joint) } // we've found a skinjoint for this joint.. + LL_DEBUGS("Avatar") << "Mesh: " << getName() << " joint " << current_joint->getName() << " matches skinjoint " << sj << LL_ENDL; // is the last joint in the array our parent? - if(mMesh->mJointRenderData.size() && mMesh->mJointRenderData[mMesh->mJointRenderData.size() - 1]->mWorldMatrix == ¤t_joint->getParent()->getWorldMatrix()) + + // SL-287 - need to update this so the results are the same if + // additional extended-skeleton joints lie between this joint + // and the original parent. + LLJoint *ancestor = getBaseSkeletonAncestor(current_joint); + if(mMesh->mJointRenderData.size() && mMesh->mJointRenderData[mMesh->mJointRenderData.size() - 1]->mWorldMatrix == &ancestor->getWorldMatrix()) { // ...then just add ourselves LLAvatarJoint* jointp = js.mJoint; mMesh->mJointRenderData.push_back(new LLJointRenderData(&jointp->getWorldMatrix(), &js)); - LL_DEBUGS() << "joint " << joint_count++ << js.mJoint->getName() << LL_ENDL; + LL_DEBUGS("Avatar") << "add joint " << joint_count++ << " " << js.mJoint->getName() << LL_ENDL; } - // otherwise add our parent and ourselves + // otherwise add our ancestor and ourselves else { - mMesh->mJointRenderData.push_back(new LLJointRenderData(¤t_joint->getParent()->getWorldMatrix(), NULL)); - LL_DEBUGS() << "joint " << joint_count++ << current_joint->getParent()->getName() << LL_ENDL; + mMesh->mJointRenderData.push_back(new LLJointRenderData(&ancestor->getWorldMatrix(), NULL)); + LL_DEBUGS("Avatar") << "add2 ancestor joint " << joint_count++ << " " << ancestor->getName() << LL_ENDL; mMesh->mJointRenderData.push_back(new LLJointRenderData(¤t_joint->getWorldMatrix(), &js)); - LL_DEBUGS() << "joint " << joint_count++ << current_joint->getName() << LL_ENDL; + LL_DEBUGS("Avatar") << "add2 joint " << joint_count++ << " " << current_joint->getName() << LL_ENDL; } } diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index e666f177e7..61592363f5 100755 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -42,7 +42,7 @@ const S32 LL_CHARACTER_MAX_JOINTS_PER_MESH = 15; // BENTO JOINT COUNT LIMIT - need to set this to final skeleton size // (bones + attachments) + 2, rounded to next multiple of 4. -const U32 LL_CHARACTER_MAX_ANIMATED_JOINTS = 164; // must be divisible by 4! +const U32 LL_CHARACTER_MAX_ANIMATED_JOINTS = 180; // must be divisible by 4! const U32 LL_MAX_JOINTS_PER_MESH_OBJECT = 110; // These should be higher than the joint_num of any diff --git a/indra/llcommon/StackWalker.h b/indra/llcommon/StackWalker.h index 4ff6e736da..5a5ed96e6f 100644 --- a/indra/llcommon/StackWalker.h +++ b/indra/llcommon/StackWalker.h @@ -127,7 +127,7 @@ public: // in older compilers in order to use it... starting with VC7 we can declare it as "protected" protected: #endif - enum { STACKWALK_MAX_NAMELEN = 1024 }; // max name length for found symbols + enum { STACKWALK_MAX_NAMELEN = 2048 }; // max name length for found symbols protected: // Entry for each Callstack-Entry diff --git a/indra/newview/character/avatar_skeleton_spine_joints.xml b/indra/newview/character/avatar_skeleton_spine_joints.xml new file mode 100644 index 0000000000..4124df9055 --- /dev/null +++ b/indra/newview/character/avatar_skeleton_spine_joints.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index bf7cf08c63..43a81ada49 100755 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -203,7 +203,7 @@ void LLViewerJointMesh::uploadJointMatrices() // DrawElementsBLEND and utility code //-------------------------------------------------------------------- -// compate_int is used by the qsort function to sort the index array +// compare_int is used by the qsort function to sort the index array int compare_int(const void *a, const void *b) { if (*(U32*)a < *(U32*)b) From a67a01b2a3a8824213d07a303350cc401078b9a9 Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Tue, 23 Feb 2016 10:47:21 -0800 Subject: [PATCH 4/5] MAINT-6162 limit joint offset distances in old style .anim format --- indra/llcharacter/llkeyframemotion.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 0ab716d092..052ca3be58 100755 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -1610,6 +1610,12 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) if (old_version) { success = dp.unpackVector3(pos_key.mPosition, "pos"); + + //MAINT-6162 + pos_key.mPosition.mV[VX] = llclamp( pos_key.mPosition.mV[VX], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); + pos_key.mPosition.mV[VY] = llclamp( pos_key.mPosition.mV[VY], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); + pos_key.mPosition.mV[VZ] = llclamp( pos_key.mPosition.mV[VZ], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); + } else { From 78938c2eac044f8c01574394647b973725842543 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Tue, 23 Feb 2016 16:44:32 -0500 Subject: [PATCH 5/5] SL-341 - added ellipsoid-based visualization of collision volumes. --- indra/newview/llvoavatar.cpp | 131 ++++++++++++++++++++++++----------- 1 file changed, 89 insertions(+), 42 deletions(-) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 762ff95840..84d585df02 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -106,6 +106,7 @@ #include "llscenemonitor.h" #include "llsdserialize.h" #include "llcallstack.h" +#include "llrendersphere.h" extern F32 SPEED_ADJUST_MAX; extern F32 SPEED_ADJUST_MAX_SEC; @@ -1340,6 +1341,43 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) newMax.add(buffer); } +void render_sphere_and_line(const LLVector3& begin_pos, const LLVector3& end_pos, F32 sphere_scale, const LLVector3& occ_color, const LLVector3& visible_color) +{ + // Unoccluded bone portions + LLGLDepthTest normal_depth(GL_TRUE); + + // Draw line segment for unoccluded joint + gGL.diffuseColor3f(visible_color[0], visible_color[1], visible_color[2]); + + gGL.begin(LLRender::LINES); + gGL.vertex3fv(begin_pos.mV); + gGL.vertex3fv(end_pos.mV); + gGL.end(); + + + // Draw sphere representing joint pos + gGL.pushMatrix(); + gGL.scalef(sphere_scale, sphere_scale, sphere_scale); + gSphere.renderGGL(); + gGL.popMatrix(); + + LLGLDepthTest depth_under(GL_TRUE, GL_FALSE, GL_GREATER); + + // Occluded bone portions + gGL.diffuseColor3f(occ_color[0], occ_color[1], occ_color[2]); + + gGL.begin(LLRender::LINES); + gGL.vertex3fv(begin_pos.mV); + gGL.vertex3fv(end_pos.mV); + gGL.end(); + + // Draw sphere representing joint pos + gGL.pushMatrix(); + gGL.scalef(sphere_scale, sphere_scale, sphere_scale); + gSphere.renderGGL(); + gGL.popMatrix(); +} + //----------------------------------------------------------------------------- // renderCollisionVolumes() //----------------------------------------------------------------------------- @@ -1348,10 +1386,36 @@ void LLVOAvatar::renderCollisionVolumes() std::ostringstream ostr; for (S32 i = 0; i < mNumCollisionVolumes; i++) { - mCollisionVolumes[i].renderCollision(); + //mCollisionVolumes[i].renderCollision(); ostr << mCollisionVolumes[i].getName() << ", "; } + for (S32 i = 0; i < mNumCollisionVolumes; i++) + { + LLAvatarJointCollisionVolume& collision_volume = mCollisionVolumes[i]; + + collision_volume.updateWorldMatrix(); + + gGL.pushMatrix(); + gGL.multMatrix( &collision_volume.getXform()->getWorldMatrix().mMatrix[0][0] ); + + LLVector3 begin_pos(0,0,0); + LLVector3 end_pos(collision_volume.getEnd()); + static F32 sphere_scale = 1.0f; + static F32 center_dot_scale = 0.05f; + + static LLVector3 CV_COLOR_OCCLUDED(0.0f, 0.0f, 1.0f); + static LLVector3 CV_COLOR_VISIBLE(0.5f, 0.5f, 1.0f); + static LLVector3 DOT_COLOR_OCCLUDED(1.0f, 1.0f, 1.0f); + static LLVector3 DOT_COLOR_VISIBLE(1.0f, 1.0f, 1.0f); + + render_sphere_and_line(begin_pos, end_pos, sphere_scale, CV_COLOR_OCCLUDED, CV_COLOR_VISIBLE); + render_sphere_and_line(begin_pos, end_pos, center_dot_scale, DOT_COLOR_OCCLUDED, DOT_COLOR_VISIBLE); + + gGL.popMatrix(); + } + + if (mNameText.notNull()) { LLVector4a unused; @@ -1374,6 +1438,13 @@ void LLVOAvatar::renderBones() avatar_joint_list_t::iterator iter = mSkeleton.begin(); avatar_joint_list_t::iterator end = mSkeleton.end(); + static LLVector3 BASE_COLOR_OCCLUDED(1.0f, 0.0f, 0.0f); + 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 F32 SPHERE_SCALEF = 0.003f; + for (; iter != end; ++iter) { LLJoint* jointp = *iter; @@ -1386,52 +1457,28 @@ void LLVOAvatar::renderBones() jointp->updateWorldMatrix(); LLJoint::SupportCategory sc = jointp->getSupport(); + LLVector3 occ_color, visible_color; + 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()); + + F32 sphere_scale = SPHERE_SCALEF; + gGL.pushMatrix(); gGL.multMatrix( &jointp->getXform()->getWorldMatrix().mMatrix[0][0] ); - gGL.begin(LLRender::LINES); - - LLVector3 v[] = - { - LLVector3(0,0,0), - LLVector3(0,0,0), - }; - v[1] = jointp->getEnd(); - - LLGLDepthTest normal_depth(GL_TRUE); - - // Unoccluded bone portions - if (sc == LLJoint::SUPPORT_BASE) - { - gGL.diffuseColor3f( 1.0f, 0.5f, 0.5f ); - } - else - { - gGL.diffuseColor3f( 0.5f, 1.0f, 0.5f ); - } + render_sphere_and_line(begin_pos, end_pos, sphere_scale, occ_color, visible_color); - - gGL.vertex3fv(v[0].mV); - gGL.vertex3fv(v[1].mV); - - LLGLDepthTest depth_under(GL_TRUE, GL_FALSE, GL_GREATER); - - // Unoccluded bone portions - if (sc == LLJoint::SUPPORT_BASE) - { - gGL.diffuseColor3f( 1.0f, 0.0f, 0.0f ); - } - else - { - gGL.diffuseColor3f( 0.0f, 1.0f, 0.0f ); - } - - gGL.vertex3fv(v[0].mV); - gGL.vertex3fv(v[1].mV); - - gGL.end(); - gGL.popMatrix(); }