summaryrefslogtreecommitdiff
path: root/world/src/mesh.rs
diff options
context:
space:
mode:
Diffstat (limited to 'world/src/mesh.rs')
-rw-r--r--world/src/mesh.rs19
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,