From e9c1a83c51070c4f8da76540c17c2393922b6fcc Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2026 17:39:52 +0400 Subject: fix(terrain): preserve opaque shade lookup keys --- crates/fparkan-inspection/src/lib.rs | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'crates/fparkan-inspection/src/lib.rs') diff --git a/crates/fparkan-inspection/src/lib.rs b/crates/fparkan-inspection/src/lib.rs index e2b9068..be1f098 100644 --- a/crates/fparkan-inspection/src/lib.rs +++ b/crates/fparkan-inspection/src/lib.rs @@ -146,6 +146,19 @@ pub struct WearMaterialTexture { pub image: fparkan_texm::RgbaImage, } +/// Compact inspection summary of a WEAR resource stored in an archive. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct WearInspection { + /// Number of material rows. + pub materials: usize, + /// Number of lightmap rows. + pub lightmaps: usize, + /// First material resource name, when present. + pub first_material: Option, + /// Last material resource name, when present. + pub last_material: Option, +} + /// Land map/msh inspection payload. #[derive(Clone, Debug, Eq, PartialEq)] pub struct MapInspection { @@ -374,6 +387,34 @@ pub fn inspect_model_from_root( }) } +/// Inspects a WEAR resource through repository-backed lookup. +/// +/// # Errors +/// +/// Returns a string error when the resource cannot be resolved or parsed as a +/// valid WEAR payload. +pub fn inspect_wear_from_root( + root: &Path, + archive: &str, + resource: &str, +) -> Result { + let bytes = read_resource_bytes_diagnostic(root, archive, resource) + .map_err(|err| render_human(&err))?; + let wear = decode_wear(&bytes).map_err(|err| err.to_string())?; + Ok(WearInspection { + materials: wear.entries.len(), + lightmaps: wear.lightmaps.len(), + first_material: wear + .entries + .first() + .map(|entry| String::from_utf8_lossy(&entry.material.0).into_owned()), + last_material: wear + .entries + .last() + .map(|entry| String::from_utf8_lossy(&entry.material.0).into_owned()), + }) +} + /// Loads and validates a model resource through repository-backed lookup. /// /// # Errors -- cgit v1.2.3