Add support for the wall height module in the gridless pathfinder

This commit is contained in:
Manuel Vögele
2022-02-28 22:48:15 +01:00
parent 0dfdb23bfb
commit ddf89f9499
3 changed files with 67 additions and 8 deletions
+4 -1
View File
@@ -148,7 +148,7 @@ pub struct Pathfinder {
}
impl Pathfinder {
pub fn initialize<I>(walls: I, token_size: f64) -> Self
pub fn initialize<I>(walls: I, token_size: f64, token_elevation: f64) -> Self
where
I: IntoIterator<Item = Wall>,
{
@@ -162,6 +162,9 @@ impl Pathfinder {
if wall.is_door() && wall.is_open() {
continue;
}
if !wall.height.contains(token_elevation) {
continue;
}
let x_diff = wall.p2.x - wall.p1.x;
let y_diff = wall.p2.y - wall.p1.y;
let p1_angle = y_diff.atan2(x_diff).rem_euclid(2.0 * PI);