summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-11-03 22:00:46 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-11-03 22:00:46 +0000
commitfe38b3887b695f27baf791df34b7361ee11b379f (patch)
treed588f36f7add7ff5eee74a0f57f2fd6ce6682867
parentThrow if input stream not in good state reading JSON (diff)
downloadilt-fe38b3887b695f27baf791df34b7361ee11b379f.tar.bz2
ilt-fe38b3887b695f27baf791df34b7361ee11b379f.tar.xz
ilt-fe38b3887b695f27baf791df34b7361ee11b379f.zip
Remove extrusion extents that rounded to the same vertex
-rw-r--r--game/geoData.cpp8
-rw-r--r--test/fixtures/geoData/deform/multi1.json21
-rw-r--r--test/test-geoData.cpp12
3 files changed, 41 insertions, 0 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp
index 8975d46..1a1e530 100644
--- a/game/geoData.cpp
+++ b/game/geoData.cpp
@@ -558,6 +558,14 @@ GeoData::setHeights(const std::span<const GlobalPosition3D> triangleStrip, const
doExtrusion(extrusionVertex, direction, p1, -MAX_SLOPE),
doExtrusion(extrusionVertex, direction, p1, MAX_SLOPE));
assert(extrusionVertex.is_valid());
+ if (extrusionExtents.size() >= 2) {
+ const auto & last = *extrusionExtents.rbegin();
+ const auto & prev = *++extrusionExtents.rbegin();
+ if (last.boundaryVertex == prev.boundaryVertex
+ && last.extrusionVertex == prev.extrusionVertex) {
+ extrusionExtents.pop_back();
+ }
+ }
};
if (const Arc arc {e0, e1}; arc.length() < MIN_ARC) {
addExtrusionFor(normalize(e0 + e1) / cosf(arc.length() / 2.F));
diff --git a/test/fixtures/geoData/deform/multi1.json b/test/fixtures/geoData/deform/multi1.json
new file mode 100644
index 0000000..c7456b6
--- /dev/null
+++ b/test/fixtures/geoData/deform/multi1.json
@@ -0,0 +1,21 @@
+[
+ [
+ [
+ [
+ 100,
+ 100,
+ 100
+ ],
+ [
+ 150,
+ 100,
+ 100
+ ],
+ [
+ 100,
+ 150,
+ 100
+ ]
+ ]
+ ]
+]
diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp
index 35d6bae..b0261db 100644
--- a/test/test-geoData.cpp
+++ b/test/test-geoData.cpp
@@ -276,3 +276,15 @@ BOOST_DATA_TEST_CASE(deform, loadFixtureJson<DeformTerrainData>("geoData/deform/
Texture::save(tro.outImage, cam.second.c_str());
});
}
+
+BOOST_DATA_TEST_CASE(
+ deformMulti, loadFixtureJson<std::vector<std::vector<GlobalPosition3D>>>("geoData/deform/multi1.json"), points)
+{
+ BOOST_REQUIRE(!points.empty());
+ Surface surface;
+ auto gd = std::make_shared<GeoData>(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100));
+ for (const auto & strip : points) {
+ BOOST_REQUIRE_GE(strip.size(), 3);
+ BOOST_CHECK_NO_THROW(gd->setHeights(strip, surface));
+ }
+}