aboutsummaryrefslogtreecommitdiff
path: root/src/geometry
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2024-01-22 21:45:40 +0100
committerGitHub <noreply@github.com>2024-01-22 21:45:40 +0100
commitaef85ec2554476485dbf3de5f01257ced22bfe2f (patch)
tree0fbfae9a523835079c9a362a93a69f2e78ccca25 /src/geometry
parent9ac3503b879f95fcdf5414470ba5aedf195b9a97 (diff)
parent6cb727390a6172e539b3f0ef91c2861457495258 (diff)
downloadrapier-aef85ec2554476485dbf3de5f01257ced22bfe2f.tar.gz
rapier-aef85ec2554476485dbf3de5f01257ced22bfe2f.tar.bz2
rapier-aef85ec2554476485dbf3de5f01257ced22bfe2f.zip
Merge pull request #579 from dimforge/joints-improvements
Feat: implement a "small-steps" velocity-based constraints solver + joint improvements
Diffstat (limited to 'src/geometry')
-rw-r--r--src/geometry/contact_pair.rs2
-rw-r--r--src/geometry/narrow_phase.rs8
2 files changed, 7 insertions, 3 deletions
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<Real>,
/// 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,