Skip to content

Commit

Permalink
Fix collision-detection regression with convex polyhedron caused by t…
Browse files Browse the repository at this point in the history
…he internal edges handling
  • Loading branch information
sebcrozet committed Feb 26, 2023
1 parent e058023 commit 03aee7d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/query/contact_manifolds/contact_manifolds_pfm_pfm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::query::{
};
use crate::shape::{PackedFeatureId, PolygonalFeature, PolygonalFeatureMap, Shape};
use na::Unit;
use std::any::Any;

/// Computes the contact manifold between two convex shapes implementing the `PolygonalSupportMap`
/// trait, both represented as `Shape` trait-objects.
Expand Down Expand Up @@ -92,13 +93,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
7 changes: 7 additions & 0 deletions src/shape/polygonal_feature_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ 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.
fn is_convex_polyhedron(&self) -> bool {
false
}
}

impl PolygonalFeatureMap for Segment {
Expand Down

0 comments on commit 03aee7d

Please sign in to comment.