diff options
author | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2025-01-02 17:29:09 +0000 |
---|---|---|
committer | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2025-01-02 17:29:11 +0000 |
commit | 02c37c477099f69d1468a51ab66d05f3e7bf35fd (patch) | |
tree | 012c510a7f3baacb89157de985badd3a5fbdbacd | |
parent | Return angle of intersection of arc with line (diff) | |
download | ilt-02c37c477099f69d1468a51ab66d05f3e7bf35fd.tar.bz2 ilt-02c37c477099f69d1468a51ab66d05f3e7bf35fd.tar.xz ilt-02c37c477099f69d1468a51ab66d05f3e7bf35fd.zip |
Fix curve walk edge case where the curve legitimately returns to the previous faceterrain-for-networks
-rw-r--r-- | game/geoData.cpp | 6 | ||||
-rw-r--r-- | test/test-geoData.cpp | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp index 45e6590..f0e38d0 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -315,16 +315,14 @@ GeoData::walkUntil(const PointFace & from, GlobalPosition2D to, GlobalPosition2D while (step.current.is_valid() && !op(step)) { step.previous = step.current; for (const auto next : fh_range(step.current)) { - if (opposite_halfedge_handle(next) == step.exitHalfedge) { - continue; - } step.current = opposite_face_handle(next); if (step.current.is_valid()) { const auto e1 = point(to_vertex_handle(next)); const auto e2 = point(to_vertex_handle(opposite_halfedge_handle(next))); if (const auto intersect = arc.crossesLineAt(e1, e2)) { step.exitHalfedge = next; - step.exitPosition = intersect.value().first; + arc.ep0 = step.exitPosition = intersect.value().first; + arc.first = std::nextafter(intersect.value().second, INFINITY); break; } } diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 049d896..8e5ef2d 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -216,6 +216,11 @@ BOOST_DATA_TEST_CASE(walkTerrainCurveSetsFromFace, {310050000, 490008845}, {310003003, 490003003}, }}, + {{310999999, 490205000}, {310999999, 490203000}, {310999000, 490204000}, {1631, 1632, 1631}, + { + {311000000, 490204999}, + {311000000, 490203001}, + }}, }), from, to, centre, visits, exits) { @@ -225,6 +230,7 @@ BOOST_DATA_TEST_CASE(walkTerrainCurveSetsFromFace, std::vector<GlobalPosition2D> exited; BOOST_CHECK_NO_THROW(fixedTerrtain.walk(from, to, centre, [&](const auto & step) { visited.emplace_back(step.current.idx()); + BOOST_REQUIRE(!std::ranges::contains(exited, step.exitPosition)); exited.emplace_back(step.exitPosition); })); BOOST_CHECK_EQUAL_COLLECTIONS(visited.begin(), visited.end(), visits.begin(), visits.end()); |