diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-07 15:25:00 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-07 15:25:00 +0100 |
commit | d7fdcfd791f011e33fb9720e7451e56410411e4f (patch) | |
tree | 7db39bb3e9d99ecba7761e8be3d7ae35b288ce2f /world/src/mesh.rs | |
parent | 92ab896339692c7dab300ad4d11a94fa03ee3ef4 (diff) | |
download | weareserver-d7fdcfd791f011e33fb9720e7451e56410411e4f.tar weareserver-d7fdcfd791f011e33fb9720e7451e56410411e4f.tar.bz2 weareserver-d7fdcfd791f011e33fb9720e7451e56410411e4f.tar.zst |
fix armature duplication
Diffstat (limited to 'world/src/mesh.rs')
-rw-r--r-- | world/src/mesh.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/world/src/mesh.rs b/world/src/mesh.rs index 96976ce..fa5dc4d 100644 --- a/world/src/mesh.rs +++ b/world/src/mesh.rs @@ -18,7 +18,10 @@ use crate::{Args, TextureCache, load_texture}; use anyhow::Result; use gltf::{Mesh, Node, buffer::Data}; use log::{debug, info, warn}; -use std::path::Path; +use std::{ + collections::{BTreeMap, BTreeSet}, + path::Path, +}; use weareshared::{ Affine3A, Vec3A, resources::{MeshPart, Prefab}, @@ -36,6 +39,7 @@ pub fn import_mesh( prefab: &mut Prefab, args: &Args, texture_cache: &TextureCache, + joint_index_map: &BTreeMap<(usize, u16), u32>, ) -> Result<()> { for p in mesh.primitives() { let name = mesh.name().or(node.name()).map(|e| e.to_owned()); @@ -81,8 +85,17 @@ pub fn import_mesh( let va_joint_index = reader .read_joints(0) .map(|iter| { - let a = iter.into_u16().collect::<Vec<_>>(); + let si = node.skin().unwrap().index(); + let a = iter + .into_u16() + .map(|x| x.map(|x| joint_index_map[&(si, x)])) + .collect::<Vec<_>>(); debug!("{} vertex joint indecies", a.len()); + eprintln!( + "index {:?} {:?}", + node.name(), + a.iter().flatten().collect::<BTreeSet<_>>() + ); if a.len() != num_vertex { warn!("joint index count does not vertex count") } @@ -343,7 +356,7 @@ pub fn import_mesh( None }; - let armature = node.skin().map(|s| s.index() as u32); + let armature = node.skin().map(|s| 0); let mesh = store.set(&MeshPart { name, |