In a 2D grid world with known boundary, there are :-
org
)How to ray trace from center of every white block in the grid to center of org
efficiently?
For each block, I want a single boolean - whether it is lit.
In other words, I want the determine whether org
can see each block (for whole world) directly or not.
Use standard ray tracing to trace each and every white block toward org
, but its performance is very bad. I feel that a lot of computation is redundant.
Related : https://en.wikipedia.org/wiki/Any-angle_path_planning : The algorithm is still for one white block - not the whole world.
You can use Line algorithms like Bresenham's line algorithm or Xiaolin Wu's line algorithm to find the pixels in the path.
The same can be used for multiple lights as well. This will be efficient, as you only calculate one line for each pixel.