Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point-in-mesh containment check which treats mesh as solid #317

Open
clbarnes opened this issue Nov 27, 2019 · 1 comment
Open

Point-in-mesh containment check which treats mesh as solid #317

clbarnes opened this issue Nov 27, 2019 · 1 comment

Comments

@clbarnes
Copy link

clbarnes commented Nov 27, 2019

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

  1. Assumes mesh is well-formed (watertight and correctly wound)
  2. Depends on ray casting for point queries, which is not necessarily ideal for keeping things modular
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant