diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-02-13 19:57:41 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-02-13 19:57:41 +0000 |
commit | 4b175adffdf68f35589ed48c82baa15723a9af0a (patch) | |
tree | 64b691b118b059640e19f1dc690722ae176784ca /game/geoDataMesh.h | |
parent | Replace mesh generation counter with afterChange event (diff) | |
download | ilt-4b175adffdf68f35589ed48c82baa15723a9af0a.tar.bz2 ilt-4b175adffdf68f35589ed48c82baa15723a9af0a.tar.xz ilt-4b175adffdf68f35589ed48c82baa15723a9af0a.zip |
Move basic setHeights lambdas into proper helper functions
Diffstat (limited to 'game/geoDataMesh.h')
-rw-r--r-- | game/geoDataMesh.h | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/game/geoDataMesh.h b/game/geoDataMesh.h index 00db67c..5d0bade 100644 --- a/game/geoDataMesh.h +++ b/game/geoDataMesh.h @@ -1,7 +1,6 @@ #pragma once #include "config/types.h" -#include "ray.h" #include "triangle.h" #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh> #include <source_location> @@ -61,6 +60,36 @@ protected: [[nodiscard]] HalfEdgePoints points(HalfEdgeVertices) const; template<glm::length_t D> + [[nodiscard]] auto + vertexDistanceFunction(GlobalPosition<D> point) const + { + struct DistanceCalculator { + [[nodiscard]] std::pair<VertexHandle, float> + operator()(VertexHandle compVertex) const + { + return std::make_pair( + compVertex, ::distance<D, GlobalDistance, glm::defaultp>(point, mesh->point(compVertex))); + } + + [[nodiscard]] + std::pair<HalfedgeHandle, float> + operator()(const HalfedgeHandle compHalfedge) const + { + const auto edgePoints = mesh->points(mesh->toVertexHandles(compHalfedge)); + return std::make_pair(compHalfedge, Triangle<2> {edgePoints.second, edgePoints.first, point}.height()); + }; + + const GeoDataMesh * mesh; + GlobalPosition<D> point; + }; + + return DistanceCalculator {this, point}; + } + + [[nodiscard]] bool canFlip(HalfedgeHandle edge) const; + [[nodiscard]] std::optional<EdgeHandle> shouldFlip(HalfedgeHandle next, GlobalPosition2D startPoint) const; + + template<glm::length_t D> [[nodiscard]] RelativeDistance length(HalfedgeHandle heh) const { |