Skip to content

Commit

Permalink
Hopefully fixed everything now
Browse files Browse the repository at this point in the history
  • Loading branch information
Olle-Lukowski committed May 26, 2024
1 parent da43104 commit 4f480ed
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 59 deletions.
48 changes: 38 additions & 10 deletions crates/bevy_math/src/cubic_splines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{Vec2, VectorSpace};

use thiserror::Error;

#[cfg(feature = "reflect")]
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::prelude::*;

/// A spline composed of a single cubic Bezier curve.
Expand Down Expand Up @@ -44,7 +44,11 @@ use bevy_reflect::prelude::*;
/// let positions: Vec<_> = bezier.iter_positions(100).collect();
/// ```
#[derive(Clone, Debug)]
#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect), reflect(Debug))]
#[cfg_attr(
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug)
)]
pub struct CubicBezier<P: VectorSpace> {
/// The control points of the Bezier curve
pub control_points: Vec<[P; 4]>,
Expand Down Expand Up @@ -118,7 +122,11 @@ impl<P: VectorSpace> CubicGenerator<P> for CubicBezier<P> {
/// let positions: Vec<_> = hermite.iter_positions(100).collect();
/// ```
#[derive(Clone, Debug)]
#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect), reflect(Debug))]
#[cfg_attr(
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug)
)]
pub struct CubicHermite<P: VectorSpace> {
/// The control points of the Hermite curve
pub control_points: Vec<(P, P)>,
Expand Down Expand Up @@ -187,7 +195,11 @@ impl<P: VectorSpace> CubicGenerator<P> for CubicHermite<P> {
/// let positions: Vec<_> = cardinal.iter_positions(100).collect();
/// ```
#[derive(Clone, Debug)]
#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect), reflect(Debug))]
#[cfg_attr(
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug)
)]
pub struct CubicCardinalSpline<P: VectorSpace> {
/// Tension
pub tension: f32,
Expand Down Expand Up @@ -278,7 +290,11 @@ impl<P: VectorSpace> CubicGenerator<P> for CubicCardinalSpline<P> {
/// let positions: Vec<_> = b_spline.iter_positions(100).collect();
/// ```
#[derive(Clone, Debug)]
#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect), reflect(Debug))]
#[cfg_attr(
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug)
)]
pub struct CubicBSpline<P: VectorSpace> {
/// The control points of the spline
pub control_points: Vec<P>,
Expand Down Expand Up @@ -398,7 +414,11 @@ pub enum CubicNurbsError {
/// let positions: Vec<_> = nurbs.iter_positions(100).collect();
/// ```
#[derive(Clone, Debug)]
#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect), reflect(Debug))]
#[cfg_attr(
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug)
)]
pub struct CubicNurbs<P: VectorSpace> {
/// The control points of the NURBS
pub control_points: Vec<P>,
Expand Down Expand Up @@ -649,7 +669,7 @@ pub trait CubicGenerator<P: VectorSpace> {
/// Segments can be chained together to form a longer compound curve.
#[derive(Copy, Clone, Debug, Default, PartialEq)]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, Default)
)]
Expand Down Expand Up @@ -812,7 +832,11 @@ impl CubicSegment<Vec2> {
/// Use any struct that implements the [`CubicGenerator`] trait to create a new curve, such as
/// [`CubicBezier`].
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect), reflect(Debug))]
#[cfg_attr(
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug)
)]
pub struct CubicCurve<P: VectorSpace> {
/// Segments of the curve
pub segments: Vec<CubicSegment<P>>,
Expand Down Expand Up @@ -947,7 +971,7 @@ pub trait RationalGenerator<P: VectorSpace> {
/// Segments can be chained together to form a longer compound curve.
#[derive(Copy, Clone, Debug, Default, PartialEq)]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, Default)
)]
Expand Down Expand Up @@ -1078,7 +1102,11 @@ impl<P: VectorSpace> RationalSegment<P> {
/// Use any struct that implements the [`RationalGenerator`] trait to create a new curve, such as
/// [`CubicNurbs`], or convert [`CubicCurve`] using `into/from`.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect), reflect(Debug))]
#[cfg_attr(
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug)
)]
pub struct RationalCurve<P: VectorSpace> {
/// The segments in the curve
pub segments: Vec<RationalSegment<P>>,
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_math/src/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,12 @@ impl approx::UlpsEq for Dir2 {
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
#[doc(alias = "Direction3d")]
Expand Down Expand Up @@ -492,12 +492,12 @@ impl approx::UlpsEq for Dir3 {
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
#[doc(alias = "Direction3dA")]
Expand Down
40 changes: 20 additions & 20 deletions crates/bevy_math/src/primitives/dim2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,12 @@ mod arc_tests {
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
pub struct Ellipse {
Expand Down Expand Up @@ -866,12 +866,12 @@ impl Measured2d for Ellipse {
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
#[doc(alias = "Ring")]
Expand Down Expand Up @@ -1090,12 +1090,12 @@ impl Measured2d for Rhombus {
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
pub struct Plane2d {
Expand Down Expand Up @@ -1131,12 +1131,12 @@ impl Plane2d {
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
pub struct Line2d {
Expand All @@ -1150,12 +1150,12 @@ impl Primitive2d for Line2d {}
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
#[doc(alias = "LineSegment2d")]
Expand Down Expand Up @@ -1214,7 +1214,7 @@ impl Segment2d {
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
Expand Down Expand Up @@ -1275,12 +1275,12 @@ impl BoxedPolyline2d {
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
pub struct Triangle2d {
Expand Down Expand Up @@ -1446,12 +1446,12 @@ impl Measured2d for Triangle2d {
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
#[doc(alias = "Quad")]
Expand Down Expand Up @@ -1539,7 +1539,7 @@ impl Measured2d for Rectangle {
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
Expand Down Expand Up @@ -1600,12 +1600,12 @@ impl BoxedPolygon {
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
pub struct RegularPolygon {
Expand Down Expand Up @@ -1746,12 +1746,12 @@ impl Measured2d for RegularPolygon {
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
feature = "reflect",
feature = "bevy_reflect",
derive(bevy_reflect::Reflect),
reflect(Debug, PartialEq)
)]
#[cfg_attr(
all(feature = "serialize", feature = "reflect"),
all(feature = "serialize", feature = "bevy_reflect"),
reflect(Serialize, Deserialize)
)]
#[doc(alias = "stadium", alias = "pill")]
Expand Down
Loading

0 comments on commit 4f480ed

Please sign in to comment.