From 1523401911b46d220ddc597c136fe279324d600b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 23 Nov 2024 14:04:28 +0000 Subject: Remove split face specialisation --- game/geoData.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'game/geoData.h') diff --git a/game/geoData.h b/game/geoData.h index ed1734c..5daa7a4 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -185,9 +185,6 @@ protected: void update_vertex_normals_only(); void update_vertex_normals_only(VertexIter start); - using OpenMesh::TriMesh_ArrayKernelT::split; - void split(FaceHandle); - private: GlobalPosition3D lowerExtent {}, upperExtent {}; }; -- cgit v1.2.3 From 2be260117a757288d419cf1564ccd6b91794399e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 23 Nov 2024 14:18:56 +0000 Subject: Pass setHeights options as a struct with defaults --- game/geoData.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'game/geoData.h') diff --git a/game/geoData.h b/game/geoData.h index 5daa7a4..51bb28b 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -142,7 +142,16 @@ public: [[nodiscard]] HalfedgeHandle findEntry(const GlobalPosition2D from, const GlobalPosition2D to) const; - void setHeights(const std::span triangleStrip, const Surface &); + struct SetHeightsOpts { + static constexpr auto DEFAULT_NEAR_NODE_TOLERANACE = 500.F; + static constexpr auto DEFAULT_MAX_SLOPE = 0.5F; + + const Surface & surface; + RelativeDistance nearNodeTolerance = DEFAULT_NEAR_NODE_TOLERANACE; + RelativeDistance maxSlope = DEFAULT_MAX_SLOPE; + }; + + void setHeights(std::span triangleStrip, const SetHeightsOpts &); [[nodiscard]] auto getExtents() const -- cgit v1.2.3 From eee7e7ae1e91e42561e1a2b5bec448f04c2b2298 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 24 Nov 2024 00:46:03 +0000 Subject: Add Triangle::centroid --- game/geoData.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'game/geoData.h') diff --git a/game/geoData.h b/game/geoData.h index 51bb28b..c28dd14 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -53,7 +53,8 @@ public: }; template struct Triangle : public glm::vec<3, glm::vec> { - using base = glm::vec<3, glm::vec>; + using Point = glm::vec; + using base = glm::vec<3, Point>; using base::base; template Triangle(const GeoData * m, Range range) @@ -64,12 +65,20 @@ public: }); } - [[nodiscard]] glm::vec + [[nodiscard]] Point operator*(BaryPosition bari) const { return p(0) + (difference(p(0), p(1)) * bari.x) + (difference(p(0), p(2)) * bari.y); } + [[nodiscard]] Point + centroid() const + { + return [this](std::integer_sequence) { + return Point {(p(0)[axis] + p(1)[axis] + p(2)[axis]) / 3 ...}; + }(std::make_integer_sequence()); + } + [[nodiscard]] auto area() const requires(Dim == 3) -- cgit v1.2.3 From 2e1a91564c4765dbdc3f633ba0ff8a4af7164503 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 27 Nov 2024 02:50:06 +0000 Subject: Update new/moved vertex normals --- game/geoData.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'game/geoData.h') diff --git a/game/geoData.h b/game/geoData.h index c28dd14..71ec85f 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -200,8 +200,9 @@ protected: [[nodiscard]] RelativeDistance length(const HalfedgeHandle) const; [[nodiscard]] GlobalPosition3D centre(const HalfedgeHandle) const; - void update_vertex_normals_only(); - void update_vertex_normals_only(VertexIter start); + void updateAllVertexNormals(); + template void updateAllVertexNormals(const R &); + void updateVertexNormal(VertexHandle); private: GlobalPosition3D lowerExtent {}, upperExtent {}; -- cgit v1.2.3 From d982157ee2711f2a28a8ca0dc5f882424626217c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 1 Dec 2024 14:06:28 +0000 Subject: Remove GeoData::difference for points, use global version --- game/geoData.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'game/geoData.h') diff --git a/game/geoData.h b/game/geoData.h index 71ec85f..dcc28e0 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -68,7 +68,7 @@ public: [[nodiscard]] Point operator*(BaryPosition bari) const { - return p(0) + (difference(p(0), p(1)) * bari.x) + (difference(p(0), p(2)) * bari.y); + return p(0) + (::difference(p(1), p(0)) * bari.x) + (::difference(p(2), p(0)) * bari.y); } [[nodiscard]] Point @@ -83,14 +83,14 @@ public: area() const requires(Dim == 3) { - return glm::length(crossProduct(difference(p(0), p(1)), difference(p(0), p(2)))) / 2.F; + return glm::length(crossProduct(::difference(p(1), p(0)), ::difference(p(2), p(0)))) / 2.F; } [[nodiscard]] Normal3D normal() const requires(Dim == 3) { - return crossProduct(difference(p(0), p(1)), difference(p(0), p(2))); + return crossProduct(::difference(p(1), p(0)), ::difference(p(2), p(0))); } [[nodiscard]] Normal3D @@ -190,13 +190,6 @@ protected: [[nodiscard]] HalfedgeHandle findBoundaryStart() const; [[nodiscard]] RelativePosition3D difference(const HalfedgeHandle) const; - template - [[nodiscard]] static RelativePosition - difference(const GlobalPosition a, const GlobalPosition b) - { - return b - a; - } - [[nodiscard]] RelativeDistance length(const HalfedgeHandle) const; [[nodiscard]] GlobalPosition3D centre(const HalfedgeHandle) const; -- cgit v1.2.3 From f9e6220bf8b17681cb2f395ab64851a72659a070 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 1 Dec 2024 16:56:14 +0000 Subject: Move GeoData::Triangle to global lib --- game/geoData.h | 89 ++++++---------------------------------------------------- 1 file changed, 8 insertions(+), 81 deletions(-) (limited to 'game/geoData.h') diff --git a/game/geoData.h b/game/geoData.h index dcc28e0..79924d3 100644 --- a/game/geoData.h +++ b/game/geoData.h @@ -4,6 +4,7 @@ #include "config/types.h" #include "ray.h" #include "surface.h" +#include "triangle.h" #include #include #include @@ -52,85 +53,7 @@ public: mutable FaceHandle _face {}; }; - template struct Triangle : public glm::vec<3, glm::vec> { - using Point = glm::vec; - using base = glm::vec<3, Point>; - using base::base; - - template Triangle(const GeoData * 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]] Point - operator*(BaryPosition bari) const - { - return p(0) + (::difference(p(1), p(0)) * bari.x) + (::difference(p(2), p(0)) * bari.y); - } - - [[nodiscard]] Point - centroid() const - { - return [this](std::integer_sequence) { - return Point {(p(0)[axis] + p(1)[axis] + p(2)[axis]) / 3 ...}; - }(std::make_integer_sequence()); - } - - [[nodiscard]] auto - area() const - requires(Dim == 3) - { - return glm::length(crossProduct(::difference(p(1), p(0)), ::difference(p(2), p(0)))) / 2.F; - } - - [[nodiscard]] Normal3D - normal() const - requires(Dim == 3) - { - return crossProduct(::difference(p(1), p(0)), ::difference(p(2), p(0))); - } - - [[nodiscard]] Normal3D - nnormal() const - requires(Dim == 3) - { - return glm::normalize(normal()); - } - - [[nodiscard]] auto - angle(glm::length_t c) const - { - return Arc {P(c), P(c + 2), P(c + 1)}.length(); - } - - template - [[nodiscard]] auto - angleAt(const GlobalPosition pos) const - requires(D <= Dim) - { - for (glm::length_t i {}; i < 3; ++i) { - if (GlobalPosition {p(i)} == pos) { - return angle(i); - } - } - return 0.F; - } - - [[nodiscard]] inline auto - p(const glm::length_t i) const - { - return base::operator[](i); - } - - [[nodiscard]] inline auto - P(const glm::length_t i) const - { - return base::operator[](i % 3); - } - }; + template using Triangle = ::Triangle; [[nodiscard]] FaceHandle findPoint(GlobalPosition2D) const; [[nodiscard]] FaceHandle findPoint(GlobalPosition2D, FaceHandle start) const; @@ -178,9 +101,13 @@ public: protected: template [[nodiscard]] Triangle - triangle(FaceHandle f) const + triangle(FaceHandle face) const { - return {this, fv_range(f)}; + Triangle triangle; + std::ranges::transform(fv_range(face), triangle.begin(), [this](auto vertex) { + return point(vertex); + }); + return triangle; } [[nodiscard]] static bool triangleContainsPoint(const GlobalPosition2D, const Triangle<2> &); -- cgit v1.2.3