+
+ pub fn intersect_walls(&self, p1: Point<f64>, p2: Point<f64>) -> IntersectResult {
+ let c = point!(p2.x as isize / self.wall_grid.cell_size.width as isize, p2.y as isize / self.wall_grid.cell_size.height as isize);
+ if let Some(walls) = self.wall_grid.at(c) {
+ for w in walls {
+ if let Intersection::Point(p) = Intersection::lines(p1, p2, w.p1, w.p2) {
+ let wall = Wall {
+ edge: Rc::clone(&w),
+ };
+ return IntersectResult::Intersection(wall, p)
+ }
+ }
+ }
+ IntersectResult::None
+ }
+}
+
+pub enum IntersectResult {
+ Intersection(Wall, Point<f64>),
+ None