summary refs log tree commit diff
path: root/src/Math/Ray.hpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2024-02-05 13:48:13 +0100
committerMel <einebeere@gmail.com>2024-02-05 13:48:13 +0100
commit091bf9e418ffdcf36e1735ed78d544f3d1b86785 (patch)
tree58b1cd88d9822b14c90da757cc26acb64bf9bad5 /src/Math/Ray.hpp
parentbcb89e0554e43d37daf74b3ef6e466b6630752cd (diff)
downloadmeowcraft-091bf9e418ffdcf36e1735ed78d544f3d1b86785.tar.zst
meowcraft-091bf9e418ffdcf36e1735ed78d544f3d1b86785.zip
More precise collision detection (and less NaNs)
Diffstat (limited to 'src/Math/Ray.hpp')
-rw-r--r--src/Math/Ray.hpp2
1 files changed, 2 insertions, 0 deletions
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.