From 50e24e24ed4f89352b2178d0525ac996bb4e4fcd Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Fri, 27 Jun 2025 12:49:52 +0200 Subject: [PATCH] Fix crash when disabling `SoftBody3D` while using Jolt Physics --- modules/jolt_physics/objects/jolt_soft_body_3d.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/jolt_physics/objects/jolt_soft_body_3d.cpp b/modules/jolt_physics/objects/jolt_soft_body_3d.cpp index 7cc0b69e64..8f200faf36 100644 --- a/modules/jolt_physics/objects/jolt_soft_body_3d.cpp +++ b/modules/jolt_physics/objects/jolt_soft_body_3d.cpp @@ -74,7 +74,8 @@ JPH::ObjectLayer JoltSoftBody3D::_get_object_layer() const { void JoltSoftBody3D::_space_changing() { JoltObject3D::_space_changing(); - if (in_space()) { + // Note that we should not use `in_space()` as the condition here, since we could have cleared the mesh at this point. + if (jolt_body != nullptr) { jolt_settings = new JPH::SoftBodyCreationSettings(jolt_body->GetSoftBodyCreationSettings()); jolt_settings->mSettings = nullptr; }