feat(terrain): separate shade material selections

This commit is contained in:
2026-07-18 17:31:13 +04:00
parent 7a7578d0db
commit 575124830b
4 changed files with 65 additions and 5 deletions
+23
View File
@@ -211,6 +211,22 @@ pub struct TerrainMaterialPair {
pub flags: u16,
}
impl TerrainMaterialPair {
/// Returns the material-manager selection used by `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`].
#[must_use]
pub const fn shade_selection(self) -> TerrainMaterialSelection {
TerrainMaterialSelection {
table_index: 0,
material_index: self.material_lookup,
}
}
}
impl TerrainSlotTable {
/// Returns the render-dispatch header for one decoded slot record.
#[must_use]
@@ -1569,6 +1585,13 @@ mod tests {
},
])
);
assert_eq!(
document.slot_material_pairs(0).expect("material pairs")[0].shade_selection(),
TerrainMaterialSelection {
table_index: 0,
material_index: 0x0102,
}
);
assert_eq!(document.slot_material_pairs(1), None);
document.slots.slots_raw[0][2..4].copy_from_slice(&3_u16.to_le_bytes());
+3 -1
View File
@@ -27,7 +27,9 @@ use std::collections::VecDeque;
///
/// Applications access this semantic terrain API through this terrain crate
/// rather than taking a direct dependency on the binary-format parser.
pub use fparkan_terrain_format::{TerrainMaterialLayers, TerrainMaterialSelection};
pub use fparkan_terrain_format::{
TerrainMaterialLayers, TerrainMaterialPair, TerrainMaterialSelection,
};
/// Terrain world.
#[derive(Clone, Debug, Default)]