summaryrefslogtreecommitdiff
path: root/world/src/main.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-02-25 20:21:40 +0100
committermetamuffin <metamuffin@disroot.org>2025-02-25 20:21:45 +0100
commitbe22ec62f2f692b5dc4ca0b334d905164fb45ff2 (patch)
treecd80efeea07a504eaa729d552211bd34b06da679 /world/src/main.rs
parentae98273c288b0ba357b5d97231136d75273edd4e (diff)
downloadweareserver-be22ec62f2f692b5dc4ca0b334d905164fb45ff2.tar
weareserver-be22ec62f2f692b5dc4ca0b334d905164fb45ff2.tar.bz2
weareserver-be22ec62f2f692b5dc4ca0b334d905164fb45ff2.tar.zst
fix vrm first person bone
Diffstat (limited to 'world/src/main.rs')
-rw-r--r--world/src/main.rs30
1 files changed, 24 insertions, 6 deletions
diff --git a/world/src/main.rs b/world/src/main.rs
index 9222b3e..be39a4a 100644
--- a/world/src/main.rs
+++ b/world/src/main.rs
@@ -403,6 +403,7 @@ fn main() -> Result<()> {
};
let mut anim_joint_index_to_arm_index = BTreeMap::new();
+ let mut joint_index_to_ibm = BTreeMap::new();
for n in gltf.nodes() {
if let Some(name) = n.name() {
let Some(vrm_name) = (if let Some(map) = &anim_name_map {
@@ -422,10 +423,22 @@ fn main() -> Result<()> {
}
}
}
+ for s in gltf.skins() {
+ let reader = s.reader(|buf| Some(&buffers[buf.index()]));
+ if let Some(ibms) = reader.read_inverse_bind_matrices() {
+ for (jn, ibm) in s.joints().zip(ibms) {
+ joint_index_to_ibm.insert(
+ jn.index(),
+ transform_to_affine(Transform::Matrix { matrix: ibm }),
+ );
+ }
+ }
+ }
for a in gltf.animations() {
prefab.animation.push(import_animation(
a,
&store,
+ &BTreeMap::new(),
&anim_joint_index_to_arm_index,
&BTreeMap::new(),
&buffers,
@@ -438,6 +451,7 @@ fn main() -> Result<()> {
prefab.animation.push(import_animation(
a,
&store,
+ &BTreeMap::new(),
&joint_index_to_arm_index,
&node_to_meshes,
&buffers,
@@ -450,12 +464,16 @@ fn main() -> Result<()> {
|| !vrm.bone_node_names.is_empty()
{
info!("avatar info enabled");
- prefab.avatar_info = Some(store.set(&AvatarInfoPart {
- armature: Some(0), // TODO
- camera_mount: vrm.camera_mount.map(|e| e as u32),
- camera_mount_offset: vrm.camera_mount_offset,
- ..Default::default()
- })?);
+ prefab.avatar_info = Some(
+ store.set(&AvatarInfoPart {
+ armature: Some(0), // TODO
+ camera_mount: vrm
+ .camera_mount
+ .map(|e| joint_index_to_arm_index[&e] as u32),
+ camera_mount_offset: vrm.camera_mount_offset,
+ ..Default::default()
+ })?,
+ );
}
prefab.armature = if armature.parent.as_ref().is_some_and(|a| !a.is_empty()) {