dimforge / parry

2D and 3D collision-detection library for Rust.
https://parry.rs
Apache License 2.0
534 stars 93 forks source link

`Triangle::contains_point` gives false-positives #75

Closed wlinna closed 2 months ago

wlinna commented 2 years ago

Triangle::contains_point gives false-positives. I have a point and a triangle pair for which rapier3d::parry::query::PointQuery::distance_to_local_point returns 0.15627049. When I check the point and the triangle visually, the point is clearly NOT at/in the triangle. However, Triangle::contains_point returns true for the pair. Here's the code to reproduce.

        let p = na::Point3::new(22.01,3.7,-0.291);
        let tri = rapier3d::prelude::Triangle::new(
            na::Point3::new(21.94, 3.7, 0.0), 
            na::Point3::new(22.255, 3.7, -0.315),
            na::Point3::new(22.255, 3.5, -0.315)
        );
        let dist = rapier3d::parry::query::PointQuery::distance_to_local_point(&tri, &p, true);
        dbg!(dist); // 0.15627049
        assert!(!tri.contains_point(&p)); // FAILS

I'm using rapier3d 0.11.1, which still installs the old parry3d 0.7.1.

wlinna commented 2 years ago

Just tested this on parry3d 0.9, and the bug remains. The numbers haven't changed

wlinna commented 2 months ago

I tested this with parry 0.14, and the bug is gone Fixed by https://github.com/dimforge/parry/pull/78