dimforge / parry

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

Treat TriMesh as solid in project_local_point_and_get_feature with dim2 #196

Closed wlinna closed 2 months ago

wlinna commented 2 months ago

Fixes the issue in 2D where project_local_point_and_get_feature of TriMesh would NOT return a triangle enclosing the point. This can happen when two triangles share an edge and that edge is closest to the query point.

This can happen because project_local_point_and_get_feature does not treat TriMesh as solid. However, in 2D TriMeshes can be treated as solid.

This change introduced by this PR is a subtly breaking change, because earlier versions would project to one of the edges. I think breaking this API "contract" is reasonable, because the earlier behavior was misleading, with the returned PointProjection telling that the point was not inside and the feature id being incorrect, and always being set to a Face variant anyway.

sebcrozet commented 2 months ago

That makes sense. Thank you @wlinna for the fix and test cases! And thank you @Ralith for the review.