mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Put curve-related stuff behind a feature (#15790)
# Objective A bunch of code is used only if you care about the `Curve` trait. Put it behind a feature so it can be ignored if wanted. ## Solution Added a default feature `curve` to `bevy_math` which feature-gates the `curve` module and internal integrations. ## Testing Tested compiling with the feature enabled and disabled.
This commit is contained in:
parent
7d40e3ec87
commit
123a19afa9
3 changed files with 25 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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<Vec2> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "curve")]
|
||||
impl<P: VectorSpace> Curve<P> for CubicSegment<P> {
|
||||
#[inline]
|
||||
fn domain(&self) -> Interval {
|
||||
|
@ -1199,6 +1199,7 @@ impl<P: VectorSpace> CubicCurve<P> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "curve")]
|
||||
impl<P: VectorSpace> Curve<P> for CubicCurve<P> {
|
||||
#[inline]
|
||||
fn domain(&self) -> Interval {
|
||||
|
@ -1370,6 +1371,7 @@ impl<P: VectorSpace> RationalSegment<P> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "curve")]
|
||||
impl<P: VectorSpace> Curve<P> for RationalSegment<P> {
|
||||
#[inline]
|
||||
fn domain(&self) -> Interval {
|
||||
|
@ -1526,6 +1528,7 @@ impl<P: VectorSpace> RationalCurve<P> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "curve")]
|
||||
impl<P: VectorSpace> Curve<P> for RationalCurve<P> {
|
||||
#[inline]
|
||||
fn domain(&self) -> Interval {
|
||||
|
|
|
@ -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};
|
||||
|
|
Loading…
Reference in a new issue