How can I retrieve all intersection points between a line and a mesh?

I’m trying to obtain all intersection points between a line and a mesh by using the line trace functions. In a simple scenario with two cubes, the line trace functions only return the first hit on each cube’s component. For example, if a line passes through the front and back face of a cube, it only returns the first hit (e.g., the front face) and then continues to return the first hit on the second cube. How can I retrieve all the intersection points?

some one suggested using the first result to construct a second line trace to obtain all the points, but once inside the cube, the trace function doesn’t return anything. Additionally, some one mentioned tracing again from the back, which might work for a cube but not for more complex polyhedrons.

Do you have any ideas to address this issue, or should I explore alternatives to the line trace functions as it may not be the right approach?

Below are the images illustrating the situation. As you can see, the two front faces are hit but the back faces are not checked.

Linetraces only works when hit a face with the normals in the opposite direction.
(the ‘visible’ side).

What you can do is once you recursively get the hits from side A,
then you make line traces in the opposite direction from
last trace position to first one and then get hits from B sides :slight_smile:

it needs to recursively use line tracing from both sides. Do we have any simple solutions available for this?

OK, it worked, although looks a bit strange, but it still a solution.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.