Skip to content

world: city bundles version 2, so a generated world is written and read as a bundle (GB1) - #1385

Merged
transfix merged 1 commit into
masterfrom
feat/world-bundle-v2
Nov 20, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/world-bundle-v2

Conversation

@transfix

Copy link
Copy Markdown
Owner

The first phase of ARIADNE_WORLDS §18.8 (design in #1380): a generated world can be written as a city bundle and read back as the same world.

Version 2 bundle (version 1 still loads unchanged). city_bundle_bytes writes the files in memory:

  • world.json: the surface table by name, every item (file, roles, surface, placement), edge walls, region, water level, the generator with its seed and params, and a content hash (city_bundle_hash: SHA-256 over every other file, in name order);
  • terrain.json plus terrain.f32 (heights, north first), and terrain_surfaces.u16 (one surface per cell: the nav and contact materials);
  • a glb per mesh item, one mesh per surface, with vertices in first-use order so that reading and writing again gives the same bytes;
  • any extra files the caller adds.

load_city_bundle reads version 2 when a bundle has world.json. write_city_bundle writes the files to a directory, and city_bundle_memory_reader reads them from memory.

glb through assimp. The model handler's write used to throw. It now exports through assimp's glTF 2 exporter, and a new write_model_to_memory does the same without a file. read_model_from_memory gains an exact mode (no joined vertices, no generated normals, lines kept). Builds without assimp throw unsupported_model_file_type, and the tests skip there.

Generated worlds. generated_world_bundle writes geometry()'s items, the needles, the water level and the generator. generated_world_params_json and generated_world_params_from_json round-trip the params, for the seed-and-hash path.

Tests (world_bundle_v2_test, MSVC Release, all pass):

  • a glb reads back exactly;
  • a world reads back with the same terrain heights, cell surfaces, items, roles, placement and face surfaces, and writes the same bytes again;
  • a directory reads the same as memory;
  • bad bundles say why;
  • a generated world reads back as the same world, and the same params give the same hash;
  • two loads simulate to the same Jolt state hash, and the loaded terrain matches the generated one within 1 cm.

The existing CityBundle, PhysicsWorldGeometry, AriadneData and model tests pass (77 in ctest).

Not in this PR: the dataset path (GB2), the renderer (GB3), the lab's save (GB4), clients (GB5). The props' LOD rungs, streets.json and ground.png come with the renderer.

…ad as a bundle (GB1)

ARIADNE_WORLDS section 18.8, first phase. A world_geometry is written as a
version 2 city bundle, the files in memory so the browser writes what
natively does:
- world.json: the surface table by name, every item (file, roles, surface,
  placement), edge walls, region, water level, the generator with its seed
  and params, and a content hash;
- terrain.json with its heights in terrain.f32, and terrain_surfaces.u16
  (one surface per cell: the nav and contact materials);
- a glb per mesh item, one mesh per surface, vertices in first-use order so
  what is read writes the same bytes again.
load_city_bundle reads version 2 when a bundle has world.json; version 1
loads as before.

The glb comes from assimp's glTF 2 exporter: the model handler's write and a
new write_model_to_memory fill what used to throw. read_model_from_memory
gains an exact mode (no joined vertices or generated normals, lines kept),
and lines read back.

generated_world_bundle writes a generated world (geometry()'s items, the
needles, the water level, the generator), and generated_world_params_json
round-trips its params.

Tests (world_bundle_v2_test): a glb reads back exactly; a world reads back
with the same terrain, cell surfaces, items, roles, placement and face
surfaces, and writes the same bytes again; a directory reads as memory does;
bad bundles say why; a generated world reads back as the same world, the
same params make the same hash; two loads simulate to the same state hash
and the loaded terrain is the generated one to Jolt.
@transfix
transfix enabled auto-merge (squash) November 20, 2026 03:38
@transfix
transfix merged commit 75aff9c into master Nov 20, 2026
29 checks passed
@transfix
transfix deleted the feat/world-bundle-v2 branch November 20, 2026 05:59
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