Files
benilla-octo/crates/benilla-formats/tests/m2_playable_animation_lookup.rs
Sam SungandClaude Opus 5.5 8505187668 Comments in benilla-formats: one line of fact each, no history, no record numbers (#130)
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>
2026-09-24 19:38:53 +07:00

56 lines
2.4 KiB
Rust

//! The M2 `playableAnimationLookup`, which resolves an animation id the model lacks: 203 rows in
//! every shipped M2, sized to `AnimationData.dbc`'s playable set.
use benilla_formats::{open_chain, parse_m2_playable_animation_lookup};
#[test]
fn humanmale_playable_animation_lookup_matches_the_byte_verified_shape() {
let data = benilla_formats::wow_data_or_skip!();
let chain = open_chain(&data).expect("open chain");
let bytes = chain
.read("character\\human\\male\\humanmale.m2")
.expect("read m2");
let pal = parse_m2_playable_animation_lookup(&bytes).expect("parse playable animation lookup");
assert_eq!(pal.len(), 203);
// HumanMale authors Stand, Death, WalkBackwards, Walk and Run, so they map to themselves.
for id in [0u16, 1, 3, 4, 5] {
let row = pal[id as usize];
assert_eq!(row.resolved_id, id, "row {id} should be identity");
assert_eq!(row.dir_flags, 0, "row {id} should carry no dir-flags code");
}
// Row 6 packs `0x00030001`, Death with dir-flags 3, which the DBC Fallback walk (`0x711bf0`)
// over row 6 (Fallback 1, Flags 0x28) reproduces.
assert_eq!(pal[6].resolved_id, 1, "row 6 -> Death, the DBC-walk proof");
assert_eq!(pal[6].dir_flags, 3, "row 6's direction/variant code");
assert_eq!(pal[32].resolved_id, 16, "row 32 substitutes AttackUnarmed");
}
/// The stealth clips, 119 StealthWalk and 120 StealthStand: a player model authors both, and where
/// a creature authors neither the baked lookup steps them to Walk and Stand, so a prowling druid
/// cat walks as usual in the reference too.
#[test]
fn the_stealth_clips_are_authored_by_players_and_absent_from_the_druid_cat() {
let data = benilla_formats::wow_data_or_skip!();
let chain = open_chain(&data).expect("open chain");
let pal = |path: &str| {
parse_m2_playable_animation_lookup(&chain.read(path).expect("read m2")).expect("parse pal")
};
for model in [
"character\\human\\male\\humanmale.m2",
"character\\nightelf\\female\\nightelffemale.m2",
] {
let p = pal(model);
assert_eq!(p[119].resolved_id, 119, "{model} authors StealthWalk");
assert_eq!(p[120].resolved_id, 120, "{model} authors StealthStand");
}
let cat = pal("creature\\druidcat\\druidcat.m2");
assert_eq!(cat[119].resolved_id, 4, "cat StealthWalk -> Walk");
assert_eq!(cat[120].resolved_id, 0, "cat StealthStand -> Stand");
}