pub trait RealConv {
#[allow(clippy::wrong_self_convention)]
fn as_f32(self) -> f32;
#[allow(clippy::wrong_self_convention)] fn as_f64(self) -> f64;
fn from_f32(f: f32) -> Self;
fn from_f64(f: f64) -> Self;
}
#[cfg(not(feature = "double-precision"))] #[cfg_attr(published_docs, doc(cfg(not(feature = "double-precision"))))]
mod real_mod {
#[allow(non_camel_case_types)]
pub type real = f32;
impl super::RealConv for real {
#[inline]
fn as_f32(self) -> f32 {
self
}
#[inline]
fn as_f64(self) -> f64 {
self as f64
}
#[inline]
fn from_f32(f: f32) -> Self {
f
}
#[inline]
fn from_f64(f: f64) -> Self {
f as f32
}
}
pub mod real_consts {
pub use std::f32::consts::*;
}
pub type RVec2 = glam::Vec2;
pub type RVec3 = glam::Vec3;
pub type RVec4 = glam::Vec4;
pub type RMat2 = glam::Mat2;
pub type RMat3 = glam::Mat3;
pub type RMat4 = glam::Mat4;
pub type RQuat = glam::Quat;
pub type RAffine2 = glam::Affine2;
pub type RAffine3 = glam::Affine3A;
}
#[cfg(feature = "double-precision")] #[cfg_attr(published_docs, doc(cfg(feature = "double-precision")))]
mod real_mod {
#[allow(non_camel_case_types)]
pub type real = f64;
impl super::RealConv for real {
#[inline]
fn as_f32(self) -> f32 {
self as f32
}
#[inline]
fn as_f64(self) -> f64 {
self
}
#[inline]
fn from_f32(f: f32) -> Self {
f as f64
}
#[inline]
fn from_f64(f: f64) -> Self {
f
}
}
pub mod real_consts {
pub use std::f64::consts::*;
}
pub type RVec2 = glam::DVec2;
pub type RVec3 = glam::DVec3;
pub type RVec4 = glam::DVec4;
pub type RMat2 = glam::DMat2;
pub type RMat3 = glam::DMat3;
pub type RMat4 = glam::DMat4;
pub type RQuat = glam::DQuat;
pub type RAffine2 = glam::DAffine2;
pub type RAffine3 = glam::DAffine3;
}
#[rustfmt::skip] pub use real_mod::{real, real_consts};
pub(crate) use real_mod::*;
#[macro_export]
macro_rules! real {
($f:literal) => {{
let f: $crate::builtin::real = $f;
f
}};
}
#[macro_export]
macro_rules! reals {
($($f:literal),* $(,)?) => {{
let arr = [$($crate::real!($f)),*];
arr
}};
}