Skip to content

generated_world G1: terrain sources, generators by name, the terrain as a geometry source - #976

Merged
transfix merged 2 commits into
masterfrom
feat/world-terrain-source
Nov 2, 2026
Merged

transfix merged 2 commits into
masterfrom
feat/world-terrain-source

Conversation

@transfix

@transfix transfix commented Nov 2, 2026

Copy link
Copy Markdown
Owner

G1 of docs/roadmap/GENERATED-WORLD-ROADMAP.md (now revision 3): one terrain interface, generators switchable by name, and the terrain as an Ariadne geometry source.

Terrain sources

  • cvc::world::terrain_source (inc/cvc/world/terrain_source.h): sample, slope_deg, bounds(), the datum the raster's classes scale by (sea_level_m, relief_m), and optional buildable / channel / cliff masks. world::heightfield implements it.
  • raster_heightfield: a gridded relief (bilinear, clamped to its edge, optional mask planes) for any generator's DEM. sample_terrain rasterizes any source; read_npy and load_dem read an elevation .npy (anchored at 0, stretched to the relief).
  • world_model (terrain()), raster(), the scatter and the city take the interface; world_params::terrain hands one in.

Generators by name

  • generated_world_params::terrain (fbm, dem) and ::city (districts, none), plus terrain_file. register_terrain_generator / register_city_generator add a host's own; an unknown name throws before any work.
  • The city respects a generator's masks: roads avoid the water and the channel / cliff masks, lots also stay on the buildable mask, district centres keep off blocked ground.
  • The generated_world node reads terrain: / city: / terrain_file:, seeds world.terrain / world.city / world.terrain_file, and publishes the registered names for world_controls.ari's new Terrain and City combos. A failing generator keeps the world and reports the error in world.status.

The terrain as a geometry source

  • source: { terrain: { generator, size, resolution, seed, amp, file, preset } } in any document, or heightfield: { generator: ... } with its layers on top. It is a heightfield, so ground:, bodies and band colours work on it.

Bugs fixed on the way

  • The fBm seed was XORed with the world seed (the same number), so every seed stood on the same ground. The default world is now seed 5: its two towns fill the 110 buildings asked (seed 7 builds 76 on its new ground).
  • The city's buildings were never stamped into the material / occupancy raster. They are now occupied, hard concrete-wall cells, at least one per building.
  • The terrain mesh's cells read the raster's material half a cell off.
  • road_network::distance_to_road scanned every segment when no road was within about 30–60 m, which on a big world is most queries. New distance_within(x, y, r) bounds a query (used by on_or_near_road and the lots' block-depth probe), and distance_to_road widens its window instead of scanning. Results are unchanged.

Measured (native Release, this box, CVC_TL_PROF=1 terrain_lab --half H): a 5 km world (half 2500) generated in 10.0 s, 8.0 s of it in the city's proximity queries; it now takes about 1.4 s (city 8,041 → 132 ms). A 1.2 km world takes about 0.5 s. The World half slider already goes to 10 km.

Tested locally (Windows, MSVC 14.44, Release): world_terrain (6, new), world_generated (13), world_roads (12), world_sites (14), world_raster, world_scatter, world_heightfield, world_bundle, world_geometry, world_buildings, world_road_mesh, world_road_raster, world_surface, nav_world_planes, nav_material_raster, system_macro_headers, physics_world, ariadne_loader (214 incl. the new TerrainSource; AriadneUri.StoreFileAtomicallyOverwrites failed once and passed 5/5 on rerun, a Windows rename flake in the URI store), cvcgl_ariadne_realize (new checks: published generator names, a city switch, an unknown generator kept, the terrain source matches the fbm generator) and cvcgl_ariadne_physics. arigl renders terrain_lab.ari (new thumbnail). Not run: the wasm build and browser timing; the gallery deploy is broken on master until #975 merges.

Still to do in G1's area: a polyline → road_network converter for an imported street map, and a service road kind.

…as a geometry source

- cvc::world::terrain_source (sample, slope, bounds, datum, optional buildable / channel / cliff
  masks); heightfield implements it; raster_heightfield is a gridded relief for any generator's
  DEM; sample_terrain rasterizes any source; read_npy + load_dem read an elevation .npy.
  world_model, raster(), the scatter and the city take the interface.
- Generators by name: generated_world_params::terrain ("fbm", "dem") and ::city ("districts",
  "none"), register_terrain_generator / register_city_generator for a host's own. The
  generated_world node reads terrain: / city: / terrain_file:, seeds world.terrain / world.city /
  world.terrain_file, publishes the registered names, and keeps the world on a failure with the
  error in world.status; world_controls.ari gets Terrain and City combos.
- The terrain as a geometry source: source: { terrain: {...} }, or a heightfield with a
  generator: (its layers add on top).
- Fixes: the fBm seed was XORed with itself, so every seed had the same ground (the default
  world is now seed 5); the city's buildings were never in the material / occupancy raster;
  terrain cells read the raster half a cell off; distance_to_road scanned every segment when no
  road was within about 30 to 60 m (distance_within bounds a query): a 5 km world generated in
  10 s and now takes about 1.4 s natively.
- GENERATED-WORLD-ROADMAP.md revision 3; ARIADNE.md; a new gallery thumbnail.
@transfix
transfix enabled auto-merge (squash) November 2, 2026 19:09
@transfix
transfix merged commit 6cc8cfd into master Nov 2, 2026
21 of 27 checks passed
@transfix
transfix deleted the feat/world-terrain-source branch November 2, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant