Commit Graph

47 Commits

Author SHA1 Message Date
8b27343069 Merge pull request #816 from trigger337/fix/world-build-stage-cleanup
world_build: restore write mode before unlink on replace failure in _write_json_atomic (WORLD-BUILD-STAGE-CLEANUP)
2026-11-29 19:36:31 +01:00
da4fd4ea0b Merge pull request #1633 from KoLolX3/fix/world-build-case-lock
world_build: share locks across case and Unicode variants (WORLD-BUILD-CASE-LOCK)
2026-11-28 20:40:14 +01:00
00131bb85e main keeps its own runtime, tools and tests; the branch's variants stay on port/d3d12-nvidia
After the merge the tree held this branch's older states of files main maintains. Run against main's code,
tests/test_acphal_abi.py and 11 of the 15 translator tests that differed failed, and the C++ runtime would have
been built from two generations of its sources. So that the merge cannot break what main builds and tests:

- runtime/ is main's, file for file (68 files only this branch had are not carried over);
- every file under tools/, tests/ and docs/ that both sides have is main's (80 files);
- ten translator tests only this branch has, which test rules main's translator does not have, and their
  fixtures are left out.

What main gains: d3d12/ (the Rust D3D12 runtime), its launchers and helpers (Launcher.bat, scripts/play*.ps1,
play-linux.sh, port_ctl.py, smooth-motion.ps1, fetch_vkd3d_proton.py, sync_victory.py), mods/example_lua, eleven
notes under docs/, seven tools and the tests that pass with main's code, the README's sections and credits, and
the "Runtime traps" section of AGENTS.md. Everything left out here is on the branch port/d3d12-nvidia.

