-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add reflect impls to IRect and URect #9191
Conversation
use bevy_reflect_derive::impl_reflect_struct; | ||
|
||
impl_reflect_struct!( | ||
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these types should also add Hash
to this list, since they implement Hash
(unlike Rect
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should Hash
be put behind a #[cfg_attr(not(target_arch = "spirv"), derive(Hash))]
attribute since IVec2
/UVec2
have that cfg?
I just added the Hash
derive but without the cfg flag because IVec2
/UVec2
's Debug
implementation is also #[cfg_attr(not(target_arch = "spirv")]
, yet Debug
is still derived directly on IRect
/URect
.
I also added Eq
derives for convenience, but I couldn't add Eq
to the reflect derive since the compiler complained about ReflectEq
, which I couldn't find. Does there exist an Eq
reflect trait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Yeah I would try to match the same flags that the source code defines. Actually, I don't think it's necessary right? As long as the rect types are fine I think it should be fine too. I could be wrong though.
And no, there is no ReflectEq
. Eq
is not treated specially by the macro either (unlike PartialEq
, Debug
, and Hash
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is that bevy would just fail to compile for the spirv target architecture, since the Hash and Debug derive macro requirements wouldn't be satisfied. But bevy would probably already fail to compile on this arch for many other reasons, so I don't see this as a problem.
Objective
This attempts to make the new IRect and URect structs in bevy_math more similar to the existing Rect struct.
Solution
Add reflect implementations for IRect and URect, since one already exists for Rect.