Skip to content

Commit

Permalink
Merge pull request #127 from dimforge/fix-convex
Browse files Browse the repository at this point in the history
Fix collision-detection regression with convex polyhedron caused by the internal edges handling
  • Loading branch information
sebcrozet authored Feb 26, 2023
2 parents e058023 + 62c5ab7 commit dcce08c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/query/contact_manifolds/contact_manifolds_pfm_pfm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ pub fn contact_manifold_pfm_pfm<'a, ManifoldData, ContactData, S1, S2>(
false,
);

if manifold.points.is_empty() {
// cfg!(feature = "dim3") || (cfg!(feature = "dim2") && manifold.points.is_empty()) {
if (cfg!(feature = "dim2") && manifold.points.is_empty())
// TODO: this test is a workaround until we figure-out a way to
// determine the feature ids for the GJK/EPA contact.
|| pfm1.is_convex_polyhedron()
|| pfm2.is_convex_polyhedron()
{
let contact = TrackedContact::new(
p1,
pos12.inverse_transform_point(&p2_1),
PackedFeatureId::UNKNOWN, // FIXME: We don't know what features are involved.
PackedFeatureId::UNKNOWN, // FIXME
PackedFeatureId::UNKNOWN, // TODO: We don't know what features are involved.
PackedFeatureId::UNKNOWN,
(p2_1 - p1).dot(&dir),
);
manifold.points.push(contact);
Expand Down
4 changes: 4 additions & 0 deletions src/shape/convex_polyhedron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,10 @@ impl PolygonalFeatureMap for ConvexPolyhedron {
out_feature.fid = PackedFeatureId::face(best_fid as u32);
out_feature.num_vertices = num_vertices as usize;
}

fn is_convex_polyhedron(&self) -> bool {
true
}
}

/*
Expand Down
8 changes: 8 additions & 0 deletions src/shape/polygonal_feature_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ use na::{ComplexField, RealField}; // for .abs() and .copysign()
pub trait PolygonalFeatureMap: SupportMap {
/// Compute the support polygonal face of `self` towards the `dir`.
fn local_support_feature(&self, dir: &Unit<Vector<Real>>, out_feature: &mut PolygonalFeature);

// TODO: this is currently just a workaround for https://github.com/dimforge/rapier/issues/417
// until we get a better way to deal with the issue without breaking internal edges
// handling.
/// Is this shape a `ConvexPolyhedron`?
fn is_convex_polyhedron(&self) -> bool {
false
}
}

impl PolygonalFeatureMap for Segment {
Expand Down

0 comments on commit dcce08c

Please sign in to comment.