FOV algorithms return a set coordinates, visible from a starting place. Computing these works in the same fashion as Map generators do: using a user-supplied callback function. This time, however, user has to supply two callbacks:
compute
method, which receives FOV data.Input callback is called by the FOV algorithm to retrieve visibility information for a given coordinate pair. This callback must return true
(light passes)
or false
(light does nto pass). Output callback is called with these arguments: x
, y
, r
and visibility
:
the meaning is that "the place at [x,y] is visible with a distance of r". The last argument specifies the amount of visibility (0..1).
FOV computation is initiated by calling the compute
method with the following arguments:
x
y
r
– maximum visibility radiuscallback
– output callback functionFor now, there is only one FOV algorithm available: the Precise Shadowcasting.