Fix an edge case for cell connectivity

This commit is contained in:
Dustin Carlino 2022-01-15 18:00:11 +00:00
parent 3a60a465e0
commit 6b79201d21
2 changed files with 11 additions and 8 deletions

View File

@ -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
}
}
}

View File

@ -270,14 +270,17 @@ fn floodfill(
},
);
for i in [current.src_i, current.dst_i] {
for next in &map.get_i(i).roads {
let next_road = map.get_r(*next);
if !perimeter.interior.contains(next) {
// 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 let Some(filter) = modal_filters.intersections.get(&i) {
if !filter.allows_turn(current.id, *next) {
continue;