From 9d088dd1443e08e19c6feba5cd3787e6846b05df Mon Sep 17 00:00:00 2001 From: Aevyrie Date: Sat, 28 Oct 2023 14:53:38 -0700 Subject: [PATCH] Add `Cubic` prefix to all cubic curve generators (#10299) # Objective - Fixes #10258 ## Solution - Renamed. --- ## Changelog - Changed: `BSpline` -> `CubicBSpline` - Changed: `CardinalSpline` -> `CubicCardinalSpline` - Changed: `Hermite` -> `CubicHermite` ## Migration Guide - Rename: `BSpline` -> `CubicBSpline` - Rename: `CardinalSpline` -> `CubicCardinalSpline` - Rename: `Hermite` -> `CubicHermite` --- crates/bevy_math/src/cubic_splines.rs | 24 ++++++++++++------------ crates/bevy_math/src/lib.rs | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/crates/bevy_math/src/cubic_splines.rs b/crates/bevy_math/src/cubic_splines.rs index dc89a00e1a..9f4fc365f7 100644 --- a/crates/bevy_math/src/cubic_splines.rs +++ b/crates/bevy_math/src/cubic_splines.rs @@ -120,13 +120,13 @@ impl CubicGenerator

for CubicBezier

{ /// vec2(0.0, 1.0), /// vec2(0.0, 1.0), /// ]; -/// let hermite = Hermite::new(points, tangents).to_curve(); +/// let hermite = CubicHermite::new(points, tangents).to_curve(); /// let positions: Vec<_> = hermite.iter_positions(100).collect(); /// ``` -pub struct Hermite { +pub struct CubicHermite { control_points: Vec<(P, P)>, } -impl Hermite

{ +impl CubicHermite

{ /// Create a new Hermite curve from sets of control points. pub fn new( control_points: impl IntoIterator, @@ -137,7 +137,7 @@ impl Hermite

{ } } } -impl CubicGenerator

for Hermite

{ +impl CubicGenerator

for CubicHermite

{ #[inline] fn to_curve(&self) -> CubicCurve

{ let char_matrix = [ @@ -184,15 +184,15 @@ impl CubicGenerator

for Hermite

{ /// vec2(5.0, 3.0), /// vec2(9.0, 8.0), /// ]; -/// let cardinal = CardinalSpline::new(0.3, points).to_curve(); +/// let cardinal = CubicCardinalSpline::new(0.3, points).to_curve(); /// let positions: Vec<_> = cardinal.iter_positions(100).collect(); /// ``` -pub struct CardinalSpline { +pub struct CubicCardinalSpline { tension: f32, control_points: Vec

, } -impl CardinalSpline

{ +impl CubicCardinalSpline

{ /// Build a new Cardinal spline. pub fn new(tension: f32, control_points: impl Into>) -> Self { Self { @@ -209,7 +209,7 @@ impl CardinalSpline

{ } } } -impl CubicGenerator

for CardinalSpline

{ +impl CubicGenerator

for CubicCardinalSpline

{ #[inline] fn to_curve(&self) -> CubicCurve

{ let s = self.tension; @@ -252,13 +252,13 @@ impl CubicGenerator

for CardinalSpline

{ /// vec2(5.0, 3.0), /// vec2(9.0, 8.0), /// ]; -/// let b_spline = BSpline::new(points).to_curve(); +/// let b_spline = CubicBSpline::new(points).to_curve(); /// let positions: Vec<_> = b_spline.iter_positions(100).collect(); /// ``` -pub struct BSpline { +pub struct CubicBSpline { control_points: Vec

, } -impl BSpline

{ +impl CubicBSpline

{ /// Build a new Cardinal spline. pub fn new(control_points: impl Into>) -> Self { Self { @@ -266,7 +266,7 @@ impl BSpline

{ } } } -impl CubicGenerator

for BSpline

{ +impl CubicGenerator

for CubicBSpline

{ #[inline] fn to_curve(&self) -> CubicCurve

{ let char_matrix = [ diff --git a/crates/bevy_math/src/lib.rs b/crates/bevy_math/src/lib.rs index b88de2e3a6..106f0ba08d 100644 --- a/crates/bevy_math/src/lib.rs +++ b/crates/bevy_math/src/lib.rs @@ -21,7 +21,8 @@ pub mod prelude { #[doc(hidden)] pub use crate::{ cubic_splines::{ - BSpline, CardinalSpline, CubicBezier, CubicGenerator, CubicSegment, Hermite, + CubicBSpline, CubicBezier, CubicCardinalSpline, CubicGenerator, CubicHermite, + CubicSegment, }, BVec2, BVec3, BVec4, EulerRot, IRect, IVec2, IVec3, IVec4, Mat2, Mat3, Mat4, Quat, Ray, Rect, URect, UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3, Vec3Swizzles, Vec4,