summaryrefslogtreecommitdiff
path: root/game/terrain2.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-11-03 20:12:03 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-11-03 20:12:03 +0000
commit3931bda936aba6ddae26c1d9f1d450781df800e8 (patch)
treec66bb3e540354baa2e45a782d8ae1f012be33a96 /game/terrain2.h
parentHelper to get cartesian position from baricentric on Triangle (diff)
downloadilt-3931bda936aba6ddae26c1d9f1d450781df800e8.tar.bz2
ilt-3931bda936aba6ddae26c1d9f1d450781df800e8.tar.xz
ilt-3931bda936aba6ddae26c1d9f1d450781df800e8.zip
Implement terrain intersect ray
Diffstat (limited to 'game/terrain2.h')
-rw-r--r--game/terrain2.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/game/terrain2.h b/game/terrain2.h
index da9f823..5539a50 100644
--- a/game/terrain2.h
+++ b/game/terrain2.h
@@ -1,9 +1,11 @@
#pragma once
#include "collections.h" // IWYU pragma: keep IterableCollection
+#include "ray.h"
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#include <filesystem>
#include <glm/vec2.hpp>
+#include <optional>
#include <thirdparty/openmesh/glmcompat.h>
struct TerrainTraits : public OpenMesh::DefaultTraits {
@@ -66,6 +68,8 @@ public:
[[nodiscard]] FaceHandle findPoint(glm::vec2, FaceHandle start) const;
[[nodiscard]] glm::vec3 positionAt(const PointFace &) const;
+ [[nodiscard]] std::optional<glm::vec3> intersectRay(const Ray &) const;
+ [[nodiscard]] std::optional<glm::vec3> intersectRay(const Ray &, FaceHandle start) const;
void walk(const PointFace & from, const glm::vec2 to, const std::function<void(FaceHandle)> & op) const;
void walkUntil(const PointFace & from, const glm::vec2 to, const std::function<bool(FaceHandle)> & op) const;