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>
39 lines
1.2 KiB
Rust
39 lines
1.2 KiB
Rust
//! Dump an M2's bones and vertices (position, UV, bone binding):
|
|
//! `cargo run -p benilla-m2 --example dump_verts <file.m2>`.
|
|
|
|
use std::io::Cursor;
|
|
|
|
fn main() {
|
|
let path = std::env::args()
|
|
.nth(1)
|
|
.expect("usage: dump_verts <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!("bones: {}", model.bones.len());
|
|
for (i, b) in model.bones.iter().enumerate() {
|
|
println!(
|
|
" bone {i}: key {} parent {} flags {:#06x} pivot ({:+.3},{:+.3},{:+.3})",
|
|
b.key_bone,
|
|
b.parent,
|
|
b.flags.bits(),
|
|
b.pivot.x,
|
|
b.pivot.y,
|
|
b.pivot.z
|
|
);
|
|
}
|
|
println!("vertices: {}", model.vertices.len());
|
|
for (i, v) in model.vertices.iter().enumerate() {
|
|
println!(
|
|
" v {i:3}: pos ({:+.3},{:+.3},{:+.3}) uv ({:+.3},{:+.3}) bones {:?} w {:?}",
|
|
v.position.x,
|
|
v.position.y,
|
|
v.position.z,
|
|
v.tex_coords.x,
|
|
v.tex_coords.y,
|
|
v.bone_indices,
|
|
v.bone_weights
|
|
);
|
|
}
|
|
}
|