1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-04 02:41:19 +00:00

Merge branch 'fix_physics_crash' into 'master'

Fix crash in physics worker on removing object (#7950)

Closes #7950

See merge request OpenMW/openmw!4057
This commit is contained in:
jvoisin 2024-04-28 00:25:43 +00:00
commit 3e63b507d4

View File

@ -275,10 +275,13 @@ namespace
if (mAdvanceSimulation)
{
MWWorld::Ptr standingOn;
auto* ptrHolder
= static_cast<MWPhysics::PtrHolder*>(scheduler->getUserPointer(frameData.mStandingOn));
if (ptrHolder)
standingOn = ptrHolder->getPtr();
if (frameData.mStandingOn != nullptr)
{
auto* const ptrHolder
= static_cast<MWPhysics::PtrHolder*>(scheduler->getUserPointer(frameData.mStandingOn));
if (ptrHolder != nullptr)
standingOn = ptrHolder->getPtr();
}
actor->setStandingOnPtr(standingOn);
// the "on ground" state of an actor might have been updated by a traceDown, don't overwrite the
// change
@ -650,15 +653,15 @@ namespace MWPhysics
void PhysicsTaskScheduler::addCollisionObject(
btCollisionObject* collisionObject, int collisionFilterGroup, int collisionFilterMask)
{
mCollisionObjects.insert(collisionObject);
MaybeExclusiveLock lock(mCollisionWorldMutex, mLockingPolicy);
mCollisionObjects.insert(collisionObject);
mCollisionWorld->addCollisionObject(collisionObject, collisionFilterGroup, collisionFilterMask);
}
void PhysicsTaskScheduler::removeCollisionObject(btCollisionObject* collisionObject)
{
mCollisionObjects.erase(collisionObject);
MaybeExclusiveLock lock(mCollisionWorldMutex, mLockingPolicy);
mCollisionObjects.erase(collisionObject);
mCollisionWorld->removeCollisionObject(collisionObject);
}