From 0ec5b3f7ee049a45fa6a87101813ea9717eecbbb Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 2 Dec 2023 16:25:27 +0000 Subject: Extend ray for intersect walk to cover the extents of the map --- game/geoData.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'game') diff --git a/game/geoData.cpp b/game/geoData.cpp index d092d00..6c6f1df 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -202,17 +202,19 @@ GeoData::intersectRay(const Ray & ray) const GeoData::intersectRay(const Ray & ray, FaceHandle face) const { std::optional out; - walkUntil(PointFace {ray.start, face}, ray.start + (ray.direction * 10000.F), [&out, &ray, this](FaceHandle face) { - BaryPosition bari {}; - float dist {}; - const auto t = triangle<3>(face); - if (glm::intersectRayTriangle( - ray.start, ray.direction, t[0], t[1], t[2], bari, dist)) { - out = t * bari; - return true; - } - return false; - }); + walkUntil(PointFace {ray.start, face}, + ray.start.xy() + (ray.direction.xy() * RelativePosition2D(upperExtent.xy() - lowerExtent.xy())), + [&out, &ray, this](FaceHandle face) { + BaryPosition bari {}; + float dist {}; + const auto t = triangle<3>(face); + if (glm::intersectRayTriangle( + ray.start, ray.direction, t[0], t[1], t[2], bari, dist)) { + out = t * bari; + return true; + } + return false; + }); return out; } -- cgit v1.2.3