mirror of
https://codeberg.org/icewind/vbspview.git
synced 2026-06-03 18:24:09 +02:00
handle water
This commit is contained in:
parent
eb3df01eb6
commit
cbb139c9d1
1 changed files with 24 additions and 5 deletions
|
|
@ -43,23 +43,42 @@ pub fn load_material(
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let path = format!("{}.vmt", name.to_ascii_lowercase());
|
let path = format!("{}.vmt", name.to_ascii_lowercase().trim_end_matches(".vmt"));
|
||||||
let raw = loader.load_from_paths(&path, &dirs)?;
|
let raw = loader.load_from_paths(&path, &dirs)?;
|
||||||
|
|
||||||
let vmt = parse_vdf(raw)?;
|
let vmt = parse_vdf(raw)?;
|
||||||
let vmt = resolve_vmt_patch(vmt, loader)?;
|
let vmt = resolve_vmt_patch(vmt, loader)?;
|
||||||
|
|
||||||
|
let material_type = vmt
|
||||||
|
.keys()
|
||||||
|
.next()
|
||||||
|
.ok_or(Error::Other("empty vmt"))?
|
||||||
|
.to_ascii_lowercase();
|
||||||
|
if material_type == "water" {
|
||||||
|
return Ok(CpuMaterial {
|
||||||
|
albedo: Color {
|
||||||
|
r: 82,
|
||||||
|
g: 180,
|
||||||
|
b: 217,
|
||||||
|
a: 128,
|
||||||
|
},
|
||||||
|
name: name.into(),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let table = vmt
|
let table = vmt
|
||||||
.values()
|
.values()
|
||||||
.next()
|
.next()
|
||||||
.expect("empty vmt")
|
.ok_or(Error::Other("empty vmt"))?
|
||||||
.as_table()
|
.as_table()
|
||||||
.expect("vmt not a table");
|
.ok_or(Error::Other("vmt not a table"))?;
|
||||||
let base_texture = table
|
let base_texture = table
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|(key, value)| (key.to_ascii_lowercase() == "$basetexture").then_some(value))
|
.find_map(|(key, value)| (key.to_ascii_lowercase() == "$basetexture").then_some(value))
|
||||||
.expect("no $basetexture")
|
.ok_or(Error::Other("no $basetexture"))?
|
||||||
.as_value()
|
.as_value()
|
||||||
.expect("$basetexture not a value")
|
.ok_or(Error::Other("$basetexture not a value"))?
|
||||||
.to_string()
|
.to_string()
|
||||||
.to_ascii_lowercase()
|
.to_ascii_lowercase()
|
||||||
.replace('\\', "/")
|
.replace('\\', "/")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue