If there are no real-time requirements, I would first try brute force.
1M * 1M ray-> triangle tests should not take more than a few minutes (on the CPU).
If this is a problem, the second thing to do is to limit the search area by calculating the graph / adjacency relation between triangles / polygons in the target grid. After the initial assumption fails, you can try neighboring triangles. This, of course, depends on the lack of self-spell / multiple hit points. (which, in my opinion, is one interpretation of "visibility does not apply to this problem").
In addition, depending on how pathological the topologies are, you can try to display the environment of the target cell on a single cube (each pixel will consist of a list of triangles projected onto it) and check the initial candidate for one ray-> abab test + search.
Given the feedback, there is another simple option - dividing the space into a simple 3D grid, where each measurement can be divided into a histogram of x / y / z locations or even regularly.
- 100x100x100 grid has a very manageable size of 1e6 records.
- the maximum number of cubes to visit is proportional to the diameter (max 300)
There are ~ 60,000 extreme cells, which implies an order of 10 triangles per cell
Cautions: triangles should be placed on each cell that they occupy - a conservative algorithm places them in cells to which they do not belong; large triangles are likely to require clipping and reassembly.
source share