fast-voxel-traversal-algorithm
fast-voxel-traversal-algorithm copied to clipboard
the way tMax is calculated covers only one quadrant of directions
I'm trying to understand the suggestion on how to compute tMax
which is describes as below
// grid.minBound.x is the lower left corner of the grid.
// current_X_index is the current X index where the ray begins. If it starts outside, this is 1.
// ray_origin.x is the x-coordinate of where the ray originates.
// ray.direction.x is the x-direction of the ray’s travel path.
tMax = (grid.minBound.x + current_X_index - ray_origin.x) / ray.direction.x);
I think this implies that the direction of travel is always up right. If the travel direction is to the right then I believe it should be:
tMax = (grid.minBound.x + current_X_index - 1 + ray_origin.x) / ray.direction.x);
If anyone else is interested in extending this to all direction quadrants, here is the solution I settled on.