summaryrefslogtreecommitdiff
path: root/world/src/main.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-02-11 23:43:58 +0100
committermetamuffin <metamuffin@disroot.org>2025-02-11 23:43:58 +0100
commitae9e813eaf5b04c8dddc9da1a1f5d50da1f5bddb (patch)
treeb49dc88fa527bf12c6efe9a3aa3eb7d8923b43ee /world/src/main.rs
parent174f668c437a83bdb7787a828b0c4fb7f2521aa1 (diff)
downloadweareserver-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/main.rs')
-rw-r--r--world/src/main.rs35
1 files changed, 26 insertions, 9 deletions
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::<Vec<_>>()
+ };
+
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();