underwater doesn't have base texture

This commit is contained in:
Robin Appelman 2023-12-19 18:29:06 +01:00
commit 47e37c5b81
3 changed files with 8 additions and 4 deletions

View file

@ -88,7 +88,7 @@ impl Material {
Material::VertexLitGeneric(mat) => &mat.base_texture, Material::VertexLitGeneric(mat) => &mat.base_texture,
Material::UnlitGeneric(mat) => &mat.base_texture, Material::UnlitGeneric(mat) => &mat.base_texture,
Material::WorldVertexTransition(mat) => &mat.base_texture, Material::WorldVertexTransition(mat) => &mat.base_texture,
Material::Water(mat) => &mat.base_texture, Material::Water(mat) => mat.base_texture.as_deref().unwrap_or_default(),
Material::EyeRefract(mat) => &mat.iris, Material::EyeRefract(mat) => &mat.iris,
_ => "", _ => "",
} }

View file

@ -5,8 +5,12 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WaterMaterial { pub struct WaterMaterial {
/// Usually referred to as a "sludge-layer", acts as a layer on top of the surface of the $AboveWater Material. /// Usually referred to as a "sludge-layer", acts as a layer on top of the surface of the $AboveWater Material.
#[serde(rename = "$basetexture", deserialize_with = "deserialize_path")] #[serde(
pub base_texture: String, rename = "$basetexture",
default,
deserialize_with = "deserialize_path"
)]
pub base_texture: Option<String>,
/// Tells this material is used for models and not brushes. /// Tells this material is used for models and not brushes.
#[serde(rename = "$abovewater", default)] #[serde(rename = "$abovewater", default)]
pub above_water: bool, pub above_water: bool,

View file

@ -3,7 +3,7 @@ source: tests/parse.rs
expression: result expression: result
--- ---
water(WaterMaterial( water(WaterMaterial(
r#$basetexture: "swamp/water/water_murky", r#$basetexture: Some("swamp/water/water_murky"),
r#$abovewater: true, r#$abovewater: true,
r#$bottommaterial: Some("swamp/water/water_murky_beneath.vmt"), r#$bottommaterial: Some("swamp/water/water_murky_beneath.vmt"),
r#$underwaterover: None, r#$underwaterover: None,