Part of #41: the comments of `benilla-formats` (the library, its extract tools, examples and tests) are rewritten to the rule in `docs/METHOD.md`, which is what the code does and the reference fact behind it, in a line. 19,654 comment lines become 7,264. Fixes #105: the WMO collision comments now name walking's box-query leaf `0x6bca50` and the camera and line-of-sight segment-query leaf `0x6bc700`, in `models/collision.rs`, `examples/wmo_bsp.rs` and `tests/chain.rs`. - **The mechanical strip.** The citations that were only a private record number go first, and each edit is shown to be a pure removal. - **Wrong facts corrected.** The rewrite corrects the comments that stated wrong facts. Among them: - A placed doodad's material alpha reads file slot 0 on its spawn clock, while the reference reads bone 0's armed sequence, re-rolled every play window. The old text said doodads are armed once at load. - The fog end is stored ×36 and scaled once at load (`0x6d6090`). It is not raw. - The MCSH bit picks a map doodad's sun scale, 1.0 lit or 0.5 shadowed. 2.5 belongs to an entity's light node. - `SpellRec` is the row as stored, column × 4, not a translated copy. - A global sequence's clock is anchored at the instance's attach time (`0x714352`). - Particle twinkle is a gated size multiplier (`0x7b2adc`). - The blob shadow sizes from the Stand box. - Data claims are checked against the install: the weapon-trail kits' parameters and alphas, the beam rows' noise, and the maps' `field_16`. - Dozens more turned up on the way: renamed or deleted items, docs sitting on the wrong item, stale counts and links. - **Deviation labels.** "Deviation:" now marks only a choice with a reason. An unbuilt behaviour says so plainly. - **Verification.** Every file strips to identical code, and `cargo fmt --check` is clean. Four second readers compared every file old against new, restored the facts the rewrite had dropped, and checked each new citation against the reference, the code and the shipped data. 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>
76 lines
2.3 KiB
Rust
76 lines
2.3 KiB
Rust
//! Keys are selected by absolute timestamp within each sequence's band, so every key of every
|
|
//! sequence lands inside `[0, duration]`.
|
|
|
|
use benilla_formats::{open_chain, parse_m2_animations, ModelAnimation};
|
|
|
|
/// Simple rigs (rabbit, chicken) through humanoid ones (kobold, murloc).
|
|
const CREATURES: &[&str] = &[
|
|
"Creature\\Rabbit\\Rabbit.m2",
|
|
"Creature\\Chicken\\Chicken.m2",
|
|
"Creature\\Deer\\Deer.m2",
|
|
"Creature\\Kobold\\Kobold.m2",
|
|
"Creature\\Wolf\\Wolf.m2",
|
|
"Creature\\Murloc\\Murloc.m2",
|
|
"Creature\\Bear\\Bear.m2",
|
|
"Creature\\Cat\\Cat.m2",
|
|
];
|
|
|
|
#[test]
|
|
fn creature_animation_keyframes_stay_within_their_sequence() {
|
|
let data = benilla_formats::wow_data_or_skip!();
|
|
let mut chain = open_chain(&data).expect("open vanilla patch chain");
|
|
|
|
let mut checked = 0;
|
|
for path in CREATURES {
|
|
let Ok(bytes) = chain.read_file(path) else {
|
|
continue; // not in this install
|
|
};
|
|
let anims = parse_m2_animations(&bytes);
|
|
assert!(
|
|
!anims.is_empty(),
|
|
"{path}: a creature should have sequences"
|
|
);
|
|
// Records are not ordered by id (Rabbit's record 0 is Walk): the idle is found by id.
|
|
let ids: Vec<u16> = anims.iter().map(|a| a.anim_id).collect();
|
|
assert!(
|
|
ids.contains(&0),
|
|
"{path}: no Stand (id 0) among sequence ids {ids:?}"
|
|
);
|
|
for anim in &anims {
|
|
assert!(
|
|
anim.duration > 0.0,
|
|
"{path}: anim {} has no duration",
|
|
anim.anim_id
|
|
);
|
|
let max_t = max_key_time(anim);
|
|
assert!(
|
|
max_t <= anim.duration + 1e-3,
|
|
"{path}: anim {} key at {max_t:.3}s exceeds duration {:.3}s — a cross-sequence leak",
|
|
anim.anim_id,
|
|
anim.duration
|
|
);
|
|
}
|
|
checked += 1;
|
|
}
|
|
assert!(
|
|
checked > 0,
|
|
"no test creatures present — expected at least the rabbit"
|
|
);
|
|
}
|
|
|
|
fn max_key_time(anim: &ModelAnimation) -> f32 {
|
|
let mut max = 0.0_f32;
|
|
for b in &anim.bones {
|
|
for (t, _) in &b.translation {
|
|
max = max.max(*t);
|
|
}
|
|
for (t, _) in &b.rotation {
|
|
max = max.max(*t);
|
|
}
|
|
for (t, _) in &b.scale {
|
|
max = max.max(*t);
|
|
}
|
|
}
|
|
max
|
|
}
|