dimforge / parry

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

Ray casts which touch a TriMesh edge report intersection with a backface #171

Open clbarnes opened 6 months ago

clbarnes commented 6 months ago

This issue was originally reported on ncollide: https://github.com/dimforge/ncollide/issues/335

Imagine Santa's sled knocking some snow off the top of a roof. It could be argued that no impact happened, or it could be argued that the impact happened with the edge. parry3d reports that Santa collided with the inside of the house.

This is important for using ray casting to determine whether a point is inside a mesh. As per https://github.com/dimforge/ncollide/issues/317, I am casting a ray and checking whether it intersected with a backface. In the motivating example, a point nowhere near the mesh happens to cast a ray which skims a ridge in the mesh: due to this issue, a backface intersection is reported.

The issue is demonstrated here (on the parry branch): https://github.com/clbarnes/ncollide-issue-graze/tree/parry

clbarnes commented 6 months ago

Note that the motivating example for this, containment checks for points in meshes, is now potentially made obsolete by contains_local_point actually doing a solid containment check if the pseudonorms are calculated.