From d7fdcfd791f011e33fb9720e7451e56410411e4f Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 7 Feb 2025 15:25:00 +0100 Subject: fix armature duplication --- world/src/mesh.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'world/src/mesh.rs') 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::>(); + let si = node.skin().unwrap().index(); + let a = iter + .into_u16() + .map(|x| x.map(|x| joint_index_map[&(si, x)])) + .collect::>(); debug!("{} vertex joint indecies", a.len()); + eprintln!( + "index {:?} {:?}", + node.name(), + a.iter().flatten().collect::>() + ); 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, -- cgit v1.2.3-70-g09d2