summaryrefslogtreecommitdiff
path: root/game/terrain2.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-11-04 12:14:59 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-11-04 12:26:00 +0000
commitc463bce75418a145d319f214571e30df311ff8df (patch)
tree07dab50c7ad4b728aff6b993bdc9bcf43b912c58 /game/terrain2.h
parentStatic helper for loading ASCII grid data (diff)
downloadilt-c463bce75418a145d319f214571e30df311ff8df.tar.bz2
ilt-c463bce75418a145d319f214571e30df311ff8df.tar.xz
ilt-c463bce75418a145d319f214571e30df311ff8df.zip
Calculate and expose the extents of the terrain mesh
Diffstat (limited to 'game/terrain2.h')
-rw-r--r--game/terrain2.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/game/terrain2.h b/game/terrain2.h
index 69cd380..eda56d0 100644
--- a/game/terrain2.h
+++ b/game/terrain2.h
@@ -77,8 +77,17 @@ public:
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;
+ [[nodiscard]] auto
+ getExtents() const
+ {
+ return std::tie(lowerExtent, upperExtent);
+ }
+
protected:
[[nodiscard]] static bool triangleContainsPoint(const glm::vec2, const glm::vec2, const glm::vec2, const glm::vec2);
[[nodiscard]] bool triangleContainsPoint(const glm::vec2, FaceHandle) const;
[[nodiscard]] bool triangleContainsPoint(const glm::vec2, ConstFaceVertexIter) const;
+
+private:
+ glm::vec3 lowerExtent {}, upperExtent {};
};