From 63bf4bf868ec0a415631b8285a8ef6e689e80c7b Mon Sep 17 00:00:00 2001 From: Frederic Chardon Date: Wed, 29 Dec 2021 15:11:48 +0100 Subject: [PATCH] Solve 2 bugs in projectile movement simulation: - properly initialize mSimulationPosition in the constructor. Unlucky thread scheduling can cause processHits to be called before the first simulation run, causing the projectile to vanish to whatever value the variable happens to contains. - don't continue moving the projectile after a hit. The position would continue to be updated to some senseless value. --- apps/openmw/mwphysics/mtphysics.cpp | 3 ++- apps/openmw/mwphysics/projectile.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index 2f7e3b5995..5fcda2dfa0 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -185,7 +185,8 @@ namespace } void operator()(MWPhysics::ProjectileSimulation& sim) const { - MWPhysics::MovementSolver::move(sim.second, mPhysicsDt, mCollisionWorld); + if (sim.first->isActive()) + MWPhysics::MovementSolver::move(sim.second, mPhysicsDt, mCollisionWorld); } }; diff --git a/apps/openmw/mwphysics/projectile.cpp b/apps/openmw/mwphysics/projectile.cpp index 9f8962d5e6..6176738043 100644 --- a/apps/openmw/mwphysics/projectile.cpp +++ b/apps/openmw/mwphysics/projectile.cpp @@ -33,6 +33,7 @@ Projectile::Projectile(const MWWorld::Ptr& caster, const osg::Vec3f& position, f mPosition = position; mPreviousPosition = position; + mSimulationPosition = position; setCaster(caster); const int collisionMask = CollisionType_World | CollisionType_HeightMap |