//! How much of the "decoded geometry" belongs to SCENE COMPOSITES rather than to
//! real meshes? A composite (`rou_*`, `e_rou_*`) carries node transforms; the
//! anchor scan nevertheless finds a block for it, and that pseudo-geometry lands
//! in coverage and consistency counts.
//! Usage: composite_geometry <resource3d_dir>
use sylpheed_formats::mesh::{scene_world_nodes, Xbg7Model};
fn main() {
    let dir = std::env::args().nth(1).expect("resource3d dir");
    let mut files: Vec<_> = std::fs::read_dir(&dir)
        .unwrap()
        .flatten()
        .map(|e| e.path())
        .filter(|p| p.extension().and_then(|s| s.to_str()) == Some("xpr"))
        .collect();
    files.sort();
    let (mut total, mut composite, mut composite_named) = (0usize, 0usize, 0usize);
    for f in &files {
        let Ok(bytes) = std::fs::read(f) else { continue };
        for m in Xbg7Model::anchor_models_cancellable(&bytes, 0.0, &|| false) {
            total += 1;
            let has_nodes = !scene_world_nodes(&bytes, &m.name).is_empty();
            let named = m.name.starts_with("rou_") || m.name.starts_with("e_rou_");
            if has_nodes {
                composite += 1;
            }
            if named {
                composite_named += 1;
            }
        }
    }
    println!(
        "{total} decoded; {composite} have scene nodes (a composite), {composite_named} are named rou_/e_rou_"
    );
}
