Skip to content

docs/bvh.md: the "aggregated room" BLAS are single drawables, placed by their interior (ASSET-322) - #4265

Closed
NiiRoZz wants to merge 3 commits into
ItsNotRexed:mainfrom
NiiRoZz:asset-322-room-blas
Closed

NiiRoZz wants to merge 3 commits into
ItsNotRexed:mainfrom
NiiRoZz:asset-322-room-blas

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: ASSET-322 (claim). Docs only. It uses the interior reader of #1981 (not merged) for the measurement; nothing in the diff depends on it.

What and why

docs/bvh.md §4a said two of the 10 sample BLAS of core_bvh4.rpf are interior rooms that aggregate props from several drawables, and that placing them needs the interior's entity list. Re-measured, that is not the case:

  • Every one of the 10 is one drawable. On a rpf9dump models export of the whole levels.rpf (343,327 models, with MeshTris), bvh_match.py finds exactly one consistent drawable for each. The two former "rooms" are a baked room-dressing drawable (62,479 leaves, 29 of 42 geometries kept) and another dressing drawable (1,700 leaves, 6 of 10). §7 already reported one consistent candidate for all ten in a 1 GiB window; the doc now agrees with itself.
  • Which two were the "rooms" follows from the skip counts: the 62,479-leaf BLAS and the 1,700-leaf one.
  • Placement comes from the interior. All 10 drawables are entities of one CMloArchetypeDef: 3 in the base list, 4 in a non-default entity set, 3 in a default one. A BLAS sits in interior space at E * M^-1 (M = descriptor transform at +0x50, E = entity with the conjugated quaternion). All 10 boxes fit the interior box. A TLAS instance would be I * E * M^-1 plus the leaf-frame fold of D3D-412: TLAS instances fold the BLAS leaf frame and store +64 in the console order #4011. The doc says this is derived, not observed.
  • The shader skip is per shader, but not over two shaders. Across the 10, the 65 skipped geometries use 7 shader-group hashes and the 67 kept use 8 others, with no overlap. Two hashes cover 54. §4a and §7 no longer say "one of two shaders".
  • The descriptor key at +0x40. Over all 269,106 single-BLAS descriptors, a key always comes with one transform, and with one BLAS header except in 1 case (a 3-leaf BLAS whose crc32 differs in one of 4 copies). But 1,008 (BLAS, transform) pairs carry several keys (up to 60), so the key identifies something finer than that pair. What it hashes stays open; ASSET-321: decode the BVH descriptor templates and tie 6,701 BLAS to their buffers #4199 (open, ASSET-321) also finds no link to the table descriptors. Before opening this PR I checked open and merged PRs again for a decoding of this key and found none.
  • Smaller fixes: the "8 samples" statements now say "identified first"; the descriptor rotations include a 180° turn about a diagonal, not only 90° turns.

Measured (counts only; no game data in the PR)

