Optimize field of vision algorithm in a grid tiled map
I used to do this with a canned array of vectors which went thru every point within a fixed max distance. Really it neead be no more than +/- 0/1 data for X and Y progression along an angle, a growing offset for eact vector (I even reused the same +/- 0/1 array flopping over its use on each half quandrant 8 similar pattern upon a 45 degree wedge).
You grow vector til you hit then the rest is LOS blocked yeyond.
Its a low cost processing (simplified math and tight loops).
Hmm Amit has a page on this: http://www.redblobgames.com/articles/visibility/
Though, also, you probably don't need to do an actual raycast for the initial check, which I think is what wodinoneeye is saying, you could do a bresenham/wu line walk to check if a tile is empty or not.
Hmm Amit has a page on this: http://www.redblobgames.com/articles/visibility/
Though, also, you probably don't need to do an actual raycast for the initial check, which I think is what wodinoneeye is saying, you could do a bresenham/wu line walk to check if a tile is empty or not.
Actually its not a 'ray trace' but a precanned set of stepped vectors for a fixed radius grid test (the whole surrounding grid from the centerpoint or limited to only some of the 8 half quadrants if a limited boresite is used. That for fast culling of whats NOT within view and then more precise methods can be done on the identified grid edges/boxes (or the now identified sets of objects within those grid boxes). Because of the stepping order, you also get a sequence that might be useful for calculating a progressive partial visibility through intervening obstacles. I used to make the diagonal cases inclusive of assuming visibility (leaving questionable cases to culling later with more accurate methods).
I also used this quick cull method while doing rough influence maps.