From 403505df3240322a0251abbd8bd66e8f57021913 Mon Sep 17 00:00:00 2001 From: devil-ira Date: Fri, 2 Dec 2022 16:56:11 +0100 Subject: [PATCH 1/2] tweaks --- crates/bevy_math/src/ray.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/bevy_math/src/ray.rs b/crates/bevy_math/src/ray.rs index a755465dc1470..dd73e12dd7ea8 100644 --- a/crates/bevy_math/src/ray.rs +++ b/crates/bevy_math/src/ray.rs @@ -17,7 +17,7 @@ impl Ray { let denominator = plane_normal.dot(self.direction); if denominator.abs() > f32::EPSILON { let distance = (plane_origin - self.origin).dot(plane_normal) / denominator; - if distance >= f32::EPSILON { + if distance > f32::EPSILON { return Some(distance); } } @@ -32,17 +32,17 @@ impl Ray { } #[cfg(test)] -mod test { +mod tests { use super::*; #[test] - fn intersects_plane() { + fn intersect_plane() { let ray = Ray { origin: Vec3::ZERO, direction: Vec3::Z, }; - // Orthogonal, and test that plane_normal direction doesn't matter + // Orthogonal, and test that an inverse plane_normal has the same result assert_eq!(Some(1.), ray.intersect_plane(Vec3::Z, Vec3::Z)); assert_eq!(Some(1.), ray.intersect_plane(Vec3::Z, Vec3::NEG_Z)); assert_eq!(None, ray.intersect_plane(Vec3::NEG_Z, Vec3::Z)); @@ -52,13 +52,13 @@ mod test { assert_eq!(Some(1.), ray.intersect_plane(Vec3::Z, Vec3::ONE)); assert_eq!(None, ray.intersect_plane(Vec3::NEG_Z, Vec3::ONE)); - // Parralel + // Parallel assert_eq!(None, ray.intersect_plane(Vec3::X, Vec3::X)); - // Parralel with simulated rounding error + // Parallel with simulated rounding error assert_eq!( None, - ray.intersect_plane(Vec3::X, Vec3::X + Vec3::Z * f32::EPSILON) + ray.intersect_plane(Vec3::X, Vec3::new(1., 0., f32::EPSILON)) ); } } From 7ad96c4753a1a3107f81507c61093aff87137a0d Mon Sep 17 00:00:00 2001 From: devil-ira Date: Sat, 3 Dec 2022 14:39:32 +0100 Subject: [PATCH 2/2] revert --- crates/bevy_math/src/ray.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_math/src/ray.rs b/crates/bevy_math/src/ray.rs index dd73e12dd7ea8..b4d8e7b03f5a8 100644 --- a/crates/bevy_math/src/ray.rs +++ b/crates/bevy_math/src/ray.rs @@ -58,7 +58,7 @@ mod tests { // Parallel with simulated rounding error assert_eq!( None, - ray.intersect_plane(Vec3::X, Vec3::new(1., 0., f32::EPSILON)) + ray.intersect_plane(Vec3::X, Vec3::X + Vec3::Z * f32::EPSILON) ); } }