ncollide
ncollide copied to clipboard
Point-in-mesh containment check which treats mesh as solid
This could use ray casting.
Workaround
fn mesh_contains_point<T: RealField>(mesh: &TriMesh<T>, point: &Point3<T>) -> bool {
if !mesh.aabb().contains_local_point(point) {
return false;
}
match mesh.toi_and_normal_with_ray(
&Isometry3::identity(),
&Ray::new(*point, Vector::new(T::one(), T::zero(), T::zero())),
false, // unused
) {
Some(intersection) => mesh.is_backface(intersection.feature),
None => false,
}
}
Issues
- Assumes mesh is well-formed (watertight and correctly wound)
- Depends on ray casting for point queries, which is not necessarily ideal for keeping things modular
Note some weirdness around handling of intersection with edges in that workaround.