summaryrefslogtreecommitdiff
path: root/game/geoData.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-03-31 20:31:15 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-03-31 20:35:37 +0100
commitac71ff90e86baa549904794375ebb2f9245d92b2 (patch)
treeadc8854c16878a4a19d9d6f2fd16a9a82817b386 /game/geoData.cpp
parentSplit faces with two large boundary sides (diff)
downloadilt-ac71ff90e86baa549904794375ebb2f9245d92b2.tar.bz2
ilt-ac71ff90e86baa549904794375ebb2f9245d92b2.tar.xz
ilt-ac71ff90e86baa549904794375ebb2f9245d92b2.zip
Split long boundary edges
Diffstat (limited to 'game/geoData.cpp')
-rw-r--r--game/geoData.cpp16
1 files changed, 16 insertions, 0 deletions
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<const GlobalPosition3D> 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<const GlobalPosition3D> 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 {