From 389c35e08ed282d4c337ba86c84c109ef05d5ba0 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sat, 22 Dec 2012 16:30:38 -0600 Subject: [PATCH] Pulled LLAvatarJoint out of LLViewerJoint --- indra/llappearance/CMakeLists.txt | 2 +- indra/llappearance/llavatarjoint.cpp | 326 ++++++++++++++++ indra/llappearance/llavatarjoint.h | 22 +- indra/llappearance/lljointpickname.h | 6 +- indra/llcharacter/lljoint.cpp | 66 ++-- indra/llcharacter/lljoint.h | 48 +-- indra/newview/llfloaterimagepreview.cpp | 4 +- indra/newview/llviewerjoint.cpp | 473 +----------------------- indra/newview/llviewerjoint.h | 94 +---- indra/newview/llviewerjointmesh.cpp | 8 +- indra/newview/llvoavatar.cpp | 84 ++--- indra/newview/llvoavatar.h | 46 +-- indra/newview/llvoavatarself.cpp | 5 - indra/newview/llvoavatarself.h | 2 - 14 files changed, 482 insertions(+), 704 deletions(-) create mode 100644 indra/llappearance/llavatarjoint.cpp diff --git a/indra/llappearance/CMakeLists.txt b/indra/llappearance/CMakeLists.txt index 1552dbbec..53b62fa1a 100644 --- a/indra/llappearance/CMakeLists.txt +++ b/indra/llappearance/CMakeLists.txt @@ -29,7 +29,7 @@ include_directories( set(llappearance_SOURCE_FILES #llavatarappearance.cpp - #llavatarjoint.cpp + llavatarjoint.cpp #llavatarjointmesh.cpp #lldriverparam.cpp #lllocaltextureobject.cpp diff --git a/indra/llappearance/llavatarjoint.cpp b/indra/llappearance/llavatarjoint.cpp new file mode 100644 index 000000000..1b8978a49 --- /dev/null +++ b/indra/llappearance/llavatarjoint.cpp @@ -0,0 +1,326 @@ +/** + * @file llavatarjoint.cpp + * @brief Implementation of LLAvatarJoint class + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +//----------------------------------------------------------------------------- +// Header Files +//----------------------------------------------------------------------------- +#include "llavatarjoint.h" + +#include "llgl.h" +#include "llrender.h" +#include "llmath.h" +#include "llglheaders.h" +#include "llavatarappearance.h" + +const F32 DEFAULT_AVATAR_JOINT_LOD = 0.0f; + +//----------------------------------------------------------------------------- +// Static Data +//----------------------------------------------------------------------------- +BOOL LLAvatarJoint::sDisableLOD = FALSE; + +//----------------------------------------------------------------------------- +// LLAvatarJoint() +// Class Constructors +//----------------------------------------------------------------------------- +LLAvatarJoint::LLAvatarJoint() : + LLJoint() +{ + init(); +} + +LLAvatarJoint::LLAvatarJoint(const std::string &name, LLJoint *parent) : + LLJoint(name, parent) +{ + init(); +} + +LLAvatarJoint::LLAvatarJoint(S32 joint_num) : + LLJoint(joint_num) +{ + init(); +} + + +void LLAvatarJoint::init() +{ + mValid = FALSE; + mComponents = SC_JOINT | SC_BONE | SC_AXES; + mMinPixelArea = DEFAULT_AVATAR_JOINT_LOD; + mPickName = PN_DEFAULT; + mVisible = TRUE; + mMeshID = 0; + mIsTransparent = FALSE; +} + + +//----------------------------------------------------------------------------- +// ~LLAvatarJoint() +// Class Destructor +//----------------------------------------------------------------------------- +LLAvatarJoint::~LLAvatarJoint() +{ +} + + +//-------------------------------------------------------------------- +// setValid() +//-------------------------------------------------------------------- +void LLAvatarJoint::setValid( BOOL valid, BOOL recursive ) +{ + //---------------------------------------------------------------- + // set visibility for this joint + //---------------------------------------------------------------- + mValid = valid; + + //---------------------------------------------------------------- + // set visibility for children + //---------------------------------------------------------------- + if (recursive) + { + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) + { + LLAvatarJoint* joint = (LLAvatarJoint*)(*iter); + joint->setValid(valid, TRUE); + } + } + +} + +//-------------------------------------------------------------------- +// setSkeletonComponents() +//-------------------------------------------------------------------- +void LLAvatarJoint::setSkeletonComponents( U32 comp, BOOL recursive ) +{ + mComponents = comp; + if (recursive) + { + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) + { + LLAvatarJoint* joint = dynamic_cast(*iter); + joint->setSkeletonComponents(comp, recursive); + } + } +} + +void LLAvatarJoint::setVisible(BOOL visible, BOOL recursive) +{ + mVisible = visible; + + if (recursive) + { + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) + { + LLAvatarJoint* joint = (LLAvatarJoint*)(*iter); + joint->setVisible(visible, recursive); + } + } +} + +void LLAvatarJoint::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area) +{ + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) + { + LLAvatarJoint* joint = dynamic_cast(*iter); + joint->updateFaceSizes(num_vertices, num_indices, pixel_area); + } +} + +void LLAvatarJoint::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update) +{ + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) + { + LLAvatarJoint* joint = dynamic_cast(*iter); + joint->updateFaceData(face, pixel_area, damp_wind, terse_update); + } +} + +void LLAvatarJoint::updateJointGeometry() +{ + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) + { + LLAvatarJoint* joint = dynamic_cast(*iter); + joint->updateJointGeometry(); + } +} + + +BOOL LLAvatarJoint::updateLOD(F32 pixel_area, BOOL activate) +{ + BOOL lod_changed = FALSE; + BOOL found_lod = FALSE; + + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) + { + LLAvatarJoint* joint = dynamic_cast(*iter); + F32 jointLOD = joint->getLOD(); + + if (found_lod || jointLOD == DEFAULT_AVATAR_JOINT_LOD) + { + // we've already found a joint to enable, so enable the rest as alternatives + lod_changed |= joint->updateLOD(pixel_area, TRUE); + } + else + { + if (pixel_area >= jointLOD || sDisableLOD) + { + lod_changed |= joint->updateLOD(pixel_area, TRUE); + found_lod = TRUE; + } + else + { + lod_changed |= joint->updateLOD(pixel_area, FALSE); + } + } + } + return lod_changed; +} + +void LLAvatarJoint::dump() +{ + for (child_list_t::iterator iter = mChildren.begin(); + iter != mChildren.end(); ++iter) + { + LLAvatarJoint* joint = dynamic_cast(*iter); + joint->dump(); + } +} + + +void LLAvatarJoint::setMeshesToChildren() +{ + removeAllChildren(); + for (avatar_joint_mesh_list_t::iterator iter = mMeshParts.begin(); + iter != mMeshParts.end(); iter++) + { + addChild((LLJoint*)(*iter)); + } +} +//----------------------------------------------------------------------------- +// LLAvatarJointCollisionVolume() +//----------------------------------------------------------------------------- + +LLAvatarJointCollisionVolume::LLAvatarJointCollisionVolume() +{ + mUpdateXform = FALSE; +} + +/*virtual*/ +U32 LLAvatarJointCollisionVolume::render( F32 pixelArea, BOOL first_pass, BOOL is_dummy ) +{ + llerrs << "Cannot call render() on LLAvatarJointCollisionVolume" << llendl; + return 0; +} + +LLVector3 LLAvatarJointCollisionVolume::getVolumePos(LLVector3 &offset) +{ + mUpdateXform = TRUE; + + LLVector3 result = offset; + result.scaleVec(getScale()); + result.rotVec(getWorldRotation()); + result += getWorldPosition(); + + return result; +} + +void LLAvatarJointCollisionVolume::renderCollision() +{ + updateWorldMatrix(); + + gGL.pushMatrix(); + gGL.multMatrix( &mXform.getWorldMatrix().mMatrix[0][0] ); + + gGL.diffuseColor3f( 0.f, 0.f, 1.f ); + + gGL.begin(LLRender::LINES); + + LLVector3 v[] = + { + LLVector3(1,0,0), + LLVector3(-1,0,0), + LLVector3(0,1,0), + LLVector3(0,-1,0), + + LLVector3(0,0,-1), + LLVector3(0,0,1), + }; + + //sides + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[2].mV); + + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[3].mV); + + gGL.vertex3fv(v[1].mV); + gGL.vertex3fv(v[2].mV); + + gGL.vertex3fv(v[1].mV); + gGL.vertex3fv(v[3].mV); + + + //top + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[4].mV); + + gGL.vertex3fv(v[1].mV); + gGL.vertex3fv(v[4].mV); + + gGL.vertex3fv(v[2].mV); + gGL.vertex3fv(v[4].mV); + + gGL.vertex3fv(v[3].mV); + gGL.vertex3fv(v[4].mV); + + + //bottom + gGL.vertex3fv(v[0].mV); + gGL.vertex3fv(v[5].mV); + + gGL.vertex3fv(v[1].mV); + gGL.vertex3fv(v[5].mV); + + gGL.vertex3fv(v[2].mV); + gGL.vertex3fv(v[5].mV); + + gGL.vertex3fv(v[3].mV); + gGL.vertex3fv(v[5].mV); + + gGL.end(); + + gGL.popMatrix(); +} + + +// End diff --git a/indra/llappearance/llavatarjoint.h b/indra/llappearance/llavatarjoint.h index 71b03c905..e10ddcf39 100644 --- a/indra/llappearance/llavatarjoint.h +++ b/indra/llappearance/llavatarjoint.h @@ -34,7 +34,7 @@ #include "lljointpickname.h" class LLFace; -class LLAvatarJointMesh; +class LLViewerJointMesh; extern const F32 DEFAULT_AVATAR_JOINT_LOD; @@ -45,7 +45,7 @@ class LLAvatarJoint : public LLJoint { public: - /*LLAvatarJoint(); + LLAvatarJoint(); LLAvatarJoint(S32 joint_num); // *TODO: Only used for LLVOAvatarSelf::mScreenp. *DOES NOT INITIALIZE mResetAfterRestoreOldXform* LLAvatarJoint(const std::string &name, LLJoint *parent = NULL); @@ -59,12 +59,12 @@ public: // Returns true if this object is transparent. // This is used to determine in which order to draw objects. - virtual BOOL isTransparent() { return mIsTransparent; }*/ + virtual BOOL isTransparent() { return mIsTransparent; } // Returns true if this object should inherit scale modifiers from its immediate parent - virtual BOOL inheritScale() = 0; + virtual BOOL inheritScale() { return FALSE; } - /*enum Components + enum Components { SC_BONE = 1, SC_JOINT = 2, @@ -118,21 +118,21 @@ protected: F32 mMinPixelArea; LLJointPickName mPickName; BOOL mVisible; - S32 mMeshID;*/ + S32 mMeshID; }; class LLAvatarJointCollisionVolume : public LLAvatarJoint { public: - LLAvatarJointCollisionVolume() {}; + LLAvatarJointCollisionVolume(); virtual ~LLAvatarJointCollisionVolume() {}; - //*virtual*/ BOOL inheritScale() { return TRUE; } - //*virtual*/ U32 render( F32 pixelArea, BOOL first_pass = TRUE, BOOL is_dummy = FALSE ) = 0; + /*virtual*/ BOOL inheritScale() { return TRUE; } + /*virtual*/ U32 render( F32 pixelArea, BOOL first_pass = TRUE, BOOL is_dummy = FALSE ); - virtual void renderCollision() = 0; + void renderCollision(); - virtual LLVector3 getVolumePos(LLVector3 &offset) = 0; + LLVector3 getVolumePos(LLVector3 &offset); }; #endif // LL_LLAVATARJOINT_H diff --git a/indra/llappearance/lljointpickname.h b/indra/llappearance/lljointpickname.h index 133fd74eb..3843e6e6a 100644 --- a/indra/llappearance/lljointpickname.h +++ b/indra/llappearance/lljointpickname.h @@ -28,7 +28,7 @@ #ifndef LL_LLJOINTPICKNAME_H #define LL_LLJOINTPICKNAME_H -class LLJoint; +class LLViewerJointMesh; // Sets the OpenGL selection stack name that is pushed and popped // with this joint state. The default value indicates that no name @@ -44,6 +44,6 @@ enum LLJointPickName PN_5 = 5 }; -typedef std::vector avatar_joint_mesh_list_t; +typedef std::vector avatar_joint_mesh_list_t; -#endif // LL_LLJOINTPICKNAME_H \ No newline at end of file +#endif // LL_LLJOINTPICKNAME_H diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 091cfa859..f7c51c701 100644 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -2,31 +2,25 @@ * @file lljoint.cpp * @brief Implementation of LLJoint class. * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -46,7 +40,9 @@ S32 LLJoint::sNumTouches = 0; // LLJoint() // Class Constructor //----------------------------------------------------------------------------- -LLJoint::LLJoint() + + +void LLJoint::init() { mName = "unnamed"; mParent = NULL; @@ -54,7 +50,20 @@ LLJoint::LLJoint() mXform.setScale(LLVector3(1.0f, 1.0f, 1.0f)); mDirtyFlags = MATRIX_DIRTY | ROTATION_DIRTY | POSITION_DIRTY; mUpdateXform = TRUE; - mJointNum = -1; +} + +LLJoint::LLJoint() : + mJointNum(-1) +{ + init(); + touch(); + mResetAfterRestoreOldXform = false; +} + +LLJoint::LLJoint(S32 joint_num) : + mJointNum(joint_num) +{ + init(); touch(); mResetAfterRestoreOldXform = false; } @@ -64,15 +73,12 @@ LLJoint::LLJoint() // LLJoint() // Class Constructor //----------------------------------------------------------------------------- -LLJoint::LLJoint(const std::string &name, LLJoint *parent) +LLJoint::LLJoint(const std::string &name, LLJoint *parent) : + mJointNum(0) { - mName = "unnamed"; - mParent = NULL; - mXform.setScaleChildOffset(TRUE); - mXform.setScale(LLVector3(1.0f, 1.0f, 1.0f)); - mDirtyFlags = MATRIX_DIRTY | ROTATION_DIRTY | POSITION_DIRTY; + init(); mUpdateXform = FALSE; - mJointNum = 0; + // *TODO: mResetAfterRestoreOldXform is not initialized!!! setName(name); if (parent) diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index e2d6672b5..351f0f580 100644 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -2,31 +2,25 @@ * @file lljoint.h * @brief Implementation of LLJoint class. * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -110,10 +104,15 @@ public: public: LLJoint(); + LLJoint(S32 joint_num); LLJoint( const std::string &name, LLJoint *parent=NULL ); virtual ~LLJoint(); +private: + void init(); + +public: // set name and parent void setup( const std::string &name, LLJoint *parent=NULL ); @@ -140,7 +139,9 @@ public: // get/set local position const LLVector3& getPosition(); void setPosition( const LLVector3& pos ); - + + void setDefaultPosition( const LLVector3& pos ); + // get/set world position LLVector3 getWorldPosition(); LLVector3 getLastWorldPosition(); @@ -181,8 +182,7 @@ public: virtual BOOL isAnimatable() const { return TRUE; } S32 getJointNum() const { return mJointNum; } - void setJointNum(S32 joint_num) { mJointNum = joint_num; } - + void restoreOldXform( void ); void restoreToDefaultXform( void ); void setDefaultFromCurrentXform( void ); diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index edb961685..905c5f600 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -685,7 +685,7 @@ void LLImagePreviewAvatar::setPreviewTarget(const std::string& joint_name, const } mDummyAvatar->mRoot.setVisible(FALSE, TRUE); - mTargetMesh = (LLViewerJointMesh*)mDummyAvatar->mRoot.findJoint(mesh_name); + mTargetMesh = dynamic_cast(mDummyAvatar->mRoot.findJoint(mesh_name)); mTargetMesh->setTestTexture(mTextureName); mTargetMesh->setVisible(TRUE, FALSE); mCameraDistance = distance; @@ -702,7 +702,7 @@ void LLImagePreviewAvatar::clearPreviewTexture(const std::string& mesh_name) { if (mDummyAvatar) { - LLViewerJointMesh *mesh = (LLViewerJointMesh*)mDummyAvatar->mRoot.findJoint(mesh_name); + LLViewerJointMesh *mesh = dynamic_cast(mDummyAvatar->mRoot.findJoint(mesh_name)); // clear out existing test mesh if (mesh) { diff --git a/indra/newview/llviewerjoint.cpp b/indra/newview/llviewerjoint.cpp index a907f102f..e46299f9d 100644 --- a/indra/newview/llviewerjoint.cpp +++ b/indra/newview/llviewerjoint.cpp @@ -35,50 +35,26 @@ #include "llrender.h" #include "llmath.h" #include "llglheaders.h" -#include "llrendersphere.h" #include "llvoavatar.h" #include "pipeline.h" -#define DEFAULT_LOD 0.0f - -const S32 MIN_PIXEL_AREA_3PASS_HAIR = 64*64; - -//----------------------------------------------------------------------------- -// Static Data -//----------------------------------------------------------------------------- -BOOL LLViewerJoint::sDisableLOD = FALSE; +static const S32 MIN_PIXEL_AREA_3PASS_HAIR = 64*64; //----------------------------------------------------------------------------- // LLViewerJoint() -// Class Constructor +// Class Constructors //----------------------------------------------------------------------------- -LLViewerJoint::LLViewerJoint() - : LLJoint() -{ - init(); -} +LLViewerJoint::LLViewerJoint() : + LLAvatarJoint() +{ } +LLViewerJoint::LLViewerJoint(const std::string &name, LLJoint *parent) : + LLAvatarJoint(name, parent) +{ } -//----------------------------------------------------------------------------- -// LLViewerJoint() -// Class Constructor -//----------------------------------------------------------------------------- -LLViewerJoint::LLViewerJoint(const std::string &name, LLJoint *parent) - : LLJoint(name, parent) -{ - init(); -} - - -void LLViewerJoint::init() -{ - mValid = FALSE; - mComponents = SC_JOINT | SC_BONE | SC_AXES; - mMinPixelArea = DEFAULT_LOD; - mPickName = PN_DEFAULT; - mVisible = TRUE; - mMeshID = 0; -} +LLViewerJoint::LLViewerJoint(S32 joint_num) : + LLAvatarJoint(joint_num) +{ } //----------------------------------------------------------------------------- @@ -89,154 +65,6 @@ LLViewerJoint::~LLViewerJoint() { } - -//-------------------------------------------------------------------- -// setValid() -//-------------------------------------------------------------------- -void LLViewerJoint::setValid( BOOL valid, BOOL recursive ) -{ - //---------------------------------------------------------------- - // set visibility for this joint - //---------------------------------------------------------------- - mValid = valid; - - //---------------------------------------------------------------- - // set visibility for children - //---------------------------------------------------------------- - if (recursive) - { - for (child_list_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) - { - LLViewerJoint* joint = (LLViewerJoint*)(*iter); - joint->setValid(valid, TRUE); - } - } - -} - -//-------------------------------------------------------------------- -// renderSkeleton() -// DEBUG (UNUSED) -//-------------------------------------------------------------------- -// void LLViewerJoint::renderSkeleton(BOOL recursive) -// { -// F32 nc = 0.57735f; - -// //---------------------------------------------------------------- -// // push matrix stack -// //---------------------------------------------------------------- -// gGL.pushMatrix(); - -// //---------------------------------------------------------------- -// // render the bone to my parent -// //---------------------------------------------------------------- -// if (mComponents & SC_BONE) -// { -// drawBone(); -// } - -// //---------------------------------------------------------------- -// // offset to joint position and -// // rotate to our orientation -// //---------------------------------------------------------------- -// gGL.loadIdentity(); -// gGL.multMatrix( &getWorldMatrix().mMatrix[0][0] ); - -// //---------------------------------------------------------------- -// // render joint axes -// //---------------------------------------------------------------- -// if (mComponents & SC_AXES) -// { -// gGL.begin(LLRender::LINES); -// gGL.color3f( 1.0f, 0.0f, 0.0f ); -// gGL.vertex3f( 0.0f, 0.0f, 0.0f ); -// gGL.vertex3f( 0.1f, 0.0f, 0.0f ); - -// gGL.color3f( 0.0f, 1.0f, 0.0f ); -// gGL.vertex3f( 0.0f, 0.0f, 0.0f ); -// gGL.vertex3f( 0.0f, 0.1f, 0.0f ); - -// gGL.color3f( 0.0f, 0.0f, 1.0f ); -// gGL.vertex3f( 0.0f, 0.0f, 0.0f ); -// gGL.vertex3f( 0.0f, 0.0f, 0.1f ); -// gGL.end(); -// } - -// //---------------------------------------------------------------- -// // render the joint graphic -// //---------------------------------------------------------------- -// if (mComponents & SC_JOINT) -// { -// gGL.color3f( 1.0f, 1.0f, 0.0f ); - -// gGL.begin(LLRender::TRIANGLES); - -// // joint top half -// glNormal3f(nc, nc, nc); -// gGL.vertex3f(0.0f, 0.0f, 0.05f); -// gGL.vertex3f(0.05f, 0.0f, 0.0f); -// gGL.vertex3f(0.0f, 0.05f, 0.0f); - -// glNormal3f(-nc, nc, nc); -// gGL.vertex3f(0.0f, 0.0f, 0.05f); -// gGL.vertex3f(0.0f, 0.05f, 0.0f); -// gGL.vertex3f(-0.05f, 0.0f, 0.0f); - -// glNormal3f(-nc, -nc, nc); -// gGL.vertex3f(0.0f, 0.0f, 0.05f); -// gGL.vertex3f(-0.05f, 0.0f, 0.0f); -// gGL.vertex3f(0.0f, -0.05f, 0.0f); - -// glNormal3f(nc, -nc, nc); -// gGL.vertex3f(0.0f, 0.0f, 0.05f); -// gGL.vertex3f(0.0f, -0.05f, 0.0f); -// gGL.vertex3f(0.05f, 0.0f, 0.0f); - -// // joint bottom half -// glNormal3f(nc, nc, -nc); -// gGL.vertex3f(0.0f, 0.0f, -0.05f); -// gGL.vertex3f(0.0f, 0.05f, 0.0f); -// gGL.vertex3f(0.05f, 0.0f, 0.0f); - -// glNormal3f(-nc, nc, -nc); -// gGL.vertex3f(0.0f, 0.0f, -0.05f); -// gGL.vertex3f(-0.05f, 0.0f, 0.0f); -// gGL.vertex3f(0.0f, 0.05f, 0.0f); - -// glNormal3f(-nc, -nc, -nc); -// gGL.vertex3f(0.0f, 0.0f, -0.05f); -// gGL.vertex3f(0.0f, -0.05f, 0.0f); -// gGL.vertex3f(-0.05f, 0.0f, 0.0f); - -// glNormal3f(nc, -nc, -nc); -// gGL.vertex3f(0.0f, 0.0f, -0.05f); -// gGL.vertex3f(0.05f, 0.0f, 0.0f); -// gGL.vertex3f(0.0f, -0.05f, 0.0f); - -// gGL.end(); -// } - -// //---------------------------------------------------------------- -// // render children -// //---------------------------------------------------------------- -// if (recursive) -// { -// for (child_list_t::iterator iter = mChildren.begin(); -// iter != mChildren.end(); ++iter) -// { -// LLViewerJoint* joint = (LLViewerJoint*)(*iter); -// joint->renderSkeleton(); -// } -// } - -// //---------------------------------------------------------------- -// // pop matrix stack -// //---------------------------------------------------------------- -// gGL.popMatrix(); -// } - - //-------------------------------------------------------------------- // render() //-------------------------------------------------------------------- @@ -317,13 +145,13 @@ U32 LLViewerJoint::render( F32 pixelArea, BOOL first_pass, BOOL is_dummy ) for (child_list_t::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { - LLViewerJoint* joint = (LLViewerJoint*)(*iter); + LLAvatarJoint* joint = dynamic_cast(*iter); F32 jointLOD = joint->getLOD(); if (pixelArea >= jointLOD || sDisableLOD) { triangle_count += joint->render( pixelArea, TRUE, is_dummy ); - if (jointLOD != DEFAULT_LOD) + if (jointLOD != DEFAULT_AVATAR_JOINT_LOD) { break; } @@ -333,72 +161,6 @@ U32 LLViewerJoint::render( F32 pixelArea, BOOL first_pass, BOOL is_dummy ) return triangle_count; } - -//-------------------------------------------------------------------- -// drawBone() -// DEBUG (UNUSED) -//-------------------------------------------------------------------- -// void LLViewerJoint::drawBone() -// { -// if ( mParent == NULL ) -// return; - -// F32 boneSize = 0.02f; - -// // rotate to point to child (bone direction) -// gGL.pushMatrix(); - -// LLVector3 boneX = getPosition(); -// F32 length = boneX.normVec(); - -// LLVector3 boneZ(1.0f, 0.0f, 1.0f); - -// LLVector3 boneY = boneZ % boneX; -// boneY.normVec(); - -// boneZ = boneX % boneY; - -// LLMatrix4 rotateMat; -// rotateMat.setFwdRow( boneX ); -// rotateMat.setLeftRow( boneY ); -// rotateMat.setUpRow( boneZ ); -// gGL.multMatrix( &rotateMat.mMatrix[0][0] ); - -// // render the bone -// gGL.color3f( 0.5f, 0.5f, 0.0f ); - -// gGL.begin(LLRender::TRIANGLES); - -// gGL.vertex3f( length, 0.0f, 0.0f); -// gGL.vertex3f( 0.0f, boneSize, 0.0f); -// gGL.vertex3f( 0.0f, 0.0f, boneSize); - -// gGL.vertex3f( length, 0.0f, 0.0f); -// gGL.vertex3f( 0.0f, 0.0f, -boneSize); -// gGL.vertex3f( 0.0f, boneSize, 0.0f); - -// gGL.vertex3f( length, 0.0f, 0.0f); -// gGL.vertex3f( 0.0f, -boneSize, 0.0f); -// gGL.vertex3f( 0.0f, 0.0f, -boneSize); - -// gGL.vertex3f( length, 0.0f, 0.0f); -// gGL.vertex3f( 0.0f, 0.0f, boneSize); -// gGL.vertex3f( 0.0f, -boneSize, 0.0f); - -// gGL.end(); - -// // restore matrix -// gGL.popMatrix(); -// } - -//-------------------------------------------------------------------- -// isTransparent() -//-------------------------------------------------------------------- -BOOL LLViewerJoint::isTransparent() -{ - return FALSE; -} - //-------------------------------------------------------------------- // drawShape() //-------------------------------------------------------------------- @@ -407,213 +169,4 @@ U32 LLViewerJoint::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy ) return 0; } -//-------------------------------------------------------------------- -// setSkeletonComponents() -//-------------------------------------------------------------------- -void LLViewerJoint::setSkeletonComponents( U32 comp, BOOL recursive ) -{ - mComponents = comp; - if (recursive) - { - for (child_list_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) - { - LLViewerJoint* joint = (LLViewerJoint*)(*iter); - joint->setSkeletonComponents(comp, recursive); - } - } -} - -void LLViewerJoint::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area) -{ - for (child_list_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) - { - LLViewerJoint* joint = (LLViewerJoint*)(*iter); - joint->updateFaceSizes(num_vertices, num_indices, pixel_area); - } -} - -void LLViewerJoint::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update) -{ - for (child_list_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) - { - LLViewerJoint* joint = (LLViewerJoint*)(*iter); - joint->updateFaceData(face, pixel_area, damp_wind, terse_update); - } -} - -void LLViewerJoint::updateJointGeometry() -{ - for (child_list_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) - { - LLViewerJoint* joint = (LLViewerJoint*)(*iter); - joint->updateJointGeometry(); - } -} - - -BOOL LLViewerJoint::updateLOD(F32 pixel_area, BOOL activate) -{ - BOOL lod_changed = FALSE; - BOOL found_lod = FALSE; - - for (child_list_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) - { - LLViewerJoint* joint = (LLViewerJoint*)(*iter); - F32 jointLOD = joint->getLOD(); - - if (found_lod || jointLOD == DEFAULT_LOD) - { - // we've already found a joint to enable, so enable the rest as alternatives - lod_changed |= joint->updateLOD(pixel_area, TRUE); - } - else - { - if (pixel_area >= jointLOD || sDisableLOD) - { - lod_changed |= joint->updateLOD(pixel_area, TRUE); - found_lod = TRUE; - } - else - { - lod_changed |= joint->updateLOD(pixel_area, FALSE); - } - } - } - return lod_changed; -} - -void LLViewerJoint::dump() -{ - for (child_list_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) - { - LLViewerJoint* joint = (LLViewerJoint*)(*iter); - joint->dump(); - } -} - -void LLViewerJoint::setVisible(BOOL visible, BOOL recursive) -{ - mVisible = visible; - - if (recursive) - { - for (child_list_t::iterator iter = mChildren.begin(); - iter != mChildren.end(); ++iter) - { - LLViewerJoint* joint = (LLViewerJoint*)(*iter); - joint->setVisible(visible, recursive); - } - } -} - - -void LLViewerJoint::setMeshesToChildren() -{ - removeAllChildren(); - for (std::vector::iterator iter = mMeshParts.begin(); - iter != mMeshParts.end(); iter++) - { - addChild((LLViewerJointMesh *) *iter); - } -} -//----------------------------------------------------------------------------- -// LLViewerJointCollisionVolume() -//----------------------------------------------------------------------------- - -LLViewerJointCollisionVolume::LLViewerJointCollisionVolume() -{ - mUpdateXform = FALSE; -} - -LLViewerJointCollisionVolume::LLViewerJointCollisionVolume(const std::string &name, LLJoint *parent) : LLViewerJoint(name, parent) -{ - -} - -void LLViewerJointCollisionVolume::renderCollision() -{ - updateWorldMatrix(); - - gGL.pushMatrix(); - gGL.multMatrix( &mXform.getWorldMatrix().mMatrix[0][0] ); - - gGL.diffuseColor3f( 0.f, 0.f, 1.f ); - - gGL.begin(LLRender::LINES); - - LLVector3 v[] = - { - LLVector3(1,0,0), - LLVector3(-1,0,0), - LLVector3(0,1,0), - LLVector3(0,-1,0), - - LLVector3(0,0,-1), - LLVector3(0,0,1), - }; - - //sides - gGL.vertex3fv(v[0].mV); - gGL.vertex3fv(v[2].mV); - - gGL.vertex3fv(v[0].mV); - gGL.vertex3fv(v[3].mV); - - gGL.vertex3fv(v[1].mV); - gGL.vertex3fv(v[2].mV); - - gGL.vertex3fv(v[1].mV); - gGL.vertex3fv(v[3].mV); - - - //top - gGL.vertex3fv(v[0].mV); - gGL.vertex3fv(v[4].mV); - - gGL.vertex3fv(v[1].mV); - gGL.vertex3fv(v[4].mV); - - gGL.vertex3fv(v[2].mV); - gGL.vertex3fv(v[4].mV); - - gGL.vertex3fv(v[3].mV); - gGL.vertex3fv(v[4].mV); - - - //bottom - gGL.vertex3fv(v[0].mV); - gGL.vertex3fv(v[5].mV); - - gGL.vertex3fv(v[1].mV); - gGL.vertex3fv(v[5].mV); - - gGL.vertex3fv(v[2].mV); - gGL.vertex3fv(v[5].mV); - - gGL.vertex3fv(v[3].mV); - gGL.vertex3fv(v[5].mV); - - gGL.end(); - - gGL.popMatrix(); -} - -LLVector3 LLViewerJointCollisionVolume::getVolumePos(LLVector3 &offset) -{ - mUpdateXform = TRUE; - - LLVector3 result = offset; - result.scaleVec(getScale()); - result.rotVec(getWorldRotation()); - result += getWorldPosition(); - - return result; -} - // End diff --git a/indra/newview/llviewerjoint.h b/indra/newview/llviewerjoint.h index 5750c81b4..fd262b6e8 100644 --- a/indra/newview/llviewerjoint.h +++ b/indra/newview/llviewerjoint.h @@ -30,10 +30,8 @@ //----------------------------------------------------------------------------- // Header Files //----------------------------------------------------------------------------- -#include "lljoint.h" #include "llavatarjoint.h" #include "lljointpickname.h" -#include "llavatarjoint.h" class LLFace; class LLViewerJointMesh; @@ -42,111 +40,25 @@ class LLViewerJointMesh; // class LLViewerJoint //----------------------------------------------------------------------------- class LLViewerJoint : - public LLAvatarJoint + public virtual LLAvatarJoint { 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(); - // Gets the validity of this joint - BOOL getValid() { return mValid; } - - // Sets the validity of this joint - virtual void setValid( BOOL valid, BOOL recursive=FALSE ); - - // Primarily for debugging and character setup - // Derived classes may add text/graphic output. - // Draw skeleton graphic for debugging and character setup - void renderSkeleton(BOOL recursive=TRUE); // debug only (unused) - - // Draws a bone graphic to the parent joint. - // Derived classes may add text/graphic output. - // Called by renderSkeleton(). - void drawBone(); // debug only (unused) - // Render character hierarchy. // Traverses the entire joint hierarchy, setting up // transforms and calling the drawShape(). // Derived classes may add text/graphic output. virtual U32 render( F32 pixelArea, BOOL first_pass = TRUE, BOOL is_dummy = FALSE ); // Returns triangle count - // Returns true if this object is transparent. - // This is used to determine in which order to draw objects. - virtual BOOL isTransparent(); - - // Returns true if this object should inherit scale modifiers from its immediate parent - virtual BOOL inheritScale() { return FALSE; } - // Draws the shape attached to a joint. // Called by render(). virtual U32 drawShape( F32 pixelArea, BOOL first_pass = TRUE, BOOL is_dummy = FALSE ); virtual void drawNormals() {} - - enum Components - { - SC_BONE = 1, - SC_JOINT = 2, - SC_AXES = 4 - }; - - // Selects which skeleton components to draw - void setSkeletonComponents( U32 comp, BOOL recursive = TRUE ); - - // Returns which skeleton components are enables for drawing - U32 getSkeletonComponents() { return mComponents; } - - // Sets the level of detail for this node as a minimum - // pixel area threshold. If the current pixel area for this - // object is less than the specified threshold, the node is - // not traversed. In addition, if a value is specified (not - // default of 0.0), and the pixel area is larger than the - // specified minimum, the node is rendered, but no other siblings - // of this node under the same parent will be. - F32 getLOD() { return mMinPixelArea; } - void setLOD( F32 pixelArea ) { mMinPixelArea = pixelArea; } - - void setPickName(LLJointPickName name) { mPickName = name; } - LLJointPickName getPickName() { return mPickName; } - - virtual void updateFaceSizes(U32 &num_vertices, U32& num_indices, F32 pixel_area); - virtual void updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind = FALSE, bool terse_update = false); - virtual BOOL updateLOD(F32 pixel_area, BOOL activate); - virtual void updateJointGeometry(); - virtual void dump(); - - void setVisible( BOOL visible, BOOL recursive ); - - // Takes meshes in mMeshParts and sets each one as a child joint - void setMeshesToChildren(); - -public: - static BOOL sDisableLOD; - avatar_joint_mesh_list_t mMeshParts; - void setMeshID( S32 id ) {mMeshID = id;} - -protected: - void init(); - - BOOL mValid; - U32 mComponents; - F32 mMinPixelArea; - LLJointPickName mPickName; - BOOL mVisible; - S32 mMeshID; -}; - -class LLViewerJointCollisionVolume : public LLAvatarJointCollisionVolume -{ -public: - LLViewerJointCollisionVolume(); - LLViewerJointCollisionVolume(const std::string &name, LLJoint *parent = NULL) {} - virtual ~LLViewerJointCollisionVolume() {}; - - virtual BOOL inheritScale() { return TRUE; } - - virtual void renderCollision(); - virtual LLVector3 getVolumePos(LLVector3 &offset); }; #endif // LL_LLVIEWERJOINT_H diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 48661cd54..8215fc74b 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -110,7 +110,7 @@ BOOL LLSkinJoint::setupSkinJoint( LLViewerJoint *joint) while (joint) { rootSkinOffset += joint->getSkinOffset(); - joint = (LLViewerJoint*)joint->getParent(); + joint = dynamic_cast(joint->getParent()); } mRootToJointSkinOffset = -rootSkinOffset; @@ -302,7 +302,7 @@ void LLViewerJointMesh::setMesh( LLPolyMesh *mesh ) for (jn = 0; jn < numJointNames; jn++) { //llinfos << "Setting up joint " << jointNames[jn] << llendl; - LLViewerJoint* joint = (LLViewerJoint*)(getRoot()->findJoint(jointNames[jn]) ); + LLViewerJoint* joint = dynamic_cast(getRoot()->findJoint(jointNames[jn]) ); mSkinJoints[jn].setupSkinJoint( joint ); } } @@ -310,7 +310,7 @@ void LLViewerJointMesh::setMesh( LLPolyMesh *mesh ) // setup joint array if (!mMesh->isLOD()) { - setupJoint((LLViewerJoint*)getRoot()); + setupJoint(dynamic_cast(getRoot())); } // llinfos << "joint render entries: " << mMesh->mJointRenderData.count() << llendl; @@ -361,7 +361,7 @@ void LLViewerJointMesh::setupJoint(LLViewerJoint* current_joint) for (LLJoint::child_list_t::iterator iter = current_joint->mChildren.begin(); iter != current_joint->mChildren.end(); ++iter) { - LLViewerJoint* child_joint = (LLViewerJoint*)(*iter); + LLViewerJoint* child_joint = dynamic_cast(*iter); setupJoint(child_joint); } } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 1807fa13c..b0024dbf5 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1084,7 +1084,6 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mIsBuilt = FALSE; mNumJoints = 0; - mSkeleton = NULL; mNumCollisionVolumes = 0; mCollisionVolumes = NULL; @@ -1179,7 +1178,9 @@ LLVOAvatar::~LLVOAvatar() mRoot.removeAllChildren(); mJointMap.clear(); - deleteAndClearArray(mSkeleton); + std::for_each(mSkeleton.begin(), mSkeleton.end(), DeletePointer()); + mSkeleton.clear(); + deleteAndClearArray(mCollisionVolumes); mNumJoints = 0; @@ -1207,11 +1208,11 @@ LLVOAvatar::~LLVOAvatar() std::for_each(mMeshes.begin(), mMeshes.end(), DeletePairedPointer()); mMeshes.clear(); - for (std::vector::iterator jointIter = mMeshLOD.begin(); + for (avatar_joint_list_t::iterator jointIter = mMeshLOD.begin(); jointIter != mMeshLOD.end(); ++jointIter) { - LLViewerJoint* joint = (LLViewerJoint *) *jointIter; + LLViewerJoint* joint = dynamic_cast(*jointIter); std::for_each(joint->mMeshParts.begin(), joint->mMeshParts.end(), DeletePointer()); joint->mMeshParts.clear(); } @@ -1274,7 +1275,7 @@ BOOL LLVOAvatar::isFullyTextured() const avatar_joint_mesh_list_t::iterator meshIter = joint->mMeshParts.begin(); if (meshIter != joint->mMeshParts.end()) { - LLViewerJointMesh *mesh = (LLViewerJointMesh *) *meshIter; + LLViewerJointMesh *mesh = (LLViewerJointMesh*)*meshIter; if (!mesh) { continue; // nonexistent mesh OK @@ -2191,7 +2192,7 @@ BOOL LLVOAvatar::setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent if (info->mIsJoint) { - joint = (LLViewerJoint*)getCharacterJoint(joint_num); + joint = dynamic_cast(getCharacterJoint(joint_num)); if (!joint) { llwarns << "Too many bones" << llendl; @@ -2390,24 +2391,24 @@ void LLVOAvatar::buildCharacter() //------------------------------------------------------------------------- // initialize "well known" joint pointers //------------------------------------------------------------------------- - mPelvisp = (LLViewerJoint*)mRoot.findJoint("mPelvis"); - mTorsop = (LLViewerJoint*)mRoot.findJoint("mTorso"); - mChestp = (LLViewerJoint*)mRoot.findJoint("mChest"); - mNeckp = (LLViewerJoint*)mRoot.findJoint("mNeck"); - mHeadp = (LLViewerJoint*)mRoot.findJoint("mHead"); - mSkullp = (LLViewerJoint*)mRoot.findJoint("mSkull"); - mHipLeftp = (LLViewerJoint*)mRoot.findJoint("mHipLeft"); - mHipRightp = (LLViewerJoint*)mRoot.findJoint("mHipRight"); - mKneeLeftp = (LLViewerJoint*)mRoot.findJoint("mKneeLeft"); - mKneeRightp = (LLViewerJoint*)mRoot.findJoint("mKneeRight"); - mAnkleLeftp = (LLViewerJoint*)mRoot.findJoint("mAnkleLeft"); - mAnkleRightp = (LLViewerJoint*)mRoot.findJoint("mAnkleRight"); - mFootLeftp = (LLViewerJoint*)mRoot.findJoint("mFootLeft"); - mFootRightp = (LLViewerJoint*)mRoot.findJoint("mFootRight"); - mWristLeftp = (LLViewerJoint*)mRoot.findJoint("mWristLeft"); - mWristRightp = (LLViewerJoint*)mRoot.findJoint("mWristRight"); - mEyeLeftp = (LLViewerJoint*)mRoot.findJoint("mEyeLeft"); - mEyeRightp = (LLViewerJoint*)mRoot.findJoint("mEyeRight"); + mPelvisp = mRoot.findJoint("mPelvis"); + mTorsop = mRoot.findJoint("mTorso"); + mChestp = mRoot.findJoint("mChest"); + mNeckp = mRoot.findJoint("mNeck"); + mHeadp = mRoot.findJoint("mHead"); + mSkullp = mRoot.findJoint("mSkull"); + mHipLeftp = mRoot.findJoint("mHipLeft"); + mHipRightp = mRoot.findJoint("mHipRight"); + mKneeLeftp = mRoot.findJoint("mKneeLeft"); + mKneeRightp = mRoot.findJoint("mKneeRight"); + mAnkleLeftp = mRoot.findJoint("mAnkleLeft"); + mAnkleRightp = mRoot.findJoint("mAnkleRight"); + mFootLeftp = mRoot.findJoint("mFootLeft"); + mFootRightp = mRoot.findJoint("mFootRight"); + mWristLeftp = mRoot.findJoint("mWristLeft"); + mWristRightp = mRoot.findJoint("mWristRight"); + mEyeLeftp = mRoot.findJoint("mEyeLeft"); + mEyeRightp = mRoot.findJoint("mEyeRight"); //------------------------------------------------------------------------- // Make sure "well known" pointers exist @@ -5915,19 +5916,6 @@ LLJoint *LLVOAvatar::getJoint( const std::string &name ) return jointp; } -//----------------------------------------------------------------------------- -// resetJointPositions -//----------------------------------------------------------------------------- -void LLVOAvatar::resetJointPositions( void ) -{ - for(S32 i = 0; i < (S32)mNumJoints; ++i) - { - mSkeleton[i].restoreOldXform(); - mSkeleton[i].setId( LLUUID::null ); - } - mHasPelvisOffset = false; - mPelvisFixup = mLastPelvisFixup; -} //----------------------------------------------------------------------------- // resetSpecificJointPosition //----------------------------------------------------------------------------- @@ -6102,17 +6090,17 @@ LLVector3 LLVOAvatar::getPosAgentFromGlobal(const LLVector3d &position) //----------------------------------------------------------------------------- BOOL LLVOAvatar::allocateCharacterJoints( U32 num ) { - deleteAndClearArray(mSkeleton); + std::for_each(mSkeleton.begin(), mSkeleton.end(), DeletePointer()); + mSkeleton.clear(); mNumJoints = 0; - mSkeleton = new LLViewerJoint[num]; - for(S32 joint_num = 0; joint_num < (S32)num; joint_num++) { - mSkeleton[joint_num].setJointNum(joint_num); + mSkeleton.push_back(new LLViewerJoint(joint_num)); } - if (!mSkeleton) + + if (mSkeleton.empty() || !mSkeleton[0]) { return FALSE; } @@ -6129,7 +6117,7 @@ BOOL LLVOAvatar::allocateCollisionVolumes( U32 num ) deleteAndClearArray(mCollisionVolumes); mNumCollisionVolumes = 0; - mCollisionVolumes = new LLViewerJointCollisionVolume[num]; + mCollisionVolumes = new LLAvatarJointCollisionVolume[num]; if (!mCollisionVolumes) { return FALSE; @@ -6307,13 +6295,13 @@ BOOL LLVOAvatar::loadAvatar() //----------------------------------------------------------------------------- BOOL LLVOAvatar::loadSkeletonNode () { - mRoot.addChild( &mSkeleton[0] ); + mRoot.addChild( mSkeleton[0] ); for (std::vector::iterator iter = mMeshLOD.begin(); iter != mMeshLOD.end(); ++iter) { - LLViewerJoint *joint = (LLViewerJoint *) *iter; + LLAvatarJoint *joint = *iter; joint->mUpdateXform = FALSE; joint->setMeshesToChildren(); } @@ -6325,19 +6313,19 @@ BOOL LLVOAvatar::loadSkeletonNode () mRoot.addChild(mMeshLOD[MESH_ID_SKIRT]); mRoot.addChild(mMeshLOD[MESH_ID_HEAD]); - LLViewerJoint *skull = (LLViewerJoint*)mRoot.findJoint("mSkull"); + LLAvatarJoint *skull = (LLAvatarJoint*)mRoot.findJoint("mSkull"); if (skull) { skull->addChild(mMeshLOD[MESH_ID_HAIR] ); } - LLViewerJoint *eyeL = (LLViewerJoint*)mRoot.findJoint("mEyeLeft"); + LLAvatarJoint *eyeL = (LLAvatarJoint*)mRoot.findJoint("mEyeLeft"); if (eyeL) { eyeL->addChild( mMeshLOD[MESH_ID_EYEBALL_LEFT] ); } - LLViewerJoint *eyeR = (LLViewerJoint*)mRoot.findJoint("mEyeRight"); + LLAvatarJoint *eyeR = (LLAvatarJoint*)mRoot.findJoint("mEyeRight"); if (eyeR) { eyeR->addChild( mMeshLOD[MESH_ID_EYEBALL_RIGHT] ); diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 7ecaf074e..a24d4dd51 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -241,7 +241,6 @@ public: virtual LLJoint* getJoint(const std::string &name); virtual LLJoint* getRootJoint() { return &mRoot; } - void resetJointPositions( void ); void resetJointPositionsToDefault( void ); void resetSpecificJointPosition( const std::string& name ); virtual const LLUUID& getID() const; @@ -400,9 +399,10 @@ public: BOOL setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent, S32 ¤t_volume_num, S32 ¤t_joint_num); virtual BOOL buildSkeleton(const LLAvatarSkeletonInfo *info); private: + typedef std::vector avatar_joint_list_t; BOOL mIsBuilt; // state of deferred character building S32 mNumJoints; - LLViewerJoint* mSkeleton; + avatar_joint_list_t mSkeleton; //-------------------------------------------------------------------- // Pelvis height adjustment members. @@ -417,24 +417,24 @@ private: // Cached pointers to well known joints //-------------------------------------------------------------------- public: - LLViewerJoint* mPelvisp; - LLViewerJoint* mTorsop; - LLViewerJoint* mChestp; - LLViewerJoint* mNeckp; - LLViewerJoint* mHeadp; - LLViewerJoint* mSkullp; - LLViewerJoint* mEyeLeftp; - LLViewerJoint* mEyeRightp; - LLViewerJoint* mHipLeftp; - LLViewerJoint* mHipRightp; - LLViewerJoint* mKneeLeftp; - LLViewerJoint* mKneeRightp; - LLViewerJoint* mAnkleLeftp; - LLViewerJoint* mAnkleRightp; - LLViewerJoint* mFootLeftp; - LLViewerJoint* mFootRightp; - LLViewerJoint* mWristLeftp; - LLViewerJoint* mWristRightp; + LLJoint* mPelvisp; + LLJoint* mTorsop; + LLJoint* mChestp; + LLJoint* mNeckp; + LLJoint* mHeadp; + LLJoint* mSkullp; + LLJoint* mEyeLeftp; + LLJoint* mEyeRightp; + LLJoint* mHipLeftp; + LLJoint* mHipRightp; + LLJoint* mKneeLeftp; + LLJoint* mKneeRightp; + LLJoint* mAnkleLeftp; + LLJoint* mAnkleRightp; + LLJoint* mFootLeftp; + LLJoint* mFootRightp; + LLJoint* mWristLeftp; + LLJoint* mWristRightp; //-------------------------------------------------------------------- // XML parse tree @@ -706,7 +706,7 @@ private: typedef std::multimap polymesh_map_t; polymesh_map_t mMeshes; - std::vector mMeshLOD; + avatar_joint_list_t mMeshLOD; //-------------------------------------------------------------------- // Destroy invisible mesh @@ -917,9 +917,9 @@ private: //-------------------------------------------------------------------- public: S32 mNumCollisionVolumes; - LLViewerJointCollisionVolume* mCollisionVolumes; + LLAvatarJointCollisionVolume* mCollisionVolumes; virtual S32 getNumCollisionVolumes() { return mNumCollisionVolumes; } - virtual LLAvatarJointCollisionVolume* getCollisionVolume(S32 i) { return (LLAvatarJointCollisionVolume*)&mCollisionVolumes[i]; } + virtual LLAvatarJointCollisionVolume* getCollisionVolume(S32 i) { return &mCollisionVolumes[i]; } protected: virtual BOOL allocateCollisionVolumes(U32 num); diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 89bfba65d..44b221edd 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -590,11 +590,6 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) } return LLVOAvatar::getJoint(name); } -//virtual -void LLVOAvatarSelf::resetJointPositions( void ) -{ - return LLVOAvatar::resetJointPositions(); -} // virtual BOOL LLVOAvatarSelf::setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake ) { diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index f5970c705..23346ccb2 100644 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -95,8 +95,6 @@ public: /*virtual*/ void requestStopMotion(LLMotion* motion); /*virtual*/ LLJoint* getJoint(const std::string &name); - void resetJointPositions( void ); - /*virtual*/ BOOL setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake = FALSE ); /*virtual*/ BOOL setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake = FALSE ); /*virtual*/ BOOL setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake = FALSE );