feat(citygen): per-theme street subdivision and blocks

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jeffrey Wilcke
2026-10-12 16:53:26 +02:00
parent 6ba66d5e63
commit 9cc97b87cf
3 changed files with 508 additions and 2 deletions

View File

@@ -130,7 +130,7 @@ impl StageRunner for ArterialsStage {
#[cfg(test)]
mod tests {
use crate::generate::testutil::small;
use crate::geom::Rect;
use crate::geom::{Grid, Rect};
use crate::params::WaterMode;
use crate::pathing::components;
use crate::tile::Terrain;
@@ -152,7 +152,16 @@ mod tests {
.any(|p| st.tiles.get(p).is_some_and(|t| t.terrain == Terrain::Road));
assert!(near, "district {:?} centre not on road", d.id);
}
let comps = components(st.tiles.size(), |p| st.tiles[p].terrain == Terrain::Road);
// The arterial stamps themselves form one connected network.
let mut mask = Grid::filled(st.tiles.size(), false);
for path in &c.arterials {
for p in path {
mask.fill_rect(Rect::new(p.x - 1, p.y - 1, 4, 4), true);
}
}
let comps = components(st.tiles.size(), |p| {
mask[p] && matches!(st.tiles[p].terrain, Terrain::Road | Terrain::Bridge)
});
assert_eq!(comps.len(), 1);
}