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 }
|
], default-features = false, optional = true }
|
||||||
rand_distr = { version = "0.4.3", optional = true }
|
rand_distr = { version = "0.4.3", optional = true }
|
||||||
smallvec = { version = "1.11" }
|
smallvec = { version = "1.11" }
|
||||||
|
|
||||||
bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [
|
bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [
|
||||||
"glam",
|
"glam",
|
||||||
], optional = true }
|
], optional = true }
|
||||||
|
@ -41,7 +40,7 @@ bevy_math = { path = ".", version = "0.15.0-dev", features = ["approx"] }
|
||||||
glam = { version = "0.29", features = ["approx"] }
|
glam = { version = "0.29", features = ["approx"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["rand", "bevy_reflect"]
|
default = ["rand", "bevy_reflect", "curve"]
|
||||||
serialize = ["dep:serde", "glam/serde"]
|
serialize = ["dep:serde", "glam/serde"]
|
||||||
# Enable approx for glam types to approximate floating point equality comparisons and assertions
|
# Enable approx for glam types to approximate floating point equality comparisons and assertions
|
||||||
approx = ["dep:approx", "glam/approx"]
|
approx = ["dep:approx", "glam/approx"]
|
||||||
|
@ -56,6 +55,8 @@ glam_assert = ["glam/glam-assert"]
|
||||||
debug_glam_assert = ["glam/debug-glam-assert"]
|
debug_glam_assert = ["glam/debug-glam-assert"]
|
||||||
# Enable the rand dependency for shape_sampling
|
# Enable the rand dependency for shape_sampling
|
||||||
rand = ["dep:rand", "dep:rand_distr", "glam/rand"]
|
rand = ["dep:rand", "dep:rand_distr", "glam/rand"]
|
||||||
|
# Include code related to the Curve trait
|
||||||
|
curve = []
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
|
@ -2,15 +2,14 @@
|
||||||
|
|
||||||
use core::{fmt::Debug, iter::once};
|
use core::{fmt::Debug, iter::once};
|
||||||
|
|
||||||
use crate::{
|
use crate::{ops::FloatPow, Vec2, VectorSpace};
|
||||||
curve::{Curve, Interval},
|
|
||||||
ops::FloatPow,
|
|
||||||
Vec2, VectorSpace,
|
|
||||||
};
|
|
||||||
|
|
||||||
use derive_more::derive::{Display, Error};
|
use derive_more::derive::{Display, Error};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
|
#[cfg(feature = "curve")]
|
||||||
|
use crate::curve::{Curve, Interval};
|
||||||
|
|
||||||
#[cfg(feature = "bevy_reflect")]
|
#[cfg(feature = "bevy_reflect")]
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, 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> {
|
impl<P: VectorSpace> Curve<P> for CubicSegment<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn domain(&self) -> Interval {
|
fn domain(&self) -> Interval {
|
||||||
|
@ -1199,6 +1199,7 @@ impl<P: VectorSpace> CubicCurve<P> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "curve")]
|
||||||
impl<P: VectorSpace> Curve<P> for CubicCurve<P> {
|
impl<P: VectorSpace> Curve<P> for CubicCurve<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn domain(&self) -> Interval {
|
fn domain(&self) -> Interval {
|
||||||
|
@ -1370,6 +1371,7 @@ impl<P: VectorSpace> RationalSegment<P> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "curve")]
|
||||||
impl<P: VectorSpace> Curve<P> for RationalSegment<P> {
|
impl<P: VectorSpace> Curve<P> for RationalSegment<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn domain(&self) -> Interval {
|
fn domain(&self) -> Interval {
|
||||||
|
@ -1526,6 +1528,7 @@ impl<P: VectorSpace> RationalCurve<P> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "curve")]
|
||||||
impl<P: VectorSpace> Curve<P> for RationalCurve<P> {
|
impl<P: VectorSpace> Curve<P> for RationalCurve<P> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn domain(&self) -> Interval {
|
fn domain(&self) -> Interval {
|
||||||
|
|
|
@ -17,7 +17,6 @@ pub mod bounding;
|
||||||
pub mod common_traits;
|
pub mod common_traits;
|
||||||
mod compass;
|
mod compass;
|
||||||
pub mod cubic_splines;
|
pub mod cubic_splines;
|
||||||
pub mod curve;
|
|
||||||
mod direction;
|
mod direction;
|
||||||
mod float_ord;
|
mod float_ord;
|
||||||
mod isometry;
|
mod isometry;
|
||||||
|
@ -26,13 +25,17 @@ pub mod primitives;
|
||||||
mod ray;
|
mod ray;
|
||||||
mod rects;
|
mod rects;
|
||||||
mod rotation2d;
|
mod rotation2d;
|
||||||
|
|
||||||
|
#[cfg(feature = "curve")]
|
||||||
|
pub mod curve;
|
||||||
|
|
||||||
#[cfg(feature = "rand")]
|
#[cfg(feature = "rand")]
|
||||||
pub mod sampling;
|
pub mod sampling;
|
||||||
pub use compass::{CompassOctant, CompassQuadrant};
|
|
||||||
|
|
||||||
pub use affine3::*;
|
pub use affine3::*;
|
||||||
pub use aspect_ratio::AspectRatio;
|
pub use aspect_ratio::AspectRatio;
|
||||||
pub use common_traits::*;
|
pub use common_traits::*;
|
||||||
|
pub use compass::{CompassOctant, CompassQuadrant};
|
||||||
pub use direction::*;
|
pub use direction::*;
|
||||||
pub use float_ord::*;
|
pub use float_ord::*;
|
||||||
pub use isometry::{Isometry2d, Isometry3d};
|
pub use isometry::{Isometry2d, Isometry3d};
|
||||||
|
@ -40,10 +43,12 @@ pub use ops::FloatPow;
|
||||||
pub use ray::{Ray2d, Ray3d};
|
pub use ray::{Ray2d, Ray3d};
|
||||||
pub use rects::*;
|
pub use rects::*;
|
||||||
pub use rotation2d::Rot2;
|
pub use rotation2d::Rot2;
|
||||||
|
|
||||||
|
#[cfg(feature = "curve")]
|
||||||
|
pub use curve::Curve;
|
||||||
|
|
||||||
#[cfg(feature = "rand")]
|
#[cfg(feature = "rand")]
|
||||||
pub use sampling::FromRng;
|
pub use sampling::{FromRng, ShapeSample};
|
||||||
#[cfg(feature = "rand")]
|
|
||||||
pub use sampling::ShapeSample;
|
|
||||||
|
|
||||||
/// The math prelude.
|
/// The math prelude.
|
||||||
///
|
///
|
||||||
|
@ -56,7 +61,6 @@ pub mod prelude {
|
||||||
CubicHermite, CubicNurbs, CubicNurbsError, CubicSegment, CyclicCubicGenerator,
|
CubicHermite, CubicNurbs, CubicNurbsError, CubicSegment, CyclicCubicGenerator,
|
||||||
RationalCurve, RationalGenerator, RationalSegment,
|
RationalCurve, RationalGenerator, RationalSegment,
|
||||||
},
|
},
|
||||||
curve::*,
|
|
||||||
direction::{Dir2, Dir3, Dir3A},
|
direction::{Dir2, Dir3, Dir3A},
|
||||||
ops,
|
ops,
|
||||||
primitives::*,
|
primitives::*,
|
||||||
|
@ -65,6 +69,10 @@ pub mod prelude {
|
||||||
UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles,
|
UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[cfg(feature = "curve")]
|
||||||
|
pub use crate::curve::*;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[cfg(feature = "rand")]
|
#[cfg(feature = "rand")]
|
||||||
pub use crate::sampling::{FromRng, ShapeSample};
|
pub use crate::sampling::{FromRng, ShapeSample};
|
||||||
|
|
Loading…
Reference in a new issue