diff options
| author | Sébastien Crozet <sebcrozet@dimforge.com> | 2024-04-14 15:53:35 +0200 |
|---|---|---|
| committer | Sébastien Crozet <sebastien@crozet.re> | 2024-04-30 23:10:46 +0200 |
| commit | 3ddf2441ea6c43aa98718e0ce8650c3b804062d4 (patch) | |
| tree | cb788bf95da707a683fd949d887d071c68934ae6 /src/geometry | |
| parent | 15c07cfeb3d59f116b26eec32e4590dc45d6c26c (diff) | |
| download | rapier-3ddf2441ea6c43aa98718e0ce8650c3b804062d4.tar.gz rapier-3ddf2441ea6c43aa98718e0ce8650c3b804062d4.tar.bz2 rapier-3ddf2441ea6c43aa98718e0ce8650c3b804062d4.zip | |
feat: add exact mlcp solver for pais of 2 constraints
Diffstat (limited to 'src/geometry')
| -rw-r--r-- | src/geometry/narrow_phase.rs | 29 |
1 files changed, 29 insertions, 0 deletions
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; |
