summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-12-02 16:25:27 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-12-02 16:37:41 +0000
commit0ec5b3f7ee049a45fa6a87101813ea9717eecbbb (patch)
tree69f380cc3c11667951c8f4ecd639987977c81a23 /game
parentReplace positionAt with pure integer version (diff)
downloadilt-0ec5b3f7ee049a45fa6a87101813ea9717eecbbb.tar.bz2
ilt-0ec5b3f7ee049a45fa6a87101813ea9717eecbbb.tar.xz
ilt-0ec5b3f7ee049a45fa6a87101813ea9717eecbbb.zip
Extend ray for intersect walk to cover the extents of the map
Diffstat (limited to 'game')
-rw-r--r--game/geoData.cpp24
1 files changed, 13 insertions, 11 deletions
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<GlobalPosition3D> 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<RelativePosition3D::value_type, glm::defaultp>(
- 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<RelativePosition3D::value_type, glm::defaultp>(
+ ray.start, ray.direction, t[0], t[1], t[2], bari, dist)) {
+ out = t * bari;
+ return true;
+ }
+ return false;
+ });
return out;
}