diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp index cbf77603949..5b07a0256e8 100644 --- a/core/math/geometry_2d.cpp +++ b/core/math/geometry_2d.cpp @@ -292,14 +292,16 @@ Vector> Geometry2D::_polypaths_do_operation(PolyBooleanOperation } Vector> polypaths; - for (PathsD::size_type i = 0; i < paths.size(); ++i) { + polypaths.resize(paths.size()); + for (PathsD::size_type i = 0; i < paths.size(); i++) { const PathD &path = paths[i]; Vector polypath; + polypath.resize(path.size()); for (PathsD::size_type j = 0; j < path.size(); ++j) { - polypath.push_back(Point2(static_cast(path[j].x), static_cast(path[j].y))); + polypath.set(j, Point2(static_cast(path[j].x), static_cast(path[j].y))); } - polypaths.push_back(polypath); + polypaths.set(i, polypath); } return polypaths; } @@ -353,14 +355,16 @@ Vector> Geometry2D::_polypath_offset(const Vector &p_poly // to attain the desired precision. Vector> polypaths; + polypaths.resize(paths.size()); for (PathsD::size_type i = 0; i < paths.size(); ++i) { const PathD &path = paths[i]; Vector polypath2; + polypath2.resize(path.size()); for (PathsD::size_type j = 0; j < path.size(); ++j) { - polypath2.push_back(Point2(static_cast(path[j].x), static_cast(path[j].y))); + polypath2.set(j, Point2(static_cast(path[j].x), static_cast(path[j].y))); } - polypaths.push_back(polypath2); + polypaths.set(i, polypath2); } return polypaths; }