style(simulation): gate bounce — box GenCompletion::BodyAnalyzed state; clippy/fmt sweeps

BodyWorldState grew past clippy's large-enum-variant threshold when it
began retaining Layer1Output (T-1170 Ruling 4b) — boxed, with the two
insert sites deref'd; manual_contains x2 (drainage tests),
cloned_ref_to_slice_refs x3 (river_course tests), fmt wraps.
gen_queue 18/18; clippy -D warnings clean; fmt --check clean.

Tickets: T-1170

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 14:14:23 +02:00
co-authored by Claude Fable 5
parent 27fab8566a
commit 958de5420e
6 changed files with 232 additions and 59 deletions
+61 -17
View File
@@ -15,9 +15,7 @@ use bevy_ecs::prelude::Resource;
use serde::{Deserialize, Serialize};
use crate::atlas::body_params_reader::BodyParamsReader;
use crate::atlas::body_world_state::{
BodyWorldState, BodyWorldStateCache, RiverNetwork, SimTick,
};
use crate::atlas::body_world_state::{BodyWorldState, BodyWorldStateCache, RiverNetwork, SimTick};
use crate::atlas::cascade::CascadeLayer;
use crate::atlas::city_context_reader::CityContextReader;
use crate::atlas::district_profile::{BodyParams, DistrictPos};
@@ -1206,7 +1204,8 @@ fn invent_courses_near_window(
ta.h,
params.body_radius_km,
);
let chord_m = ((anchor_a.0 - anchor_b.0).powi(2) + (anchor_a.1 - anchor_b.1).powi(2)).sqrt();
let chord_m =
((anchor_a.0 - anchor_b.0).powi(2) + (anchor_a.1 - anchor_b.1).powi(2)).sqrt();
let inflate_m = chord_m * COURSE_BBOX_INFLATION_FRACTION;
let (bx0, bx1) = (
anchor_a.0.min(anchor_b.0) - inflate_m,
@@ -1321,8 +1320,15 @@ fn crop_course_to_window(
EdgeTerminusKind::EdgeDrain => CourseTerminus::EdgeDrain,
EdgeTerminusKind::Interior => CourseTerminus::ContinuesBeyondWindow,
EdgeTerminusKind::Mouth => {
match resolve_mouth_terminus(course, seed, body_id, params, ta, climate, min_wavelength_m)
{
match resolve_mouth_terminus(
course,
seed,
body_id,
params,
ta,
climate,
min_wavelength_m,
) {
Some(mouth_point) => {
// Replace the cropped course's tail with the resolved
// mouth point (bisected against the last land
@@ -1521,8 +1527,15 @@ pub fn build_district_window_layer(
// delta close to the Discipline item 2 ~5% budget.
let step_m = granularity.spacing_m();
let window_rect = window_world_rect(center_world_m, half, side, step_m);
let invented_courses =
invent_courses_near_window(seed, params, ta, river_network, window_rect, granularity, min_wavelength_m);
let invented_courses = invent_courses_near_window(
seed,
params,
ta,
river_network,
window_rect,
granularity,
min_wavelength_m,
);
// One Rayon task per row: derive_window_cell(row, ..) for every col, then
// scatter that row's results into the flat arrays. Row order in the
@@ -1624,8 +1637,15 @@ fn build_district_window_layer_serial(
let mut glaciation = vec![0u8; cells];
let step_m = granularity.spacing_m();
let window_rect = window_world_rect(center_world_m, half, side, step_m);
let invented_courses =
invent_courses_near_window(seed, params, ta, river_network, window_rect, granularity, min_wavelength_m);
let invented_courses = invent_courses_near_window(
seed,
params,
ta,
river_network,
window_rect,
granularity,
min_wavelength_m,
);
for row in 0..side {
let row_cells: Vec<WindowCell> = (0..side)
.map(|col| {
@@ -2783,13 +2803,37 @@ mod tests {
// Two DIFFERENT window rects, both containing `mid` well inside
// their bounds (so both windows' crop ranges include the shared
// stretch, not just a single boundary point).
let window_a = (mid.0 - 20_000.0, mid.1 - 20_000.0, mid.0 + 5_000.0, mid.1 + 5_000.0);
let window_b = (mid.0 - 5_000.0, mid.1 - 5_000.0, mid.0 + 20_000.0, mid.1 + 20_000.0);
let window_a = (
mid.0 - 20_000.0,
mid.1 - 20_000.0,
mid.0 + 5_000.0,
mid.1 + 5_000.0,
);
let window_b = (
mid.0 - 5_000.0,
mid.1 - 5_000.0,
mid.0 + 20_000.0,
mid.1 + 20_000.0,
);
let invented_a =
invent_courses_near_window(seed, &params, &ta, rn, window_a, WindowGranularity::District, 0.0);
let invented_b =
invent_courses_near_window(seed, &params, &ta, rn, window_b, WindowGranularity::District, 0.0);
let invented_a = invent_courses_near_window(
seed,
&params,
&ta,
rn,
window_a,
WindowGranularity::District,
0.0,
);
let invented_b = invent_courses_near_window(
seed,
&params,
&ta,
rn,
window_b,
WindowGranularity::District,
0.0,
);
let course_a = invented_a
.iter()
@@ -5300,7 +5344,7 @@ mod tests {
// Serve the completed state back through the proxy: the cache-hit
// branch must build and include the region grid.
cache.insert(body_state);
cache.insert(*body_state);
let ready = handle_atlas_request(
&req("GJ1c"),
&mut cache,