Comment 6 for bug 1483960

Revision history for this message
Mingye Wang (artoria2e5) wrote :

Horrible recursions in lib2geom at https://bazaar.launchpad.net/~lib2geom-hackers/lib2geom/trunk/view/head:/src/2geom/bezier-curve.cpp#L483.

This might be an effective fix (too lazy to get the full source):

--- /tmp/bezier-curve.cpp 2015-11-29 21:09:35.115705600 -0500
+++ /tmp/bezier-curve2.cpp 2015-11-29 21:10:59.503905100 -0500
@@ -469,7 +469,7 @@
     Coord lower = distance(a0, a3);
     Coord upper = distance(a0, a1) + distance(a1, a2) + distance(a2, a3);

- if (upper - lower < 2*tolerance) return (lower + upper)/2;
+ if (upper - lower <= 2*tolerance) return (lower + upper)/2;

     Point // Casteljau subdivision
         // b0 = a0,
--

Or we can check for our terrible tolerance == 0 case:

--- /tmp/bezier-curve.cpp 2015-11-29 21:09:35.115705600 -0500
+++ /tmp/bezier-curve2.cpp 2015-11-29 21:14:50.323817300 -0500
@@ -469,7 +469,7 @@
     Coord lower = distance(a0, a3);
     Coord upper = distance(a0, a1) + distance(a1, a2) + distance(a2, a3);

- if (upper - lower < 2*tolerance) return (lower + upper)/2;
+ if (upper - lower < 2*tolerance || tolerance == 0.0) return (lower + upper)/2;

     Point // Casteljau subdivision
         // b0 = a0,