fix(simulation): review follow-ups on foundation types (#1006)

- Derive MorphologyZone Default (#[default] AlluvialPlain), drop manual
  impl — clears the clippy --all-targets warning (pre-push gate).
- Fix floor_at_voxel_z doc (described the inverse function).
- Document floor_at_voxel_z / voxel_range_for_floor voxel-z as
  building-relative (base_floor = z:0) for #982-985 callers.
- TODO(#957): districts keyed by city_id is a stub; use district_id.

clippy --all-targets clean; 1259 lib tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-30 19:16:03 +02:00
co-authored by Claude Opus 4.8
parent 46b8688fa3
commit 899f447eed
3 changed files with 27 additions and 17 deletions
+1 -4
View File
@@ -111,10 +111,7 @@ pub enum GenCompletion {
block_pos: (u32, u32),
},
/// Work item failed — body_id or city_id for logging.
Failed {
item: GenWorkItem,
reason: String,
},
Failed { item: GenWorkItem, reason: String },
}
// ---------------------------------------------------------------------------
+2
View File
@@ -88,6 +88,8 @@ fn drain_generation_completions(
} => {
if !body_id.is_empty() {
if let Some(body_state) = cache.peek_mut(&body_id) {
// TODO(#957): keying by city_id is a stub — a city has multiple districts;
// use DistrictSkeleton.district_id as the DistrictId key when real skeleton gen lands.
body_state.districts.insert(city_id, state);
} else {
tracing::warn!(
+24 -13
View File
@@ -555,9 +555,13 @@ impl FloorExtent {
}
}
/// Map a D-110 floor index to the first voxel-z value at that floor's base.
/// Map a building-relative voxel-z coordinate to the D-110 floor index that contains it.
///
/// Returns `None` if `floor_index` is outside `[base_floor, base_floor + floor_count)`.
/// Returns the floor index whose voxel span covers `voxel_z`, or `None` if `voxel_z`
/// falls outside the building's extent (below base floor or above the topmost floor).
///
/// `voxel_z` is building-relative: the base floor maps to z = 0. Callers working in
/// world space must subtract the building's world-base z offset before calling this method.
pub fn floor_at_voxel_z(&self, voxel_z: i32) -> Option<i8> {
let voxel_z_for_base = self.voxel_z_for_floor(self.base_floor)?;
if voxel_z < voxel_z_for_base {
@@ -584,6 +588,9 @@ impl FloorExtent {
/// Map a D-110 floor index to the inclusive voxel-z range `(min_z, max_z)`.
///
/// Returns `None` if `floor_index` is outside the building's extent.
///
/// The returned range is building-relative: the base floor maps to z = 0. Callers working
/// in world space must add the building's world-base z offset to the returned values.
pub fn voxel_range_for_floor(&self, floor_index: i8) -> Option<(i32, i32)> {
let base_z = self.voxel_z_for_floor(self.base_floor)?;
let relative = floor_index as i16 - self.base_floor as i16;
@@ -741,15 +748,24 @@ pub enum DoorInitialState {
pub enum DoorCredential {
None,
/// Door is only accessible during specified hours (023, inclusive range).
TemporalWindow { open_hour: u8, close_hour: u8 },
TemporalWindow {
open_hour: u8,
close_hour: u8,
},
/// Requires an employment credential from this corporation.
Corporate { corp_id: String },
Corporate {
corp_id: String,
},
/// Requires a residence credential in this block.
Resident { block_id: String },
Resident {
block_id: String,
},
/// Law-enforcement / government authority only.
Authority,
/// Social trust score threshold (basis points; D-010 integer, 10 000 = 1.0).
Social { trust_threshold_bps: u32 },
Social {
trust_threshold_bps: u32,
},
}
/// What a door connects to on the other side (D-231).
@@ -807,7 +823,7 @@ pub struct DoorSpec {
/// Shared by all tiles in a region; constrains street geometry (D-234)
/// and acts as a soft weight on cultural-template eligibility (D-232).
/// Carried on `CityGenerationContext` (D-233 amend to D-199).
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)]
pub enum MorphologyZone {
/// Steep-sided inlet — ribbon/hub-and-spoke streets only; pier geometry on water edges.
Fjord,
@@ -816,6 +832,7 @@ pub enum MorphologyZone {
/// Meandering river reach — any pattern.
MeanderReach,
/// Flat alluvial plain — any pattern; primary default for plains settlements.
#[default]
AlluvialPlain,
/// Open ocean surface (deep-water context) — hub-and-spoke; perimeter access priority.
OpenOcean,
@@ -835,12 +852,6 @@ pub enum MorphologyZone {
Unknown,
}
impl Default for MorphologyZone {
fn default() -> Self {
MorphologyZone::AlluvialPlain
}
}
/// Built-form archetype derived from a settlement's dominant commodity (D-233).
///
/// 5 archetypes projected from the 8 cargo-type classifications in `commodities.toml`;