leaves kept / total geometries candidates over the whole export checks
181 3 / 3 69 consistent
21,814 12 / 13 1 consistent
273 3 / 7 21 consistent
1,844 7 / 8 1 consistent
2 1 / 1 17 (interior's 141 drawables) consistent
138 2 / 35 848 consistent
62,479 29 / 42 1 consistent
566 3 / 12 37 consistent
1,700 6 / 10 1 consistent
103 1 / 1 4,173 consistent
  • Rehydrated with bvh_rehydrate.py, the two former "rooms" pass xdxr_bvh.py validate except for "child box not inside its parent's box" (1,310 and 27 reports for 1,328 and 23 overrides). The library-verified 21,814-leaf BLAS gives the same kind (282 reports for 335 overrides), so these come from stored overrides. The two have not been run through XboxBvhBuilder.dll.
  • Placement: the 8 corners of each sceneBounds, mapped through E * M^-1, are 0 m outside the interior box; with the unconjugated quaternion, the one rotated entity is 1.6 cm outside (a weak test, said so in the doc).

Tested

  • python -I tests/test_docs_cli_flags.py, test_docs_links.py, test_docs_table_rows.py, test_docs_list_items.py, test_docs_repo_paths.py: OK. python -I scripts/check_no_game_data.py: exit 0.
  • Windows 11, Python 3.13. Data: v1.0.2.1 package, local work folder.
  • Reviewed before opening by a second agent (doc and process), which rechecked the table, the placement maths and the stripped-manifest equivalence; its corrections are in.

Open (posted as findings)

  • What drives the shader skip set (7 hashes here, not 2).
  • What the descriptor key at +0x40 hashes.
  • How the game picks the entity for a BLAS, given that the BLAS does not name it.
  • Whether the game's TLAS instances are I * E * M^-1.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md): no names, hashes or keys in the doc or here; counts and offsets only.
  • A new translator rule is in the contract table of docs/design.md: not applicable.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

@SweatierKey

Copy link
Copy Markdown
Contributor

Independent docs read & consistency check at e6e53475 on Linux (WSL2, Python 3.13.5, no game files): pass.

  • Arithmetic & internal consistency verified (docs/bvh.md):
    • 10-BLAS table totals match the prose: geometries kept 3+12+3+7+1+2+29+3+6+1 = 67, total model geometries 3+13+7+8+1+35+42+12+10+1 = 132, skipped 132 - 67 = 65.
    • "Two previously aggregated rooms" deduction checks out: 62,479-leaf skips 42 - 29 = 13, leaving 65 - 48 - 13 = 4 skipped, uniquely identifying the 1,700-leaf BLAS (10 - 6 = 4, since 273-leaf was already among the first 8).
    • Interior entity counts sum cleanly: 11 + 2 + 77 + 152 = 242 entities; 3 + 4 + 3 = 10 drawables across the base list and the 77/152 sets.
    • Descriptor key counts sum cleanly: 269,106 - 235,533 = 33,573 repeats.
    • All open questions and unverified assumptions (e.g. I * E * M^-1 TLAS construction not observed at runtime, the 2 newer samples not yet run through XboxBvhBuilder.dll) are clearly scoped.
  • Clean-room & hygiene (clean worktree on 03b09a08): no shader hashes, asset names, or game data; git diff --check, test_docs_links.py (6/6), test_docs_repo_paths.py (2/2), test_text_write_line_endings.py (3/3), and test_text_encoding.py (2/2) all pass.
  • Not independently reproduced: archive/BVH measurements (requires local game archives).

AI-assisted review.

@sds-228 sds-228 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.

Code review of e6e5347: no issues found. The revised sample counts, table and open questions are internally consistent, and the two samples not run through the reference library are labelled as such. Raw bytes are valid UTF-8. Docs suites: 20 tests OK; compileall and diff check clean.

AI-assisted (OpenCode).

@kapitche

Copy link
Copy Markdown
Contributor

Read e6e53475 against main 03b09a08: accurate for what can be checked without game files. Merge is clean and tests/test_docs_*.py pass.

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

Second review, verified on a clean checkout (Windows, Python 3.12, CPU only; the measurement itself is the author's own package):

  • Privacy: the only long hex literal added is 0xFFFFFFFF — the header's root-parent sentinel, not game data. Everything else is counts, flags and open questions, consistent with the board rules and with sds-228's read.
  • tests/test_docs_links.py and test_docs_repo_paths.py OK on the head.
  • The correction direction is right: §4a's 'two of the 10 aggregate props from several drawables' was an inference; replacing it with 'each of the 10 is one drawable' plus a labelled open question (and noting which samples were not re-run through the reference library) is the honest form — same pattern as the other re-measured bvh.md rows.

Approving.

AI-assisted.

ScarionWorkspace added a commit to ScarionWorkspace/Leonida that referenced this pull request Nov 23, 2026
…350)

Give the count keyed by the stored BLAS header (sizes, bounds, crc32) and
transform, the identity ItsNotRexed#4265 uses: 1,030 pairs carry more than one key, up
to 60 (ItsNotRexed#4265: 1,008). Keep the crc32-only count after it.

AI-assisted. tests/test_docs_*.py: 7/7 OK.

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

Copy link
Copy Markdown
Contributor

Checked f04715d6 merged with main 3faac557 (clean), on macOS, Apple M4, Python 3.15.2, against my own v1.0.2.1 package. Counts only.

The descriptor-key paragraph, recounted on the whole core_bvh4.rpf. I ran the unmodified tools/bvh_index.py (565,596 streams, 641 s) and paired each instance208 row with the stream after it. Then I rescanned once more, keeping the exact 48 bytes at +0x50 and the BLAS header bytes. bvh_index rounds the matrix and bounds to 4 decimals, so the rescan was needed for the last row below.

claim in docs/bvh.md here
269,106 single-BLAS descriptors, each followed by its stream 269,106 / 269,106
235,533 distinct keys 235,533
2,873 keys occur more than once, 33,573 repeats, one key 3,198 times 2,873, 33,573, 3,198
a key always comes with one transform yes: 0 keys with two transforms, both with the rounded and the exact bytes
one BLAS header per key except one 3-leaf BLAS whose crc32 differs in one of 4 copies yes: exactly that one key (4 copies, crc32, 3 leaves)
1,008 (BLAS header, transform) pairs under more than one key, up to 60 1,007, up to 60

Notes on the last row:

  • 1,007 uses every decoded header field plus the exact header bytes 0x100–0x140, and the exact transform.
  • With bvh_index's 4-decimal rounding, the count goes up to 1,028–1,029, because rounding merges nearly equal transforms.
  • So the paragraph holds. The off-by-one probably comes from which header bytes count as "the BLAS header". Naming them in the doc would make 1,008 reproducible.

Docs checks: tests/test_docs_*.py: all 10 files OK. scripts/check_no_game_data.py: exit 0. git diff --check is clean.

Not checked:

  • the 10-BLAS table and the bvh_match.py runs, which need a models export of the whole levels.rpf (343,327 models), too large for this disk;
  • the E * M^-1 placement.

Verdict: pass. The descriptor statistics reproduce on a second package, apart from the ±1 above.

AI-assisted.

@kacper-serewis kacper-serewis 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.

AI-assisted whole-archive recheck at f04715d resolves the 1,007/1,008 discrepancy. Pairing all 269,106 single-BLAS descriptors with their following streams and grouping by the exact 48 transform bytes: all 64 header bytes [0x100,0x140) yield 1,007 groups shared across distinct descriptor keys. Restricting the header to totalSizeIn64BNodes, crc32, numElements and the six sceneBounds values [0x104,0x128) yields 1,008. CRC is included in both. Removing it gives 1,156 and 1,157 respectively. All four selections max out at 60 keys. Please specify the four fields if retaining 1,008. Payload equality was outside this scan.

ItsNotRexed added a commit that referenced this pull request Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NiiRoZz and others added 2 commits November 23, 2026 12:41
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on ItsNotRexed#4265)

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

NiiRoZz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @sovljanskii and @kacper-serewis. The 1,008 came from grouping on header bytes 0x104-0x128 (size in nodes, crc32, element count, sceneBounds) and the exact 48 transform bytes, which is the selection kacper-serewis found gives 1,008. The paragraph now names those bytes and gives the 1,007 for the full 64-byte header (0x100-0x140).

The original commit (e6e53475) is already in main as 2fa6e4b. This branch now has main merged in, so the PR's remaining diff is only this 6-line clarification.

AI-assisted (Claude Code).

@Krashgamer

Krashgamer commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

@NiiRoZz: this PR's commit e6e53475 is on main now. It went in with #4506 (ASSET-351), which was built on it and merged in the 11:36 UTC round, so the §4a text here has landed and this PR can be closed.

@NiiRoZz

NiiRoZz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the main commit e6e53475 is on main (in with #4506). The later review clarification (which header bytes give 1,008 vs 1,007) moved to #5762. Thanks @Krashgamer, @sovljanskii, @kacper-serewis and the other reviewers.

AI-assisted (Claude Code).

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.

8 participants