Fix transform updates sometimes being discarded when using Jolt

Co-authored-by: Jorrit Rouwe <jrouwe@gmail.com>
This commit is contained in:
Mikael Hermansson 2026-01-25 16:36:19 +01:00
parent d5edd4a592
commit e7cf2f42cc

View file

@ -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;