From ae9e813eaf5b04c8dddc9da1a1f5d50da1f5bddb Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 11 Feb 2025 23:43:58 +0100 Subject: set first person hint based on head bones in joint_index --- world/src/main.rs | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'world/src/main.rs') diff --git a/world/src/main.rs b/world/src/main.rs index e3c365a..00a5913 100644 --- a/world/src/main.rs +++ b/world/src/main.rs @@ -189,17 +189,29 @@ fn main() -> Result<()> { } } - if !parent.is_empty() { - Some(store.set(&ArmaturePart { - name: Some(name), - parent: Some(parent), - transform: Some(transform), - })?) - } else { - None + ArmaturePart { + name: Some(name), + parent: Some(parent), + transform: Some(transform), } }; + let head_bones = { + let pa = armature.parent.clone().unwrap_or_default(); + let na = armature.name.clone().unwrap_or_default(); + (0..pa.len()) + .filter(|&(mut i)| { + let mut f = false; + while pa[i] as usize != i { + f |= na[i] == "head"; + i = pa[i] as usize; + } + f + }) + .map(|e| e as u32) + .collect::>() + }; + let mut prefab = nodes .par_iter() .map(|(trans, node)| { @@ -219,6 +231,7 @@ fn main() -> Result<()> { &texture_cache, &skin_index_to_arm_index, &vrm, + &head_bones, )?; } } @@ -260,7 +273,11 @@ fn main() -> Result<()> { }, )?; - prefab.armature = armature.into_iter().collect(); + prefab.armature = if armature.parent.as_ref().is_some_and(|a| !a.is_empty()) { + vec![store.set(&armature)?] + } else { + vec![] + }; if let Some(skybox) = &args.skybox { let mut buf = Vec::new(); -- cgit v1.2.3-70-g09d2