diff --git a/Cargo.toml b/Cargo.toml index 24c217a..30e99eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,13 +19,13 @@ 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 } -serde = { version = "1", features = ["derive"], optional = true } +nalgebra = { version = ">=0.21, <0.33", default-features = false, optional = true } +serde = { version = "1", features = ["derive"], optional = true } [dev-dependencies] float-cmp = ">=0.6, < 0.10" diff --git a/src/interpolate.rs b/src/interpolate.rs index 2bdc703..bc1c8c8 100644 --- a/src/interpolate.rs +++ b/src/interpolate.rs @@ -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; >::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; >::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); diff --git a/src/nalgebra.rs b/src/nalgebra.rs index 37da59a..07fc2af 100644 --- a/src/nalgebra.rs +++ b/src/nalgebra.rs @@ -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, std::f32::consts::PI); -impl_Interpolate!(f32, Vector2, std::f32::consts::PI); -impl_Interpolate!(f32, Vector3, std::f32::consts::PI); -impl_Interpolate!(f32, Vector4, std::f32::consts::PI); -impl_Interpolate!(f32, Vector5, std::f32::consts::PI); -impl_Interpolate!(f32, Vector6, std::f32::consts::PI); -impl_Interpolate!(f32, Quaternion, std::f32::consts::PI); +impl_Interpolate!(f32, Vector1, f32::consts::PI); +impl_Interpolate!(f32, Vector2, f32::consts::PI); +impl_Interpolate!(f32, Vector3, f32::consts::PI); +impl_Interpolate!(f32, Vector4, f32::consts::PI); +impl_Interpolate!(f32, Vector5, f32::consts::PI); +impl_Interpolate!(f32, Vector6, f32::consts::PI); +impl_Interpolate!(f32, Quaternion, f32::consts::PI); -impl_Interpolate!(f64, Vector1, std::f64::consts::PI); -impl_Interpolate!(f64, Vector2, std::f64::consts::PI); -impl_Interpolate!(f64, Vector3, std::f64::consts::PI); -impl_Interpolate!(f64, Vector4, std::f64::consts::PI); -impl_Interpolate!(f64, Vector5, std::f64::consts::PI); -impl_Interpolate!(f64, Vector6, std::f64::consts::PI); -impl_Interpolate!(f64, Quaternion, std::f64::consts::PI); +impl_Interpolate!(f64, Vector1, f64::consts::PI); +impl_Interpolate!(f64, Vector2, f64::consts::PI); +impl_Interpolate!(f64, Vector3, f64::consts::PI); +impl_Interpolate!(f64, Vector4, f64::consts::PI); +impl_Interpolate!(f64, Vector5, f64::consts::PI); +impl_Interpolate!(f64, Vector6, f64::consts::PI); +impl_Interpolate!(f64, Quaternion, f64::consts::PI); diff --git a/src/spline.rs b/src/spline.rs index e91abc0..8f8fa30 100644 --- a/src/spline.rs +++ b/src/spline.rs @@ -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;