Checked: compileall; make_game.py --help; check_no_game_data.py over every file this adds to main; the
line-ending, docs-encoding, CI-registration and docs tests; each test file that differs from main, on its own.
Not run: the whole translator suite, the C++ build, cargo over d3d12/ after the merge (d3d12/ is byte for byte the
branch's), CI.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 17:58:38 -05:00
b87abdef57 Merge mandy's main into port/d3d12-nvidia
Brings the D3D12 runtime branch (d3d12/, its launcher scripts and notes, and the pull requests reviewed and applied
on it) together with mandy's main.

Conflicts (67 files, none under d3d12/): docs/, make_game.py, runtime/, scripts/build_runtime.ps1, tests/ and
tools/. Every one takes main's side: main is where that code is maintained, and this branch's copies were older
states of the same files or the same pull requests in another form. tests/test_fspx_unpack.py is main's too, as it
tests main's tools/fspx_unpack.py. Nothing under d3d12/ is changed by the merge.

Checked before pushing: python -m compileall over make_game.py, tools and tests; make_game.py --help;
scripts/check_no_game_data.py over the files this adds to main; tests/test_text_write_line_endings.py. The
translator suite, the C++ runtime build and CI have not run on the result.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 17:50:37 -05:00
ffc144de66 PR #1633: world_build: share locks across case and Unicode variants (WORLD-BUILD-CASE-LOCK)
From https://github.com/ProjectLeonida/mandy/pull/1633 (head d1d01cb300), applied as a reviewed patch.

Co-authored-by: KoLolX3 <KoLolX3@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 15:43:45 -05:00
98c4c09cf8 PR #816: world_build: restore write mode before unlink on replace failure in _write_json_atomic (WORLD-BUILD-STAGE-CLEANUP)
From https://github.com/ProjectLeonida/mandy/pull/816 (head d90e4b213f), applied as a reviewed patch.

Co-authored-by: trigger337 <trigger337@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-27 15:42:15 -05:00
d1d01cb300 Share world output locks across spelling variants 2026-11-24 22:32:54 -08:00
d90e4b213f world_build: restore write mode before unlink on replace failure in _write_json_atomic (WORLD-BUILD-STAGE-CLEANUP)
When writing world JSON atomically, if os.replace fails (for instance due to
permission errors), resetting os.chmod to 0o600 ensures unlinking the
temporary file does not fail on Windows with PermissionError.

agent: yes
AI-assisted: yes
2026-11-24 17:09:40 +03:00
198b5c5bcd world_build: drop a staged chunk PNG once no later chunk uses it (BUILD-WORLD-BAKED-PNG-BUDGET)
The staged build (spatial, grid and baked placements) decoded every chunk texture into a per-build
cache that kept each PNG until the build returned, so the decoded PNGs held grew with the chunk
count. Count each chunk's use of a texture before the chunks are written and drop the cache entry
when its last chunk takes it. A texture is still decoded once per build, waiters still share one
decode, and the chunks and world.json are byte-identical.

In a synthetic 24-chunk build, decoded PNGs alive while the last chunk is written fall from 26 to 3
(spatial, 1 worker) and the grid layout's peak from 26 to 11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 08:07:40 -05:00
d4a3e8f2be Restore read-only world chunks during Windows rollback (#6801)
Squash-merged after diff review of PR #6801 - world_build: restore read-only chunks during Windows rollback
2026-11-23 09:51:15 -06:00
438bf6f342 world_build: recover interrupted chunk publication on the next run (#6285)
Squash-merged after diff review of PR #6285 - world_build: recover interrupted chunk publication on the next run
2026-11-23 08:25:35 -06:00
a0e7c7912a Merge pull request #3938 from João Ramos
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:09:43 -05:00
14a79bcde1 world_build: key the output lock on the resolved path
_exclusive_output hashed normcase(abspath(out_dir)), so an 8.3 name or a
junction/symlink spelling of the same output folder took a different lock
and a second build ran into the first one's staging. Hash
normcase(realpath(out_dir)) instead; for an output folder that does not
exist yet, realpath resolves the existing parent and appends the rest, so
two first runs through different spellings still collide.

The new tests hold the lock in a child through one spelling and expect a
build through the 8.3 spelling (skipped when the volume has no 8.3 names)
and through a junction (symlink off Windows) to be refused, both before
and after the output folder exists.
2026-11-22 22:29:45 +00:00
446432ad38 world_build.py: drop the second import tempfile (round 42)
The round-42 merges added a second `import tempfile` after the
fcntl/msvcrt fallbacks; the module already imports it a few lines above.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:09:26 +00:00
e257e50a36 Merge pull request #3241 from bobcatchris 2026-11-22 15:16:06 -05:00
82a9bf392b Merge pull request #2875 from Vonsek 2026-11-22 15:12:47 -05:00
b5c90c2102 world_build: keep concurrent builds out of one output
Staging cleanup, publication and stale-chunk pruning all work on the shared
output directory, so two builds into it could delete each other's staged
chunks. Hold an OS file lock keyed by the normalized output path for the whole
build; a second build gets a clear error instead of interfering. The lock lives
in the system temp directory, so output contents and failure cleanup are
unchanged.

Credit @lucastayaralvarenga-ui for the finding.
2026-11-22 13:48:31 -06:00
9c4c8ba5b7 fix(assets): refresh world textures between builds
Single-worker world builds share a process, so caching only by DDS path and output size can reuse stale pixels from a previous build.
2026-11-22 19:34:54 +01:00
e2340a7def Merge pull request #2638 from Vonsek 2026-11-22 13:16:43 -05:00
cd7bcc34a3 Merge pull request #2566 from Leo Leahy 2026-11-22 13:16:14 -05:00
8f20f7d196 Merge pull request #2549 from Arjun Nirgudkar 2026-11-22 13:16:05 -05:00
002d3a7880 fix(tools): use finer draw distance for missing LOD boundaries
A missing child distance previously collapsed the finer draw band even when the exported placement recorded its draw distance.
2026-11-22 18:40:10 +01:00
bf7a95dc79 world_build: prune obsolete --lod-sets chunks on rebuild 2026-11-22 14:31:02 -03:00
ec9a99c69e tools: a process pool gets at most 61 workers on Windows
Windows waits on a pool's workers with WaitForMultipleObjects, which takes
at most 64 handles. With --jobs 62 or more, awc_opus.py, awc_shorts.py,
world_lights_paths.py and world_build.py stopped with "ValueError:
max_workers must be <= 61" (ProcessPoolExecutor), and anim_clips.py
(multiprocessing.Pool) printed "ValueError: need at most 63 handles" from
a helper thread and never returned: 62 workers were killed after 60 s where
61 finish in 0.8 s (Windows 11, Python 3.12.5).

awc_opus.py and awc_shorts.py default --jobs to half the CPU count, and
make_game.py hands its own --jobs to awc_opus.py, so a machine with 124
logical CPUs reached this with no option given.

tools/pool_workers.py holds the limit, and the five pools are created with
process_workers(jobs): unchanged elsewhere, 61 at most on Windows. The
job count is lowered rather than refused so that a build with a large
--jobs keeps running. world_census.py, which refuses --jobs above 61, is
not changed.

tests/test_pool_workers.py runs each tool's own code: with the limit
patched in and a recording pool (every platform), the audio tools from the
command line with --jobs 62, and the real pool with 62 jobs on Windows.
8 of its 10 tests fail on the tools as they were.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 11:54:49 -05:00
4caf9bb42b Merge pull request #2283 from Vonsek 2026-11-22 11:43:45 -05:00
82cfa38023 Merge pull request #1615 from Ewann 2026-11-22 11:40:36 -05:00
f47a241f03 fix(tools): cache world textures by source and size
A one-worker build can reuse textures from an earlier build in the same process. Include the requested size in the cache key so subsequent builds embed the expected resolution.
2026-11-22 17:34:14 +01:00
ef6139ddb3 tools: newline= on text-mode temp files and Path.open too (BUILD-468)
#1615's detector read the mode only at position 1, so Path.open(mode)
and tempfile.NamedTemporaryFile(mode) were not seen: three atomic report
writes (rbf0_tree, rtti_scan, world_build) still get CRLF on Windows.
They now pass newline="\n".

The test now reads the mode where each call takes it: open, io/gzip/
bz2/lzma.open and os.fdopen at position 1, Path.open and the tempfile
classes at position 0 (binary by default). It accepts only real mode
strings, and skips codecs, os, tarfile, zipfile and webbrowser opens.
Found by @undeadhuman37 in their review of #1615.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:54:01 +01:00
82dbc6217d world_build: validate levels requested with LOD sets 2026-11-22 16:16:30 +01:00
c79be5f872 Merge pull request #1636 from CLHelper 2026-11-22 08:08:19 -05:00
0f3e85c27a world_build: publish world.json through a private staging file
_write_json_atomic wrote world.json through a fixed "world.json.tmp": an
existing file of that name was overwritten and, when the write failed,
deleted; two builds into one output folder shared it; and its plain
os.replace had no retry for a Windows sharing violation, though the viewer
may hold world.json open during a rebuild.

It now stages through a NamedTemporaryFile in the same folder, as #425 did
for the GLB export, gives the result the mode of the file it replaces
(file_mode.published_mode), and _publish_world passes glb_writer._replace,
the retrying replace the chunks already go through.

tests/test_world_json_atomic.py: four tests fail on main (the sibling is
consumed on success and deleted on failure, two writes share a staging file,
world.json skips the retrying replace); the POSIX mode test runs on Linux.
2026-11-22 12:50:28 +00:00
daafe1ac6d Merge pull request #1508 from bbareth 2026-11-22 07:07:57 -05:00
90978a9f7e world_build.py: preserve numeric archetype hashes in placements 2026-11-22 12:49:36 +01:00
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").

tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:27:00 +00:00
99a40c54b1 world_build: instanced placements with bounded memory, and LOD chunk 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>
2026-11-22 10:02:54 +00:00
d2fae504b4 world_build: continue loading after malformed placement values
Count unhashable LOD values and overflowing position/rotation components as malformed rows, then continue loading valid neighbors. Preserve the existing unit fallback for invalid optional scales, including integers too large to convert to finite floats.

Add synthetic loader and complete-world regressions covering row counts, scale defaults, unchanged finite/zero/negative scales, region/LOD filters and resulting geometry bounds. New regressions reproduced nine errors on the unmodified base; all 178 world-related tests now pass.
2026-11-22 05:24:07 -04:00
1c56460bfb world_build: place models at their map placements (--placements)
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>
2026-11-22 08:01:15 +00:00
f21f4ceb5a fix(world_build): keep staging with unrestored previous chunks across builds
_remove_stale_staging deleted every .chunks-staging-* directory, including one
whose previous/ held chunks a failed publish could not put back, so the recovery
copy named in the error was gone on the next build. Such a directory is now kept;
empty or incomplete staging is still removed. The build_world docstring now says
that readers can see old and new chunks mixed while publishing renames them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 07:08:27 +01:00
ee7218e653 world_build: stage chunk writes so a failed rebuild preserves existing chunks
Stage chunk generation in .chunks-staging-*/ on the output volume, verify sizes and headers, and publish via rename once all chunks succeed. Previous chunks are kept in a staging backup until world.json is committed; any error or interrupt rolls back to the previous intact world.json and chunk files. Leftover staging directories from killed builds are cleaned up on the next run. Adds WorldBuildStagingTest (6 synthetic tests covering failed chunk generation, corrupt chunk rejection, world.json write failure rollback, and leftover cleanup).
2026-11-22 06:54:48 +01:00
4730befe4d Merge pull request #942 from nicolas 2026-11-22 00:33:13 -05:00
56d1273ce7 Allow world exports to select the base-color texture parameter 2026-11-21 21:44:55 -07:00
adcf2c2f8a Keep large world chunks within streaming range at spawn 2026-11-21 20:54:52 -07:00
fdebb843b6 Treat invalid optional material arrays as absent 2026-11-22 00:50:10 +01:00
645f52d3c6 Merge pull request #244 from nicolas 2026-11-21 17:07:37 -05:00
7b7a42bd3a World builder: preserve output when no input models can load 2026-11-21 17:54:33 -04:00
d4ab78ffd7 World builder: preserve unrelated GLBs during chunk cleanup 2026-11-21 14:10:17 -07:00
691527329c tools, viewer: add stdlib world.json/.glb chunk builder and harden viewer 2026-11-21 16:10:06 -03:00