diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-11 23:43:58 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-11 23:43:58 +0100 |
commit | ae9e813eaf5b04c8dddc9da1a1f5d50da1f5bddb (patch) | |
tree | b49dc88fa527bf12c6efe9a3aa3eb7d8923b43ee /world/src/mesh.rs | |
parent | 174f668c437a83bdb7787a828b0c4fb7f2521aa1 (diff) | |
download | weareserver-ae9e813eaf5b04c8dddc9da1a1f5d50da1f5bddb.tar weareserver-ae9e813eaf5b04c8dddc9da1a1f5d50da1f5bddb.tar.bz2 weareserver-ae9e813eaf5b04c8dddc9da1a1f5d50da1f5bddb.tar.zst |
set first person hint based on head bones in joint_index
Diffstat (limited to 'world/src/mesh.rs')
-rw-r--r-- | world/src/mesh.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/world/src/mesh.rs b/world/src/mesh.rs index 78ec919..4067fb8 100644 --- a/world/src/mesh.rs +++ b/world/src/mesh.rs @@ -38,6 +38,7 @@ pub fn import_mesh( texture_cache: &TextureCache, joint_index_map: &BTreeMap<(usize, u16), u32>, vrm: &VrmInfo, + head_bones: &[u32], ) -> Result<()> { for p in mesh.primitives() { let name = mesh.name().or(node.name()).map(|e| e.to_owned()); @@ -80,6 +81,7 @@ pub fn import_mesh( }) .transpose()?; + let mut many_head_bones = false; let va_joint_index = reader .read_joints(0) .map(|iter| { @@ -88,7 +90,17 @@ pub fn import_mesh( .into_u16() .map(|x| x.map(|x| joint_index_map[&(si, x)])) .collect::<Vec<_>>(); + + let head_bone_count = a + .iter() + .flatten() + .filter(|b| head_bones.contains(*b)) + .count(); + many_head_bones |= head_bone_count > a.len() / 2; debug!("{} vertex joint indecies", a.len()); + if many_head_bones { + debug!("many joints are head bones"); + } if a.len() != num_vertex { warn!("joint index count does not vertex count") } @@ -341,7 +353,7 @@ pub fn import_mesh( let g_double_sided = bool_to_opt(p.material().double_sided(), "double sided"); let hint_hide_first_person = bool_to_opt( - vrm.hide_first_person.contains(&node.index()), + many_head_bones | vrm.hide_first_person.contains(&node.index()), "hide first person hint", ); |