Skip to content

bvh_match: report geometry indices the checks do not pin (ASSET-566) - #7445

Open
Sebi2030 wants to merge 1 commit into
ItsNotRexed:mainfrom
Sebi2030:asset-566-bvh-exception
Open

Sebi2030 wants to merge 1 commit into
ItsNotRexed:mainfrom
Sebi2030:asset-566-bvh-exception

Conversation

@Sebi2030

@Sebi2030 Sebi2030 commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue as: ASSET-566 (ASSET-349 follow-up, assigned in #6603; listed in #7333)

Depends on: none. test_bvh_slot_check and test_text_write_line_endings fail on main independently of this PR
(#6513 fixes the first).

What and why

#6330 made the render-bucket rule the default and listed exceptions: BLAS that seem to keep a bucket-1 or bucket-2
geometry. A consistent candidate does not prove every geometry it names, though. The checks see the bounds, the stored
box overrides and the paired edges, not where a leaf is, so a small geometry inside the bounds can be swapped for
another of the same triangle count without any check noticing.

  • tools/bvh_match.py: for the best consistent candidate, each geometry index is tried with every other geometry of
    the same model with the same triangle count (including geometries the rules leave out and ones the candidate uses at
    another index), and every index that such a replacement also passes is reported as not pinned. An index is called
    pinned only when every replacement was run; a replacement past --pin-checks N (default 128, 0 skips) or without
    an OBJ group is not run, and the output then says the remaining indices are not known to be pinned. The --json
    report gains pinning (complete, unpinned, alternatives, tried, not_tried, no_obj_group). When no
    candidate fits under the bucket rule, the output points at --no-bucket-rule.
  • docs/bvh.md §4a: which exceptions are established, with the measurement below; §7: the option and its output;
    the Open item now asks what fills the extra index.

Measured (1.0.2.1 package, counts only; no game data in this PR)

Ground truth with no rule (--no-bucket-rule, exactly one consistent match) for the BLAS among the first 2,908
core_bvh4.rpf streams with at least two geometry indices, against the levels.rpf windows at 3 and 4 GiB. Every
replacement was run (no cap); no replacement lacked its OBJ group.

window BLAS replacements run pinned, rule exact not pinned, rule exact not pinned, rule differs not fully run
3 GiB 622 846 546 75 1 0
4 GiB 940 368 898 42 0 0
both 1,562 1,214 1,444 117 1 0
  • The rule gives exactly the kept set in every BLAS whose match is pinned (1,444 of 1,444). The one that differs has
    11 indices where the rule keeps 10; the checks pass with the bucket-3 quad in either of the last two places or both,
    so it shows one index more than the rule keeps, not a kept decal. No other first-LOD model of levels.rpf,
    data.rpf or packs.rpf has its signature.
  • bvh_match: leave out geometries by render bucket (ASSET-349) #6330's exception shape: 314 streams fit only when one left-out geometry is kept (400 flips bucket 2, 89 bucket 1).
    Over 8 windows holding 228 of them (all replacements run), 213 have no consistent candidate and 15 have one that
    keeps the flipped geometry; in all 15 that index is not pinned. None of the 16 cases establishes that the BVH keeps
    a bucket-1 or bucket-2 geometry. bvh_match: leave out geometries by render bucket (ASSET-349) #6330's own 22 were not rerun (they come from a whole-archive export);
    bvh_match.py with the default --pin-checks would settle them.
  • A BLAS has up to 66 replacements in these windows; a cap of 32 would have left 4 of the 1,562 incomplete, 128 none.
    The largest sample (62,479 leaves) runs in 3.8 s with the check.

Tested

  • python -I tests/test_bvh_match.py: 48 OK; 8 new synthetic tests (unpinned quads, a left-out geometry as a
    replacement, a fully pinned match, the --json fields, the cap, a replacement without an OBJ group, the
    --no-bucket-rule hint and its absence), 6 of which fail against main's tool.
  • test_bvh_geometry_check, test_bvh_rehydrate, test_bvh_index, test_sgd5_effects, the test_docs_* checks,
    test_check_no_game_data, test_resource_hygiene: OK. python -m compileall -q make_game.py tools tests,
    python -I make_game.py --help, python -I scripts/check_no_game_data.py (exit 0), git diff --check: OK.
  • Failing on main already, unchanged here (checked against a clean copy of main): test_bvh_slot_check
    (3 errors, bvh_slot_check: unpack 6-tuple from model_geometries() after #6330 #6513) and test_text_write_line_endings (tools/f64_omod_probe.py:268, tools/leonida_tui.py:753).
  • Windows 11, Python 3.14.7, .NET SDK 8.0.428 (rpf9dump). No GPU involved.

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed: not applicable.

🤖 Generated with Claude Code

A consistent candidate does not prove every geometry it names: the checks
see bounds, stored box overrides and paired edges, not where a leaf is, so
a small geometry inside the bounds can be swapped for another of the same
triangle count unnoticed. For the best candidate, bvh_match.py now runs
those replacements (--pin-checks, default 128) and names every index one
of them also passes. An index is called pinned only when every replacement
was run; one past the cap or without an OBJ group is reported as not run.

docs/bvh.md: with every replacement run, the render-bucket rule gives the
kept set exactly in all 1,444 of 1,562 rule-independent matches whose
indices are pinned; the remaining exception and 15 re-found exceptions
differ only on unpinned indices, so none establishes a kept bucket-1/2
geometry.

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

Copy link
Copy Markdown
Contributor

Tested ecf4554e on Windows 11 x64 with CPython 3.12.10. python -I -B tests/test_bvh_match.py passed 48/48. Five additional synthetic cases went through the actual tools/bvh_match.py CLI with --json. All five exited 0, and stdout agreed with the JSON report.

Case Replacements tried / untried Observed result
Replaceable geometry 4 / 0 Complete. Index 1 accepted geometries 0 and 2, including one already used at the other index.
Unique triangle count 0 / 0 Complete. The single index was pinned.
Cap of 3 checks 3 / 1 Incomplete. Index 1 retained its observed alternative, geometry 0.
Missing trailing OBJ group 4 / 2 Incomplete. Index 1 retained both observed alternatives. The missing group accounted for two untried replacements.
Cap of 0 checks — The JSON pinning field was null and stdout omitted the pinning summary.

Both incomplete searches explicitly left the remaining index unresolved. Each fixture used one synthetic model. CPU only. AI-assisted with Codex.

@airp1ane

Copy link
Copy Markdown
Contributor

Tested ecf4554 on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass.

Ran the test files this PR adds or changes, from a clean checkout of the PR head: test_bvh_match.py - all exit 0.

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.

3 participants