From 2916a9462e9b76e9ccbe306a3dde3584f430bad6 Mon Sep 17 00:00:00 2001 From: fredzio Date: Wed, 21 Oct 2020 21:28:01 +0200 Subject: [PATCH] Fix standing actors logic: it is updated in the solver only if the actor is standing on "something". The ground is not "something", so in case the actor goes from standing on an object to the standing on the ground, this change was not taken into account. Clear the value before the simulation to solve this problem. --- apps/openmw/mwphysics/physicssystem.cpp | 11 ++++++++--- apps/openmw/mwphysics/physicssystem.hpp | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 00068c1e6..5be614b81 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -678,10 +678,10 @@ namespace MWPhysics mTimeAccum -= numSteps * mPhysicsDt; - return mTaskScheduler->moveActors(numSteps, mTimeAccum, prepareFrameData(), mStandingCollisions, skipSimulation); + return mTaskScheduler->moveActors(numSteps, mTimeAccum, prepareFrameData(numSteps), mStandingCollisions, skipSimulation); } - std::vector PhysicsSystem::prepareFrameData() + std::vector PhysicsSystem::prepareFrameData(int numSteps) { std::vector actorsFrameData; actorsFrameData.reserve(mMovementQueue.size()); @@ -723,7 +723,12 @@ namespace MWPhysics // Slow fall reduces fall speed by a factor of (effect magnitude / 200) const float slowFall = 1.f - std::max(0.f, std::min(1.f, effects.get(ESM::MagicEffect::SlowFall).getMagnitude() * 0.005f)); - actorsFrameData.emplace_back(std::move(physicActor), character, mStandingCollisions[character], moveToWaterSurface, movement, slowFall, waterlevel); + // Ue current value only if we don't advance the simulation. Otherwise we might get a stale value. + MWWorld::Ptr standingOn; + if (numSteps == 0) + standingOn = mStandingCollisions[character]; + + actorsFrameData.emplace_back(std::move(physicActor), character, standingOn, moveToWaterSurface, movement, slowFall, waterlevel); } mMovementQueue.clear(); return actorsFrameData; diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index f89a29cae..3198c5d44 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -237,7 +237,7 @@ namespace MWPhysics void updateWater(); - std::vector prepareFrameData(); + std::vector prepareFrameData(int numSteps); osg::ref_ptr mUnrefQueue;