PDA

View Full Version : Efficient way to return all boxes hit by a ray.



_NoName_
05-25-2017, 12:43 PM
Im not sure if Im right in this forum because my question is not realy about openGL.
I have an idea how I could solve the problem in the title but I want to know your oppinion about that before I waste time In programming something not working.

Basicly the idea is to have a grid of boxes with height = width, all of these boxes are the same size and they don't have a gap between each other, I also have a function to calculate the box index which belongs to a point.

Now I calculate a box around the grid and calculate the hit points of a ray with it.
So I know the intersection points and of course the rays direction, now I take the direction, normalize it and devide it by 2. ( Im not realy sure if I need /2 but I feel better with it)
The resulting vector is now my "step size". (I call this vector v)
So if I take now my first intersection point add v, calculate the box which belongs to the resulting point and do this again and again until I reach my second intersection point I shouldn't miss any box. (rigth ?)

But Im not sure about that so I ask for your oppinion.

Thanks.