diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-07 13:04:31 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-07 13:04:31 +0000 |
commit | 6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6 (patch) | |
tree | 46c42bcbef1f12c4f46d53b4e0c4736bea506b51 /game/geoData.cpp | |
parent | Unified crossProduct (diff) | |
download | ilt-6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6.tar.bz2 ilt-6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6.tar.xz ilt-6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6.zip |
Template Ray on position type
Diffstat (limited to 'game/geoData.cpp')
-rw-r--r-- | game/geoData.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp index 816733f..b30a35b 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -194,23 +194,23 @@ GeoData::positionAt(const PointFace & p) const } [[nodiscard]] std::optional<GlobalPosition3D> -GeoData::intersectRay(const Ray & ray) const +GeoData::intersectRay(const Ray<GlobalPosition3D> & ray) const { return intersectRay(ray, findPoint(ray.start)); } [[nodiscard]] std::optional<GlobalPosition3D> -GeoData::intersectRay(const Ray & ray, FaceHandle face) const +GeoData::intersectRay(const Ray<GlobalPosition3D> & ray, FaceHandle face) const { std::optional<GlobalPosition3D> out; walkUntil(PointFace {ray.start, face}, - ray.start.xy() + (ray.direction.xy() * RelativePosition2D(upperExtent.xy() - lowerExtent.xy())), + ray.start.xy() + + GlobalPosition2D(ray.direction.xy() * RelativePosition2D(upperExtent.xy() - lowerExtent.xy())), [&out, &ray, this](FaceHandle face) { BaryPosition bari {}; - float dist {}; + RelativeDistance 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)) { + if (ray.intersectTriangle(t.x, t.y, t.z, bari, dist)) { out = t * bari; return true; } |