diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-02-13 01:36:42 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-02-13 01:36:42 +0000 |
commit | 849f4aa735352704995ffb51bf23dadf795bb119 (patch) | |
tree | 6f610f55791d7dc7ade6ebf5be42227f63979f75 /game/geoData.cpp | |
parent | Add helpers for testing for triangle overlap/containedness (diff) | |
download | ilt-849f4aa735352704995ffb51bf23dadf795bb119.tar.bz2 ilt-849f4aa735352704995ffb51bf23dadf795bb119.tar.xz ilt-849f4aa735352704995ffb51bf23dadf795bb119.zip |
Include face handle in intersectRay result
Diffstat (limited to 'game/geoData.cpp')
-rw-r--r-- | game/geoData.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp index ae43f3f..0dbc0ac 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -213,16 +213,16 @@ GeoData::positionAt(const PointFace & p) const return positionOnTriangle(p.point, triangle<3>(p.face(this))); } -[[nodiscard]] std::optional<GlobalPosition3D> +[[nodiscard]] GeoData::IntersectionResult GeoData::intersectRay(const Ray<GlobalPosition3D> & ray) const { return intersectRay(ray, findPoint(ray.start)); } -[[nodiscard]] std::optional<GlobalPosition3D> +[[nodiscard]] GeoData::IntersectionResult GeoData::intersectRay(const Ray<GlobalPosition3D> & ray, FaceHandle face) const { - std::optional<GlobalPosition3D> out; + GeoData::IntersectionResult out; walkUntil(PointFace {ray.start, face}, ray.start.xy() + GlobalPosition2D(ray.direction.xy() * RelativePosition2D(upperExtent.xy() - lowerExtent.xy())), @@ -231,7 +231,7 @@ GeoData::intersectRay(const Ray<GlobalPosition3D> & ray, FaceHandle face) const RelativeDistance dist {}; const auto t = triangle<3>(face); if (ray.intersectTriangle(t.x, t.y, t.z, bari, dist)) { - out = t * bari; + out.emplace(t * bari, face); return true; } return false; |