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>
90 lines
4.0 KiB
Rust
90 lines
4.0 KiB
Rust
//! FixColorVertexAlpha, the portal fade: MOCV vertices at a portal whose far side is an exterior
|
|
//! group turn `(255, 255, 255, 255)`, interior-to-interior portals whiten nothing, and there is no
|
|
//! MOPY alpha pre-pass. A capture of the reference's uploaded MOCV for the Northshire abbey matches
|
|
//! the file in all 678 vertices of group 1 and in 496 of 506 in group 3.
|
|
|
|
use benilla_formats::{parse_wmo_root, wmo_group_fixed_colors, Chain};
|
|
|
|
/// (slots the fade rewrites, slot count, mean luminance before, after) for one group.
|
|
fn fade_census(reader: &Chain, stem: &str, gi: u32) -> (usize, usize, f32, f32) {
|
|
let root_bytes = reader.read(&format!("{stem}.wmo")).expect("read root");
|
|
let root = parse_wmo_root(&root_bytes).expect("parse root");
|
|
let gbytes = reader
|
|
.read(&format!("{stem}_{gi:03}.wmo"))
|
|
.expect("read group");
|
|
let raw = benilla_formats::wmo_group_raw_colors(&gbytes).expect("group carries MOCV");
|
|
let fixed = wmo_group_fixed_colors(&gbytes, &root).expect("group carries MOCV");
|
|
let lum =
|
|
|c: [u8; 4]| 0.299 * f32::from(c[2]) + 0.587 * f32::from(c[1]) + 0.114 * f32::from(c[0]);
|
|
let n = raw.len().max(1) as f32;
|
|
let changed = raw.iter().zip(&fixed).filter(|(a, b)| a != b).count();
|
|
(
|
|
changed,
|
|
raw.len(),
|
|
raw.iter().map(|&c| lum(c)).sum::<f32>() / n,
|
|
fixed.iter().map(|&c| lum(c)).sum::<f32>() / n,
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn abbey_matches_the_reference_capture() {
|
|
let data = benilla_formats::wow_data_or_skip!();
|
|
let reader = Chain::open(&data).expect("open vanilla patch chain");
|
|
let stem = "World\\wmo\\Azeroth\\Buildings\\NSabbey\\NSabbey";
|
|
|
|
let (changed, total, _, _) = fade_census(&reader, stem, 1);
|
|
assert_eq!(total, 678, "capture's group 1 upload was 678 vertices");
|
|
assert_eq!(
|
|
changed, 0,
|
|
"group 1's portals all lead to interior neighbours — the capture read it byte-exact"
|
|
);
|
|
|
|
let (changed, total, before, after) = fade_census(&reader, stem, 3);
|
|
assert_eq!(total, 506, "capture's group 3 upload was 506 vertices");
|
|
assert_eq!(
|
|
changed, 10,
|
|
"the capture read 496/506 byte-exact — the fade's whole footprint is 10 slots \
|
|
(an infinite-plane distance test rewrites 12; the MOPY pre-pass would rewrite 372)"
|
|
);
|
|
// Those 10 are near-white in the file already (225..254).
|
|
assert!(
|
|
(before - after).abs() < 0.5,
|
|
"abbey g003 mean luminance moved {before} → {after}"
|
|
);
|
|
}
|
|
|
|
/// Dire Maul's five entrance corridors author their walkway at MOCV `(10, 10, 40)`, alpha 0, which
|
|
/// the interior TRANS lighting renders near-black; its corners sit in the doorway portals, so the
|
|
/// fade takes them white.
|
|
#[test]
|
|
fn dire_maul_entrance_corridor_floors_are_lit() {
|
|
let data = benilla_formats::wow_data_or_skip!();
|
|
let reader = Chain::open(&data).expect("open vanilla patch chain");
|
|
let stem = "World\\wmo\\Dungeon\\KL_Diremaul\\KL_Diremaul";
|
|
|
|
for gi in [12, 14, 17, 27, 31] {
|
|
let root_bytes = reader.read(&format!("{stem}.wmo")).expect("read root");
|
|
let root = parse_wmo_root(&root_bytes).expect("parse root");
|
|
let gbytes = reader
|
|
.read(&format!("{stem}_{gi:03}.wmo"))
|
|
.expect("read group");
|
|
let raw = benilla_formats::wmo_group_raw_colors(&gbytes).expect("MOCV");
|
|
let fixed = wmo_group_fixed_colors(&gbytes, &root).expect("MOCV");
|
|
|
|
let dark = raw.iter().filter(|c| **c == [40, 10, 10, 0]).count();
|
|
assert!(
|
|
dark >= 4,
|
|
"g{gi:03} should author its walkway quad at BGRA (40,10,10,0); found {dark} such slots"
|
|
);
|
|
// A corner just off the portal plane takes the partial lerp at t ≈ 0.997 and lands on 254.
|
|
for (i, (r, f)) in raw.iter().zip(&fixed).enumerate() {
|
|
if *r == [40, 10, 10, 0] {
|
|
assert!(
|
|
f.iter().all(|&c| c >= 250),
|
|
"g{gi:03} v{i}: the corridor floor must whiten, or it renders black — got {f:?}"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|