From aff6e910480631abc4826a954eaafa2f196b3827 Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Sun, 25 Jan 2026 16:36:19 +0100 Subject: [PATCH] Fix transform updates sometimes being discarded when using Jolt Co-authored-by: Jorrit Rouwe (cherry picked from commit e7cf2f42cc71179cb7e4d7caa35f3d3a9834dc66) --- modules/jolt_physics/spaces/jolt_space_3d.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/jolt_physics/spaces/jolt_space_3d.cpp b/modules/jolt_physics/spaces/jolt_space_3d.cpp index 065d077866..402b07489a 100644 --- a/modules/jolt_physics/spaces/jolt_space_3d.cpp +++ b/modules/jolt_physics/spaces/jolt_space_3d.cpp @@ -126,7 +126,6 @@ JoltSpace3D::JoltSpace3D(JPH::JobSystem *p_job_system) : physics_system->SetGravity(JPH::Vec3::sZero()); physics_system->SetContactListener(contact_listener); physics_system->SetSoftBodyContactListener(contact_listener); - physics_system->SetBodyActivationListener(body_activation_listener); physics_system->SetSimCollideBodyVsBody([](const JPH::Body &p_body1, const JPH::Body &p_body2, JPH::Mat44Arg p_transform_com1, JPH::Mat44Arg p_transform_com2, JPH::CollideShapeSettings &p_collide_shape_settings, JPH::CollideShapeCollector &p_collector, const JPH::ShapeFilter &p_shape_filter) { if (p_body1.IsSensor() || p_body2.IsSensor()) { @@ -187,6 +186,8 @@ void JoltSpace3D::step(float p_step) { _pre_step(p_step); + physics_system->SetBodyActivationListener(body_activation_listener); + const JPH::EPhysicsUpdateError update_error = physics_system->Update(p_step, 1, temp_allocator, job_system); if ((update_error & JPH::EPhysicsUpdateError::ManifoldCacheFull) != JPH::EPhysicsUpdateError::None) { @@ -210,6 +211,9 @@ void JoltSpace3D::step(float p_step) { JoltProjectSettings::max_contact_constraints)); } + // We only want a listener during the step, as it will otherwise be called when pending bodies are flushed, which causes issues (e.g. GH-115322). + physics_system->SetBodyActivationListener(nullptr); + _post_step(p_step); stepping = false;