Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/jolt_physics/spaces/jolt_space_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down