Skip to content
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

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions crates/bevy_reflect/src/impls/glam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,39 @@ impl_reflect_struct!(
}
);

impl_reflect_struct!(
#[reflect(Debug, PartialEq, Default)]
struct BVec2 {
x: bool,
y: bool,
}
);
impl_reflect_struct!(
#[reflect(Debug, PartialEq, Default)]
struct BVec3 {
x: bool,
y: bool,
z: bool,
}
);
impl_reflect_struct!(
#[reflect(Debug, PartialEq, Default)]
struct BVec3A {}
);
impl_reflect_struct!(
#[reflect(Debug, PartialEq, Default)]
struct BVec4 {
x: bool,
y: bool,
z: bool,
w: bool,
}
);
impl_reflect_struct!(
#[reflect(Debug, PartialEq, Default)]
struct BVec4A {}
);

impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct DVec2 {
Expand All @@ -113,6 +146,13 @@ impl_reflect_struct!(
}
);

impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct Mat2 {
x_axis: Vec2,
y_axis: Vec2,
}
);
impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct Mat3 {
Expand All @@ -121,6 +161,14 @@ impl_reflect_struct!(
z_axis: Vec3,
}
);
impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct Mat3A {
x_axis: Vec3A,
y_axis: Vec3A,
z_axis: Vec3A,
}
);
impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct Mat4 {
Expand All @@ -131,6 +179,13 @@ impl_reflect_struct!(
}
);

impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct DMat2 {
x_axis: DVec2,
y_axis: DVec2,
}
);
impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct DMat3 {
Expand All @@ -149,6 +204,36 @@ impl_reflect_struct!(
}
);

impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct Affine2 {
matrix2: Mat2,
translation: Vec2,
}
);
impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct Affine3A {
matrix3: Mat3A,
translation: Vec3A,
}
);

impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct DAffine2 {
matrix2: DMat2,
translation: DVec2,
}
);
impl_reflect_struct!(
#[reflect(Debug, PartialEq, Serialize, Deserialize, Default)]
struct DAffine3 {
matrix3: DMat3,
translation: DVec3,
}
);

// Quat fields are read-only (as of now), and reflection is currently missing
// mechanisms for read-only fields. I doubt those mechanisms would be added,
// so for now quaternions will remain as values. They are represented identically
Expand Down