diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-17 19:27:27 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-17 19:27:27 +0100 |
commit | 1ca762dedcdd6c87086560dd56ab3566b08243d0 (patch) | |
tree | f8380d79dfaafe07a252fbf27f4a22c7a750078b /world/src/mesh.rs | |
parent | 7ead3dfc316fb109f8f30eea1aa00eb01a4ce1a6 (diff) | |
download | weareserver-1ca762dedcdd6c87086560dd56ab3566b08243d0.tar weareserver-1ca762dedcdd6c87086560dd56ab3566b08243d0.tar.bz2 weareserver-1ca762dedcdd6c87086560dd56ab3566b08243d0.tar.zst |
remove --z-up flag and fix inherited transform
Diffstat (limited to 'world/src/mesh.rs')
-rw-r--r-- | world/src/mesh.rs | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/world/src/mesh.rs b/world/src/mesh.rs index 2bcf4c0..79e0edc 100644 --- a/world/src/mesh.rs +++ b/world/src/mesh.rs @@ -18,9 +18,9 @@ use crate::{Args, TextureCache, load_texture}; use anyhow::Result; use gltf::{Mesh, Node, buffer::Data}; use log::{debug, info}; -use std::{f32::consts::PI, path::Path}; +use std::path::Path; use weareshared::{ - Affine3A, Mat3A, Vec3A, + Affine3A, Vec3A, resources::{MeshPart, Prefab}, store::ResourceStore, vec2, vec3a, @@ -28,6 +28,7 @@ use weareshared::{ pub fn import_mesh( mesh: Mesh, + trans: Affine3A, buffers: &[Data], store: &ResourceStore, path_base: &Path, @@ -350,26 +351,6 @@ pub fn import_mesh( va_roughness: None, })?; - prefab - .mesh - .push((node_transform_to_affine(node, args), mesh)) + prefab.mesh.push((trans, mesh)) }) } - -pub fn node_transform_to_affine(node: &Node, args: &Args) -> Affine3A { - let mat = node.transform().matrix(); - let mut aff = Affine3A::from_cols_array_2d(&[ - [mat[0][0], mat[0][1], mat[0][2]], - [mat[1][0], mat[1][1], mat[1][2]], - [mat[2][0], mat[2][1], mat[2][2]], - [mat[3][0], mat[3][1], mat[3][2]], - ]); - aff.matrix3 *= args.scale.unwrap_or(1.); - aff.translation *= args.scale.unwrap_or(1.); - if args.z_up { - let r = Mat3A::from_rotation_x(PI / 2.); - aff.matrix3 *= r; - aff.translation = r * aff.translation; - } - aff -} |