summaryrefslogtreecommitdiff
path: root/game/terrain2.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-11-02 20:37:08 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-11-02 20:37:08 +0000
commit1117f91396da00fc48158866ff0ffd1883c4cbd1 (patch)
tree1d40ab338c5a1a911dd8fd47f65bc99ed761800d /game/terrain2.h
parentAdd test-terrain dependency on sample height data (diff)
downloadilt-1117f91396da00fc48158866ff0ffd1883c4cbd1.tar.bz2
ilt-1117f91396da00fc48158866ff0ffd1883c4cbd1.tar.xz
ilt-1117f91396da00fc48158866ff0ffd1883c4cbd1.zip
Generic N-dimensional terrain triangle
Diffstat (limited to 'game/terrain2.h')
-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;