diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-11-14 01:12:42 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-11-14 01:12:42 +0000 |
commit | 272f46f548506680af212187ff420918241670fe (patch) | |
tree | 06098805f47d87897a04a02c23853cfd491cb8a0 /game/geoData.cpp | |
parent | Reverse order of last boundary part addition (diff) | |
download | ilt-272f46f548506680af212187ff420918241670fe.tar.bz2 ilt-272f46f548506680af212187ff420918241670fe.tar.xz ilt-272f46f548506680af212187ff420918241670fe.zip |
Fix do bounary part iteration
Exit when current vertex is adjacent to the end
Diffstat (limited to 'game/geoData.cpp')
-rw-r--r-- | game/geoData.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp index bf9aee0..f84f4e2 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -510,24 +510,22 @@ GeoData::setHeights(const std::span<const GlobalPosition3D> triangleStrip, const = [this, &boundaryTriangles](VertexHandle start, VertexHandle end, const Triangle<3> & triangle) { boundaryTriangles.emplace(start, &triangle); const auto endPoint = point(end); - while (std::any_of(voh_begin(start), voh_end(start), [&](const auto & outHalf) { - const auto next = next_halfedge_handle(outHalf); - if (next == end) { - return false; - } - const auto startPoint = point(start); - const auto nextStartPoint = point(from_vertex_handle(next)); - const auto nextEndPoint = point(to_vertex_handle(next)); - if (linesCross(startPoint, endPoint, nextStartPoint, nextEndPoint)) { - if (const auto intersection = linesIntersectAt( - startPoint.xy(), endPoint.xy(), nextStartPoint.xy(), nextEndPoint.xy())) { - start = split(edge_handle(next), positionOnTriangle(*intersection, triangle)); - boundaryTriangles.emplace(start, &triangle); - return true; - } - } - return false; - })) { } + while (!std::ranges::contains(vv_range(start), end) + && std::ranges::any_of(voh_range(start), [&](const auto & outHalf) { + const auto next = next_halfedge_handle(outHalf); + const auto startPoint = point(start); + const auto nextStartPoint = point(from_vertex_handle(next)); + const auto nextEndPoint = point(to_vertex_handle(next)); + if (linesCross(startPoint, endPoint, nextStartPoint, nextEndPoint)) { + if (const auto intersection = linesIntersectAt(startPoint.xy(), endPoint.xy(), + nextStartPoint.xy(), nextEndPoint.xy())) { + start = split(edge_handle(next), positionOnTriangle(*intersection, triangle)); + boundaryTriangles.emplace(start, &triangle); + return true; + } + } + return false; + })) { } }; auto doBoundary = [&doBoundaryPart, triangle = strip.begin()](const auto & verts) mutable { const auto & [a, b, c] = verts; |