From 3a5c3b97376f530a63f5754b28da421940b69fa4 Mon Sep 17 00:00:00 2001 From: Al McElrath Date: Tue, 10 Sep 2024 17:20:28 -0700 Subject: [PATCH 1/9] Retain extracted component type. Fixes #10284. --- crates/bevy_scene/src/dynamic_scene_builder.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/bevy_scene/src/dynamic_scene_builder.rs b/crates/bevy_scene/src/dynamic_scene_builder.rs index 26084c1a3e27f..29a8a7a8882b1 100644 --- a/crates/bevy_scene/src/dynamic_scene_builder.rs +++ b/crates/bevy_scene/src/dynamic_scene_builder.rs @@ -6,7 +6,7 @@ use bevy_ecs::{ reflect::{AppTypeRegistry, ReflectComponent, ReflectResource}, world::World, }; -use bevy_reflect::PartialReflect; +use bevy_reflect::{PartialReflect, ReflectFromReflect}; use bevy_utils::default; use std::collections::BTreeMap; @@ -278,7 +278,17 @@ impl<'w> DynamicSceneBuilder<'w> { .get(type_id)? .data::()? .reflect(original_entity)?; - entry.components.push(component.clone_value()); + + // Clone the via `FromReflect`. Unlike `PartialReflect::clone_value` this + // retains the original type and `ReflectSerialize` type data which is needed to + // deserialize. + let component = type_registry + .get(type_id)? + .data::()? + .from_reflect(component.as_partial_reflect())? + .into_partial_reflect(); + + entry.components.push(component); Some(()) }; extract_and_push(); From f776f757729086a29ddbcafcd96ba9bd946ef27c Mon Sep 17 00:00:00 2001 From: Al McElrath Date: Wed, 11 Sep 2024 16:13:51 -0700 Subject: [PATCH 2/9] Attempt to deserialize using FromReflect. --- crates/bevy_scene/src/serde.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/bevy_scene/src/serde.rs b/crates/bevy_scene/src/serde.rs index 497c4c4afcf50..2974661a51d49 100644 --- a/crates/bevy_scene/src/serde.rs +++ b/crates/bevy_scene/src/serde.rs @@ -3,11 +3,11 @@ use crate::{DynamicEntity, DynamicScene}; use bevy_ecs::entity::Entity; use bevy_reflect::serde::{TypedReflectDeserializer, TypedReflectSerializer}; -use bevy_reflect::PartialReflect; use bevy_reflect::{ serde::{ReflectDeserializer, TypeRegistrationDeserializer}, TypeRegistry, }; +use bevy_reflect::{PartialReflect, ReflectFromReflect}; use bevy_utils::HashSet; use serde::ser::SerializeMap; use serde::{ @@ -471,9 +471,19 @@ impl<'a, 'de> Visitor<'de> for SceneMapVisitor<'a> { ))); } - entries.push( - map.next_value_seed(TypedReflectDeserializer::new(registration, self.registry))?, - ); + let value = + map.next_value_seed(TypedReflectDeserializer::new(registration, self.registry))?; + + // Attempt to convert using FromReflect. + let value = self + .registry + .get(registration.type_id()) + .and_then(|tr| tr.data::()) + .and_then(|fr| fr.from_reflect(value.as_partial_reflect())) + .map(|v| v.into_partial_reflect()) + .unwrap_or(value); + + entries.push(value); } Ok(entries) From 3de8aa35d110a98a2a4abd81943aa63672824bcb Mon Sep 17 00:00:00 2001 From: Al McElrath Date: Wed, 11 Sep 2024 16:37:35 -0700 Subject: [PATCH 3/9] Fall back to clone_value. --- crates/bevy_scene/src/dynamic_scene_builder.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/bevy_scene/src/dynamic_scene_builder.rs b/crates/bevy_scene/src/dynamic_scene_builder.rs index 29a8a7a8882b1..37782bb2a77d0 100644 --- a/crates/bevy_scene/src/dynamic_scene_builder.rs +++ b/crates/bevy_scene/src/dynamic_scene_builder.rs @@ -274,19 +274,20 @@ impl<'w> DynamicSceneBuilder<'w> { return None; } - let component = type_registry - .get(type_id)? + let type_registration = type_registry.get(type_id)?; + + let component = type_registration .data::()? .reflect(original_entity)?; // Clone the via `FromReflect`. Unlike `PartialReflect::clone_value` this // retains the original type and `ReflectSerialize` type data which is needed to // deserialize. - let component = type_registry - .get(type_id)? - .data::()? - .from_reflect(component.as_partial_reflect())? - .into_partial_reflect(); + let component = type_registration + .data::() + .and_then(|fr| fr.from_reflect(component.as_partial_reflect())) + .map(|r| r.into_partial_reflect()) + .unwrap_or_else(|| component.clone_value()); entry.components.push(component); Some(()) From 1c0c066d4ce046f331192cfb39b97110a50153b8 Mon Sep 17 00:00:00 2001 From: Al McElrath Date: Thu, 12 Sep 2024 08:13:15 -0700 Subject: [PATCH 4/9] Clippy. --- crates/bevy_scene/src/dynamic_scene_builder.rs | 2 +- crates/bevy_scene/src/serde.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_scene/src/dynamic_scene_builder.rs b/crates/bevy_scene/src/dynamic_scene_builder.rs index 37782bb2a77d0..bcba328078581 100644 --- a/crates/bevy_scene/src/dynamic_scene_builder.rs +++ b/crates/bevy_scene/src/dynamic_scene_builder.rs @@ -286,7 +286,7 @@ impl<'w> DynamicSceneBuilder<'w> { let component = type_registration .data::() .and_then(|fr| fr.from_reflect(component.as_partial_reflect())) - .map(|r| r.into_partial_reflect()) + .map(PartialReflect::into_partial_reflect) .unwrap_or_else(|| component.clone_value()); entry.components.push(component); diff --git a/crates/bevy_scene/src/serde.rs b/crates/bevy_scene/src/serde.rs index 2974661a51d49..a54b6090d45df 100644 --- a/crates/bevy_scene/src/serde.rs +++ b/crates/bevy_scene/src/serde.rs @@ -480,7 +480,7 @@ impl<'a, 'de> Visitor<'de> for SceneMapVisitor<'a> { .get(registration.type_id()) .and_then(|tr| tr.data::()) .and_then(|fr| fr.from_reflect(value.as_partial_reflect())) - .map(|v| v.into_partial_reflect()) + .map(PartialReflect::into_partial_reflect) .unwrap_or(value); entries.push(value); From 532e916f1ac82a9425df68ef3ba693c05201aea6 Mon Sep 17 00:00:00 2001 From: "Al M." Date: Fri, 13 Sep 2024 11:48:50 -0700 Subject: [PATCH 5/9] Fix comment. Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com> --- crates/bevy_scene/src/dynamic_scene_builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_scene/src/dynamic_scene_builder.rs b/crates/bevy_scene/src/dynamic_scene_builder.rs index bcba328078581..01e90a8e43cef 100644 --- a/crates/bevy_scene/src/dynamic_scene_builder.rs +++ b/crates/bevy_scene/src/dynamic_scene_builder.rs @@ -280,7 +280,7 @@ impl<'w> DynamicSceneBuilder<'w> { .data::()? .reflect(original_entity)?; - // Clone the via `FromReflect`. Unlike `PartialReflect::clone_value` this + // Clone via `FromReflect`. Unlike `PartialReflect::clone_value` this // retains the original type and `ReflectSerialize` type data which is needed to // deserialize. let component = type_registration From 1ab0b930e0689d3a185c056ef44b0016754c3b95 Mon Sep 17 00:00:00 2001 From: Al McElrath Date: Sat, 14 Sep 2024 08:44:36 -0700 Subject: [PATCH 6/9] Add test for custom serialization. --- crates/bevy_scene/src/serde.rs | 73 +++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/crates/bevy_scene/src/serde.rs b/crates/bevy_scene/src/serde.rs index a54b6090d45df..659f7a3b0a972 100644 --- a/crates/bevy_scene/src/serde.rs +++ b/crates/bevy_scene/src/serde.rs @@ -501,10 +501,10 @@ mod tests { use bevy_ecs::query::{With, Without}; use bevy_ecs::reflect::{AppTypeRegistry, ReflectMapEntities}; use bevy_ecs::world::FromWorld; - use bevy_reflect::{Reflect, ReflectSerialize}; + use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; use bincode::Options; use serde::de::DeserializeSeed; - use serde::Serialize; + use serde::{Deserialize, Serialize}; use std::io::BufReader; #[derive(Component, Reflect, Default)] @@ -517,6 +517,30 @@ mod tests { #[reflect(Component)] struct Baz(i32); + // De/serialize as hex. + mod qux { + use serde::{de::Error, Deserialize, Deserializer, Serializer}; + + pub fn serialize(value: &u32, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(&format!("{:X}", value)) + } + + pub fn deserialize<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + u32::from_str_radix(<&str as Deserialize>::deserialize(deserializer)?, 16) + .map_err(Error::custom) + } + } + + #[derive(Component, Copy, Clone, Reflect, Debug, PartialEq, Serialize, Deserialize)] + #[reflect(Component, Serialize, Deserialize)] + struct Qux(#[serde(with = "qux")] u32); + #[derive(Component, Reflect, Default)] #[reflect(Component)] struct MyComponent { @@ -565,6 +589,7 @@ mod tests { registry.register::(); registry.register::(); registry.register::(); + registry.register::(); registry.register::(); registry.register::(); registry.register::(); @@ -689,6 +714,18 @@ mod tests { assert_eq!(1, dst_world.query::<&Baz>().iter(&dst_world).count()); } + fn roundtrip_ron(world: &World) -> (DynamicScene, DynamicScene) { + let scene = DynamicScene::from_world(&world); + let registry = world.resource::().read(); + let serialized = scene.serialize(®istry).unwrap(); + let mut deserializer = ron::de::Deserializer::from_str(&serialized).unwrap(); + let scene_deserializer = SceneDeserializer { + type_registry: ®istry, + }; + let deserialized_scene = scene_deserializer.deserialize(&mut deserializer).unwrap(); + (scene, deserialized_scene) + } + #[test] fn should_roundtrip_with_later_generations_and_obsolete_references() { let mut world = create_world(); @@ -700,19 +737,7 @@ mod tests { world.despawn(a); world.spawn(MyEntityRef(foo)).insert(Bar(123)); - let registry = world.resource::(); - - let scene = DynamicScene::from_world(&world); - - let serialized = scene - .serialize(&world.resource::().read()) - .unwrap(); - let mut deserializer = ron::de::Deserializer::from_str(&serialized).unwrap(); - let scene_deserializer = SceneDeserializer { - type_registry: ®istry.0.read(), - }; - - let deserialized_scene = scene_deserializer.deserialize(&mut deserializer).unwrap(); + let (scene, deserialized_scene) = roundtrip_ron(&world); let mut map = EntityHashMap::default(); let mut dst_world = create_world(); @@ -740,6 +765,24 @@ mod tests { .all(|r| world.get_entity(r.0).is_none())); } + #[test] + fn should_roundtrip_with_custom_serialization() { + let mut world = create_world(); + let qux = Qux(42); + world.spawn(qux); + + let (scene, deserialized_scene) = roundtrip_ron(&world); + + assert_eq!(1, deserialized_scene.entities.len()); + assert_scene_eq(&scene, &deserialized_scene); + + let mut world = create_world(); + deserialized_scene + .write_to_world(&mut world, &mut EntityHashMap::default()) + .unwrap(); + assert_eq!(&qux, world.query::<&Qux>().single(&world)) + } + #[test] fn should_roundtrip_postcard() { let mut world = create_world(); From 2023dd750426b629877d4db2928c0f6756757f0c Mon Sep 17 00:00:00 2001 From: Al McElrath Date: Sat, 14 Sep 2024 09:19:13 -0700 Subject: [PATCH 7/9] Clippy. --- crates/bevy_scene/src/serde.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_scene/src/serde.rs b/crates/bevy_scene/src/serde.rs index 659f7a3b0a972..d57dcc3f81d04 100644 --- a/crates/bevy_scene/src/serde.rs +++ b/crates/bevy_scene/src/serde.rs @@ -715,7 +715,7 @@ mod tests { } fn roundtrip_ron(world: &World) -> (DynamicScene, DynamicScene) { - let scene = DynamicScene::from_world(&world); + let scene = DynamicScene::from_world(world); let registry = world.resource::().read(); let serialized = scene.serialize(®istry).unwrap(); let mut deserializer = ron::de::Deserializer::from_str(&serialized).unwrap(); @@ -780,7 +780,7 @@ mod tests { deserialized_scene .write_to_world(&mut world, &mut EntityHashMap::default()) .unwrap(); - assert_eq!(&qux, world.query::<&Qux>().single(&world)) + assert_eq!(&qux, world.query::<&Qux>().single(&world)); } #[test] From 4e988a3555031201f3e5b9e8aa789d569be0996e Mon Sep 17 00:00:00 2001 From: Al McElrath Date: Sat, 14 Sep 2024 12:48:55 -0700 Subject: [PATCH 8/9] Impl. `ReflectSerialize` and `ReflectDeserialize` for glam types. --- crates/bevy_reflect/src/impls/glam.rs | 78 +++++++++++++-------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/crates/bevy_reflect/src/impls/glam.rs b/crates/bevy_reflect/src/impls/glam.rs index 06823374b0c08..8d54a5d5c9940 100644 --- a/crates/bevy_reflect/src/impls/glam.rs +++ b/crates/bevy_reflect/src/impls/glam.rs @@ -1,10 +1,10 @@ use crate as bevy_reflect; -use crate::prelude::ReflectDefault; +use crate::{std_traits::ReflectDefault, ReflectDeserialize, ReflectSerialize}; use bevy_reflect_derive::{impl_reflect, impl_reflect_value}; use glam::*; impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct IVec2 { x: i32, @@ -12,7 +12,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct IVec3 { x: i32, @@ -21,7 +21,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct IVec4 { x: i32, @@ -32,7 +32,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct I64Vec2 { x: i64, @@ -41,7 +41,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct I64Vec3 { x: i64, @@ -51,7 +51,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct I64Vec4 { x: i64, @@ -62,7 +62,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct UVec2 { x: u32, @@ -70,7 +70,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct UVec3 { x: u32, @@ -79,7 +79,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct UVec4 { x: u32, @@ -90,7 +90,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct U64Vec2 { x: u64, @@ -98,7 +98,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct U64Vec3 { x: u64, @@ -107,7 +107,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, Hash, PartialEq, Default)] + #[reflect(Debug, Hash, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct U64Vec4 { x: u64, @@ -118,7 +118,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Vec2 { x: f32, @@ -126,7 +126,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Vec3 { x: f32, @@ -135,7 +135,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Vec3A { x: f32, @@ -144,7 +144,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Vec4 { x: f32, @@ -155,7 +155,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct BVec2 { x: bool, @@ -163,7 +163,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct BVec3 { x: bool, @@ -172,7 +172,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct BVec4 { x: bool, @@ -183,7 +183,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct DVec2 { x: f64, @@ -191,7 +191,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct DVec3 { x: f64, @@ -200,7 +200,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct DVec4 { x: f64, @@ -211,7 +211,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Mat2 { x_axis: Vec2, @@ -219,7 +219,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Mat3 { x_axis: Vec3, @@ -228,7 +228,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Mat3A { x_axis: Vec3A, @@ -237,7 +237,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Mat4 { x_axis: Vec4, @@ -248,7 +248,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct DMat2 { x_axis: DVec2, @@ -256,7 +256,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct DMat3 { x_axis: DVec3, @@ -265,7 +265,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct DMat4 { x_axis: DVec4, @@ -276,7 +276,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Affine2 { matrix2: Mat2, @@ -284,7 +284,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Affine3A { matrix3: Mat3A, @@ -293,7 +293,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct DAffine2 { matrix2: DMat2, @@ -301,7 +301,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct DAffine3 { matrix3: DMat3, @@ -310,7 +310,7 @@ impl_reflect!( ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct Quat { x: f32, @@ -320,7 +320,7 @@ impl_reflect!( } ); impl_reflect!( - #[reflect(Debug, PartialEq, Default)] + #[reflect(Debug, PartialEq, Default, Deserialize, Serialize)] #[type_path = "glam"] struct DQuat { x: f64, @@ -330,6 +330,6 @@ impl_reflect!( } ); -impl_reflect_value!(::glam::EulerRot(Debug, Default)); -impl_reflect_value!(::glam::BVec3A(Debug, Default)); -impl_reflect_value!(::glam::BVec4A(Debug, Default)); +impl_reflect_value!(::glam::EulerRot(Debug, Default, Deserialize, Serialize)); +impl_reflect_value!(::glam::BVec3A(Debug, Default, Deserialize, Serialize)); +impl_reflect_value!(::glam::BVec4A(Debug, Default, Deserialize, Serialize)); From dc9d5387509719b946f6efdd642ab7201c373d3a Mon Sep 17 00:00:00 2001 From: Al McElrath Date: Sat, 14 Sep 2024 13:05:34 -0700 Subject: [PATCH 9/9] Fix glam tests. --- crates/bevy_reflect/src/lib.rs | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index 64216bfc09467..3de005cd5ed1a 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -2943,12 +2943,7 @@ bevy_reflect::tests::Test { let output = to_string_pretty(&ser, config).unwrap(); let expected = r#" { - "glam::Quat": ( - x: 1.0, - y: 2.0, - z: 3.0, - w: 4.0, - ), + "glam::Quat": (1.0, 2.0, 3.0, 4.0), }"#; assert_eq!(expected, format!("\n{output}")); @@ -2958,12 +2953,7 @@ bevy_reflect::tests::Test { fn quat_deserialization() { let data = r#" { - "glam::Quat": ( - x: 1.0, - y: 2.0, - z: 3.0, - w: 4.0, - ), + "glam::Quat": (1.0, 2.0, 3.0, 4.0), }"#; let mut registry = TypeRegistry::default(); @@ -3002,11 +2992,7 @@ bevy_reflect::tests::Test { let output = to_string_pretty(&ser, config).unwrap(); let expected = r#" { - "glam::Vec3": ( - x: 12.0, - y: 3.0, - z: -6.9, - ), + "glam::Vec3": (12.0, 3.0, -6.9), }"#; assert_eq!(expected, format!("\n{output}")); @@ -3016,11 +3002,7 @@ bevy_reflect::tests::Test { fn vec3_deserialization() { let data = r#" { - "glam::Vec3": ( - x: 12.0, - y: 3.0, - z: -6.9, - ), + "glam::Vec3": (12.0, 3.0, -6.9), }"#; let mut registry = TypeRegistry::default();