example fixes

This commit is contained in:
Robin Appelman 2023-12-21 20:57:10 +01:00
commit 8431ff6613
3 changed files with 10 additions and 9 deletions

9
Cargo.lock generated
View file

@ -1054,16 +1054,15 @@ dependencies = [
[[package]]
name = "gltf"
version = "1.4.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b78f069cf941075835822953c345b9e1edd67ae347b81ace3aea9de38c2ef33"
checksum = "ad2dcfb6dd7a66f9eb3d181a29dcfb22d146b0bcdc2e1ed1713cbf03939a88ea"
dependencies = [
"base64",
"byteorder",
"gltf-json",
"image 0.24.7",
"lazy_static",
"serde_json",
"urlencoding",
]
@ -1081,9 +1080,9 @@ dependencies = [
[[package]]
name = "gltf-json"
version = "1.4.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "655951ba557f2bc69ea4b0799446bae281fa78efae6319968bdd2c3e9a06d8e1"
checksum = "7d5b810806b78dde4b71a95cc0e6fdcab34c4c617da3574df166f9987be97d03"
dependencies = [
"gltf-derive",
"serde",

View file

@ -26,8 +26,8 @@ iai = "0.1"
vtf = "0.1.6"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
gltf-json = "1.3.0"
gltf = "1.3.0"
gltf-json = "=1.3.0"
gltf = "=1.3.0"
image = "0.23.14"
clap = { version = "4.4.11", features = ["derive"] }
main_error = "0.1.2"

View file

@ -54,7 +54,7 @@ pub fn load_material(
let path = format!("{}.vmt", name.to_ascii_lowercase().trim_end_matches(".vmt"));
let path = loader
.find_in_paths(&path, &dirs)
.ok_or(Error::Other(format!("Can't find file {}", path)))?;
.ok_or_else(|| Error::Other(format!("Can't find file {}", path)))?;
let raw = loader.load(&path)?.expect("didn't find foudn path?");
let vdf = String::from_utf8(raw)?;
@ -71,7 +71,9 @@ pub fn load_material(
Ok::<_, Error>(vdf)
})?;
let base_texture = material.base_texture();
let base_texture = material
.base_texture()
.ok_or_else(|| Error::Other("no basetexture".into()))?;
let translucent = material.translucent();
let glass = material.surface_prop() == Some("glass");