Files
benilla-octo/crates/benilla-m2/examples/dump_attach.rs
T
Sam SungandClaude Opus 5.5 bf8a15de02 Comments in the small crates: one line of fact each, no history, no record numbers (#93)
Part of #41: the comments of the thirteen small crates (`benilla-adt`, `-blp`, `-buildstamp`, `-bytes`, `-dbc`, `-m2`, `-mpq`, `-srp`, `-visual`, `-wdt`, `-wmo`, `-worldview` and `benilla`) rewritten to the rule in `docs/METHOD.md`: what the code does and the reference fact behind it, in a line. 2,176 comment lines become 1,029.

- The citations that were only a private record number go first, mechanically, each edit shown to be a pure removal.
- The rewrite corrects the comments that stated wrong facts: the M2 header's selection-ring claim, the texture-transform and MCNK impassable-flag notes, a DBC reader note that said short records zero-pad (they do not, #17), and about twenty more found on the way. The SRP handshake's redraw and redial are marked as a deviation, with the measured reason.
- Verified: every file strips to identical code, and `cargo fmt --check` is clean. A second reader compared every file old against new and restored the facts the rewrite had dropped.

String literals are untouched; they are #92.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 15:51:18 +07:00

38 lines
1.3 KiB
Rust

//! Dump an M2's attachments and event markers with their bone's parent:
//! `cargo run -p benilla-m2 --example dump_attach <file.m2>`, extracted first with `mpqx`
//! (benilla-formats).
use std::io::Cursor;
fn main() {
let path = std::env::args()
.nth(1)
.expect("usage: dump_attach <file.m2>");
let data = std::fs::read(&path).expect("read m2");
let m2 = benilla_m2::parse_m2(&mut Cursor::new(data.as_slice())).expect("parse m2");
let model = m2.model();
println!("attachments: {}", model.attachments.len());
for a in &model.attachments {
let bone = model.bones.get(a.bone as usize);
let parent = bone.map_or(-1, |b| b.parent);
println!(
"id {:2} bone {:3} (parent {:3}) pos ({:+.3},{:+.3},{:+.3})",
a.id, a.bone, parent, a.position[0], a.position[1], a.position[2]
);
}
println!("event markers: {}", model.event_markers.len());
for m in &model.event_markers {
let bone = model.bones.get(m.bone as usize);
let parent = bone.map_or(-1, |b| b.parent);
println!(
"{} bone {:3} (parent {:3}) pos ({:+.3},{:+.3},{:+.3})",
String::from_utf8_lossy(&m.ident),
m.bone,
parent,
m.position[0],
m.position[1],
m.position[2]
);
}
}