- Pelvis offsets are now preserved

- Fix for CTS-261
meow-7.2.2
prep 2010-10-28 13:40:15 -04:00
parent 7863674626
commit 53d5fd1e9b
5 changed files with 75 additions and 12 deletions

View File

@ -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() );
}
}
}
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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();
}
}
}
}

View File

@ -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 );
}
}
}
}
}