fix(simulation): Layer-1 self-describing grid dims + Moore basin trace (#960)

Two Layer-1 generation fixes surfaced by the per-layer atlas viewer:

- Layer1Output now carries grid_w/grid_h (the downsampled working-grid the
  positions live in). The client maps overlays from these, so the scale is
  correct for any source heightmap resolution rather than assuming the texture
  size — fixes overlays projecting at half scale into a corner.
- Drainage basin boundaries are traced as ordered, non-self-crossing contours
  via Moore-neighbour tracing instead of an angle-from-centroid sort. The sort
  produced star-shaped, self-crossing polygons for concave basins that rendered
  as straight chords across the map.

Golden (cascade_layer1.json) and the cross-language atlas_response_ready
fixture regenerated. 100 atlas lib tests + the new tracer test pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-25 10:02:32 +02:00
co-authored by Claude Opus 4.7
parent c3bcf09c72
commit adbd7f6744
6 changed files with 3074 additions and 2369 deletions
+8
View File
@@ -32,6 +32,12 @@ pub struct Layer1Output {
/// Geographic attractors (D-209) with sub-biome + cost (D-210), sorted by
/// `(attractor_type, row, col)`.
pub attractors: Vec<GeographicAttractor>,
/// Working-grid dimensions every position in this output (river cells, basin
/// boundaries, attractor positions) is expressed in — equals the downsampled
/// heightmap size. The client maps these onto the displayed heightmap (#960),
/// so the overlay scale stays correct for any source resolution (mod-safe).
pub grid_w: u32,
pub grid_h: u32,
}
/// Run the Layer-1 topography pipeline for a single body.
@@ -60,6 +66,8 @@ pub fn run_layer1(hm: &BodyHeightmap) -> Layer1Output {
river_network: drainage.river_network,
drainage_basins: drainage.drainage_basins,
attractors,
grid_w: hm.width,
grid_h: hm.height,
}
}