From 6b79201d217b4be54bb02ea4622bfa30a606afa6 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Sat, 15 Jan 2022 18:00:11 +0000 Subject: [PATCH] Fix an edge case for cell connectivity --- game/src/ltn/auto.rs | 4 ++-- game/src/ltn/mod.rs | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/game/src/ltn/auto.rs b/game/src/ltn/auto.rs index 574310337b..9c70173c0b 100644 --- a/game/src/ltn/auto.rs +++ b/game/src/ltn/auto.rs @@ -139,14 +139,14 @@ fn only_one_border(app: &mut App, neighborhood: &Neighborhood) { .modal_filters .roads .insert(road.id, 0.1 * road.length()); + break; } else if road.dst_i == *i { app.session .modal_filters .roads .insert(road.id, 0.9 * road.length()); + break; } - // Sometimes a cell has multiple roads connecing to the same border, so don't - // stop looking even once we add one filter } } } diff --git a/game/src/ltn/mod.rs b/game/src/ltn/mod.rs index a5280f66e9..8df0568b68 100644 --- a/game/src/ltn/mod.rs +++ b/game/src/ltn/mod.rs @@ -270,14 +270,17 @@ fn floodfill( }, ); for i in [current.src_i, current.dst_i] { + // It's possible for one border intersection to have two roads in the interior of the + // neighborhood. Don't consider a turn between those roads through this intersection as + // counting as connectivity -- we're right at the boundary road, so it's like leaving + // and re-entering the neighborhood. + if neighborhood_borders.contains(&i) { + cell_borders.insert(i); + continue; + } + for next in &map.get_i(i).roads { let next_road = map.get_r(*next); - if !perimeter.interior.contains(next) { - if neighborhood_borders.contains(&i) { - cell_borders.insert(i); - } - continue; - } if let Some(filter) = modal_filters.intersections.get(&i) { if !filter.allows_turn(current.id, *next) { continue;