diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-10-31 19:36:16 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-10-31 19:36:16 +0000 |
commit | b46cf55d66f262778bf0353650f00620c7740f2a (patch) | |
tree | fa05eb4f71f31f33fdb86441d9877fad352d2d52 /game/terrain2.h | |
parent | Update walk/walkUntil to work on PointFace from parameter (diff) | |
download | ilt-b46cf55d66f262778bf0353650f00620c7740f2a.tar.bz2 ilt-b46cf55d66f262778bf0353650f00620c7740f2a.tar.xz ilt-b46cf55d66f262778bf0353650f00620c7740f2a.zip |
Make PointFace harder to misuse
Diffstat (limited to 'game/terrain2.h')
-rw-r--r-- | game/terrain2.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/game/terrain2.h b/game/terrain2.h index 1a4e263..641d608 100644 --- a/game/terrain2.h +++ b/game/terrain2.h @@ -19,10 +19,26 @@ public: explicit TerrainMesh(const std::filesystem::path &); struct PointFace { + // NOLINTNEXTLINE(hicpp-explicit-conversions) PointFace(const glm::vec2 p) : point {p} { } + PointFace(const glm::vec2 p, FaceHandle face) : point {p}, _face {face} { } + + PointFace(const glm::vec2 p, const TerrainMesh *); + PointFace(const glm::vec2 p, const TerrainMesh *, FaceHandle start); + const glm::vec2 point; - mutable FaceHandle face {}; + [[nodiscard]] FaceHandle face(const TerrainMesh *) const; + [[nodiscard]] FaceHandle face(const TerrainMesh *, FaceHandle start) const; + + [[nodiscard]] bool + isLocated() const + { + return _face.is_valid(); + } + + private: + mutable FaceHandle _face {}; }; [[nodiscard]] FaceHandle findPoint(glm::vec2) const; @@ -35,7 +51,4 @@ 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; - - bool locate(const PointFace &) const; - bool locate(const PointFace &, FaceHandle start) const; }; |