Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix contact constraints being cleared many times with many backends #424

Merged
merged 1 commit into from
Jul 13, 2024
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
15 changes: 12 additions & 3 deletions src/collision/narrow_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ impl<C: AnyCollider> Plugin for NarrowPhasePlugin<C> {
);

if self.generate_constraints {
if is_first_instance {
// Clear contact constraints.
app.add_systems(
self.schedule,
(|mut constraints: ResMut<ContactConstraints>| {
constraints.clear();
})
.after(NarrowPhaseSet::PostProcess)
.before(NarrowPhaseSet::GenerateConstraints),
);
}

// Generate contact constraints.
app.add_systems(
self.schedule,
Expand Down Expand Up @@ -262,9 +274,6 @@ fn generate_constraints<C: AnyCollider>(
) {
let delta_secs = time.delta_seconds_adjusted();

// Clear contact constraints.
constraints.clear();

// TODO: Parallelize.
for contacts in narrow_phase.collisions.get_internal().values() {
let Ok([collider1, collider2]) = narrow_phase
Expand Down