From 1117f91396da00fc48158866ff0ffd1883c4cbd1 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 2 Nov 2023 20:37:08 +0000 Subject: Generic N-dimensional terrain triangle --- game/terrain2.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 #include #include @@ -41,6 +42,19 @@ public: mutable FaceHandle _face {}; }; + template struct Triangle : public glm::vec<3, glm::vec> { + using base = glm::vec<3, glm::vec>; + using base::base; + + template 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; -- cgit v1.2.3