From f380b20ddf1ead6447a6ee6e137a14c4aa226c12 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 23 Mar 2024 21:41:10 +0000 Subject: Handle and test concave surface boundaries --- game/geoData.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'game') diff --git a/game/geoData.cpp b/game/geoData.cpp index 80a4eba..30c382c 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -446,11 +446,20 @@ GeoData::setHeights(const std::span triangleStrip) return extrusionDir; }; // Previous half edge end to current half end start arc tangents - const Arc arc {e0, e1}; - const auto limit = std::ceil(arc.length() * 5.F / pi); - const auto inc = arc.length() / limit; - for (float step = 0; step <= limit; step += 1.F) { - const auto direction = sincosf(arc.first + (step * inc)); + if (const Arc arc {e0, e1}; arc.length() < pi) { + const auto limit = std::ceil(arc.length() * 5.F / pi); + const auto inc = arc.length() / limit; + for (float step = 0; step <= limit; step += 1.F) { + const auto direction = sincosf(arc.first + (step * inc)); + VertexHandle extrusionVertex; + extrusionExtents.emplace_back(boundaryVertex, extrusionVertex, + doExtrusion(extrusionVertex, direction, p1, -MAX_SLOPE), + doExtrusion(extrusionVertex, direction, p1, MAX_SLOPE)); + assert(extrusionVertex.is_valid()); + } + } + else { + const auto direction = normalize(e0 + e1) / sinf((arc.length() - pi) / 2.F); VertexHandle extrusionVertex; extrusionExtents.emplace_back(boundaryVertex, extrusionVertex, doExtrusion(extrusionVertex, direction, p1, -MAX_SLOPE), -- cgit v1.2.3