From 48e594b7c4b866fe5d1aa4187d9e5f22b29b6376 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 19 Aug 2013 08:09:23 -0700 Subject: [PATCH] Improve stepping down when starting on the ground --- apps/openmw/mwworld/physicssystem.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index c7294b4f96..48d397d31e 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -128,6 +128,7 @@ namespace MWWorld position.z += halfExtents.z; OEngine::Physic::ActorTracer tracer; + bool wasOnGround = false; bool isOnGround = false; Ogre::Vector3 inertia(0.0f); Ogre::Vector3 velocity; @@ -140,15 +141,22 @@ namespace MWWorld } else { + velocity = Ogre::Quaternion(Ogre::Radian(-refpos.rot[2]), Ogre::Vector3::UNIT_Z) * movement; + if(physicActor->getOnGround()) + inertia = velocity; + else + { + inertia = physicActor->getInertialForce(); + velocity += inertia; + } + if(!(movement.z > 0.0f)) { + wasOnGround = physicActor->getOnGround(); tracer.doTrace(colobj, position, position-Ogre::Vector3(0,0,2), engine); if(tracer.mFraction < 1.0f && getSlope(tracer.mPlaneNormal) <= sMaxSlope) isOnGround = true; } - inertia = physicActor->getInertialForce(); - velocity = Ogre::Quaternion(Ogre::Radian(-refpos.rot[2]), Ogre::Vector3::UNIT_Z) * movement; - velocity += inertia; } if(isOnGround) @@ -172,10 +180,9 @@ namespace MWWorld break; } - //std::cout<<"angle: "<setInertialForce(Ogre::Vector3(0.0f)); else { - if(physicActor->getOnGround()) - inertia = velocity; inertia.z -= time*627.2f; physicActor->setInertialForce(inertia); }