From 3d2f9a86e56f16b2111822802aa49e28367d851e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 1 Apr 2024 21:02:57 +0100 Subject: Boundary edge and one time split with repeated 4-way split of large faces --- game/geoData.cpp | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/game/geoData.cpp b/game/geoData.cpp index 059b03d..1d11fda 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -457,7 +457,6 @@ GeoData::setHeights(const std::span triangleStrip) { static const RelativeDistance MAX_SLOPE = 1.5F; static const RelativeDistance MIN_ARC = 0.01F; - static const RelativeDistance MAX_EDGE_LENGTH = 20'000.F; if (triangleStrip.size() < 3) { return; @@ -474,36 +473,17 @@ GeoData::setHeights(const std::span triangleStrip) const auto [a, b, c] = newVert; add_face(a, b, c); }); - // Split faces with two large boundary sides - boundaryWalk( - [this](const auto boundaryHeh) { - const auto nextHeh = next_halfedge_handle(boundaryHeh); - const auto faceHandle = opposite_face_handle(boundaryHeh); - if (faceHandle != opposite_face_handle(nextHeh)) { - return; - } - if (length(boundaryHeh) < MAX_EDGE_LENGTH || length(nextHeh) < MAX_EDGE_LENGTH) { - return; - } - - const auto t = triangle<3>(faceHandle); - const auto centre = t * RelativePosition2D {.3F, .3F}; - split(faceHandle, centre); - }, - *voh_begin(newVerts.front())); - // Split long boundary edges - while ([this, start = *voh_begin(newVerts.front())]() { - size_t countSplit = 0; - boundaryWalk( - [this, &countSplit](const auto boundaryHeh) { - if (length(boundaryHeh) > MAX_EDGE_LENGTH) { - split(edge_handle(boundaryHeh), centre(boundaryHeh)); - ++countSplit; - } - }, - start); - return countSplit; - }() > 0) { } + for (auto start = faces_sbegin(); std::any_of(start, faces_end(), [this, &start](const auto fh) { + static constexpr auto MAX_FACE_AREA = 100'000'000.F; + if (triangle<3>(fh).area() > MAX_FACE_AREA) { + split(fh); + start = FaceIter {*this, FaceHandle(fh), true}; + return true; + } + return false; + });) { + ; + } // Extrude corners struct Extrusion { -- cgit v1.2.3