summaryrefslogtreecommitdiff
path: root/world/src/main.rs
diff options
context:
space:
mode:
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();