From 8b3088a9e5e33acf3e6ae123e91e9d91269b4dae Mon Sep 17 00:00:00 2001
From: Petr Mikheev <ptmikheev@gmail.com>
Date: Thu, 24 Dec 2020 03:00:09 +0100
Subject: [PATCH] Fix #5743

---
 apps/openmw/mwmechanics/character.cpp | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp
index 1784869651..483492034d 100644
--- a/apps/openmw/mwmechanics/character.cpp
+++ b/apps/openmw/mwmechanics/character.cpp
@@ -2265,18 +2265,19 @@ void CharacterController::update(float duration, bool animationOnly)
                 sndMgr->playSound3D(mPtr, sound, 1.f, 1.f, MWSound::Type::Foot, MWSound::PlayMode::NoPlayerLocal);
         }
 
-        if (turnToMovementDirection)
+        if (turnToMovementDirection && !isFirstPersonPlayer &&
+            (movestate == CharState_SwimRunForward || movestate == CharState_SwimWalkForward ||
+             movestate == CharState_SwimRunBack || movestate == CharState_SwimWalkBack))
         {
-            float targetSwimmingPitch;
-            if (inwater && vec.y() != 0 && !isFirstPersonPlayer && !movementSettings.mIsStrafing)
-                targetSwimmingPitch = -mPtr.getRefData().getPosition().rot[0];
-            else
-                targetSwimmingPitch = 0;
-            float maxSwimPitchDelta = 3.0f * duration;
             float swimmingPitch = mAnimation->getBodyPitchRadians();
+            float targetSwimmingPitch = -mPtr.getRefData().getPosition().rot[0];
+            float maxSwimPitchDelta = 3.0f * duration;
             swimmingPitch += osg::clampBetween(targetSwimmingPitch - swimmingPitch, -maxSwimPitchDelta, maxSwimPitchDelta);
             mAnimation->setBodyPitchRadians(swimmingPitch);
         }
+        else
+            mAnimation->setBodyPitchRadians(0);
+
         static const bool swimUpwardCorrection = Settings::Manager::getBool("swim upward correction", "Game");
         if (inwater && isPlayer && !isFirstPersonPlayer && swimUpwardCorrection)
         {