fix no_std

This commit is contained in:
Max Känner 2024-01-05 15:50:26 +01:00
parent f6fa4ecbce
commit 35881a8122
4 changed files with 40 additions and 21 deletions

View File

@ -19,12 +19,12 @@ impl-cgmath = ["cgmath"]
impl-glam = ["glam"]
impl-nalgebra = ["nalgebra"]
serialization = ["serde"]
std = []
std = ["nalgebra/std"]
[dependencies]
cgmath = { version = ">=0.17, <0.19", optional = true }
glam = { version = ">=0.10, <0.25", optional = true }
nalgebra = { version = ">=0.21, <0.33", optional = true }
nalgebra = { version = ">=0.21, <0.33", default-features = false, optional = true }
serde = { version = "1", features = ["derive"], optional = true }
[dev-dependencies]

View File

@ -112,10 +112,15 @@ macro_rules! impl_Interpolate {
}
}
#[cfg(feature = "std")]
fn cosine(t: $t, a: Self, b: Self) -> Self {
let cos_nt = (1. - (t * $pi).cos()) * 0.5;
<Self as $crate::interpolate::Interpolate<$t>>::lerp(cos_nt, a, b)
}
#[cfg(not(feature = "std"))]
fn cosine(t: $t, a: Self, b: Self) -> Self {
unimplemented!();
}
fn lerp(t: $t, a: Self, b: Self) -> Self {
a * (1. - t) + b * t
@ -176,10 +181,15 @@ macro_rules! impl_InterpolateT {
}
}
#[cfg(feature = "std")]
fn cosine(t: $t, a: Self, b: Self) -> Self {
let cos_nt = (1. - (t * $pi).cos()) * 0.5;
<Self as $crate::interpolate::Interpolate<$t>>::lerp(cos_nt, a, b)
}
#[cfg(not(feature = "std"))]
fn cosine(t: $t, a: Self, b: Self) -> Self {
unimplemented!()
}
fn lerp(t: $t, a: Self, b: Self) -> Self {
let t = Self::from(t);
@ -232,6 +242,6 @@ macro_rules! impl_InterpolateT {
};
}
impl_Interpolate!(f32, f32, std::f32::consts::PI);
impl_Interpolate!(f64, f64, std::f64::consts::PI);
impl_InterpolateT!(f32, f64, std::f32::consts::PI);
impl_Interpolate!(f32, f32, f32::consts::PI);
impl_Interpolate!(f64, f64, f64::consts::PI);
impl_InterpolateT!(f32, f64, f32::consts::PI);

View File

@ -1,18 +1,27 @@
#[cfg(not(feature = "std"))]
use core::f32;
#[cfg(not(feature = "std"))]
use core::f64;
#[cfg(feature = "std")]
use std::f32;
#[cfg(feature = "std")]
use std::f64;
use crate::impl_Interpolate;
use nalgebra::{Quaternion, Vector1, Vector2, Vector3, Vector4, Vector5, Vector6};
impl_Interpolate!(f32, Vector1<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector2<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector3<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector4<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector5<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector6<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Quaternion<f32>, std::f32::consts::PI);
impl_Interpolate!(f32, Vector1<f32>, f32::consts::PI);
impl_Interpolate!(f32, Vector2<f32>, f32::consts::PI);
impl_Interpolate!(f32, Vector3<f32>, f32::consts::PI);
impl_Interpolate!(f32, Vector4<f32>, f32::consts::PI);
impl_Interpolate!(f32, Vector5<f32>, f32::consts::PI);
impl_Interpolate!(f32, Vector6<f32>, f32::consts::PI);
impl_Interpolate!(f32, Quaternion<f32>, f32::consts::PI);
impl_Interpolate!(f64, Vector1<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector2<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector3<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector4<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector5<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector6<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Quaternion<f64>, std::f64::consts::PI);
impl_Interpolate!(f64, Vector1<f64>, f64::consts::PI);
impl_Interpolate!(f64, Vector2<f64>, f64::consts::PI);
impl_Interpolate!(f64, Vector3<f64>, f64::consts::PI);
impl_Interpolate!(f64, Vector4<f64>, f64::consts::PI);
impl_Interpolate!(f64, Vector5<f64>, f64::consts::PI);
impl_Interpolate!(f64, Vector6<f64>, f64::consts::PI);
impl_Interpolate!(f64, Quaternion<f64>, f64::consts::PI);

View File

@ -1,6 +1,6 @@
//! Spline curves and operations.
#[cfg(feature = "std")]
// #[cfg(feature = "std")]
use crate::interpolate::{Interpolate, Interpolator};
use crate::interpolation::Interpolation;
use crate::key::Key;