compute_fov

Function compute_fov 

Source
pub fn compute_fov<F, G>(origin: Pos, is_blocking: &mut F, mark_visible: &mut G)
where F: FnMut(Pos) -> bool, G: FnMut(Pos),
Expand description

Compute FOV information for a given position using the shadow mapping algorithm.

This uses the is_blocking closure, which checks whether a given position is blocked (such as by a wall), and is expected to capture some kind of grid or map from the user.

The mark_visible closure provides the ability to collect visible tiles. This may push them to a vector (captured in the closure’s environment), or modify a cloned version of the map.

I tried to write a nicer API which would modify the map as a separate user data, but I can’t work out the lifetime annotations.