Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix collision-detection regression with convex polyhedron caused by the internal edges handling #127

Merged
merged 2 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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