summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-03-23 21:41:10 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-03-23 21:41:10 +0000
commitf380b20ddf1ead6447a6ee6e137a14c4aa226c12 (patch)
treea654a3a219811df7d645683f6fac5697ffd1c776
parentCreate extents purely from corner arcs (diff)
downloadilt-f380b20ddf1ead6447a6ee6e137a14c4aa226c12.tar.bz2
ilt-f380b20ddf1ead6447a6ee6e137a14c4aa226c12.tar.xz
ilt-f380b20ddf1ead6447a6ee6e137a14c4aa226c12.zip
Handle and test concave surface boundaries
-rw-r--r--game/geoData.cpp19
-rw-r--r--test/fixtures/geoData/deform/1.json41
2 files changed, 55 insertions, 5 deletions
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<const GlobalPosition3D> 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),
diff --git a/test/fixtures/geoData/deform/1.json b/test/fixtures/geoData/deform/1.json
index fb45ce4..6930238 100644
--- a/test/fixtures/geoData/deform/1.json
+++ b/test/fixtures/geoData/deform/1.json
@@ -156,5 +156,46 @@
"/tmp/geoData5.tga"
]
]
+ ],
+ [
+ [
+ [
+ 1500,
+ 2000,
+ 800
+ ],
+ [
+ 3000,
+ 2000,
+ 800
+ ],
+ [
+ 5000,
+ 4000,
+ 800
+ ],
+ [
+ 3500,
+ 700,
+ 800
+ ]
+ ],
+ [
+ [
+ [
+ [
+ -1000,
+ -3000,
+ 7000
+ ],
+ [
+ 1,
+ 1,
+ -1.5
+ ]
+ ],
+ "/tmp/geoData6.tga"
+ ]
+ ]
]
]