summaryrefslogtreecommitdiff
path: root/game/terrain2.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-10-28 02:34:45 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-10-28 12:35:11 +0100
commit16bec12e3e75e95d251745f904ac4e15af9c9724 (patch)
treefb4c24204dd1ff71fc55fb0b8a1eb909a35046fb /game/terrain2.h
parentMove OpenMesh/GLM compatibility structs to common place (diff)
downloadilt-16bec12e3e75e95d251745f904ac4e15af9c9724.tar.bz2
ilt-16bec12e3e75e95d251745f904ac4e15af9c9724.tar.xz
ilt-16bec12e3e75e95d251745f904ac4e15af9c9724.zip
Initial OpenMesh based terrain data and tests
Diffstat (limited to 'game/terrain2.h')
-rw-r--r--game/terrain2.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/game/terrain2.h b/game/terrain2.h
new file mode 100644
index 0000000..d2da8d0
--- /dev/null
+++ b/game/terrain2.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
+#include <filesystem>
+#include <glm/vec2.hpp>
+#include <thirdparty/openmesh/glmcompat.h>
+
+struct TerrainTraits : public OpenMesh::DefaultTraits {
+ FaceAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status);
+ EdgeAttributes(OpenMesh::Attributes::Status);
+ VertexAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status);
+ HalfedgeAttributes(OpenMesh::Attributes::Normal | OpenMesh::Attributes::Status);
+ using Point = glm::vec3;
+ using Normal = glm::vec3;
+};
+
+class TerrainMesh : public OpenMesh::TriMesh_ArrayKernelT<TerrainTraits> {
+public:
+ explicit TerrainMesh(const std::filesystem::path &);
+
+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;
+};