diff --git a/crates/bevy_math/Cargo.toml b/crates/bevy_math/Cargo.toml index bfd6535a866f4..74ed8dee85abc 100644 --- a/crates/bevy_math/Cargo.toml +++ b/crates/bevy_math/Cargo.toml @@ -26,7 +26,6 @@ rand = { version = "0.8", features = [ ], default-features = false, optional = true } rand_distr = { version = "0.4.3", optional = true } smallvec = { version = "1.11" } - bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [ "glam", ], optional = true } @@ -41,7 +40,7 @@ bevy_math = { path = ".", version = "0.15.0-dev", features = ["approx"] } glam = { version = "0.29", features = ["approx"] } [features] -default = ["rand", "bevy_reflect"] +default = ["rand", "bevy_reflect", "curve"] serialize = ["dep:serde", "glam/serde"] # Enable approx for glam types to approximate floating point equality comparisons and assertions approx = ["dep:approx", "glam/approx"] @@ -56,6 +55,8 @@ glam_assert = ["glam/glam-assert"] debug_glam_assert = ["glam/debug-glam-assert"] # Enable the rand dependency for shape_sampling rand = ["dep:rand", "dep:rand_distr", "glam/rand"] +# Include code related to the Curve trait +curve = [] [lints] workspace = true diff --git a/crates/bevy_math/src/cubic_splines.rs b/crates/bevy_math/src/cubic_splines.rs index 66d7df3d32870..87d95b0fc2d85 100644 --- a/crates/bevy_math/src/cubic_splines.rs +++ b/crates/bevy_math/src/cubic_splines.rs @@ -2,15 +2,14 @@ use core::{fmt::Debug, iter::once}; -use crate::{ - curve::{Curve, Interval}, - ops::FloatPow, - Vec2, VectorSpace, -}; +use crate::{ops::FloatPow, Vec2, VectorSpace}; use derive_more::derive::{Display, Error}; use itertools::Itertools; +#[cfg(feature = "curve")] +use crate::curve::{Curve, Interval}; + #[cfg(feature = "bevy_reflect")] use bevy_reflect::{std_traits::ReflectDefault, Reflect}; @@ -1062,6 +1061,7 @@ impl CubicSegment { } } +#[cfg(feature = "curve")] impl Curve

for CubicSegment

{ #[inline] fn domain(&self) -> Interval { @@ -1199,6 +1199,7 @@ impl CubicCurve

{ } } +#[cfg(feature = "curve")] impl Curve

for CubicCurve

{ #[inline] fn domain(&self) -> Interval { @@ -1370,6 +1371,7 @@ impl RationalSegment

{ } } +#[cfg(feature = "curve")] impl Curve

for RationalSegment

{ #[inline] fn domain(&self) -> Interval { @@ -1526,6 +1528,7 @@ impl RationalCurve

{ } } +#[cfg(feature = "curve")] impl Curve

for RationalCurve

{ #[inline] fn domain(&self) -> Interval { diff --git a/crates/bevy_math/src/lib.rs b/crates/bevy_math/src/lib.rs index 984a068ff82a4..46062fc852665 100644 --- a/crates/bevy_math/src/lib.rs +++ b/crates/bevy_math/src/lib.rs @@ -17,7 +17,6 @@ pub mod bounding; pub mod common_traits; mod compass; pub mod cubic_splines; -pub mod curve; mod direction; mod float_ord; mod isometry; @@ -26,13 +25,17 @@ pub mod primitives; mod ray; mod rects; mod rotation2d; + +#[cfg(feature = "curve")] +pub mod curve; + #[cfg(feature = "rand")] pub mod sampling; -pub use compass::{CompassOctant, CompassQuadrant}; pub use affine3::*; pub use aspect_ratio::AspectRatio; pub use common_traits::*; +pub use compass::{CompassOctant, CompassQuadrant}; pub use direction::*; pub use float_ord::*; pub use isometry::{Isometry2d, Isometry3d}; @@ -40,10 +43,12 @@ pub use ops::FloatPow; pub use ray::{Ray2d, Ray3d}; pub use rects::*; pub use rotation2d::Rot2; + +#[cfg(feature = "curve")] +pub use curve::Curve; + #[cfg(feature = "rand")] -pub use sampling::FromRng; -#[cfg(feature = "rand")] -pub use sampling::ShapeSample; +pub use sampling::{FromRng, ShapeSample}; /// The math prelude. /// @@ -56,7 +61,6 @@ pub mod prelude { CubicHermite, CubicNurbs, CubicNurbsError, CubicSegment, CyclicCubicGenerator, RationalCurve, RationalGenerator, RationalSegment, }, - curve::*, direction::{Dir2, Dir3, Dir3A}, ops, primitives::*, @@ -65,6 +69,10 @@ pub mod prelude { UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles, }; + #[doc(hidden)] + #[cfg(feature = "curve")] + pub use crate::curve::*; + #[doc(hidden)] #[cfg(feature = "rand")] pub use crate::sampling::{FromRng, ShapeSample};