summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-04-01 21:02:57 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-04-01 21:02:57 +0100
commit3d2f9a86e56f16b2111822802aa49e28367d851e (patch)
treee2f06112b4564375f6156c0b282e761debd9f12c
parentAdd lots of simple triangle property helpers (diff)
downloadilt-3d2f9a86e56f16b2111822802aa49e28367d851e.tar.bz2
ilt-3d2f9a86e56f16b2111822802aa49e28367d851e.tar.xz
ilt-3d2f9a86e56f16b2111822802aa49e28367d851e.zip
Boundary edge and one time split with repeated 4-way split of large faces
-rw-r--r--game/geoData.cpp42
1 files 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<const GlobalPosition3D> 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<const GlobalPosition3D> 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 {