fix(terrain): preserve opaque shade lookup keys

This commit is contained in:
2026-07-18 17:39:52 +04:00
parent 575124830b
commit e9c1a83c51
5 changed files with 131 additions and 46 deletions
+9 -15
View File
@@ -212,18 +212,15 @@ pub struct TerrainMaterialPair {
}
impl TerrainMaterialPair {
/// Returns the material-manager selection used by `GetShade`.
/// Returns the opaque lookup key supplied to `GetShade`.
///
/// `GetShade` owns a manager loaded only with `Shade.wea`, so its
/// 16-bit lookup occupies row bits of that manager's table zero. It is
/// deliberately separate from the `Land1.wea`/`Land2.wea` selections
/// carried by [`TerrainMaterialLayers`].
/// This is deliberately separate from the `Land1.wea`/`Land2.wea`
/// selectors carried by [`TerrainMaterialLayers`]. Although `GetShade`
/// owns a manager loaded from `Shade.wea`, this key is not a WEAR row:
/// observed map values exceed that table's row count.
#[must_use]
pub const fn shade_selection(self) -> TerrainMaterialSelection {
TerrainMaterialSelection {
table_index: 0,
material_index: self.material_lookup,
}
pub const fn shade_lookup_key(self) -> u16 {
self.material_lookup
}
}
@@ -1586,11 +1583,8 @@ mod tests {
])
);
assert_eq!(
document.slot_material_pairs(0).expect("material pairs")[0].shade_selection(),
TerrainMaterialSelection {
table_index: 0,
material_index: 0x0102,
}
document.slot_material_pairs(0).expect("material pairs")[0].shade_lookup_key(),
0x0102
);
assert_eq!(document.slot_material_pairs(1), None);