diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llappearance/llpolyskeletaldistortion.cpp | 12 | ||||
-rwxr-xr-x | indra/llcharacter/lljoint.cpp | 43 | ||||
-rwxr-xr-x | indra/llcharacter/lljoint.h | 7 | ||||
-rwxr-xr-x | indra/newview/llvoavatar.cpp | 74 | ||||
-rwxr-xr-x | indra/newview/llvoavatar.h | 1 | ||||
-rwxr-xr-x | indra/newview/llvoavatarself.cpp | 5 | ||||
-rwxr-xr-x | indra/newview/llvovolume.cpp | 51 |
7 files changed, 89 insertions, 104 deletions
diff --git a/indra/llappearance/llpolyskeletaldistortion.cpp b/indra/llappearance/llpolyskeletaldistortion.cpp index 4ba16691c2..eb86f77d97 100644 --- a/indra/llappearance/llpolyskeletaldistortion.cpp +++ b/indra/llappearance/llpolyskeletaldistortion.cpp @@ -192,7 +192,7 @@ void LLPolySkeletalDistortion::apply( ESex avatar_sex ) { LLFastTimer t(FTM_POLYSKELETAL_DISTORTION_APPLY); - F32 effective_weight = ( getSex() & avatar_sex ) ? mCurWeight : getDefaultWeight(); + F32 effective_weight = ( getSex() & avatar_sex ) ? mCurWeight : getDefaultWeight(); LLJoint* joint; joint_vec_map_t::iterator iter; @@ -204,8 +204,10 @@ void LLPolySkeletalDistortion::apply( ESex avatar_sex ) joint = iter->first; LLVector3 newScale = joint->getScale(); LLVector3 scaleDelta = iter->second; - newScale = newScale + (effective_weight * scaleDelta) - (mLastWeight * scaleDelta); - joint->setScale(newScale); + newScale = newScale + (effective_weight * scaleDelta) - (mLastWeight * scaleDelta); + //An aspect of attached mesh objects (which contain joint offsets) that need to be cleaned up when detached + joint->storeScaleForReset( newScale ); + joint->setScale(newScale); } for (iter = mJointOffsets.begin(); @@ -214,8 +216,8 @@ void LLPolySkeletalDistortion::apply( ESex avatar_sex ) { joint = iter->first; LLVector3 newPosition = joint->getPosition(); - LLVector3 positionDelta = iter->second; - newPosition = newPosition + (effective_weight * positionDelta) - (mLastWeight * positionDelta); + LLVector3 positionDelta = iter->second; + newPosition = newPosition + (effective_weight * positionDelta) - (mLastWeight * positionDelta); joint->setPosition(newPosition); } diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 09a7c11a22..672d9faee4 100755 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -48,8 +48,11 @@ void LLJoint::init() mParent = NULL; mXform.setScaleChildOffset(TRUE); mXform.setScale(LLVector3(1.0f, 1.0f, 1.0f)); + mOldXform.setScaleChildOffset(TRUE); + mOldXform.setScale(LLVector3(1.0f, 1.0f, 1.0f)); mDirtyFlags = MATRIX_DIRTY | ROTATION_DIRTY | POSITION_DIRTY; mUpdateXform = TRUE; + mResetAfterRestoreOldXform = false; } LLJoint::LLJoint() : @@ -57,7 +60,6 @@ LLJoint::LLJoint() : { init(); touch(); - mResetAfterRestoreOldXform = false; } LLJoint::LLJoint(S32 joint_num) : @@ -65,7 +67,6 @@ LLJoint::LLJoint(S32 joint_num) : { init(); touch(); - mResetAfterRestoreOldXform = false; } @@ -78,7 +79,6 @@ LLJoint::LLJoint(const std::string &name, LLJoint *parent) : { init(); mUpdateXform = FALSE; - // *TODO: mResetAfterRestoreOldXform is not initialized!!! setName(name); if (parent) @@ -239,11 +239,8 @@ const LLVector3& LLJoint::getPosition() //-------------------------------------------------------------------- void LLJoint::setPosition( const LLVector3& pos ) { -// if (mXform.getPosition() != pos) - { - mXform.setPosition(pos); - touch(MATRIX_DIRTY | POSITION_DIRTY); - } + mXform.setPosition(pos); + touch(MATRIX_DIRTY | POSITION_DIRTY); } @@ -251,10 +248,9 @@ void LLJoint::setPosition( const LLVector3& pos ) // setPosition() //-------------------------------------------------------------------- void LLJoint::setDefaultFromCurrentXform( void ) -{ +{ mDefaultXform = mXform; - touch(MATRIX_DIRTY | POSITION_DIRTY); - + touch(ALL_DIRTY); } //-------------------------------------------------------------------- @@ -263,26 +259,29 @@ void LLJoint::setDefaultFromCurrentXform( void ) void LLJoint::storeCurrentXform( const LLVector3& pos ) { mOldXform = mXform; - mResetAfterRestoreOldXform = true; + mResetAfterRestoreOldXform = true; setPosition( pos ); + + touch(ALL_DIRTY); } + //-------------------------------------------------------------------- -// restoreOldXform() +// storeScaleForReset() //-------------------------------------------------------------------- -void LLJoint::restoreOldXform( void ) +void LLJoint::storeScaleForReset( const LLVector3& scale ) { - mResetAfterRestoreOldXform = false; - mXform = mOldXform; + mOldXform.setScale( scale ); } //-------------------------------------------------------------------- // restoreOldXform() //-------------------------------------------------------------------- -void LLJoint::restoreToDefaultXform( void ) +void LLJoint::restoreOldXform( void ) { - mXform = mDefaultXform; - setPosition( mXform.getPosition() ); + mXform = mOldXform; + mXform.setScaleChildOffset( mOldXform.getScaleChildOffset() ); + mResetAfterRestoreOldXform = false; + mDirtyFlags = ALL_DIRTY; } - //-------------------------------------------------------------------- // getWorldPosition() //-------------------------------------------------------------------- @@ -404,7 +403,7 @@ void LLJoint::setWorldRotation( const LLQuaternion& rot ) //-------------------------------------------------------------------- const LLVector3& LLJoint::getScale() { - return mXform.getScale(); + return mXform.getScale(); } //-------------------------------------------------------------------- @@ -413,7 +412,7 @@ const LLVector3& LLJoint::getScale() void LLJoint::setScale( const LLVector3& scale ) { // if (mXform.getScale() != scale) - { + { mXform.setScale(scale); touch(); } diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index 2b1e2005c6..aeb16f796a 100755 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -84,6 +84,7 @@ protected: LLXformMatrix mDefaultXform; LLUUID mId; + public: U32 mDirtyFlags; BOOL mUpdateXform; @@ -160,7 +161,7 @@ public: // get/set local scale const LLVector3& getScale(); void setScale( const LLVector3& scale ); - + void storeScaleForReset( const LLVector3& scale ); // get/set world matrix const LLMatrix4 &getWorldMatrix(); void setWorldMatrix( const LLMatrix4& mat ); @@ -185,7 +186,6 @@ public: S32 getJointNum() const { return mJointNum; } void restoreOldXform( void ); - void restoreToDefaultXform( void ); void setDefaultFromCurrentXform( void ); void storeCurrentXform( const LLVector3& pos ); @@ -196,8 +196,7 @@ public: //If the old transform flag has been set, then the reset logic in avatar needs to be aware(test) of it const BOOL doesJointNeedToBeReset( void ) const { return mResetAfterRestoreOldXform; } - //Setter for joint reset flag - void setJointToBeReset( BOOL val ) { mResetAfterRestoreOldXform = val; } + }; #endif // LL_LLJOINT_H diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 96afd2e15d..83b7ac9e75 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -106,7 +106,7 @@ extern F32 SPEED_ADJUST_MAX; extern F32 SPEED_ADJUST_MAX_SEC; extern F32 ANIM_SPEED_MAX; extern F32 ANIM_SPEED_MIN; - +extern U32 JOINT_COUNT_REQUIRED_FOR_FULLRIG; // #define OUTPUT_BREAST_DATA @@ -1234,6 +1234,7 @@ LLTexLayerSet* LLVOAvatar::createTexLayerSet() const LLVector3 LLVOAvatar::getRenderPosition() const { + if (mDrawable.isNull() || mDrawable->getGeneration() < 0) { return getPositionAgent(); @@ -1256,6 +1257,8 @@ const LLVector3 LLVOAvatar::getRenderPosition() const { return getPosition() * mDrawable->getParent()->getRenderMatrix(); } + + } void LLVOAvatar::updateDrawable(BOOL force_damped) @@ -2992,7 +2995,7 @@ bool LLVOAvatar::isVisuallyMuted() const // called on both your avatar and other avatars //------------------------------------------------------------------------ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) -{ +{ // clear debug text mDebugText.clear(); @@ -3540,9 +3543,9 @@ void LLVOAvatar::setPelvisOffset( bool hasOffset, const LLVector3& offsetAmount, { mHasPelvisOffset = hasOffset; if ( mHasPelvisOffset ) - { + { //Store off last pelvis to foot value - mLastPelvisToFoot = mPelvisToFoot; + mLastPelvisToFoot = mPelvisToFoot; mPelvisOffset = offsetAmount; mLastPelvisFixup = mPelvisFixup; mPelvisFixup = pelvisFixup; @@ -3552,18 +3555,16 @@ void LLVOAvatar::setPelvisOffset( bool hasOffset, const LLVector3& offsetAmount, // postPelvisSetRecalc //------------------------------------------------------------------------ void LLVOAvatar::postPelvisSetRecalc( void ) -{ - computeBodySize(); - mRoot->touch(); - mRoot->updateWorldMatrixChildren(); - dirtyMesh(); - updateHeadOffset(); +{ + mRoot->updateWorldMatrixChildren(); + computeBodySize(); + dirtyMesh(2); } //------------------------------------------------------------------------ -// pelisPoke +// setPelvisOffset //------------------------------------------------------------------------ void LLVOAvatar::setPelvisOffset( F32 pelvisFixupAmount ) -{ +{ mHasPelvisOffset = true; mLastPelvisFixup = mPelvisFixup; mPelvisFixup = pelvisFixupAmount; @@ -4925,22 +4926,6 @@ LLJoint *LLVOAvatar::getJoint( const std::string &name ) return jointp; } - -//----------------------------------------------------------------------------- -// resetJointPositions -//----------------------------------------------------------------------------- -void LLVOAvatar::resetJointPositions( void ) -{ - avatar_joint_list_t::iterator iter = mSkeleton.begin(); - avatar_joint_list_t::iterator end = mSkeleton.end(); - for (; iter != end; ++iter) - { - (*iter)->restoreOldXform(); - (*iter)->setId( LLUUID::null ); - } - mHasPelvisOffset = false; - mPelvisFixup = mLastPelvisFixup; -} //----------------------------------------------------------------------------- // resetSpecificJointPosition //----------------------------------------------------------------------------- @@ -4967,28 +4952,25 @@ void LLVOAvatar::resetSpecificJointPosition( const std::string& name ) // resetJointPositionsToDefault //----------------------------------------------------------------------------- void LLVOAvatar::resetJointPositionsToDefault( void ) -{ +{ //Subsequent joints are relative to pelvis avatar_joint_list_t::iterator iter = mSkeleton.begin(); avatar_joint_list_t::iterator end = mSkeleton.end(); for (; iter != end; ++iter) { LLJoint* pJoint = (*iter); - if ( pJoint->doesJointNeedToBeReset() ) - { + if ( pJoint && pJoint->doesJointNeedToBeReset() ) + { pJoint->setId( LLUUID::null ); - //restore joints to default positions, however skip over the pelvis - // *TODO: How does this pointer check skip over pelvis? - if ( pJoint ) - { - pJoint->restoreOldXform(); - } - } + pJoint->restoreOldXform(); + } } + //make sure we don't apply the joint offset mHasPelvisOffset = false; mPelvisFixup = mLastPelvisFixup; - postPelvisSetRecalc(); + + postPelvisSetRecalc(); } //----------------------------------------------------------------------------- // getCharacterPosition() @@ -5604,10 +5586,10 @@ void LLVOAvatar::cleanupAttachedMesh( LLViewerObject* pVO ) { const LLMeshSkinInfo* pSkinData = gMeshRepo.getSkinInfo( pVObj->getVolume()->getParams().getSculptID(), pVObj ); if (pSkinData - && pSkinData->mJointNames.size() > 20 // full rig - && pSkinData->mAlternateBindMatrix.size() > 0) - { - LLVOAvatar::resetJointPositionsToDefault(); + && pSkinData->mJointNames.size() > JOINT_COUNT_REQUIRED_FOR_FULLRIG // full rig + && pSkinData->mAlternateBindMatrix.size() > 0 ) + { + LLVOAvatar::resetJointPositionsToDefault(); //Need to handle the repositioning of the cam, updating rig data etc during outfit editing //This handles the case where we detach a replacement rig. if ( gAgentCamera.cameraCustomizeAvatar() ) @@ -5625,6 +5607,7 @@ void LLVOAvatar::cleanupAttachedMesh( LLViewerObject* pVO ) //----------------------------------------------------------------------------- BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object) { + for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); iter != mAttachmentPoints.end(); ++iter) @@ -5633,7 +5616,9 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object) if (attachment->isObjectAttached(viewer_object)) { + cleanupAttachedMesh( viewer_object ); + attachment->removeObject(viewer_object); lldebugs << "Detaching object " << viewer_object->mID << " from " << attachment->getName() << llendl; return TRUE; @@ -6942,7 +6927,7 @@ bool resolve_appearance_version(const LLAppearanceMessageContents& contents, S32 void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) { LL_DEBUGS("Avatar") << "starts" << llendl; - + bool enable_verbose_dumps = gSavedSettings.getBOOL("DebugAvatarAppearanceMessage"); std::string dump_prefix = getFullname() + "_" + (isSelf()?"s":"o") + "_"; if (gSavedSettings.getBOOL("BlockAvatarAppearanceMessages")) @@ -7153,7 +7138,6 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) } updateMeshTextures(); - //if (enable_verbose_dumps) dumpArchetypeXML(dump_prefix + "process_end"); } diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 48b5a6e873..90ade85177 100755 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -199,7 +199,6 @@ public: virtual LLJoint* getJoint(const std::string &name); - void resetJointPositions( void ); void resetJointPositionsToDefault( void ); void resetSpecificJointPosition( const std::string& name ); diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 05bd3101ea..a710c95233 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -671,11 +671,6 @@ LLJoint *LLVOAvatarSelf::getJoint(const std::string &name) } return LLVOAvatar::getJoint(name); } -//virtual -void LLVOAvatarSelf::resetJointPositions( void ) -{ - return LLVOAvatar::resetJointPositions(); -} // virtual BOOL LLVOAvatarSelf::setVisualParamWeight(const LLVisualParam *which_param, F32 weight, BOOL upload_bake ) { diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8730ef66bb..135c2e1eca 100755 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -81,7 +81,7 @@ const S32 MIN_QUIET_FRAMES_COALESCE = 30; const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; const F32 FORCE_CULL_AREA = 8.f; const F32 MAX_LOD_DISTANCE = 24.f; - +U32 JOINT_COUNT_REQUIRED_FOR_FULLRIG = 20; BOOL gAnimateTextures = TRUE; //extern BOOL gHideSelectedObjects; @@ -4236,6 +4236,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bool emissive = false; + //Determine if we've received skininfo that contains an + //alternate bind matrix - if it does then apply the translational component + //to the joints of the avatar. + bool pelvisGotSet = false; + { LLFastTimer t(FTM_REBUILD_VOLUME_FACE_LIST); @@ -4317,18 +4322,12 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) is_rigged = true; //get drawpool of avatar with rigged face - LLDrawPoolAvatar* pool = get_avatar_drawpool(vobj); - - //Determine if we've received skininfo that contains an - //alternate bind matrix - if it does then apply the translational component - //to the joints of the avatar. - bool pelvisGotSet = false; - + LLDrawPoolAvatar* pool = get_avatar_drawpool(vobj); + if ( pAvatarVO ) { - LLUUID currentId = vobj->getVolume()->getParams().getSculptID(); + LLUUID currentId = vobj->getVolume()->getParams().getSculptID(); const LLMeshSkinInfo* pSkinData = gMeshRepo.getSkinInfo( currentId, vobj ); - if ( pSkinData ) { const int bindCnt = pSkinData->mAlternateBindMatrix.size(); @@ -4336,43 +4335,42 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { const int jointCnt = pSkinData->mJointNames.size(); const F32 pelvisZOffset = pSkinData->mPelvisOffset; - bool fullRig = (jointCnt>=20) ? true : false; + bool fullRig = (jointCnt>=JOINT_COUNT_REQUIRED_FOR_FULLRIG) ? true : false; if ( fullRig ) - { + { for ( int i=0; i<jointCnt; ++i ) { std::string lookingForJoint = pSkinData->mJointNames[i].c_str(); - //llinfos<<"joint name "<<lookingForJoint.c_str()<<llendl; LLJoint* pJoint = pAvatarVO->getJoint( lookingForJoint ); if ( pJoint && pJoint->getId() != currentId ) { pJoint->setId( currentId ); const LLVector3& jointPos = pSkinData->mAlternateBindMatrix[i].getTranslation(); + //Set the joint position - pJoint->storeCurrentXform( jointPos ); + pJoint->storeCurrentXform( jointPos ); + //If joint is a pelvis then handle old/new pelvis to foot values if ( lookingForJoint == "mPelvis" ) { - pJoint->storeCurrentXform( jointPos ); if ( !pAvatarVO->hasPelvisOffset() ) { pAvatarVO->setPelvisOffset( true, jointPos, pelvisZOffset ); - //Trigger to rebuild viewer AV pelvisGotSet = true; } } - } - } + } + } } } } } - //If we've set the pelvis to a new position we need to also rebuild some information that the - //viewer does at launch (e.g. body size etc.) - if ( pelvisGotSet ) + + //Rebuild body data if we altered joints/pelvis + if ( pelvisGotSet && pAvatarVO ) { pAvatarVO->postPelvisSetRecalc(); - } + } if (pool) { @@ -4605,7 +4603,16 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { drawablep->clearState(LLDrawable::RIGGED); } + } + + + + + + + + } group->mBufferUsage = useage; |