From 22c8ec53426543c1d8192c2bf5744c0bb37b384c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 9 Nov 2023 11:50:48 +0100 Subject: [PATCH] Fix crash when rigidbody gets deleted during physical collision #1893 --- .../Engine/Physics/PhysX/SimulationEventCallbackPhysX.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Physics/PhysX/SimulationEventCallbackPhysX.cpp b/Source/Engine/Physics/PhysX/SimulationEventCallbackPhysX.cpp index 5968bdd78..5781e4641 100644 --- a/Source/Engine/Physics/PhysX/SimulationEventCallbackPhysX.cpp +++ b/Source/Engine/Physics/PhysX/SimulationEventCallbackPhysX.cpp @@ -137,7 +137,11 @@ void SimulationEventCallback::onContact(const PxContactPairHeader& pairHeader, c c.ThisActor = static_cast(pair.shapes[0]->userData); c.OtherActor = static_cast(pair.shapes[1]->userData); - ASSERT_LOW_LAYER(c.ThisActor && c.OtherActor); + if (c.ThisActor == nullptr || c.OtherActor == nullptr) + { + // One of the actors was deleted (eg. via RigidBody destroyed by gameplay) then skip processing this collision + continue; + } // Extract contact points while (i.hasNextPatch())