From 282de8c7f54a4087500ac918e165746c93838ff1 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Wed, 20 Aug 2014 19:40:31 -0500 Subject: [PATCH] Only use LLAvatarJoint when necessary, else LLJoint --- indra/llappearance/llavatarappearance.cpp | 6 ++--- indra/llappearance/llavatarjoint.cpp | 18 +++++++++---- indra/llappearance/llavatarjointmesh.cpp | 31 ++++++++++------------- indra/llappearance/llavatarjointmesh.h | 6 ++--- indra/newview/llviewerjoint.cpp | 2 ++ 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/indra/llappearance/llavatarappearance.cpp b/indra/llappearance/llavatarappearance.cpp index 1d05da7f3..3d3420961 100644 --- a/indra/llappearance/llavatarappearance.cpp +++ b/indra/llappearance/llavatarappearance.cpp @@ -983,19 +983,19 @@ BOOL LLAvatarAppearance::loadSkeletonNode () mRoot->addChild(mMeshLOD[MESH_ID_SKIRT]); mRoot->addChild(mMeshLOD[MESH_ID_HEAD]); - LLAvatarJoint *skull = (LLAvatarJoint*)mRoot->findJoint("mSkull"); + LLJoint *skull = mRoot->findJoint("mSkull"); if (skull) { skull->addChild(mMeshLOD[MESH_ID_HAIR] ); } - LLAvatarJoint *eyeL = (LLAvatarJoint*)mRoot->findJoint("mEyeLeft"); + LLJoint *eyeL = mRoot->findJoint("mEyeLeft"); if (eyeL) { eyeL->addChild( mMeshLOD[MESH_ID_EYEBALL_LEFT] ); } - LLAvatarJoint *eyeR = (LLAvatarJoint*)mRoot->findJoint("mEyeRight"); + LLJoint *eyeR = mRoot->findJoint("mEyeRight"); if (eyeR) { eyeR->addChild( mMeshLOD[MESH_ID_EYEBALL_RIGHT] ); diff --git a/indra/llappearance/llavatarjoint.cpp b/indra/llappearance/llavatarjoint.cpp index 5153debff..b40475fdc 100644 --- a/indra/llappearance/llavatarjoint.cpp +++ b/indra/llappearance/llavatarjoint.cpp @@ -125,7 +125,8 @@ void LLAvatarJoint::setSkeletonComponents( U32 comp, BOOL recursive ) iter != mChildren.end(); ++iter) { LLAvatarJoint* joint = dynamic_cast(*iter); - joint->setSkeletonComponents(comp, recursive); + if (joint) + joint->setSkeletonComponents(comp, recursive); } } } @@ -152,7 +153,8 @@ void LLAvatarJoint::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pix iter != mChildren.end(); ++iter) { LLAvatarJoint* joint = dynamic_cast(*iter); - joint->updateFaceSizes(num_vertices, num_indices, pixel_area); + if (joint) + joint->updateFaceSizes(num_vertices, num_indices, pixel_area); } } @@ -162,7 +164,8 @@ void LLAvatarJoint::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, iter != mChildren.end(); ++iter) { LLAvatarJoint* joint = dynamic_cast(*iter); - joint->updateFaceData(face, pixel_area, damp_wind, terse_update); + if (joint) + joint->updateFaceData(face, pixel_area, damp_wind, terse_update); } } @@ -172,7 +175,8 @@ void LLAvatarJoint::updateJointGeometry() iter != mChildren.end(); ++iter) { LLAvatarJoint* joint = dynamic_cast(*iter); - joint->updateJointGeometry(); + if (joint) + joint->updateJointGeometry(); } } @@ -186,6 +190,9 @@ BOOL LLAvatarJoint::updateLOD(F32 pixel_area, BOOL activate) iter != mChildren.end(); ++iter) { LLAvatarJoint* joint = dynamic_cast(*iter); + if (!joint) + continue; + F32 jointLOD = joint->getLOD(); if (found_lod || jointLOD == DEFAULT_AVATAR_JOINT_LOD) @@ -215,7 +222,8 @@ void LLAvatarJoint::dump() iter != mChildren.end(); ++iter) { LLAvatarJoint* joint = dynamic_cast(*iter); - joint->dump(); + if (joint) + joint->dump(); } } diff --git a/indra/llappearance/llavatarjointmesh.cpp b/indra/llappearance/llavatarjointmesh.cpp index 5099e5481..7a9508968 100644 --- a/indra/llappearance/llavatarjointmesh.cpp +++ b/indra/llappearance/llavatarjointmesh.cpp @@ -83,30 +83,28 @@ LLSkinJoint::~LLSkinJoint() //----------------------------------------------------------------------------- // LLSkinJoint::setupSkinJoint() //----------------------------------------------------------------------------- -BOOL LLSkinJoint::setupSkinJoint( LLAvatarJoint *joint) +void LLSkinJoint::setupSkinJoint( LLJoint *joint) { + mRootToJointSkinOffset.clearVec(); + mRootToParentJointSkinOffset.clearVec(); + // find the named joint - mJoint = joint; - if ( !mJoint ) + if (!(mJoint = joint)) { llinfos << "Can't find joint" << llendl; + return; } // compute the inverse root skin matrix - mRootToJointSkinOffset.clearVec(); - - LLVector3 rootSkinOffset; - while (joint) + do { - rootSkinOffset += joint->getSkinOffset(); - joint = (LLAvatarJoint*)joint->getParent(); - } + mRootToJointSkinOffset -= joint->getSkinOffset(); + } while (joint = joint->getParent()); - mRootToJointSkinOffset = -rootSkinOffset; mRootToParentJointSkinOffset = mRootToJointSkinOffset; mRootToParentJointSkinOffset += mJoint->getSkinOffset(); - return TRUE; + return; } @@ -307,15 +305,14 @@ void LLAvatarJointMesh::setMesh( LLPolyMesh *mesh ) for (jn = 0; jn < numJointNames; jn++) { //llinfos << "Setting up joint " << jointNames[jn] << llendl; - LLAvatarJoint* joint = (LLAvatarJoint*)(getRoot()->findJoint(jointNames[jn]) ); - mSkinJoints[jn].setupSkinJoint( joint ); + mSkinJoints[jn].setupSkinJoint( getRoot()->findJoint(jointNames[jn]) ); } } // setup joint array if (!mMesh->isLOD()) { - setupJoint((LLAvatarJoint*)getRoot()); + setupJoint(getRoot()); } // llinfos << "joint render entries: " << mMesh->mJointRenderData.count() << llendl; @@ -324,7 +321,7 @@ void LLAvatarJointMesh::setMesh( LLPolyMesh *mesh ) //----------------------------------------------------------------------------- // setupJoint() //----------------------------------------------------------------------------- -void LLAvatarJointMesh::setupJoint(LLAvatarJoint* current_joint) +void LLAvatarJointMesh::setupJoint(LLJoint* current_joint) { // llinfos << "Mesh: " << getName() << llendl; @@ -345,7 +342,7 @@ void LLAvatarJointMesh::setupJoint(LLAvatarJoint* current_joint) if(mMesh->mJointRenderData.count() && mMesh->mJointRenderData[mMesh->mJointRenderData.count() - 1]->mWorldMatrix == ¤t_joint->getParent()->getWorldMatrix()) { // ...then just add ourselves - LLAvatarJoint* jointp = js.mJoint; + LLJoint* jointp = js.mJoint; mMesh->mJointRenderData.put(new LLJointRenderData(&jointp->getWorldMatrix(), &js)); // llinfos << "joint " << joint_count << js.mJoint->getName() << llendl; // joint_count++; diff --git a/indra/llappearance/llavatarjointmesh.h b/indra/llappearance/llavatarjointmesh.h index 53b82c50a..5dece5972 100644 --- a/indra/llappearance/llavatarjointmesh.h +++ b/indra/llappearance/llavatarjointmesh.h @@ -49,9 +49,9 @@ class LLSkinJoint public: LLSkinJoint(); ~LLSkinJoint(); - BOOL setupSkinJoint( LLAvatarJoint *joint); + void setupSkinJoint( LLJoint *joint); - LLAvatarJoint *mJoint; + LLJoint* mJoint; LLVector3 mRootToJointSkinOffset; LLVector3 mRootToParentJointSkinOffset; }; @@ -122,7 +122,7 @@ public: void setMesh( LLPolyMesh *mesh ); // Sets up joint matrix data for rendering - void setupJoint(LLAvatarJoint* current_joint); + void setupJoint(LLJoint* current_joint); // Sets ID for picking void setMeshID( S32 id ) {mMeshID = id;} diff --git a/indra/newview/llviewerjoint.cpp b/indra/newview/llviewerjoint.cpp index e46299f9d..2ce476092 100644 --- a/indra/newview/llviewerjoint.cpp +++ b/indra/newview/llviewerjoint.cpp @@ -146,6 +146,8 @@ U32 LLViewerJoint::render( F32 pixelArea, BOOL first_pass, BOOL is_dummy ) iter != mChildren.end(); ++iter) { LLAvatarJoint* joint = dynamic_cast(*iter); + if (!joint) + continue; F32 jointLOD = joint->getLOD(); if (pixelArea >= jointLOD || sDisableLOD) {