summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/terrain2.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/game/terrain2.h b/game/terrain2.h
index 641d608..c2c3d19 100644
--- a/game/terrain2.h
+++ b/game/terrain2.h
@@ -1,5 +1,6 @@
#pragma once
+#include "collections.h" // IWYU pragma: keep IterableCollection
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#include <filesystem>
#include <glm/vec2.hpp>
@@ -41,6 +42,19 @@ public:
mutable FaceHandle _face {};
};
+ template<glm::length_t Dim> struct Triangle : public glm::vec<3, glm::vec<Dim, glm::vec2::value_type>> {
+ using base = glm::vec<3, glm::vec<Dim, glm::vec2::value_type>>;
+ using base::base;
+
+ template<IterableCollection Range> Triangle(const TerrainMesh * m, Range range)
+ {
+ assert(std::distance(range.begin(), range.end()) == 3);
+ std::transform(range.begin(), range.end(), &base::operator[](0), [m](auto vh) {
+ return m->point(vh);
+ });
+ }
+ };
+
[[nodiscard]] FaceHandle findPoint(glm::vec2) const;
[[nodiscard]] FaceHandle findPoint(glm::vec2, FaceHandle start) const;