-
-
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
[Merged by Bors] - implement reflection for more glam types #5194
Conversation
Added an implementation for EulerRot too, but that one on top of no impl_reflect_value!(EulerRot(Debug, Default)); I think that's all of glam ? |
Hmm not sure what's happening with the wasm builds, Should I conditionally disable those macros on wasm, or not have the SIMD versions at all ? |
I've looked into this and the relevant glam LOC are here: https://github.com/bitshifter/glam-rs/blob/58285f7b127cb93b314e22344bac678b9ba4298f/src/bool.rs#L25-L35. There is a glam issue about this behaviour here: bitshifter/glam-rs#306, For now these reflect impls are behind SIMD features consistent with the glam type aliases, but this might be surprising for people building for multiple platforms. |
please mention the glam issue in the comment 👍 |
Co-authored-by: François <[email protected]>
bors r+ |
# Objective - To implement `Reflect` for more glam types. ## Solution insert `impl_reflect_struct` invocations for more glam types. I am not sure about the boolean vectors, since none of them implement `Serde::Serialize/Deserialize`, and the SIMD versions don't have public fields. I do still think implementing reflection is useful for BVec's since then they can be incorporated into `Reflect`'ed components and set dynamically even if as a whole + it's more consistent. ## Changelog Implemented `Reflect` for the following types - BVec2 - BVec3 - **BVec3A** (on simd supported platforms only) - BVec4 - **BVec4A** (on simd supported platforms only) - Mat2 - Mat3A - DMat2 - Affine2 - Affine3A - DAffine2 - DAffine3 - EulerRot
What is the use case for serializing or reflecting the I'm also curious about the use case for reflecting |
So I think the main argument for reflecting those is consistency, as an example, I am writing But that's just why I personally prefer this approach. Other than that, I don't have anything specific in mind but I also don't see why these shouldn't be supported as subfields of components or resources. There may be a neat use case for boolean vectors or serializing them, why should we limit the non-rust user? Same reasoning applies for EulerRot, while bevy has an established preference for coordinates, someone might prefer not to use this and roll their own transforms. So my argument here is basically, why not? Now Serialization is not really that big of a deal here, the API difference between platforms is however. I guess if performance would be much worse with the alternative consistent API though, then platform-consistent-reflecting has lower priority than performance of the other glam operations. |
Thanks for the explanation, exposing to script does make a lot of sense. To be clear I'm not opposing this but I did want to understand the why a bit better. The performance question issue is a bit theoretical at the moment, it would require a bit of work to determine if it was a real problem. For example, I probably should have started this discussion on the glam issue but I was interested in the bevy context :) |
Yeah no worries, I get why you'd want context! The scalar implementation probably sounds like the best solution in the context of bevy, but I have no expertise in this area |
# Objective - To implement `Reflect` for more glam types. ## Solution insert `impl_reflect_struct` invocations for more glam types. I am not sure about the boolean vectors, since none of them implement `Serde::Serialize/Deserialize`, and the SIMD versions don't have public fields. I do still think implementing reflection is useful for BVec's since then they can be incorporated into `Reflect`'ed components and set dynamically even if as a whole + it's more consistent. ## Changelog Implemented `Reflect` for the following types - BVec2 - BVec3 - **BVec3A** (on simd supported platforms only) - BVec4 - **BVec4A** (on simd supported platforms only) - Mat2 - Mat3A - DMat2 - Affine2 - Affine3A - DAffine2 - DAffine3 - EulerRot
# Objective - To implement `Reflect` for more glam types. ## Solution insert `impl_reflect_struct` invocations for more glam types. I am not sure about the boolean vectors, since none of them implement `Serde::Serialize/Deserialize`, and the SIMD versions don't have public fields. I do still think implementing reflection is useful for BVec's since then they can be incorporated into `Reflect`'ed components and set dynamically even if as a whole + it's more consistent. ## Changelog Implemented `Reflect` for the following types - BVec2 - BVec3 - **BVec3A** (on simd supported platforms only) - BVec4 - **BVec4A** (on simd supported platforms only) - Mat2 - Mat3A - DMat2 - Affine2 - Affine3A - DAffine2 - DAffine3 - EulerRot
# Objective - To implement `Reflect` for more glam types. ## Solution insert `impl_reflect_struct` invocations for more glam types. I am not sure about the boolean vectors, since none of them implement `Serde::Serialize/Deserialize`, and the SIMD versions don't have public fields. I do still think implementing reflection is useful for BVec's since then they can be incorporated into `Reflect`'ed components and set dynamically even if as a whole + it's more consistent. ## Changelog Implemented `Reflect` for the following types - BVec2 - BVec3 - **BVec3A** (on simd supported platforms only) - BVec4 - **BVec4A** (on simd supported platforms only) - Mat2 - Mat3A - DMat2 - Affine2 - Affine3A - DAffine2 - DAffine3 - EulerRot
Objective
Reflect
for more glam types.Solution
insert
impl_reflect_struct
invocations for more glam types. I am not sure about the boolean vectors, since none of them implementSerde::Serialize/Deserialize
, and the SIMD versions don't have public fields.I do still think implementing reflection is useful for BVec's since then they can be incorporated into
Reflect
'ed components and set dynamically even if as a whole + it's more consistent.Changelog
Implemented
Reflect
for the following types