From c27629bd471986199ccc49cf8eb88230ad05974e Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 31 Dec 2019 15:45:20 -0400 Subject: [PATCH] Re-apply commit b0094b5: Fix BezierCurve:render to avoid adding collinear points in some situations. Resolves issue #1501. --HG-- branch : minor --- src/modules/math/BezierCurve.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/math/BezierCurve.cpp b/src/modules/math/BezierCurve.cpp index 83957a8c1..e27a6ea23 100644 --- a/src/modules/math/BezierCurve.cpp +++ b/src/modules/math/BezierCurve.cpp @@ -69,11 +69,14 @@ void subdivide(vector &points, int k) subdivide(right, k-1); // merge (right is in reversed order) - points.resize(left.size() + right.size() - 1); - for (size_t i = 0; i < left.size(); ++i) + // By this point the 'left' array has a point at the end that's collinear + // with other points. It's still needed for the subdivide calls above but we + // can get rid of it here. + points.resize(left.size() + right.size() - 2); + for (size_t i = 0; i < left.size() - 1; ++i) points[i] = left[i]; for (size_t i = 1; i < right.size(); ++i) - points[i-1 + left.size()] = right[right.size() - i - 1]; + points[i-1 + left.size() - 1] = right[right.size() - i - 1]; } }