mirror of
https://codeberg.org/icewind/vbsp-to-gltf.git
synced 2026-06-03 18:24:07 +02:00
improve error handling when loading materials
This commit is contained in:
parent
7546456665
commit
bfe990521f
4 changed files with 44 additions and 34 deletions
54
Cargo.lock
generated
54
Cargo.lock
generated
|
|
@ -624,22 +624,23 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "3.0.2"
|
||||
version = "5.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.7"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"winapi",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1134,9 +1135,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "keyvalues-parser"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d990301996c856ea07a84bc291e76f1273db52683663efc05c8d355976897e5"
|
||||
checksum = "7e4c8354918309196302015ac9cae43362f1a13d0d5c5539a33b4c2fd2cd6d25"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_derive",
|
||||
|
|
@ -1145,14 +1146,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "keyvalues-serde"
|
||||
version = "0.1.0"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da419ac133bb3ddf0dbf9c12fcc0ce01d994fcb65f6f1713faf15cc689320b5f"
|
||||
checksum = "0447866c47c00f8bd1949618e8f63017cf93e985b4684dc28d784527e2882390"
|
||||
dependencies = [
|
||||
"keyvalues-parser",
|
||||
"once_cell",
|
||||
"paste",
|
||||
"regex",
|
||||
"serde",
|
||||
"thiserror",
|
||||
]
|
||||
|
|
@ -1516,6 +1514,12 @@ version = "1.19.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
|
|
@ -1613,6 +1617,15 @@ version = "1.0.15"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "path-dedot"
|
||||
version = "3.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.1"
|
||||
|
|
@ -2342,10 +2355,11 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|||
|
||||
[[package]]
|
||||
name = "steamlocate"
|
||||
version = "2.0.0-alpha.0"
|
||||
version = "2.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b1568c4a70a26c4373fe1131ffa4eff055459631b6e40c6bc118615f2d870c3"
|
||||
checksum = "c3b6a4810c4e7fecb0123a9a8ba99b335c17d92e636c265ef99108ee4734c812"
|
||||
dependencies = [
|
||||
"crc",
|
||||
"dirs",
|
||||
"keyvalues-parser",
|
||||
"keyvalues-serde",
|
||||
|
|
@ -2510,10 +2524,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tf-asset-loader"
|
||||
version = "0.1.5"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "326290157536076fb15061d8c070966bc7fddc43a17c24f444cfcc4cb11ac7a1"
|
||||
checksum = "c4cd8dbb785f43ecd6bf4c6410b8e9a73f06b1115542a16dccc50aed257d29b3"
|
||||
dependencies = [
|
||||
"path-dedot",
|
||||
"steamlocate",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
|
|
@ -3318,11 +3333,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.10.1"
|
||||
version = "0.51.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
|
||||
checksum = "937f3df7948156640f46aacef17a70db0de5917bda9c92b0f751f3a955b588fc"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
"cfg-if",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ name = "vbsp-to-gltf"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.80.0"
|
||||
default-run = "vbsp-to-gltf"
|
||||
|
||||
[lib]
|
||||
name = "vbsp_to_gltf"
|
||||
|
|
@ -27,7 +28,7 @@ tracing-tree = "0.4.0"
|
|||
vtf = "0.3.0"
|
||||
vmt-parser = "0.2.0"
|
||||
image = "0.25.2"
|
||||
tf-asset-loader = { version = "0.1.5", features = ["zip"] }
|
||||
tf-asset-loader = { version = "0.1.7", features = ["zip"] }
|
||||
vmdl = "0.2"
|
||||
clap = { version = "4.4.18", features = ["derive"] }
|
||||
gltf-json = { version = "1.4.1", features = ["KHR_texture_transform"] }
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ pub fn load_material(
|
|||
let path = loader
|
||||
.find_in_paths(&path, &dirs)
|
||||
.ok_or(Error::Other(format!("Can't find file {}", path)))?;
|
||||
let raw = loader.load(&path)?.expect("didn't find foudn path?");
|
||||
let raw = loader.load(&path)?.expect("didn't find found path?");
|
||||
let vdf = String::from_utf8(raw)?;
|
||||
|
||||
let material = from_str(&vdf).map_err(|e| {
|
||||
|
|
|
|||
19
src/prop.rs
19
src/prop.rs
|
|
@ -131,7 +131,7 @@ pub fn push_or_get_model(
|
|||
match get_mesh_index(&gltf.meshes, &skinned_name) {
|
||||
Some(index) => Some(index),
|
||||
None => {
|
||||
let prop = load_prop(loader, model).expect("failed to load prop");
|
||||
let prop = load_prop(loader, model).ok()?;
|
||||
if prop.vertices().is_empty() {
|
||||
None
|
||||
} else {
|
||||
|
|
@ -242,18 +242,11 @@ pub fn push_primitive(
|
|||
gltf.accessors.push(accessor);
|
||||
|
||||
let material = if options.textures {
|
||||
let texture = skin
|
||||
.texture_info(mesh.material_index())
|
||||
.expect("mat out of bounds");
|
||||
let texture_path = find_material(&texture.name, &texture.search_paths, loader)
|
||||
.expect("failed to find texture");
|
||||
Some(push_or_get_material(
|
||||
buffer,
|
||||
gltf,
|
||||
loader,
|
||||
&texture_path,
|
||||
options,
|
||||
))
|
||||
let texture = skin.texture_info(mesh.material_index());
|
||||
let texture_path =
|
||||
texture.and_then(|texture| find_material(&texture.name, &texture.search_paths, loader));
|
||||
texture_path
|
||||
.map(|texture_path| push_or_get_material(buffer, gltf, loader, &texture_path, options))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue