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

Ray intersection behavior on edges and vertex #2317

Open
brandonrwin opened this issue Nov 2, 2024 · 1 comment
Open

Ray intersection behavior on edges and vertex #2317

brandonrwin opened this issue Nov 2, 2024 · 1 comment

Comments

@brandonrwin
Copy link

RayMeshIntersector.intersects_location() has the following comment:

If you are counting the number of hits a ray had, this method
should be used as if only the triangle index is used on- edge hits
will be counted twice.

I'm having trouble understanding this, but I think what it's trying to say to me doesn't go far enough.

There's three possibilities for a ray hitting a "sane" mesh:

  1. Hits the interior of a triangle: one hit, one triangle
  2. Hits an edge: two hits, one for each triangle the edge belongs to
  3. Hits a vertex: n hits, one for each triangle the vertex belongs to

So, my questions are:

  1. How does trimesh.ray.raytriangle handle 3? From the comment, it's not clear what I should do in the case of 2 or 3. Maybe we can come up with something that provides some more direct guidance for edges, and a clear indication of vertex behavior.
  2. As is, the comment appears to be incorrect when embree is used (see below).

For embree's handling of edge and vertex hits, a develop said:

For context, I'm making a, probably futile, attempt to quickly use this in a real world scenario, where a ray passing through without detection means real world things get smashed. 😅

@brandonrwin
Copy link
Author

brandonrwin commented Nov 7, 2024

What do you think of this, for a modified comment?

Edge and vertex hits will not be detected reliably. Edges can result in 0, 1, or 2 hits and vertices can result in 0 to n hits, where n is the number of triangles that share that vertex. Multiple rays, with slight offsets, can be used to help prevent the 0 hit case.

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