Remove completion threshold-based turning for the player (#8447)

This commit is contained in:
Alexei Kotov 2025-04-11 06:08:42 +03:00
parent ea8369eff0
commit 96c4467cc3

View file

@ -2301,17 +2301,13 @@ namespace MWMechanics
}
else
{
// Do not play turning animation for player if rotation speed is very slow.
// Actual threshold should take framerate in account.
float rotationThreshold = (isPlayer ? 0.015f : 0.001f) * 60 * duration;
// It seems only bipedal actors use turning animations.
// Also do not use turning animations in the first-person view and when sneaking.
if (!sneak && !isFirstPersonPlayer && isBiped)
{
if (effectiveRotation > rotationThreshold)
if (effectiveRotation > 0.f)
movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight;
else if (effectiveRotation < -rotationThreshold)
else if (effectiveRotation < 0.f)
movestate = inwater ? CharState_SwimTurnLeft : CharState_TurnLeft;
}
}
@ -2337,34 +2333,19 @@ namespace MWMechanics
vec.y() *= std::sqrt(1.0f - swimUpwardCoef * swimUpwardCoef);
}
// Player can not use smooth turning as NPCs, so we play turning animation a bit to avoid jittering
if (isPlayer)
if (isBiped)
{
float threshold = mCurrentMovement.find("swim") == std::string::npos ? 0.4f : 0.8f;
float complete;
bool animPlaying = mAnimation->getInfo(mCurrentMovement, &complete);
if (movestate == CharState_None && jumpstate == JumpState_None && isTurning())
{
if (animPlaying && complete < threshold)
movestate = mMovementState;
}
}
else
{
if (isBiped)
{
if (mTurnAnimationThreshold > 0)
mTurnAnimationThreshold -= duration;
if (mTurnAnimationThreshold > 0)
mTurnAnimationThreshold -= duration;
if (movestate == CharState_TurnRight || movestate == CharState_TurnLeft
|| movestate == CharState_SwimTurnRight || movestate == CharState_SwimTurnLeft)
{
mTurnAnimationThreshold = 0.05f;
}
else if (movestate == CharState_None && isTurning() && mTurnAnimationThreshold > 0)
{
movestate = mMovementState;
}
if (movestate == CharState_TurnRight || movestate == CharState_TurnLeft
|| movestate == CharState_SwimTurnRight || movestate == CharState_SwimTurnLeft)
{
mTurnAnimationThreshold = 0.05f;
}
else if (movestate == CharState_None && isTurning() && mTurnAnimationThreshold > 0)
{
movestate = mMovementState;
}
}
@ -2393,11 +2374,10 @@ namespace MWMechanics
if (isTurning())
{
// Adjust animation speed from 1.0 to 1.5 multiplier
if (duration > 0)
{
float turnSpeed = std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI));
mAnimation->adjustSpeedMult(mCurrentMovement, std::max(turnSpeed, 1.0f));
mAnimation->adjustSpeedMult(mCurrentMovement, turnSpeed);
}
}
else if (mMovementState != CharState_None && mAdjustMovementAnimSpeed)