From 8c21b0b503386f583e57e2ce40e9cd5e64a0299b Mon Sep 17 00:00:00 2001 From: fredzio Date: Mon, 1 Nov 2021 12:44:36 +0100 Subject: [PATCH] Apply waterwalking even when we skip simulation. This chunk was supposed to be part of !1324 but somehow got stuck staged in my tree. --- apps/openmw/mwphysics/mtphysics.cpp | 6 ++++-- apps/openmw/mwphysics/physicssystem.cpp | 18 ------------------ apps/openmw/mwphysics/physicssystem.hpp | 1 - 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index a989493f4d..5c49dee297 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -123,8 +123,10 @@ namespace frameData.mPosition = actor->getPosition(); if (frameData.mWaterCollision && frameData.mPosition.z() < frameData.mWaterlevel && actor->canMoveToWaterSurface(frameData.mWaterlevel, mCollisionWorld)) { - frameData.mPosition.z() = frameData.mWaterlevel; - MWBase::Environment::get().getWorld()->moveObject(actor->getPtr(), frameData.mPosition, false); + const auto offset = osg::Vec3f(0, 0, frameData.mWaterlevel - frameData.mPosition.z()); + MWBase::Environment::get().getWorld()->moveObjectBy(actor->getPtr(), offset); + actor->applyOffsetChange(); + frameData.mPosition = actor->getPosition(); } frameData.mOldHeight = frameData.mPosition.z(); const auto rotation = actor->getPtr().getRefData().getPosition().asRotationVec3(); diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index af6dc109ed..a64ee70b96 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -945,24 +945,6 @@ namespace MWPhysics { } - void ActorFrameData::updatePosition(Actor& actor, btCollisionWorld* world) - { - actor.applyOffsetChange(); - mPosition = actor.getPosition(); - if (mWaterCollision && mPosition.z() < mWaterlevel && actor.canMoveToWaterSurface(mWaterlevel, world)) - { - MWBase::Environment::get().getWorld()->moveObjectBy(actor.getPtr(), osg::Vec3f(0, 0, mWaterlevel - mPosition.z())); - actor.applyOffsetChange(); - mPosition = actor.getPosition(); - } - mOldHeight = mPosition.z(); - const auto rotation = actor.getPtr().getRefData().getPosition().asRotationVec3(); - mRotation = osg::Vec2f(rotation.x(), rotation.z()); - mInertia = actor.getInertialForce(); - mStuckFrames = actor.getStuckFrames(); - mLastStuckPosition = actor.getLastStuckPosition(); - } - ProjectileFrameData::ProjectileFrameData(Projectile& projectile) : mPosition(projectile.getPosition()) , mMovement(projectile.velocity()) diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index a025f1cc8b..c31bbfbf65 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -76,7 +76,6 @@ namespace MWPhysics struct ActorFrameData { ActorFrameData(Actor& actor, bool inert, bool waterCollision, float slowFall, float waterlevel); - void updatePosition(Actor& actor, btCollisionWorld* world); osg::Vec3f mPosition; osg::Vec3f mInertia; const btCollisionObject* mStandingOn;