From 4cf3468aabe7dbd39e125b97b198bfb44271454a Mon Sep 17 00:00:00 2001 From: RCoder01 <45217840+RCoder01@users.noreply.github.com> Date: Tue, 18 Jul 2023 00:20:22 -0400 Subject: [PATCH 1/2] Add reflect impls to IRect and URect --- crates/bevy_reflect/src/impls/rect.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/bevy_reflect/src/impls/rect.rs b/crates/bevy_reflect/src/impls/rect.rs index b215a58599d20..f5e04f8d193d5 100644 --- a/crates/bevy_reflect/src/impls/rect.rs +++ b/crates/bevy_reflect/src/impls/rect.rs @@ -1,9 +1,18 @@ use crate as bevy_reflect; use crate::prelude::ReflectDefault; use crate::{ReflectDeserialize, ReflectSerialize}; -use bevy_math::{Rect, Vec2}; +use bevy_math::{IRect, IVec2, Rect, URect, UVec2, Vec2}; use bevy_reflect_derive::impl_reflect_struct; +impl_reflect_struct!( + #[reflect(Debug, PartialEq, Serialize, Deserialize, Default)] + #[type_path = "bevy_math"] + struct IRect { + min: IVec2, + max: IVec2, + } +); + impl_reflect_struct!( #[reflect(Debug, PartialEq, Serialize, Deserialize, Default)] #[type_path = "bevy_math"] @@ -12,3 +21,12 @@ impl_reflect_struct!( max: Vec2, } ); + +impl_reflect_struct!( + #[reflect(Debug, PartialEq, Serialize, Deserialize, Default)] + #[type_path = "bevy_math"] + struct URect { + min: UVec2, + max: UVec2, + } +); From aa5f10f9ad9742ca92278d63be2252488d7a57d5 Mon Sep 17 00:00:00 2001 From: RCoder01 <45217840+RCoder01@users.noreply.github.com> Date: Tue, 18 Jul 2023 01:29:41 -0400 Subject: [PATCH 2/2] Add eq/hash derive and hash reflect --- crates/bevy_math/src/rects/irect.rs | 2 +- crates/bevy_math/src/rects/urect.rs | 2 +- crates/bevy_reflect/src/impls/rect.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bevy_math/src/rects/irect.rs b/crates/bevy_math/src/rects/irect.rs index 05498cea1554e..b8a1b21a792a4 100644 --- a/crates/bevy_math/src/rects/irect.rs +++ b/crates/bevy_math/src/rects/irect.rs @@ -9,7 +9,7 @@ use crate::{IVec2, Rect, URect}; /// methods instead, which will ensure this invariant is met, unless you already have /// the minimum and maximum corners. #[repr(C)] -#[derive(Default, Clone, Copy, Debug, PartialEq)] +#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] pub struct IRect { /// The minimum corner point of the rect. diff --git a/crates/bevy_math/src/rects/urect.rs b/crates/bevy_math/src/rects/urect.rs index 1f04882d16c35..fb74a6183e9b0 100644 --- a/crates/bevy_math/src/rects/urect.rs +++ b/crates/bevy_math/src/rects/urect.rs @@ -9,7 +9,7 @@ use crate::{IRect, Rect, UVec2}; /// methods instead, which will ensure this invariant is met, unless you already have /// the minimum and maximum corners. #[repr(C)] -#[derive(Default, Clone, Copy, Debug, PartialEq)] +#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] pub struct URect { /// The minimum corner point of the rect. diff --git a/crates/bevy_reflect/src/impls/rect.rs b/crates/bevy_reflect/src/impls/rect.rs index f5e04f8d193d5..8f882eab27cc6 100644 --- a/crates/bevy_reflect/src/impls/rect.rs +++ b/crates/bevy_reflect/src/impls/rect.rs @@ -5,7 +5,7 @@ use bevy_math::{IRect, IVec2, Rect, URect, UVec2, Vec2}; use bevy_reflect_derive::impl_reflect_struct; impl_reflect_struct!( - #[reflect(Debug, PartialEq, Serialize, Deserialize, Default)] + #[reflect(Debug, PartialEq, Hash, Serialize, Deserialize, Default)] #[type_path = "bevy_math"] struct IRect { min: IVec2, @@ -23,7 +23,7 @@ impl_reflect_struct!( ); impl_reflect_struct!( - #[reflect(Debug, PartialEq, Serialize, Deserialize, Default)] + #[reflect(Debug, PartialEq, Hash, Serialize, Deserialize, Default)] #[type_path = "bevy_math"] struct URect { min: UVec2,