bevy/crates/bevy_reflect/src/impls/math/primitives3d.rs
radiish df761af49b
reflection: replace impl_reflect_struct with impl_reflect (#11437)
# Objective

- `impl_reflect_struct` doesn't cover tuple structs or enums.
- Problem brought up [on
Discord](https://discord.com/channels/691052431525675048/1002362493634629796/1190623345817960463).

## Solution

- Replaces `impl_reflect_struct` with the new `impl_reflect` which works
for tuple structs and enums too.

---

## Changelog

- Internally in `bevy_reflect_derive`, we have a new `ReflectProvenance`
type which is composed of `ReflectTraitToImpl` and `ReflectSource`.
- `impl_reflect_struct` is gone and totally superseded by
`impl_reflect`.

---------

Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
2024-01-30 14:39:01 +00:00

107 lines
2.3 KiB
Rust

use crate as bevy_reflect;
use crate::{ReflectDeserialize, ReflectSerialize};
use bevy_math::{primitives::*, Vec3};
use bevy_reflect_derive::{impl_reflect, impl_reflect_value};
impl_reflect_value!(::bevy_math::primitives::Direction3d(
Debug,
PartialEq,
Serialize,
Deserialize
));
impl_reflect!(
#[reflect(Debug, PartialEq, Serialize, Deserialize)]
#[type_path = "bevy_math::primitives"]
struct Sphere {
radius: f32,
}
);
impl_reflect!(
#[reflect(Debug, PartialEq, Serialize, Deserialize)]
#[type_path = "bevy_math::primitives"]
struct Plane3d {
normal: Direction3d,
}
);
impl_reflect!(
#[reflect(Debug, PartialEq, Serialize, Deserialize)]
#[type_path = "bevy_math::primitives"]
struct Line3d {
direction: Direction3d,
}
);
impl_reflect!(
#[reflect(Debug, PartialEq, Serialize, Deserialize)]
#[type_path = "bevy_math::primitives"]
struct Segment3d {
direction: Direction3d,
half_length: f32,
}
);
impl_reflect!(
#[reflect(Debug, PartialEq)]
#[type_path = "bevy_math::primitives"]
struct Polyline3d<const N: usize> {
vertices: [Vec3; N],
}
);
impl_reflect!(
#[reflect(Debug, PartialEq, Serialize, Deserialize)]
#[type_path = "bevy_math::primitives"]
struct Cuboid {
half_size: Vec3,
}
);
impl_reflect!(
#[reflect(Debug, PartialEq, Serialize, Deserialize)]
#[type_path = "bevy_math::primitives"]
struct Cylinder {
radius: f32,
half_height: f32,
}
);
impl_reflect!(
#[reflect(Debug, PartialEq, Serialize, Deserialize)]
#[type_path = "bevy_math::primitives"]
struct Capsule3d {
radius: f32,
half_length: f32,
}
);
impl_reflect!(
#[reflect(Debug, PartialEq, Serialize, Deserialize)]
#[type_path = "bevy_math::primitives"]
struct Cone {
radius: f32,
height: f32,
}
);
impl_reflect!(
#[reflect(Debug, PartialEq, Serialize, Deserialize)]
#[type_path = "bevy_math::primitives"]
struct ConicalFrustum {
radius_top: f32,
radius_bottom: f32,
height: f32,
}
);
impl_reflect!(
#[reflect(Debug, PartialEq, Serialize, Deserialize)]
#[type_path = "bevy_math::primitives"]
struct Torus {
minor_radius: f32,
major_radius: f32,
}
);