From 9b87f06a856c4d673642e210f8b0986cfdbac3af Mon Sep 17 00:00:00 2001 From: Sébastien Crozet Date: Sun, 21 Jan 2024 21:02:23 +0100 Subject: feat: implement new "small-steps" solver + joint improvements --- src/geometry/contact_pair.rs | 2 +- src/geometry/narrow_phase.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/geometry') diff --git a/src/geometry/contact_pair.rs b/src/geometry/contact_pair.rs index 3bef40d..44730a0 100644 --- a/src/geometry/contact_pair.rs +++ b/src/geometry/contact_pair.rs @@ -283,7 +283,7 @@ pub struct ContactManifoldData { pub struct SolverContact { /// The index of the manifold contact used to generate this solver contact. pub(crate) contact_id: u8, - /// The world-space contact point. + /// The contact point in world-space. pub point: Point, /// The distance between the two original contacts points along the contact normal. /// If negative, this is measures the penetration depth. diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs index 4500284..8b5f0c9 100644 --- a/src/geometry/narrow_phase.rs +++ b/src/geometry/narrow_phase.rs @@ -927,6 +927,7 @@ impl NarrowPhase { for manifold in &mut pair.manifolds { let world_pos1 = manifold.subshape_pos1.prepend_to(&co1.pos); + let world_pos2 = manifold.subshape_pos2.prepend_to(&co2.pos); manifold.data.solver_contacts.clear(); manifold.data.rigid_body1 = co1.parent.map(|p| p.handle); manifold.data.rigid_body2 = co2.parent.map(|p| p.handle); @@ -944,10 +945,13 @@ impl NarrowPhase { if contact.dist < prediction_distance { // Generate the solver contact. + let world_pt1 = world_pos1 * contact.local_p1; + let world_pt2 = world_pos2 * contact.local_p2; + let effective_point = na::center(&world_pt1, &world_pt2); + let solver_contact = SolverContact { contact_id: contact_id as u8, - point: world_pos1 * contact.local_p1 - + manifold.data.normal * contact.dist / 2.0, + point: effective_point, dist: contact.dist, friction, restitution, -- cgit