Skip to content

rpf9dump: models --lod N exports a drawable's other LODs (BUILD-1316) - #4548

Open
Krashgamer wants to merge 2 commits into
ItsNotRexed:mainfrom
Krashgamer:build-1316-rpf9dump-lod
Open

Krashgamer wants to merge 2 commits into
ItsNotRexed:mainfrom
Krashgamer:build-1316-rpf9dump-lod

Conversation

@Krashgamer

@Krashgamer Krashgamer commented Nov 23, 2026 •

Copy link
Copy Markdown

Item: BUILD-1316 (claim), from my finding in ASSET-351 (#4506).

Depends on: breadbbbb/rpf9-explorer#24, merged (merge commit 7ef5c51). The submodule pointer is that PR's own commit 65a9b02, now on the explorer's main; it is based on the current pin e293917, so this bump brings in only the LOD change and none of the other explorer commits since.

What was missing

rpf9dump models decodes only the LOD model list at drawable +0x50. A drawable header has four (+0x50, +0x58, +0x60, +0x68; the decoder's probe already walks all four). On the docs/bvh.md §4a interior, 101 of the 124 archetypes with a BLAS are built from the list at +0x58, so bvh_match.py finds no candidate for them in any export, however large the window (#4506).

What changed

  • Submodule: RageModelDecoder.Decode(system, graphics, drawableOffset, lod) (RageModelDecoder: decode a drawable's other LODs breadbbbb/rpf9-explorer#24). The existing overloads keep LOD 0.
  • tools/rpf9dump/Program.cs: models --lod N (0 to 3, default 0).
    • A LOD export goes to <out>/<archive>/models_lod<N>/, with the LOD 0 OBJ names. It never writes models/manifest.json, the file make_game.py resumes the models stage on.
    • The manifest records "Lod" (also 0 in a normal export).
    • A LOD export writes no embedded textures (they belong to the drawable, not to a LOD).
    • A drawable that decodes at LOD 0 but not at LOD N is counted in ModelDecodeFailures as lod-unavailable and does not fail the run.
    • --lod with another mode, or outside 0 to 3, is a usage error (exit 2).
  • Docs: docs/models.md (usage, the option, MeshModels now says "the exported LOD's list", and the failure paragraph names ModelDecodeFailures, which the manifest has had for a while); docs/bvh.md §7 (the option and the recipe's step 2).
  • tests/test_rpf9dump_lod.py:
    • Option tests on the synthetic texture-dictionary archive of test_rpf9dump_exit_codes.py (needs RPF9DUMP_DLL): out-of-range/missing values, textures --lod, the models_lod1/ directory and the Lod field.
    • A game-file test (also needs LEONIDA_GAME_DIR, skipped without it). It exports one 16 MiB window of levels.rpf at LOD 0 and 1 into a temp dir and checks counts only: LOD 1 items are a subset of LOD 0 with fewer triangles each; LOD 1 + lod-unavailable = LOD 0; no embedded textures.

Measured (counts only)

  • LOD 0 is unchanged: a 1 GiB window of levels.rpf exported with the old and the new build gives the same 1,229 manifest rows and identical OBJs, byte for byte (the manifest only gains "Lod": 0).
  • A 64 MiB window: 709 of 1,115 drawables decode at LOD 1, each with fewer triangles; the other 406 are lod-unavailable.
  • The interior's 141 drawables: 117, 90 and 67 decode at LOD 1, 2 and 3. The LOD 1 OBJs are byte-identical to the local decoder patch docs/bvh.md: where the BLAS of the §4a interior's other entities are (ASSET-351) #4506 was measured with, so its LOD 1 matches carry over.

Tested

  • python -I tests/test_rpf9dump_lod.py with RPF9DUMP_DLL and LEONIDA_GAME_DIR: 4 OK; without the game, 3 OK and 1 skipped; without the DLL, all 4 skipped.
  • test_rpf9dump_exit_codes.py, test_dotnet_rollforward.py, test_bvh_match.py, test_make_game_assets_decoder.py, test_restofworld_model_join.py: OK. dotnet run --project tests/Rpf9DumpDiagnostics: passed. All tests/test_docs_*.py: OK. python -I scripts/check_no_game_data.py: exit 0. python -m compileall -q make_game.py tools tests, python -I make_game.py --help: OK.
  • dotnet build tools/rpf9dump/rpf9dump.csproj -c Release: 0 warnings, 0 errors. Windows 11 Pro, .NET 8, Python 3.14.7, no GPU. Data: Xbox Series package 1.0.2.1 (SHA-256 verified against game/xbox-1.0.2.1.json), local work folder outside the repository.
  • Overlap: ASSET-316: rpf9dump ttpf --history reads the bc1-bc5 BCPack history tables #4050 (ASSET-316) also edits the option parsing of Program.cs and moves the submodule pointer, and rpf9-explorer: BC6H/BC7 BCPack block rebuilders and strict-mode lower-mip fallback, pin bump (ASSET-315) #4074 moves the pointer; whichever lands second takes a small rebase and a pointer that contains both explorer changes.

Checklist

  • No game data, keys or decryption: counts only, synthetic test inputs, the game-file test writes to a temp directory.
  • A new translator rule is in the contract table of docs/design.md: not applicable.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

rpf9dump models decoded only the LOD model list at drawable +0x50, but most
BLAS of the docs/bvh.md §4a interior are built from the one at +0x58, so
bvh_match.py found no candidate for them in any export. --lod N (0 to 3)
passes the LOD to the decoder (rpf9-explorer submodule bumped to the commit of
breadbbbb/rpf9-explorer#24), writes the export to models_lod<N>/ with "Lod" in
the manifest, skips the drawable's embedded textures there, and counts a
drawable without that LOD as lod-unavailable instead of a failure. LOD 0
output is unchanged byte for byte.

tests/test_rpf9dump_lod.py: option and layout tests on a synthetic archive,
and a LOD 0/1 export of one levels.rpf window that runs only with
LEONIDA_GAME_DIR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Kam471 Kam471 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.

Checked a3b8f901 on Windows 11.

  • tests/test_rpf9dump_lod.py -> 4 tests, skipped with "requires a built rpf9dump (RPF9DUMP_DLL)" (this host has no .NET SDK), so the end-to-end LOD export is not exercised here.
  • test_docs_links.py 6 OK, test_docs_design_rows.py 2 OK; git diff --check clean.
  • The submodule pointer third_party/rpf9-explorer -> 65a9b02a resolves: git submodule update --init cloned and checked out exactly 65a9b02a16df23b4e0ffe97f6cd3ddc6051109dd.

The C# path looks consistent: --lod is models-only, rejects a non-None integer or >= LodCount, sends other LODs to models_lodN so models/manifest.json is not replaced, records Lod in the manifest, and reports lod-unavailable when a drawable only decodes at LOD 0. No blocking issue from the available evidence.

@kapitche

Copy link
Copy Markdown
Contributor

Tested a3b8f90 merged with main 98fa503 on Linux (Python 3.12.16, dotnet SDK 8.0.428) and native Windows (Python 3.13.1, .NET SDK 10.0.403): pass. Submodule at the PR's pin 65a9b02, rpf9dump rebuilt from the merged tree. tests/test_rpf9dump_lod.py: Linux 4 tests OK (1 skipped, the game-file one); Windows without the game 4 run OK (1 skipped), Windows with LEONIDA_GAME_DIR set to my own dump 4 run OK, none skipped (the LOD 0/1 window test passed; I only looked at pass/fail). tests/test_rpf9dump_exit_codes.py 2 OK on Linux, docs tests 10 OK. Negative control: restored main's tools/rpf9dump/Program.cs and rebuilt: 3 failures (1 skipped) on Linux and 3 failures (1 skipped) on Windows. Arithmetic in the docs: 709 + 406 = 1,115. The 709/406 counts themselves were not re-measured.

@tupacfan04

Copy link
Copy Markdown
Contributor

Mergeable, low risk, with one contract mismatch.

dotnet build 0 warnings; the PR's tests 3 pass / 1 skipped (needs LEONIDA_GAME_DIR); the existing test_rpf9dump_exit_codes.py and Rpf9DumpDiagnostics pass; compileall clean; merge clean. Negative control: mutating "Lod": lod to 0 fails the new test.

Two gaps:

  • --lod 0 is silently accepted for textures/ttpf (tools/rpf9dump/Program.cs:45), which contradicts the body's "--lod with another mode is a usage error". The test only covers --lod 1 (tests/test_rpf9dump_lod.py:46).
  • The new test never runs against a built DLL in CI: the generic loop runs it before the build (where it skips), and the post-build step only reruns test_rpf9dump_exit_codes.py (.github/workflows/ci.yml:94-97).

AI-assisted review, no game files, no GPU.

…I (review)

--lod 0 with textures or ttpf was accepted silently; any --lod there is now a
usage error, and the test covers 0 and 1. The LOD tests need the built DLL, so
CI runs them after "Build rpf9dump", like test_rpf9dump_exit_codes.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Krashgamer

Copy link
Copy Markdown
Author

Thanks @tupacfan04, both fixed in the latest commit:

  • Any --lod outside models is now a usage error, --lod 0 included (lodGiven in Program.cs). test_lod_is_refused_outside_models checks 0 and 1.
  • CI runs tests/test_rpf9dump_lod.py after "Build rpf9dump", with RPF9DUMP_DLL, next to test_rpf9dump_exit_codes.py. The game-file test still skips there.

Re-run locally: the LOD tests pass with the game files (4 OK) and without them (3 OK, 1 skipped). test_rpf9dump_exit_codes.py, test_ci_registration.py and the docs tests also pass, and dotnet build has 0 warnings.

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.

4 participants