diff --git a/apps/openmw/mwphysics/mtphysics.cpp b/apps/openmw/mwphysics/mtphysics.cpp index 9aff85359a..a53a011f67 100644 --- a/apps/openmw/mwphysics/mtphysics.cpp +++ b/apps/openmw/mwphysics/mtphysics.cpp @@ -515,26 +515,27 @@ namespace MWPhysics mPreStepBarrier->wait(); int job = 0; - while ((job = mNextJob.fetch_add(1, std::memory_order_relaxed)) < mNumJobs) + while (mRemainingSteps && (job = mNextJob.fetch_add(1, std::memory_order_relaxed)) < mNumJobs) { MaybeSharedLock lockColWorld(mCollisionWorldMutex, mThreadSafeBullet); if(const auto actor = mActorsFrameData[job].mActor.lock()) - { - if (mRemainingSteps) - MovementSolver::move(mActorsFrameData[job], mPhysicsDt, mCollisionWorld.get(), *mWorldFrameData); - else - { - auto& actorData = mActorsFrameData[job]; - handleFall(actorData, mAdvanceSimulation); - mMovementResults[actorData.mPtr] = interpolateMovements(actorData, mTimeAccum, mPhysicsDt); - } - } + MovementSolver::move(mActorsFrameData[job], mPhysicsDt, mCollisionWorld.get(), *mWorldFrameData); } mPostStepBarrier->wait(); if (!mRemainingSteps) { + while ((job = mNextJob.fetch_add(1, std::memory_order_relaxed)) < mNumJobs) + { + if(const auto actor = mActorsFrameData[job].mActor.lock()) + { + auto& actorData = mActorsFrameData[job]; + handleFall(actorData, mAdvanceSimulation); + mMovementResults[actorData.mPtr] = interpolateMovements(actorData, mTimeAccum, mPhysicsDt); + } + } + if (mLOSCacheExpiry >= 0) refreshLOSCache(); mPostSimBarrier->wait();