From 874c754b68b8af2f8cbf9c5937605e6a8d8237c3 Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Mon, 31 Aug 2020 23:16:10 +0200 Subject: [PATCH] Fix #5557 --- CHANGELOG.md | 1 + apps/openmw/mwinput/actionmanager.cpp | 2 +- apps/openmw/mwmechanics/character.cpp | 19 +++++++------------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c68e7b0f5..00d7f3539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Bug #5531: Actors flee using current rotation by axis x Bug #5539: Window resize breaks when going from a lower resolution to full screen resolution Bug #5548: Certain exhausted topics can be highlighted again even though there's no new dialogue + Bug #5557: Diagonal movement is noticeably slower with analogue stick Feature #390: 3rd person look "over the shoulder" Feature #2386: Distant Statics in the form of Object Paging Feature #5297: Add a search function to the "Datafiles" tab of the OpenMW launcher diff --git a/apps/openmw/mwinput/actionmanager.cpp b/apps/openmw/mwinput/actionmanager.cpp index d2430a612..b29aa58a2 100644 --- a/apps/openmw/mwinput/actionmanager.cpp +++ b/apps/openmw/mwinput/actionmanager.cpp @@ -141,7 +141,7 @@ namespace MWInput float xAxis = mBindingsManager->getActionValue(A_MoveLeftRight); float yAxis = mBindingsManager->getActionValue(A_MoveForwardBackward); - bool isRunning = xAxis > .75 || xAxis < .25 || yAxis > .75 || yAxis < .25; + bool isRunning = osg::Vec2f(xAxis * 2 - 1, yAxis * 2 - 1).length2() > 0.25f; if ((mAlwaysRunActive && alwaysRunAllowed) || isRunning) player.setRunState(!mBindingsManager->actionIsActive(A_Run)); else diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 449ac69bb..ad30c16bd 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1954,20 +1954,15 @@ void CharacterController::update(float duration, bool animationOnly) osg::Vec3f rot = cls.getRotationVector(mPtr); osg::Vec3f vec(movementSettings.asVec3()); - - if (isPlayer) - { - // TODO: Move this code to mwinput. - // Joystick analogue movement. - movementSettings.mSpeedFactor = std::max(std::abs(vec.x()), std::abs(vec.y())); - - // Due to the half way split between walking/running, we multiply speed by 2 while walking, unless a keyboard was used. - if(!isrunning && !sneak && !flying && movementSettings.mSpeedFactor <= 0.5f) - movementSettings.mSpeedFactor *= 2.f; - } else - movementSettings.mSpeedFactor = std::min(vec.length(), 1.f); + movementSettings.mSpeedFactor = std::min(vec.length(), 1.f); vec.normalize(); + // TODO: Move this check to mwinput. + // Joystick analogue movement. + // Due to the half way split between walking/running, we multiply speed by 2 while walking, unless a keyboard was used. + if (isPlayer && !isrunning && !sneak && !flying && movementSettings.mSpeedFactor <= 0.5f) + movementSettings.mSpeedFactor *= 2.f; + float effectiveRotation = rot.z(); bool canMove = cls.getMaxSpeed(mPtr) > 0; static const bool turnToMovementDirection = Settings::Manager::getBool("turn to movement direction", "Game");