From ac71ff90e86baa549904794375ebb2f9245d92b2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 31 Mar 2024 20:31:15 +0100 Subject: Split long boundary edges --- game/geoData.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'game') diff --git a/game/geoData.cpp b/game/geoData.cpp index d179c47..931eb6a 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -391,6 +391,9 @@ GeoData::setHeights(const std::span triangleStrip) auto hehlength = [diff](const auto heh) { return glm::length(diff(heh)); }; + auto hehcentre = [this, diff](const auto heh) { + return point(from_vertex_handle(heh)) + (diff(heh) / 2.F); + }; if (triangleStrip.size() < 3) { return; @@ -424,6 +427,19 @@ GeoData::setHeights(const std::span triangleStrip) split(faceHandle, centre); }, *voh_begin(newVerts.front())); + // Split long boundary edges + while ([hehlength, hehcentre, this, start = *voh_begin(newVerts.front())]() { + size_t countSplit = 0; + boundaryWalk( + [this, &countSplit, hehlength, hehcentre](const auto boundaryHeh) { + if (hehlength(boundaryHeh) > MAX_EDGE_LENGTH) { + split(edge_handle(boundaryHeh), hehcentre(boundaryHeh)); + ++countSplit; + } + }, + start); + return countSplit; + }() > 0) { } // Extrude corners struct Extrusion { -- cgit v1.2.3