From 3ddf2441ea6c43aa98718e0ce8650c3b804062d4 Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 14 Apr 2024 15:53:35 +0200 Subject: feat: add exact mlcp solver for pais of 2 constraints --- src/geometry/narrow_phase.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/geometry') diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs index bcf31b0..1452864 100644 --- a/src/geometry/narrow_phase.rs +++ b/src/geometry/narrow_phase.rs @@ -997,6 +997,35 @@ impl NarrowPhase { manifold.data.normal = modifiable_normal; manifold.data.user_data = modifiable_user_data; } + + /* + * TODO: When using the block solver in 3D, I’d expect this sort to help, but + * it makes the domino demo worse. Needs more investigation. + fn sort_solver_contacts(mut contacts: &mut [SolverContact]) { + while contacts.len() > 2 { + let first = contacts[0]; + let mut furthest_id = 1; + let mut furthest_dist = na::distance(&first.point, &contacts[1].point); + + for (candidate_id, candidate) in contacts.iter().enumerate().skip(2) { + let candidate_dist = na::distance(&first.point, &candidate.point); + + if candidate_dist > furthest_dist { + furthest_dist = candidate_dist; + furthest_id = candidate_id; + } + } + + if furthest_id > 1 { + contacts.swap(1, furthest_id); + } + + contacts = &mut contacts[2..]; + } + } + + sort_solver_contacts(&mut manifold.data.solver_contacts); + */ } break 'emit_events; -- cgit