Skip to content

world_build: prune obsolete --lod-sets chunks on rebuild - #2566

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
leoleahy:fix/world-build-prune-lod-chunks
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
leoleahy:fix/world-build-prune-lod-chunks

Conversation

@leoleahy

Copy link
Copy Markdown
Contributor

Claim: #2516 (comment)

What changed

With --lod-sets, tools/world_build.py:_build_instanced_world() emits chunks named c_<tier>_<ix>_<iz>.glb where <tier> comes from LOD_TIER_NAMES (hd, lod, slod1, slod2, slod3, orphan_hd, slod4). However, _CHUNK_FILE_RE only matched two-coordinate c_<ix>_<iz>.glb(.tmp) filenames, so _prune_stale_chunks() never removed obsolete LOD-set chunk files when rebuilding into the same output directory (narrowing --lod-levels, changing --region/--chunk-size, switching to a non-LOD build, or clearing with --limit 0).

  • Built _CHUNK_FILE_RE with an optional (?:<tier>_)? prefix generated from LOD_TIER_NAMES, while still leaving unrelated .glb files untouched.
  • Added LodSetsTest.test_prune_stale_chunks_removes_obsolete_lod_set_chunks in tests/test_world_instancing.py covering both direct _prune_stale_chunks() calls (including .glb.tmp and unrelated .glb preservation) and end-to-end CLI rebuilds (narrowing --lod-levels, switching off --lod-sets, and --limit 0).

No overlap with #1981 or #2283.

Testing

  • Synthetic CPU-only tests, no game files, no GPU.
  • Verified the new test fails on main (4947579) and passes with this change.
  • Windows 11 x64, Python 3.14.8:
    • python -m compileall -q make_game.py tools tests -> exit 0
    • python -I tests/test_world_instancing.py -> 27/27 OK
    • python -I tests/test_world_build.py -> 59/59 OK
    • python -I tests/test_world_place.py -> 19/19 OK
    • python -I tests/test_world_json_atomic.py -> 4 passed, 1 skipped (POSIX permission bits)
    • python -I tests/test_text_write_line_endings.py -> 2/2 OK

AI-assisted.

@ricarmandoagent

Copy link
Copy Markdown

Reviewed at bf7a95dc (head matches headRefOid). Linux, Python 3.15.2, CPU only; no game data.

  • python3 -m compileall -q make_game.py tools tests -> exit 0
  • python3 -I tests/test_world_instancing.py -> 27 tests, OK
  • python3 -I tests/test_world_build.py -> 59 tests, OK
  • python3 -I tests/test_world_place.py -> 19 tests, OK
  • python3 -I tests/test_world_json_atomic.py -> 5 tests, OK (no skip on this POSIX host; the PR's Windows run reports the permission-bits skip)
  • python3 -I tests/test_text_write_line_endings.py -> 2 tests, OK

Independent synthetic prune check, same directory with stale chunks and keep set {c_hd_0_-1.glb, c_0_-1.glb}:

  • main 4947579 leaves c_lod_0_-1.glb, c_slod2_0_-1.glb, c_orphan_hd_1_-1.glb, c_hd_0_-1.glb.tmp;
  • with this PR all four are removed, while c_hd_0_-1.glb, c_0_-1.glb, unrelated.glb, c_01_-1.glb and c_hd_0_-1.glb.bak are untouched.

So the widened regex prunes exactly the tier-prefixed .glb/.glb.tmp names and still refuses leading-zero and trailing-suffix names. No defects found.

AI-assisted review.

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested bf7a95d merged onto main 4947579 (clean merge) on Windows 11, Python 3.13: pytest tests/test_world_instancing.py: 27 passed, 2 subtests passed. Negative control: the same tests against main's copies of the changed sources give 1 failed, so the tests really cover the change.

AI-assisted (Claude Code); runs on my machine.

@edupode edupode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head bf7a95d; no findings. The changed filename regex recognizes all current LOD chunk prefixes and is consumed through fullmatch, so unrelated files remain untouched. Ran the focused synthetic stale-chunk regression on Windows: 1/1 passed. An in-memory negative control using the old regex failed on the retained LOD/temp files, confirming the regression test. The fixture creates a synthetic OBJ/entity set and runs with --no-textures; no game files or texture data used. AI-assisted review by @edupode with assistance from ChatGPT 6.2 Astra (Ultra Thinking).

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.

5 participants