Merge branch 'turnedwerewolf' into 'master'

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

Closes #8447

See merge request OpenMW/openmw!4628
This commit is contained in:
psi29a 2025-07-27 16:32:43 +00:00
commit 7637ca536b

View File

@ -2310,17 +2310,13 @@ namespace MWMechanics
} }
else 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. // It seems only bipedal actors use turning animations.
// Also do not use turning animations in the first-person view and when sneaking. // Also do not use turning animations in the first-person view and when sneaking.
if (!sneak && !isFirstPersonPlayer && isBiped) if (!sneak && !isFirstPersonPlayer && isBiped)
{ {
if (effectiveRotation > rotationThreshold) if (effectiveRotation > 0.f)
movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight; movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight;
else if (effectiveRotation < -rotationThreshold) else if (effectiveRotation < 0.f)
movestate = inwater ? CharState_SwimTurnLeft : CharState_TurnLeft; movestate = inwater ? CharState_SwimTurnLeft : CharState_TurnLeft;
} }
} }
@ -2346,34 +2342,19 @@ namespace MWMechanics
vec.y() *= std::sqrt(1.0f - swimUpwardCoef * swimUpwardCoef); 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 (isBiped)
if (isPlayer)
{ {
float threshold = mCurrentMovement.find("swim") == std::string::npos ? 0.4f : 0.8f; if (mTurnAnimationThreshold > 0)
float complete; mTurnAnimationThreshold -= duration;
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 (movestate == CharState_TurnRight || movestate == CharState_TurnLeft if (movestate == CharState_TurnRight || movestate == CharState_TurnLeft
|| movestate == CharState_SwimTurnRight || movestate == CharState_SwimTurnLeft) || movestate == CharState_SwimTurnRight || movestate == CharState_SwimTurnLeft)
{ {
mTurnAnimationThreshold = 0.05f; mTurnAnimationThreshold = 0.05f;
} }
else if (movestate == CharState_None && isTurning() && mTurnAnimationThreshold > 0) else if (movestate == CharState_None && isTurning() && mTurnAnimationThreshold > 0)
{ {
movestate = mMovementState; movestate = mMovementState;
}
} }
} }
@ -2402,11 +2383,10 @@ namespace MWMechanics
if (isTurning()) if (isTurning())
{ {
// Adjust animation speed from 1.0 to 1.5 multiplier
if (duration > 0) if (duration > 0)
{ {
float turnSpeed = std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI)); 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) else if (mMovementState != CharState_None && mAdjustMovementAnimSpeed)