diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-11 22:55:39 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-11 22:55:39 +0100 |
commit | 174f668c437a83bdb7787a828b0c4fb7f2521aa1 (patch) | |
tree | f77a863d0fb385894fa79e7cfff1aa3569f8a26c | |
parent | 81a191e702abcf77b73b9163ce43c4527a01ce13 (diff) | |
download | weareserver-174f668c437a83bdb7787a828b0c4fb7f2521aa1.tar weareserver-174f668c437a83bdb7787a828b0c4fb7f2521aa1.tar.bz2 weareserver-174f668c437a83bdb7787a828b0c4fb7f2521aa1.tar.zst |
hint_mirror from glTF node names
-rw-r--r-- | world/src/mesh.rs | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/world/src/mesh.rs b/world/src/mesh.rs index ebecfa5..78ec919 100644 --- a/world/src/mesh.rs +++ b/world/src/mesh.rs @@ -331,29 +331,24 @@ pub fn import_mesh( } let g_thickness = p.material().volume().map(|v| v.thickness_factor()); - let g_unlit = if p - .material() - .extension_value("KHR_materials_unlit") - .is_some() - { - debug!("unlit"); - Some(()) - } else { - None - }; + let g_unlit = bool_to_opt( + p.material() + .extension_value("KHR_materials_unlit") + .is_some(), + "unlit", + ); - let g_double_sided = if p.material().double_sided() { - debug!("double sided"); - Some(()) - } else { - None - }; + let g_double_sided = bool_to_opt(p.material().double_sided(), "double sided"); - let hint_hide_first_person = if vrm.hide_first_person.contains(&node.index()) { - Some(()) - } else { - None - }; + let hint_hide_first_person = bool_to_opt( + vrm.hide_first_person.contains(&node.index()), + "hide first person hint", + ); + + let hint_mirror = bool_to_opt( + node.name().unwrap_or_default().ends_with("-mirror"), + "mirror hint", + ); let armature = node.skin().map(|_| 0); @@ -391,8 +386,8 @@ pub fn import_mesh( tex_thickness, tex_occlusion, hint_hide_first_person, + hint_mirror, // not supported by gltf - hint_mirror: None, // TODO hint_static: None, // TODO Set when instancing va_transmission: None, va_emission: None, @@ -404,3 +399,12 @@ pub fn import_mesh( } Ok(()) } + +fn bool_to_opt(b: bool, log: &str) -> Option<()> { + if b { + debug!("{log}"); + Some(()) + } else { + None + } +} |