From 9c78e8cc5698af9d17f9fa3eee7bbf4ce3e9384e Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Tue, 12 Nov 2019 17:10:28 +0300 Subject: [PATCH] Make sure movement not controlled by animation has valid velocity Fixes erroneously always normalized movement speed in first person --- apps/openmw/mwmechanics/character.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 60da8b27d..e6223ac54 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1906,6 +1906,17 @@ void CharacterController::update(float duration, bool animationOnly) bool isPlayer = mPtr == MWMechanics::getPlayer(); bool godmode = isPlayer && MWBase::Environment::get().getWorld()->getGodModeState(); + float scale = mPtr.getCellRef().getScale(); + + static const bool normalizeSpeed = Settings::Manager::getBool("normalise race speed", "Game"); + if (!normalizeSpeed && mPtr.getClass().isNpc()) + { + const ESM::NPC* npc = mPtr.get()->mBase; + const ESM::Race* race = world->getStore().get().find(npc->mRace); + float weight = npc->isMale() ? race->mData.mWeight.mMale : race->mData.mWeight.mFemale; + scale *= weight; + } + if(!cls.isActor()) updateAnimQueue(); else if(!cls.getCreatureStats(mPtr).isDead()) @@ -2132,6 +2143,8 @@ void CharacterController::update(float duration, bool animationOnly) jumpstate = mAnimation->isPlaying(mCurrentJump) ? JumpState_Landing : JumpState_None; + vec.x() *= scale; + vec.y() *= scale; vec.z() = 0.0f; inJump = false; @@ -2322,20 +2335,9 @@ void CharacterController::update(float duration, bool animationOnly) else moved = osg::Vec3f(0.f, 0.f, 0.f); - float scale = mPtr.getCellRef().getScale(); moved.x() *= scale; moved.y() *= scale; - static const bool normalizeSpeed = Settings::Manager::getBool("normalise race speed", "Game"); - if (mPtr.getClass().isNpc() && !normalizeSpeed) - { - const ESM::NPC* npc = mPtr.get()->mBase; - const ESM::Race* race = world->getStore().get().find(npc->mRace); - float weight = npc->isMale() ? race->mData.mWeight.mMale : race->mData.mWeight.mFemale; - moved.x() *= weight; - moved.y() *= weight; - } - // Ensure we're moving in generally the right direction... if(speed > 0.f) {