commit
fe78bf2eb6
@ -22,12 +22,14 @@ maintenance = { status = "actively-developed" }
|
|||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
impl-cgmath = ["cgmath"]
|
impl-cgmath = ["cgmath"]
|
||||||
|
impl-glam = ["glam"]
|
||||||
impl-nalgebra = ["nalgebra", "num-traits", "simba"]
|
impl-nalgebra = ["nalgebra", "num-traits", "simba"]
|
||||||
serialization = ["serde", "serde_derive"]
|
serialization = ["serde", "serde_derive"]
|
||||||
std = []
|
std = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cgmath = { version = "0.17", optional = true }
|
cgmath = { version = "0.17", optional = true }
|
||||||
|
glam = { version = "0.10", optional = true }
|
||||||
nalgebra = { version = ">=0.21, <0.23", optional = true }
|
nalgebra = { version = ">=0.21, <0.23", optional = true }
|
||||||
num-traits = { version = "0.2", optional = true }
|
num-traits = { version = "0.2", optional = true }
|
||||||
serde = { version = "1", optional = true }
|
serde = { version = "1", optional = true }
|
||||||
|
@ -90,6 +90,9 @@ So here’s a list of currently supported features and how to enable them:
|
|||||||
- **[cgmath](https://crates.io/crates/cgmath) implementors.**
|
- **[cgmath](https://crates.io/crates/cgmath) implementors.**
|
||||||
- Adds some useful implementations of `Interpolate` for some cgmath types.
|
- Adds some useful implementations of `Interpolate` for some cgmath types.
|
||||||
- Enable with the `"impl-cgmath"` feature.
|
- Enable with the `"impl-cgmath"` feature.
|
||||||
|
- **[glam](https://crates.io/crates/glam) implementors.**
|
||||||
|
- Adds some useful implementations of `Interpolate` for some glam types.
|
||||||
|
- Enable with the `"impl-glam"` feature.
|
||||||
- **[nalgebra](https://crates.io/crates/nalgebra) implementors.**
|
- **[nalgebra](https://crates.io/crates/nalgebra) implementors.**
|
||||||
- Adds some useful implementations of `Interpolate` for some nalgebra types.
|
- Adds some useful implementations of `Interpolate` for some nalgebra types.
|
||||||
- Enable with the `"impl-nalgebra"` feature.
|
- Enable with the `"impl-nalgebra"` feature.
|
||||||
|
88
src/glam.rs
Normal file
88
src/glam.rs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
use glam::{Quat, Vec2, Vec3, Vec3A, Vec4};
|
||||||
|
|
||||||
|
use crate::interpolate::{
|
||||||
|
cubic_bezier_def, cubic_hermite_def, quadratic_bezier_def, Interpolate, Linear,
|
||||||
|
};
|
||||||
|
|
||||||
|
macro_rules! impl_interpolate_vec {
|
||||||
|
($($t:tt)*) => {
|
||||||
|
impl Linear<f32> for $($t)* {
|
||||||
|
#[inline(always)]
|
||||||
|
fn outer_mul(self, t: f32) -> Self {
|
||||||
|
self * t
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn outer_div(self, t: f32) -> Self {
|
||||||
|
self / t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Interpolate<f32> for $($t)* {
|
||||||
|
#[inline(always)]
|
||||||
|
fn lerp(a: Self, b: Self, t: f32) -> Self {
|
||||||
|
a.lerp(b, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn cubic_hermite(
|
||||||
|
x: (Self, f32),
|
||||||
|
a: (Self, f32),
|
||||||
|
b: (Self, f32),
|
||||||
|
y: (Self, f32),
|
||||||
|
t: f32,
|
||||||
|
) -> Self {
|
||||||
|
cubic_hermite_def(x, a, b, y, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn quadratic_bezier(a: Self, u: Self, b: Self, t: f32) -> Self {
|
||||||
|
quadratic_bezier_def(a, u, b, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn cubic_bezier(a: Self, u: Self, v: Self, b: Self, t: f32) -> Self {
|
||||||
|
cubic_bezier_def(a, u, v, b, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_interpolate_vec!(Vec2);
|
||||||
|
impl_interpolate_vec!(Vec3);
|
||||||
|
impl_interpolate_vec!(Vec3A);
|
||||||
|
impl_interpolate_vec!(Vec4);
|
||||||
|
|
||||||
|
impl Linear<f32> for Quat {
|
||||||
|
#[inline(always)]
|
||||||
|
fn outer_mul(self, t: f32) -> Self {
|
||||||
|
self * t
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn outer_div(self, t: f32) -> Self {
|
||||||
|
self / t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Interpolate<f32> for Quat {
|
||||||
|
#[inline(always)]
|
||||||
|
fn lerp(a: Self, b: Self, t: f32) -> Self {
|
||||||
|
a.lerp(b, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn cubic_hermite(x: (Self, f32), a: (Self, f32), b: (Self, f32), y: (Self, f32), t: f32) -> Self {
|
||||||
|
cubic_hermite_def(x, a, b, y, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn quadratic_bezier(a: Self, u: Self, b: Self, t: f32) -> Self {
|
||||||
|
quadratic_bezier_def(a, u, b, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn cubic_bezier(a: Self, u: Self, v: Self, b: Self, t: f32) -> Self {
|
||||||
|
cubic_bezier_def(a, u, v, b, t)
|
||||||
|
}
|
||||||
|
}
|
@ -91,6 +91,9 @@
|
|||||||
//! - **[cgmath](https://crates.io/crates/cgmath) implementors.**
|
//! - **[cgmath](https://crates.io/crates/cgmath) implementors.**
|
||||||
//! - Adds some useful implementations of `Interpolate` for some cgmath types.
|
//! - Adds some useful implementations of `Interpolate` for some cgmath types.
|
||||||
//! - Enable with the `"impl-cgmath"` feature.
|
//! - Enable with the `"impl-cgmath"` feature.
|
||||||
|
//! - **[glam](https://crates.io/crates/glam) implementors.**
|
||||||
|
//! - Adds some useful implementations of `Interpolate` for some glam types.
|
||||||
|
//! - Enable with the `"impl-glam"` feature.
|
||||||
//! - **[nalgebra](https://crates.io/crates/nalgebra) implementors.**
|
//! - **[nalgebra](https://crates.io/crates/nalgebra) implementors.**
|
||||||
//! - Adds some useful implementations of `Interpolate` for some nalgebra types.
|
//! - Adds some useful implementations of `Interpolate` for some nalgebra types.
|
||||||
//! - Enable with the `"impl-nalgebra"` feature.
|
//! - Enable with the `"impl-nalgebra"` feature.
|
||||||
@ -111,6 +114,8 @@ extern crate alloc;
|
|||||||
|
|
||||||
#[cfg(feature = "impl-cgmath")]
|
#[cfg(feature = "impl-cgmath")]
|
||||||
mod cgmath;
|
mod cgmath;
|
||||||
|
#[cfg(feature = "impl-glam")]
|
||||||
|
mod glam;
|
||||||
pub mod interpolate;
|
pub mod interpolate;
|
||||||
pub mod interpolation;
|
pub mod interpolation;
|
||||||
pub mod iter;
|
pub mod iter;
|
||||||
|
Loading…
Reference in New Issue
Block a user