debug_find_index_buffer scans the container for an index buffer that validates against a capture-proven vertex buffer. For eng_02_l nothing validates with the connectivity test on; with it off the nearest hit is exact pad-0 adjacency (vb-ib = 144 = 72*2). The block's mean_edge/diag is 0.417 against a 0.28 cap -- the documented false positive for coarse LODs, now caught with ground truth. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
28 lines
1.2 KiB
Rust
28 lines
1.2 KiB
Rust
//! Where could a resource's index buffer be, given the vertex buffer a runtime
|
|
//! capture proves the engine drew from? Tests the anchor scan's adjacency
|
|
//! assumption against ground truth.
|
|
use sylpheed_formats::mesh::{debug_find_index_buffer, debug_resource_params};
|
|
fn main() {
|
|
let a: Vec<String> = std::env::args().collect();
|
|
let bytes = std::fs::read(&a[1]).unwrap();
|
|
for pair in a[2..].iter() {
|
|
let (name, off) = pair.split_once('@').unwrap();
|
|
let vb = usize::from_str_radix(off.trim_start_matches("0x"), 16).unwrap();
|
|
let params = debug_resource_params(&bytes, name);
|
|
let markers = params.as_ref().map(|(m, _)| m.clone()).unwrap_or_default();
|
|
println!("{name} @ 0x{vb:x} markers={markers:?}");
|
|
let hits = debug_find_index_buffer(&bytes, name, vb);
|
|
if hits.is_empty() {
|
|
println!(" no index buffer anywhere in the container validates this block");
|
|
}
|
|
let mut hits = hits;
|
|
hits.sort_by_key(|(_, d)| d.abs());
|
|
for (ib, d) in hits.iter().take(8) {
|
|
println!(" ib 0x{ib:x} vb-ib = {d} bytes");
|
|
}
|
|
if hits.len() > 8 {
|
|
println!(" … {} total", hits.len());
|
|
}
|
|
}
|
|
}
|