Repository navigation
world_build: place models at their map placements (--placements) - #1183
Conversation
world_build placed every model at its own coordinates or in rows; it never read the CEntityDef records. - world_index.py --entities-out writes one JSON line per complete entity: archetype hash and 64-bit key, position, stored rotation, scales and LOD fields. - world_build.py --placements matches each selected entity to an exported model the way world_names.py does (lower-cased joaat of the manifest name, confirmed by the Murmur3-64 key when the row has one). It then scales by (scaleXY, scaleXY, scaleZ), rotates by the conjugate of the stored quaternion, translates and converts to glTF Y-up. Normals use the inverse-transpose; a mirroring scale flips the winding. --lod-levels (default 0,5) and --region select the entities. world.json reports the count of each outcome in stats.placements. - tests/test_world_place.py: 15 synthetic tests. - docs/world.md: "Building a placed world", with measurements on a 700 m downtown box. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 1c56460 on Linux (WSL2 Ubuntu), Python 3.12, CPU only: tests pass, one scale concern.
|
|
CI note: the red |
whattheflop
left a comment
There was a problem hiding this comment.
AI-assisted independent review of 1c56460bfbee51471fe6060a56ae6f7caf8b71be. On native Windows 11 build 26200 with uv 0.11.19 and CPython 3.12.13 x64, 16 scoped synthetic tests passed, CPU only.
A hand-built loose map and a single-stream compressed RPF9 fixture each emitted the same six entity rows. Feeding the archive output directly into world_build --placements yielded two chunks and two triangles (one verified placement, one unverified, one key mismatch, one unresolved archetype, one other LOD and one outside the region). I decoded the GLB accessors directly. A Rodrigues rotation and face-cross-product oracle for an asymmetric triangle with multi-axis rotation and nonuniform scales matched positions within 0.000015 m and normals within 0.00000003 per component. Only the reflected instance reversed winding. The spatial build without --placements produced byte-identical world.json and GLB output to the parent.
I found no blocking issues within this scope. This is local coverage for the Windows paths discussed above. City-scale memory and CI status are outside this run.
|
@kapitche thanks, and @whattheflop for the Windows run. On the memory question, you're right. The largest run so far is a 700 m × 700 m downtown box: 29,258 HD placements, 10,729 of them placed at Leonida's current rpf9-explorer pin. It came to 16 chunks and 29.3 M triangles in about 5 minutes, at 22 GB peak RSS. That is the per-instance copy you describe. A 1 km box would need roughly 45 GB, so this PR doesn't scale to the whole city. I'm keeping this PR as the transform and placement layer, since that's what your checks covered, and making bounded memory its own follow-up PR on top of it. That PR shares each model's buffers once per chunk and stores only per-instance transforms ( |
|
@kapitche, the follow-up is #1316. Placements in a chunk now share each model's geometry ( |
…sets --placements used to copy a model's geometry into every placement and keep all copies until chunking (#1183 review: 22 GB for a 700 m box). Now each model's OBJ is parsed once into a packed cache file, each chunk stores every model it uses once, and the placements are instance transforms: EXT_mesh_gpu_instancing by default (three.js GLTFLoader reads it), one plain glTF node per placement with --instancing nodes, or the old baked copies with --instancing bake. Chunks are written as soon as they are built; with --jobs N, packing and chunk writing run in N processes, at most 4N jobs in flight. Memory is about 100 bytes per placement plus the models of the chunks being written. Every instance TRS has a positive determinant. A negative XY scale is folded into the rotation; a negative Z scale draws a mirrored copy of the mesh (glTF Y negated, winding reversed). Zero-scale placements are counted as degenerate_scale. iter_placements streams the rows load_placements selects, with the same checks (load_placements is unchanged). --lod-sets builds one chunk set per lodLevel tier (c_<tier>_<x>_<z>, with the tier and grid cell in each chunk record) and writes lod_bands to world.json: a camera-distance band per tier from the entities' median childLodDist/lodDist. The viewer loads a tiered chunk while the horizontal distance to its cell is in the band (32 m slack before unloading), so each cell shows one tier; worlds without lod_bands stream as before, and the manifest check rejects unknown tiers, unordered bands and missing cells. glb_writer: pack_primitive and _MaterialTable are factored out of build_glb (output unchanged), plus build_instanced_glb / write_instanced_glb and instance_bounds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in #1006 (comment) (item 1).
What and why
tools/world_build.pyplaces every exported model at its own coordinates, or in rows (--grid-layout). It never reads the map placements, so the viewer can't show a city where it stands. This PR adds placement-driven chunks: points 3 and 4 of What a runtime needs indocs/world.md. Point 5, HD/LOD switching, is not in this PR.world_index.py --entities-out FILEwrites one JSON line per completeCEntityDef. Each line has the archetype hash and 64-bit key,position, the storedrotation,scaleXY/scaleZ,lodLevel,parentIndex,numChildren,lodDistandchildLodDist. It reuses the existingparse_resourcecollector, so the scan, the joins and the JSON/CSV output don't change. If the scan fails, no partial file is left behind.world_build.py --placements FILE [--lod-levels 0,5] [--region MINX,MINY,MAXX,MAXY]matches each selected entity to an exported model the wayworld_names.pydoes. The model is found by the lower-cased joaat of the manifestNamewithout the.#dr/.#ftsuffix. When the row has the +0x20 key, the model's Murmur3-64 must equal it; otherwise the entity is counted as akey_mismatchand not placed. Each instance is then:scaleXY,scaleXY,scaleZ),position,(x, z, -y).Normals use the inverse-transpose, and a negative scale product flips the winding. Instances go into the existing spatial chunks with the existing staging and verification.
world.jsongets"layout": "placements"and astats.placementsblock that counts each outcome (placed,placed_unverified,key_mismatch,unresolved_archetype,model_not_loadable,outside_region,other_lod_level,malformed).Without
--placements,world_buildbehaves exactly as before: the 59 existing tests pass unchanged.Measured on the 1.0.2.1 package (local; counts only)
--entities-outover the wholelevels.rpfdata area (24 parallel--start/--limitwindows)world_names.mdunresolved_archetype, 0key_mismatch.#ftfragments--no-textures --jobs 8, 256 m chunks)Checks on the same box:
Not verified: I haven't looked at the result in a browser; I only had a headless Linux box. Instances are baked into the chunk geometry rather than shared, so a dense box makes 100 MB+ chunks and building a whole city needs a lot of memory. The doc suggests a smaller
--chunk-sizefor now and lists glTF instancing and LOD switching as the next steps.Tested
python -I tests/test_world_place.py: 15 new synthetic tests.--entities-outrow format, the aggregate file still written alongside it, a meta resource producing no rows, and no partial file on error.--region/--lod-levels; nothing placeable leaves the output unchanged; option conflicts; the CLI.tests/test_world_build.py(59),test_world_index.py(17),test_world_index_three_streams.py,test_world_names.py(20) andtest_world_census.py(61, 2 skipped) pass.python -m compileall -q tools testsis clean.LC_ALL=C. It uses no clocks, closes every file before the tool reads it, and the tools write ASCII JSON.world_indexcontinuations) touchesscan_rpf. This PR only adds a collector class and the--entities-outlines inmain().docs/README.md.AI-assisted (Claude Code), CPU only, Linux. No game data: the entity rows, models and chunks stay in the local work folder.
🤖 Generated with Claude Code