An implementation of Adam Millazo's FOV algorithm
Taken from the "terminal" example
To use it you must implement the [VisibilityMap] trait on your map type. Then you can call fov::compute
with your map
which will populate visible tiles based on the map's opaque tiles.
```rust use adamfovrs::{VisibilityMap, fov}; use glam::IVec2;
struct Map {
visible: Vec
impl VisibilityMap for Map { fn isopaque(&self, p: IVec2) -> bool { self.opaque[p.x as usize][p.y as usize] } fn isinbounds(&self, p: IVec2) -> bool { p.cmpge(IVec2::ZERO).all() && p.cmplt(self.size).all() } fn setvisible(&mut self, p: IVec2) { self.visible[p.x as usize][p.y as usize] = true; } fn dist(&self, a: IVec2, b: IVec2) -> f32 { a.asf32().distance(b.asf32()) } }
fn calc_fov(map: &mut Map, p: IVec2) { fov::compute(p, 5, map); } ```