Fix crash when PhysicsMaterial asset is reloaded in editor

This commit is contained in:
2024-06-08 19:20:28 +03:00
parent 50c29f6a9b
commit 07371ddfdf
4 changed files with 16 additions and 1 deletions

View File

@@ -4474,6 +4474,16 @@ void PhysicsBackend::DestroyController(void* controller)
controllerPhysX->release();
}
void PhysicsBackend::DestroyMaterial(void* material)
{
ASSERT_LOW_LAYER(material);
auto materialPhysX = (PxMaterial*)material;
materialPhysX->userData = nullptr;
FlushLocker.Lock();
DeleteObjects.Add(materialPhysX);
FlushLocker.Unlock();
}
void PhysicsBackend::DestroyObject(void* object)
{
ASSERT_LOW_LAYER(object);

View File

@@ -81,7 +81,7 @@ void PhysicsSettings::Deserialize(DeserializeStream& stream, ISerializeModifier*
PhysicalMaterial::~PhysicalMaterial()
{
if (_material)
PhysicsBackend::DestroyObject(_material);
PhysicsBackend::DestroyMaterial(_material);
}
bool PhysicsService::Init()

View File

@@ -314,6 +314,7 @@ public:
static void DestroyShape(void* shape);
static void DestroyJoint(void* joint);
static void DestroyController(void* controller);
static void DestroyMaterial(void* material);
static void DestroyObject(void* object);
static void RemoveCollider(PhysicsColliderActor* collider);
static void RemoveJoint(Joint* joint);

View File

@@ -865,6 +865,10 @@ void PhysicsBackend::DestroyController(void* controller)
{
}
void PhysicsBackend::DestroyMaterial(void* material)
{
}
void PhysicsBackend::DestroyObject(void* object)
{
}