Repository navigation
world: save the terrain lab's world as a bundle, with exports for other software (GB4) - #1518
Merged
Merged
Conversation
transfix
force-pushed
the
feat/gb4-lab-save
branch
from
November 24, 2026 03:05
05baf41 to
447a14e
Compare
transfix
force-pushed
the
feat/gb4-lab-save
branch
from
November 24, 2026 21:01
447a14e to
028d504
Compare
… software world_controls' Save sends world.request: save; both generated_world hosts save the world shown (its dataset) with the new data_save_files: a directory, or a zip for a .zip name and always in a browser (a download). With exports it adds export/terrain.glb, a 16-bit export/heightmap.png and heightmap.json (world::city_bundle_exports); the content hash leaves export/ out, so a saved world loads back with the hash it was saved with. Also: archive::pack_zip and archive::deflate (stb_image_write's compressor), encode_png writes grey u16 at 16 bits, write_city_bundle writes subdirectories, and (data-save-files NAME TARGET [EXPORTS]) for programs.
transfix
force-pushed
the
feat/gb4-lab-save
branch
from
November 25, 2026 00:11
028d504 to
5f1ed08
Compare
transfix
enabled auto-merge (squash)
November 25, 2026 00:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GB4 of ARIADNE_WORLDS section 18.8: the terrain lab saves its world. Natively it writes a directory or a zip; in the browser it downloads a zip. A save can also include the terrain as a mesh and a 16-bit height map for other software. The saved world loads again as the same world, with the same hash.
What changes
world_controls: a "Save as" field (world.save.file), a "With terrain mesh and height map" checkbox (world.save.exports), a Save button and a status line (world.save.status).world.request: save, through the same request key as Regenerate and Stop. A save is not a rebuild.save_asprop, else its dataset's name (world). Natively that makes a directory beside the document; a name ending in.zipmakes one zip. In a browser the save is always a.zipdownload.GeneratedWorldRuntimeboth call the newsave_generated_world. It saves the node's dataset (the bundle files GB2 already puts in the store) and writes where it went, orerror: ..., toworld.save.status.data_save_files(data.h), and(data-save-files NAME TARGET [EXPORTS])for programs:.zipand always in a browser.data: { x: { uri: <it>, as: city_bundle } }.world::city_bundle_exports), underexport/:terrain.glb: the terrain as a mesh, one mesh per surface its cells use, through the same glb writer as the bundle's other items. A terrain over 1025 samples a side is resampled over the same extent.heightmap.png: 16-bit grey at full size, the north row at the top.height = min_height_m + value / 65535 * (max_height_m - min_height_m).heightmap.json: the size, bounds, spacing, height range, water level and the mesh's size.city_bundle_hashnow leavesexport/out, so a bundle with or without its exports has one hash.write_city_bundlewrites a name with a/into its subdirectory and refuses one that climbs out.archive::pack_zipandarchive::deflate(archive.h):detail::stb_zlib_compressin stb_io.cpp. No new dependency.encode_pngwrites grey u16 at 16 bits (Sub filter, big-endian samples). Before, it converted grey u16 to RGBA u8. Every other format is unchanged.Tests
ariadne_data_test:Archive.PackZipRoundTripsDeflatedAndStoredEntries: unpack gives the same files in the same order; the bytes are the same every time; the deflate stream inflates; unsafe and duplicate paths throw.ImageEncode.AGrey16PngKeepsItsSamples: the header says 16-bit grey; the IDAT inflates to exactly the expected filtered rows; an 8-bit read gives each sample's high byte.world_bundle_v2_test,CityBundleV2.AWorldsExportsAreItsTerrainForOtherSoftware:export/, and a directory withexport/loads as the same bundle.ariadne_world_dataset_test:WorldDataset.ASavedWorldLoadsAgainAsTheSameWorld: a generated world saved as a directory, a zip, and a directory with exports loads back each time with the same manifest hash, the same hash over its files, the same terrain and the same collide items; bad saves throw.WorldDataset.AGeneratedWorldNodeSavesOnRequest: a node'ssaverequest writes a zip, then a directory withexport/; the status sayssaved ...; the world isn't rebuilt; a file in the way giveserror: ....Locally (MSVC Release, full build): the new tests pass (
ariadne_data_testArchive/ImageEncode 9 of 9,world_bundle_v2_test10 of 10,ariadne_world_dataset_testWorldDataset 9 of 9), and the broad filter (world, ariadne, data, nav, bundle and cvcGL ariadne tests) passes 2,144 of 2,144,cvcgl_ariadne_dataamong them.Stacked on #1508 (GB3 part 2): until it merges, this PR's diff also shows its commit. I'll rebase onto master once it squash-merges.
Not in this PR