From c0ff72c1aef7f1ad502b838af899cb0a9be35263 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 18 Mar 2024 00:04:18 +0000 Subject: Add Ray::intersectPlane --- lib/ray.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/ray.h b/lib/ray.h index 67fdd12..a831270 100644 --- a/lib/ray.h +++ b/lib/ray.h @@ -42,6 +42,18 @@ public: }) != positions.end(); } + bool + intersectPlane(const PositionType orig, const Direction3D norm, RelativeDistance & distance) const + { + if constexpr (std::is_floating_point_v) { + return glm::intersectRayPlane(start, direction, orig, norm, distance) && distance >= 0.F; + } + else { + const RelativePosition3D origr = orig - start; + return glm::intersectRayPlane({}, direction, origr, norm, distance) && distance >= 0.F; + } + } + bool intersectTriangle(const PositionType t0, const PositionType t1, const PositionType t2, BaryPosition & bary, RelativeDistance & distance) const -- cgit v1.2.3