From ae14c194a25e258659104e89553ad48a8ae9ca3b Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 3 Feb 2025 21:46:29 +0100 Subject: armatures in prefab --- shared/src/resources.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'shared/src') diff --git a/shared/src/resources.rs b/shared/src/resources.rs index c96621d..654bfc6 100644 --- a/shared/src/resources.rs +++ b/shared/src/resources.rs @@ -30,6 +30,7 @@ pub struct Prefab { pub mesh: Vec<(Affine3A, Resource)>, pub collision: Vec<(Affine3A, Resource)>, pub light: Vec<(Vec3A, Resource)>, + pub armature: Vec>, pub environment: Option>, } @@ -50,7 +51,7 @@ pub struct EnvironmentPart { pub struct MeshPart { pub name: Option, pub index: Option>>, - pub armature: Option>, + pub armature: Option, pub g_metallic: Option, pub g_roughness: Option, pub g_albedo: Option, @@ -89,7 +90,7 @@ pub struct MeshPart { } #[derive(Debug, Default, Clone)] -pub struct Armature { +pub struct ArmaturePart { pub parent: Option>, pub transform: Option>, pub name: Option>, @@ -134,7 +135,7 @@ impl ReadWrite for PrefabIndex { } } -impl ReadWrite for Armature { +impl ReadWrite for ArmaturePart { fn write(&self, w: &mut dyn Write) -> Result<()> { write_kv_opt(w, b"parent", &self.parent)?; write_kv_opt(w, b"transform", &self.transform)?; @@ -200,6 +201,9 @@ impl ReadWrite for Prefab { for x in &self.light { write_kv_opt(w, b"light", &Some(x.clone()))?; } + for x in &self.armature { + write_kv_opt(w, b"armature", &Some(x.clone()))?; + } write_kv_opt(w, b"environment", &self.environment)?; Ok(()) } @@ -210,6 +214,7 @@ impl ReadWrite for Prefab { b"mesh" => Ok(s.mesh.push(read_slice(v)?)), b"collision" => Ok(s.collision.push(read_slice(v)?)), b"light" => Ok(s.light.push(read_slice(v)?)), + b"armature" => Ok(s.armature.push(read_slice(v)?)), b"environment" => Ok(s.environment = Some(read_slice(v)?)), x => Ok(warn!( "unknown prefab key: {:?}", -- cgit v1.2.3-70-g09d2