From ccf3976dc5be258132255e5857532a6a6b08604f Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Sat, 27 Sep 2025 13:30:04 +0200 Subject: [PATCH] Fix crash when calling `move_and_collide` with a null `jolt_body` (cherry picked from commit a285ab6bcfd1e04a9212cd53bda40293748e5210) --- .../spaces/jolt_physics_direct_space_state_3d.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.cpp b/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.cpp index 36ad136c737..e62e7289ac3 100644 --- a/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.cpp +++ b/modules/jolt_physics/spaces/jolt_physics_direct_space_state_3d.cpp @@ -861,6 +861,10 @@ Vector3 JoltPhysicsDirectSpaceState3D::get_closest_point_to_object_volume(RID p_ bool JoltPhysicsDirectSpaceState3D::body_test_motion(const JoltBody3D &p_body, const PhysicsServer3D::MotionParameters &p_parameters, PhysicsServer3D::MotionResult *r_result) const { ERR_FAIL_COND_V_MSG(space->is_stepping(), false, "body_test_motion (maybe from move_and_slide?) must not be called while the physics space is being stepped."); + if (!p_body.in_space()) { + return false; + } + space->flush_pending_objects(); const float margin = MAX((float)p_parameters.margin, 0.0001f);