Skip to main content

parry3d/utils/
relative_eq.rs

1//! This module only exists for working around the fact that glam
2//! doesn’t allow its `approx` feature to be enabled when targeting spirv.
3
4use crate::math::Vector;
5use approx::relative_eq;
6
7/// Checks approximate equality between two vectors, component-wise.
8#[inline]
9pub fn relative_eq_vector(a: Vector, b: Vector) -> bool {
10    #[cfg(feature = "dim2")]
11    return relative_eq!(a.x, b.x) && relative_eq!(a.y, b.y);
12    #[cfg(feature = "dim3")]
13    return relative_eq!(a.x, b.x) && relative_eq!(a.y, b.y) && relative_eq!(a.z, b.z);
14}