diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-05-27 13:44:08 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-05-27 13:44:08 +0100 |
commit | ad85d0843dc80d195120dd53dd4a8deee004af4b (patch) | |
tree | 420723815ac6753441f14fe51836555de5551a19 /game/geoData.h | |
parent | Merge branch 'separate-water' (diff) | |
parent | Surface asset test doesn't need render dump (diff) | |
download | ilt-ad85d0843dc80d195120dd53dd4a8deee004af4b.tar.bz2 ilt-ad85d0843dc80d195120dd53dd4a8deee004af4b.tar.xz ilt-ad85d0843dc80d195120dd53dd4a8deee004af4b.zip |
Merge remote-tracking branch 'origin/terrain-surfaces'
Diffstat (limited to 'game/geoData.h')
-rw-r--r-- | game/geoData.h | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/game/geoData.h b/game/geoData.h index 021b4c7..ed1734c 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -3,6 +3,7 @@ #include "collections.h" // IWYU pragma: keep IterableCollection #include "config/types.h" #include "ray.h" +#include "surface.h" #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh> #include <filesystem> #include <glm/vec2.hpp> @@ -20,7 +21,9 @@ struct GeoDataTraits : public OpenMesh::DefaultTraits { class GeoData : public OpenMesh::TriMesh_ArrayKernelT<GeoDataTraits> { private: - GeoData() = default; + GeoData(); + + OpenMesh::FPropHandleT<const Surface *> surface; public: static GeoData loadFromAsciiGrid(const std::filesystem::path &); @@ -61,47 +64,41 @@ public: }); } - [[nodiscard]] - glm::vec<Dim, GlobalDistance> + [[nodiscard]] glm::vec<Dim, GlobalDistance> operator*(BaryPosition bari) const { return p(0) + (difference(p(0), p(1)) * bari.x) + (difference(p(0), p(2)) * bari.y); } - [[nodiscard]] - auto + [[nodiscard]] auto area() const requires(Dim == 3) { return glm::length(crossProduct(difference(p(0), p(1)), difference(p(0), p(2)))) / 2.F; } - [[nodiscard]] - Normal3D + [[nodiscard]] Normal3D normal() const requires(Dim == 3) { return crossProduct(difference(p(0), p(1)), difference(p(0), p(2))); } - [[nodiscard]] - Normal3D + [[nodiscard]] Normal3D nnormal() const requires(Dim == 3) { return glm::normalize(normal()); } - [[nodiscard]] - auto + [[nodiscard]] auto angle(glm::length_t c) const { return Arc {P(c), P(c + 2), P(c + 1)}.length(); } template<glm::length_t D = Dim> - [[nodiscard]] - auto + [[nodiscard]] auto angleAt(const GlobalPosition<D> pos) const requires(D <= Dim) { @@ -113,8 +110,7 @@ public: return 0.F; } - [[nodiscard]] - inline auto + [[nodiscard]] inline auto p(const glm::length_t i) const { return base::operator[](i); @@ -146,7 +142,7 @@ public: [[nodiscard]] HalfedgeHandle findEntry(const GlobalPosition2D from, const GlobalPosition2D to) const; - void setHeights(const std::span<const GlobalPosition3D> triangleStrip); + void setHeights(const std::span<const GlobalPosition3D> triangleStrip, const Surface &); [[nodiscard]] auto getExtents() const @@ -154,6 +150,13 @@ public: return std::tie(lowerExtent, upperExtent); } + template<typename HandleT> + [[nodiscard]] auto + get_surface(const HandleT h) + { + return property(surface, h); + } + protected: template<glm::length_t Dim> [[nodiscard]] Triangle<Dim> @@ -183,7 +186,7 @@ protected: void update_vertex_normals_only(VertexIter start); using OpenMesh::TriMesh_ArrayKernelT<GeoDataTraits>::split; - std::array<FaceHandle, 4> split(FaceHandle); + void split(FaceHandle); private: GlobalPosition3D lowerExtent {}, upperExtent {}; |