From b459a010b0320a143fd0428f7461daf8644e8b21 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 14 May 2013 23:03:28 -0700 Subject: [PATCH] Fix vec.z being applied while not in the air --- apps/openmw/mwmechanics/character.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index ecf2cfdc92..24f55c8786 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -268,7 +268,9 @@ void CharacterController::update(float duration, Movement &movement) /* FIXME: The state should be set to Jump, and X/Y movement should be disallowed except * for the initial thrust (which would be carried by "physics" until landing). */ - if(onground && vec.z > 0.0f) + if(!onground) + vec.z = 0.0f; + else if(vec.z > 0.0f) { float z = cls.getJump(mPtr); @@ -331,12 +333,14 @@ void CharacterController::update(float duration, Movement &movement) else if(getState() != CharState_SpecialIdle) setState((inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle))); - movement.mPosition[0] += vec.x * duration; - movement.mPosition[1] += vec.y * duration; - movement.mPosition[2] += vec.z * duration; - movement.mRotation[0] += rot.x * duration; - movement.mRotation[1] += rot.y * duration; - movement.mRotation[2] += rot.z * duration; + vec *= duration; + movement.mPosition[0] += vec.x; + movement.mPosition[1] += vec.y; + movement.mPosition[2] += vec.z; + rot *= duration; + movement.mRotation[0] += rot.x; + movement.mRotation[1] += rot.y; + movement.mRotation[2] += rot.z; if(mPtr.getTypeName() == typeid(ESM::NPC).name()) {