Repository navigation
RageModelDecoder: decode a drawable's other LODs - #24
Conversation
A drawable header holds four LOD pointers (+0x50, +0x58, +0x60, +0x68); ProbeDrawable already walks all four, but Decode read only the first. Decode(system, graphics, drawableOffset, lod) picks one of them; the existing overloads keep LOD 0. A drawable without the requested LOD (a zero pointer) does not decode, like any other rejected layout. RageModel.Lod records which list the meshes come from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
breadbbbb
left a comment
There was a problem hiding this comment.
Reviewed 65a9b02 integrated into current main. No blocking defect found in the Core LOD-selection change.
265 generated controls pass across all four distinct LOD lists in standalone drawables, dictionary children and fragments. They cover missing LODs, invalid arguments/pointers, truncated inputs, model-count limits, explicit child ownership, automatic dictionary selection and unchanged legacy defaults. Another 312 decoder controls and 218 header/recovery controls pass.
All six saved native LOD 0 geometry, metadata and OBJ snapshots match baseline exactly. The saved samples do not contain complete decodable lower LODs, so positive LOD 1-3 coverage is synthetic; the full-game results in the description remain author-reported.
Release builds of App, IndexBuilder and the pinned Leonida exporter/diagnostics pass with zero warnings or errors. Leonida diagnostics and output failure/retry tests pass. Existing calls and the desktop viewer retain LOD 0; the new selection is a Core API feature. The maintainer merge will document that scope and retain the repository's source-comment policy.
Why
A drawable header holds four LOD pointers, at
+0x50,+0x58,+0x60and+0x68.ProbeDrawablealready walks all four, butModelReader.Decodereads only the first, so a caller cannot get a drawable's other LODs.Leonida needs the second one: on the interior measured for its
docs/bvh.md§4a, 101 of the 124 archetypes that have a ray-tracing BLAS incore_bvh4.rpfare built from the LOD at+0x58, not the first. Without it, itsbvh_match.pyfinds no candidate for them (ItsNotRexed/Leonida#4506, coordination item BUILD-1316).Change
Core/RageModelDecoder.csonly:RageModelDecoder.Decode(system, graphics, drawableOffset, lod): a new overload that picks the drawable's LOD model list (0 toLodCount - 1). The existing overloads pass 0, so every current caller gets the same result as before.ModelReader.Decodetakeslodand reads the pointer atdrawable + 0x50 + 8 * lod. A zero pointer (the drawable has no such LOD) isRequired against, so it does not decode, like any other rejected layout, and alodoutside 0 to 3 returns null.RageModel.Lodrecords which list the meshes come from;RageModelDecoder.LodCount = 4.Nothing else changes: the materials, embedded textures and declared bounds belong to the drawable and are read as before.
Tested
Windows 11 Pro, .NET 8, on my own copy of the files (only counts here):
dotnet build Core/RpfPreview.Core.csproj -c Release: 0 warnings, 0 errors, on this branch (frome293917) and merged intomainatb1de725(merges cleanly).rpf9dump, which now calls the new overload: LOD 0 output of a 1 GiB window oflevels.rpfis identical to the build before the change (1,229 models, every manifest row and every OBJ byte for byte).AI-assisted (Claude Code).
🤖 Generated with Claude Code