From 091bf9e418ffdcf36e1735ed78d544f3d1b86785 Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 5 Feb 2024 13:48:13 +0100 Subject: More precise collision detection (and less NaNs) --- src/Math/Ray.hpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Math/Ray.hpp') diff --git a/src/Math/Ray.hpp b/src/Math/Ray.hpp index db37ac2..4050a02 100644 --- a/src/Math/Ray.hpp +++ b/src/Math/Ray.hpp @@ -15,6 +15,8 @@ struct Ray { // [1]: https://gdbooks.gitbooks.io/3dcollisions/content/Chapter3/raycast_aabb.html // [2]: https://tavianator.com/2015/ray_box_nan.html RaycastResult cast(AABB box, Real max_distance = 0) const { + if (direction.is_zero()) return {}; + RaycastResult hit{ true }; // `t` is the time at which the ray intersects a plane of the AABB. -- cgit 1.4.1