summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llvoavatar.cpp58
-rw-r--r--indra/newview/llvoavatar.h3
-rw-r--r--indra/newview/llvovolume.cpp13
3 files changed, 39 insertions, 35 deletions
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index b1a5ea0fd6..439584c7e8 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -760,6 +760,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
mRuthDebugTimer.reset();
mDebugExistenceTimer.reset();
mPelvisOffset = LLVector3(0.0f,0.0f,0.0f);
+ mLastPelvisToFoot = 0.0f;
}
//------------------------------------------------------------------------
@@ -1331,7 +1332,20 @@ const LLVector3 LLVOAvatar::getRenderPosition() const
}
else if (isRoot())
{
- return mDrawable->getPositionAgent();
+ if ( mHasPelvisOffset )
+ {
+ LLVector3 returnVec( mDrawable->getPositionAgent() );
+ //1. Move the pelvis down by the old amount
+ returnVec[VZ] -= (mLastPelvisToFoot);
+ //2. Now move the pelvis up by the new amount
+ returnVec[VZ] += mPelvisToFoot;
+ //3. Return the fixed up pelvis position
+ return returnVec;
+ }
+ else
+ {
+ return mDrawable->getPositionAgent();
+ }
}
else
{
@@ -3454,20 +3468,13 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
if (isSelf())
{
- if ( !mHasPelvisOffset )
- {
- gAgent.setPositionAgent(getRenderPosition());
- }
- else
- {
- gAgent.setPositionAgent( getRenderPosition() + mPelvisOffset );
- }
+ gAgent.setPositionAgent(getRenderPosition());
}
root_pos = gAgent.getPosGlobalFromAgent(getRenderPosition());
resolveHeightGlobal(root_pos, ground_under_pelvis, normal);
- F32 foot_to_ground = (F32) (root_pos.mdV[VZ] - mPelvisToFoot - ground_under_pelvis.mdV[VZ]);
+ F32 foot_to_ground = (F32) (root_pos.mdV[VZ] - mPelvisToFoot - ground_under_pelvis.mdV[VZ]);
BOOL in_air = ((!LLWorld::getInstance()->getRegionFromPosGlobal(ground_under_pelvis)) ||
foot_to_ground > FOOT_GROUND_COLLISION_TOLERANCE);
@@ -3479,22 +3486,21 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
// correct for the fact that the pelvis is not necessarily the center
// of the agent's physical representation
- root_pos.mdV[VZ] -= (0.5f * mBodySize.mV[VZ]) - mPelvisToFoot;
-
+ if ( !mHasPelvisOffset )
+ {
+ root_pos.mdV[VZ] -= (0.5f * mBodySize.mV[VZ]) - mPelvisToFoot;
+ }
+ else
+ {
+ root_pos.mdV[VZ] -= (0.65f * mBodySize.mV[VZ]) - mPelvisToFoot;
+ }
+
LLVector3 newPosition = gAgent.getPosAgentFromGlobal(root_pos);
if (newPosition != mRoot.getXform()->getWorldPosition())
{
- if ( !mHasPelvisOffset )
- {
- mRoot.touch();
- mRoot.setWorldPosition( newPosition ); // regular update
- }
- else
- {
- mRoot.touch();
- mRoot.setWorldPosition( newPosition + mPelvisOffset );
- }
+ mRoot.touch();
+ mRoot.setWorldPosition( newPosition ); // regular update
}
@@ -3770,7 +3776,6 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
return TRUE;
}
-
//-----------------------------------------------------------------------------
// updateHeadOffset()
//-----------------------------------------------------------------------------
@@ -3803,6 +3808,7 @@ void LLVOAvatar::setPelvisOffset( bool hasOffset, const LLVector3& offsetAmount
mHasPelvisOffset = hasOffset;
if ( mHasPelvisOffset )
{
+ mLastPelvisToFoot = mPelvisToFoot;
mPelvisOffset = offsetAmount;
}
}
@@ -3810,9 +3816,10 @@ void LLVOAvatar::setPelvisOffset( bool hasOffset, const LLVector3& offsetAmount
// postPelvisSetRecalc
//------------------------------------------------------------------------
void LLVOAvatar::postPelvisSetRecalc( void )
-{
+{
computeBodySize();
- mRoot.updateWorldMatrixChildren();
+ mRoot.touch();
+ mRoot.updateWorldMatrixChildren();
dirtyMesh();
updateHeadOffset();
}
@@ -4543,7 +4550,6 @@ void LLVOAvatar::resolveRayCollisionAgent(const LLVector3d start_pt, const LLVec
LLWorld::getInstance()->resolveStepHeightGlobal(this, start_pt, end_pt, out_pos, out_norm, &obj);
}
-
void LLVOAvatar::resolveHeightGlobal(const LLVector3d &inPos, LLVector3d &outPos, LLVector3 &outNorm)
{
LLVector3d zVec(0.0f, 0.0f, 0.5f);
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 99d0ed76e5..1152475383 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -298,7 +298,7 @@ public:
bool mHasPelvisOffset;
LLVector3 mPelvisOffset;
-
+ F32 mLastPelvisToFoot;
LLVector3 mHeadOffset; // current head position
LLViewerJoint mRoot;
@@ -805,6 +805,7 @@ protected:
//--------------------------------------------------------------------
public:
void resolveHeightGlobal(const LLVector3d &inPos, LLVector3d &outPos, LLVector3 &outNorm);
+ bool distanceToGround( const LLVector3d &startPoint, LLVector3d &collisionPoint, F32 distToIntersectionAlongRay );
void resolveHeightAgent(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm);
void resolveRayCollisionAgent(const LLVector3d start_pt, const LLVector3d end_pt, LLVector3d &out_pos, LLVector3 &out_norm);
void slamPosition(); // Slam position to transmitted position (for teleport);
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index be987a2310..1b7cd801da 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3919,22 +3919,19 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
{
pJoint->setId( currentId );
const LLVector3& jointPos = pSkinData->mAlternateBindMatrix[i].getTranslation();
- //If joint is a pelvis then handle by setting avPos+offset
+ //Set the joint position
+ pJoint->storeCurrentXform( jointPos );
+ //If joint is a pelvis then handle old/new pelvis to foot values
if ( lookingForJoint == "mPelvis" )
{
- //Apply av pos + offset
+ pJoint->storeCurrentXform( jointPos );
if ( !pAvatarVO->hasPelvisOffset() )
{
pAvatarVO->setPelvisOffset( true, jointPos );
//Trigger to rebuild viewer AV
pelvisGotSet = true;
}
- }
- else
- {
- //Straight set for ALL joints except pelvis
- pJoint->storeCurrentXform( jointPos );
- }
+ }
}
}
}