From 9d2da632be9de04f835b649a90ad4ae1ee1c3f49 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Mon, 22 Mar 2021 09:38:53 -0700 Subject: [PATCH] Add some disabled validation that paths don't enter an access-restricted zone when they shouldn't. I'm working on an overhaul to pathfinding and zones in another branch, and need some more debugging tools. This one's ready to be checked in now. --- map_model/src/pathfind/mod.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/map_model/src/pathfind/mod.rs b/map_model/src/pathfind/mod.rs index d4c48cece3..c3328e4f7d 100644 --- a/map_model/src/pathfind/mod.rs +++ b/map_model/src/pathfind/mod.rs @@ -132,6 +132,9 @@ impl Path { if false { validate_restrictions(map, &steps); } + if false { + validate_zones(map, &steps, &orig_req); + } let mut path = Path { steps: VecDeque::from(steps), orig_req, @@ -645,6 +648,33 @@ fn validate_restrictions(map: &Map, steps: &Vec) { } } +fn validate_zones(map: &Map, steps: &Vec, req: &PathRequest) { + let z1 = map.get_parent(req.start.lane()).get_zone(map); + let z2 = map.get_parent(req.end.lane()).get_zone(map); + + for step in steps { + if let PathStep::Turn(t) = step { + if map + .get_parent(t.src) + .access_restrictions + .allow_through_traffic + .contains(req.constraints) + && !map + .get_parent(t.dst) + .access_restrictions + .allow_through_traffic + .contains(req.constraints) + { + // Maybe it's fine + let into_zone = map.get_parent(t.dst).get_zone(map); + if into_zone != z1 && into_zone != z2 { + error!("{} causes illegal entrance into a zone at {}", req, t); + } + } + } + } +} + /// Tuneable parameters for all types of routing. // These will maybe become part of the PathRequest later, but that's an extremely invasive and // space-expensive change right now.