From df78c4758e18a56b5498e8051574447d24a40cd7 Mon Sep 17 00:00:00 2001
From: pkuzic
Date: Fri, 25 Sep 2026 23:23:43 +0100
Subject: [PATCH] MONKEY (reviewfix): preserve missing stage-one UV transforms
Co-Authored-By: GPT-5.6 Sol (Codex)
---
crates/benilla-formats/src/models/m2_batches.rs | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/crates/benilla-formats/src/models/m2_batches.rs b/crates/benilla-formats/src/models/m2_batches.rs
index 6cb13f03..eca42d5f 100644
--- a/crates/benilla-formats/src/models/m2_batches.rs
+++ b/crates/benilla-formats/src/models/m2_batches.rs
@@ -492,16 +492,20 @@ pub fn parse_m2_render_submeshes(
.get(batch.texture_coord_combo_index as usize + 1)
.copied()
.unwrap_or(0);
- let combo = batch.texture_transform_combo_index.wrapping_add(1);
+ // MONKEY (reviewfix): 0xffff is the no-transform sentinel. Advancing stage 1 must
+ // keep it absent rather than wrap it onto stage 0's transform at index zero.
+ let combo = batch.texture_transform_combo_index.checked_add(1);
Some((
resolve_texture(rec, dir, skins).0,
(rec.wrap_x, rec.wrap_y),
set == 1,
batch.shader_id & 0xf == 4,
- tex_anim::bake_uv_anim(model, combo, seq0_slot),
- tex_anim::bake_uv_rot_seqs(model, combo, &seq_slots)
+ combo.and_then(|combo| tex_anim::bake_uv_anim(model, combo, seq0_slot)),
+ combo
+ .and_then(|combo| tex_anim::bake_uv_rot_seqs(model, combo, &seq_slots))
.and_then(|s| s.seq(None).cloned()),
- tex_anim::bake_uv_scale_seqs(model, combo, &seq_slots)
+ combo
+ .and_then(|combo| tex_anim::bake_uv_scale_seqs(model, combo, &seq_slots))
.and_then(|s| s.seq(None).cloned()),
))
})