From c94b3208561f97d86136148a4caba42eac640853 Mon Sep 17 00:00:00 2001 From: Charlie Burrows Date: Mon, 6 May 2024 12:43:40 -0400 Subject: [PATCH 1/2] Remove duplicate sequential points from polyline_offset polygons --- core/math/geometry_2d.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp index d60619b27ff9..25921cc1200b 100644 --- a/core/math/geometry_2d.cpp +++ b/core/math/geometry_2d.cpp @@ -308,7 +308,12 @@ Vector> Geometry2D::_polypath_offset(const Vector &p_poly Vector polypath2; for (PathsD::size_type j = 0; j < path.size(); ++j) { - polypath2.push_back(Point2(static_cast(path[j].x), static_cast(path[j].y))); + // Remove duplicate sequentual points from the polygon. + real_t x{static_cast(path[j].x)}; + real_t y{static_cast(path[j].y)}; + if(j == 0 || polypath2[polypath2.size()-1].x != x || polypath2[polypath2.size()-1].y != y) { + polypath2.push_back(Point2(x,y)); + } } polypaths.push_back(polypath2); } From 3b93ff8129494a081f602fe64a9c83fd2be65ad3 Mon Sep 17 00:00:00 2001 From: Charlie Burrows Date: Mon, 6 May 2024 13:00:57 -0400 Subject: [PATCH 2/2] clang formatter --- core/math/geometry_2d.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp index 25921cc1200b..011d40643c37 100644 --- a/core/math/geometry_2d.cpp +++ b/core/math/geometry_2d.cpp @@ -309,10 +309,10 @@ Vector> Geometry2D::_polypath_offset(const Vector &p_poly Vector polypath2; for (PathsD::size_type j = 0; j < path.size(); ++j) { // Remove duplicate sequentual points from the polygon. - real_t x{static_cast(path[j].x)}; - real_t y{static_cast(path[j].y)}; - if(j == 0 || polypath2[polypath2.size()-1].x != x || polypath2[polypath2.size()-1].y != y) { - polypath2.push_back(Point2(x,y)); + real_t x = static_cast(path[j].x); + real_t y = static_cast(path[j].y); + if (j == 0 || polypath2[polypath2.size() - 1].x != x || polypath2[polypath2.size() - 1].y != y) { + polypath2.push_back(Point2(x, y)); } } polypaths.push_back(polypath2);