diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfloatermodelpreview.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llvoavatar.cpp | 41 | ||||
-rw-r--r-- | indra/newview/llvoavatar.h | 8 | ||||
-rw-r--r-- | indra/newview/llvoavatarself.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llvovolume.cpp | 24 |
5 files changed, 75 insertions, 12 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 73707ad2f1..1c73a6cb31 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -1487,6 +1487,14 @@ void LLModelLoader::run() //Most likely an error in the asset. llwarns<<"Tried to apply joint position from .dae, but it did not exist in the avatar rig." << llendl; } + //Reposition the avatars pelvis (avPos+offset) + //if ( !strcmp( (*jointIt).first.c_str(),"mPelvis" ) )
+ if ( lookingForJoint == "mPelvis" )
+ {
+ const LLVector3& pos = gAgentAvatarp->getCharacterPosition();
+ gAgentAvatarp->setPelvisOffset( true, jointTransform.getTranslation() );
+ gAgentAvatarp->setPosition( pos + jointTransform.getTranslation() );
+ } } } } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 46c0fdf03e..b6d1d2443d 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -682,7 +682,8 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mPreviousFullyLoaded(FALSE), mFullyLoadedInitialized(FALSE), mSupportsAlphaLayers(FALSE), - mLoadedCallbacksPaused(FALSE) + mLoadedCallbacksPaused(FALSE), + mHasPelvisOffset( FALSE ) { LLMemType mt(LLMemType::MTYPE_AVATAR); //VTResume(); // VTune @@ -758,6 +759,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id, mRuthTimer.reset(); mRuthDebugTimer.reset(); mDebugExistenceTimer.reset(); + mPelvisOffset = LLVector3(0.0f,0.0f,0.0f); } //------------------------------------------------------------------------ @@ -3449,8 +3451,15 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) LLVector3d ground_under_pelvis; if (isSelf()) - { - gAgent.setPositionAgent(getRenderPosition()); + {
+ if ( !mHasPelvisOffset )
+ {
+ gAgent.setPositionAgent(getRenderPosition());
+ }
+ else
+ {
+ gAgent.setPositionAgent( getRenderPosition() + mPelvisOffset );
+ } } root_pos = gAgent.getPosGlobalFromAgent(getRenderPosition()); @@ -3475,8 +3484,16 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent) if (newPosition != mRoot.getXform()->getWorldPosition()) { - mRoot.touch(); - mRoot.setWorldPosition(newPosition ); // regular update + if ( !mHasPelvisOffset )
+ {
+ mRoot.touch();
+ mRoot.setWorldPosition( newPosition ); // regular update
+ }
+ else
+ {
+ mRoot.touch();
+ mRoot.setWorldPosition( newPosition + mPelvisOffset );
+ } } @@ -3777,6 +3794,17 @@ void LLVOAvatar::updateHeadOffset() mHeadOffset = lerp(midEyePt, mHeadOffset, u); } } +//------------------------------------------------------------------------ +// setPelvisOffset +//------------------------------------------------------------------------ +void LLVOAvatar::setPelvisOffset( bool hasOffset, const LLVector3& offsetAmount )
+{
+ mHasPelvisOffset = hasOffset;
+ if ( mHasPelvisOffset )
+ {
+ mPelvisOffset = offsetAmount;
+ }
+}
//------------------------------------------------------------------------ // updateVisibility() @@ -4915,6 +4943,7 @@ void LLVOAvatar::resetJointPositions( void ) { mSkeleton[i].restoreOldXform(); } + mHasPelvisOffset = false; } //----------------------------------------------------------------------------- // resetJointPositionsToDefault @@ -4945,6 +4974,8 @@ void LLVOAvatar::resetJointPositionsToDefault( void ) pJoint->restoreToDefaultXform(); } } + //make sure we don't apply the joint offset + mHasPelvisOffset = false; } diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index a9518d22ef..fdf44c6e70 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -282,7 +282,13 @@ protected: public: void updateHeadOffset(); - F32 getPelvisToFoot() const { return mPelvisToFoot; } + F32 getPelvisToFoot() const { return mPelvisToFoot; }
+ void setPelvisOffset( bool hasOffset, const LLVector3& translation ) ;
+ bool hasPelvisOffset( void ) { return mHasPelvisOffset; }
+
+ bool mHasPelvisOffset;
+ LLVector3 mPelvisOffset;
+ LLVector3 mHeadOffset; // current head position LLViewerJoint mRoot; diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 30c8f5b28a..0993c55706 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -1130,7 +1130,11 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) const LLMeshSkinInfo* pSkinData = gMeshRepo.getSkinInfo( pVObj->getVolume()->getParams().getSculptID() ); if ( pSkinData ) { - resetJointPositions(); + const int bindCnt = pSkinData->mAlternateBindMatrix.size(); + if ( bindCnt > 0 ) + { + resetJointPositions(); + } } } } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index e7e2830f25..0b2adc70d9 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -74,7 +74,6 @@ #include "llviewermediafocus.h" #include "llvoavatar.h" - const S32 MIN_QUIET_FRAMES_COALESCE = 30; const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; const F32 FORCE_CULL_AREA = 8.f; @@ -4053,23 +4052,38 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) //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. - const LLVOAvatar* pAvatarVO = vobj->getAvatar(); + LLVOAvatar* pAvatarVO = vobj->getAvatar(); if ( pAvatarVO ) { const LLMeshSkinInfo* pSkinData = gMeshRepo.getSkinInfo( vobj->getVolume()->getParams().getSculptID() ); + if ( pSkinData ) { - const int bindCnt = pSkinData->mAlternateBindMatrix.size(); + const int bindCnt = pSkinData->mAlternateBindMatrix.size(); if ( bindCnt > 0 ) { const int jointCnt = pSkinData->mJointNames.size(); for ( int i=0; i<jointCnt; ++i ) { std::string lookingForJoint = pSkinData->mJointNames[i].c_str(); - LLJoint* pJoint = vobj->getAvatar()->getJoint( lookingForJoint ); + LLJoint* pJoint = pAvatarVO->getJoint( lookingForJoint ); if ( pJoint ) { - pJoint->storeCurrentXform( pSkinData->mAlternateBindMatrix[i].getTranslation() ); + const LLVector3& jointPos = pSkinData->mAlternateBindMatrix[i].getTranslation(); + pJoint->storeCurrentXform( jointPos ); + //If joint is a pelvis then handle by setting avPos+offset + //if ( !strcmp( lookingForJoint.c_str(),"mPelvis" ) )
+ if ( lookingForJoint == "mPelvis" )
+ {
+ //Apply av pos + offset
+ if ( !pAvatarVO->hasPelvisOffset() )
+ {
+ pAvatarVO->setPelvisOffset( true, jointPos );
+ pAvatarVO->setPosition( pAvatarVO->getCharacterPosition() + jointPos );
+ }
+ } + + } } } |