|
|
@ -1992,26 +1992,38 @@ void CharacterController::update(float duration)
|
|
|
|
else if(rot.z() != 0.0f && !sneak && !(mPtr == getPlayer() && MWBase::Environment::get().getWorld()->isFirstPerson()))
|
|
|
|
else if(rot.z() != 0.0f && !sneak && !(mPtr == getPlayer() && MWBase::Environment::get().getWorld()->isFirstPerson()))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(rot.z() > 0.0f)
|
|
|
|
if(rot.z() > 0.0f)
|
|
|
|
{
|
|
|
|
|
|
|
|
movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight;
|
|
|
|
movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight;
|
|
|
|
mAnimation->disable(mCurrentJump);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(rot.z() < 0.0f)
|
|
|
|
else if(rot.z() < 0.0f)
|
|
|
|
{
|
|
|
|
|
|
|
|
movestate = inwater ? CharState_SwimTurnLeft : CharState_TurnLeft;
|
|
|
|
movestate = inwater ? CharState_SwimTurnLeft : CharState_TurnLeft;
|
|
|
|
mAnimation->disable(mCurrentJump);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Player can not use smooth turning as NPCs, so we play turning animation a bit to avoid jittering
|
|
|
|
|
|
|
|
if (mPtr == getPlayer())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
float threshold = mCurrentMovement.find("swim") == std::string::npos ? 0.4f : 0.8f;
|
|
|
|
|
|
|
|
float complete;
|
|
|
|
|
|
|
|
bool animPlaying = mAnimation->getInfo(mCurrentMovement, &complete);
|
|
|
|
|
|
|
|
if (movestate == CharState_None && isTurning())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (animPlaying && complete < threshold)
|
|
|
|
|
|
|
|
movestate = mMovementState;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
mTurnAnimationThreshold -= duration;
|
|
|
|
mTurnAnimationThreshold -= duration;
|
|
|
|
if (isTurning())
|
|
|
|
if (movestate == CharState_TurnRight || movestate == CharState_TurnLeft ||
|
|
|
|
|
|
|
|
movestate == CharState_SwimTurnRight || movestate == CharState_SwimTurnLeft)
|
|
|
|
|
|
|
|
{
|
|
|
|
mTurnAnimationThreshold = 0.05f;
|
|
|
|
mTurnAnimationThreshold = 0.05f;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (movestate == CharState_None && isTurning()
|
|
|
|
else if (movestate == CharState_None && isTurning()
|
|
|
|
&& mTurnAnimationThreshold > 0)
|
|
|
|
&& mTurnAnimationThreshold > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
movestate = mMovementState;
|
|
|
|
movestate = mMovementState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(movestate != CharState_None && !isTurning())
|
|
|
|
if(movestate != CharState_None && !isTurning())
|
|
|
|
clearAnimQueue();
|
|
|
|
clearAnimQueue();
|
|
|
@ -2040,8 +2052,10 @@ void CharacterController::update(float duration)
|
|
|
|
|
|
|
|
|
|
|
|
if (isTurning())
|
|
|
|
if (isTurning())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Adjust animation speed from 1.0 to 1.5 multiplier
|
|
|
|
|
|
|
|
float turnSpeed = std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI));
|
|
|
|
if (duration > 0)
|
|
|
|
if (duration > 0)
|
|
|
|
mAnimation->adjustSpeedMult(mCurrentMovement, std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI)));
|
|
|
|
mAnimation->adjustSpeedMult(mCurrentMovement, std::max(turnSpeed, 1.0f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mMovementState != CharState_None && mAdjustMovementAnimSpeed)
|
|
|
|
else if (mMovementState != CharState_None && mAdjustMovementAnimSpeed)
|
|
|
|
{
|
|
|
|
{
|
|
|
|