shape ops work in progress
major milestone: 35.8M tests pass
(all rect/triangle/quadralateral)
git-svn-id: http://skia.googlecode.com/svn/trunk@5166 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/LineQuadraticIntersection.cpp b/experimental/Intersection/LineQuadraticIntersection.cpp
index 1bc831b..e2e712f 100644
--- a/experimental/Intersection/LineQuadraticIntersection.cpp
+++ b/experimental/Intersection/LineQuadraticIntersection.cpp
@@ -128,6 +128,29 @@
for (int x = 0; x < roots; ++x) {
intersections.add(t[x], findLineT(t[x]));
}
+ // FIXME: quadratic root doesn't find t=0 or t=1, necessitating the hack below
+ if (roots == 0 || (roots == 1 && intersections.fT[0][0] >= FLT_EPSILON)) {
+ if (quad[0] == line[0]) {
+ intersections.fT[0][roots] = 0;
+ intersections.fT[1][roots++] = 0;
+ intersections.fUsed++;
+ } else if (quad[0] == line[1]) {
+ intersections.fT[0][roots] = 0;
+ intersections.fT[1][roots++] = 1;
+ intersections.fUsed++;
+ }
+ }
+ if (roots == 0 || (roots == 1 && intersections.fT[0][0] <= 1 - FLT_EPSILON)) {
+ if (quad[2] == line[1]) {
+ intersections.fT[0][roots] = 1;
+ intersections.fT[1][roots++] = 1;
+ intersections.fUsed++;
+ } else if (quad[2] == line[0]) {
+ intersections.fT[0][roots] = 1;
+ intersections.fT[1][roots++] = 0;
+ intersections.fUsed++;
+ }
+ }
return roots > 0;
}
@@ -138,7 +161,17 @@
D += F - 2 * E; // D = d - 2*e + f
E -= F; // E = -(d - e)
F -= axisIntercept;
- return quadraticRoots(D, E, F, intersections.fT[0]);
+ int roots = quadraticRoots(D, E, F, intersections.fT[0]);
+ // FIXME: ? quadraticRoots doesn't pick up intersections at 0, 1
+ if (roots < 2 && fabs(F) < FLT_EPSILON
+ && (roots == 0 || intersections.fT[0][0] >= FLT_EPSILON)) {
+ intersections.fT[0][roots++] = 0;
+ }
+ if (roots < 2 && fabs(quad[2].y - axisIntercept) < FLT_EPSILON
+ && (roots == 0 || intersections.fT[0][0] <= 1 - FLT_EPSILON)) {
+ intersections.fT[0][roots++] = 1;
+ }
+ return roots;
}
int verticalIntersect(double axisIntercept) {
@@ -148,7 +181,17 @@
D += F - 2 * E; // D = d - 2*e + f
E -= F; // E = -(d - e)
F -= axisIntercept;
- return quadraticRoots(D, E, F, intersections.fT[0]);
+ int roots = quadraticRoots(D, E, F, intersections.fT[0]);
+ // FIXME: ? quadraticRoots doesn't pick up intersections at 0, 1
+ if (roots < 2 && fabs(F) < FLT_EPSILON
+ && (roots == 0 || intersections.fT[0][0] >= FLT_EPSILON)) {
+ intersections.fT[0][roots++] = 0;
+ }
+ if (roots < 2 && fabs(quad[2].x - axisIntercept) < FLT_EPSILON
+ && (roots == 0 || intersections.fT[0][0] <= 1 - FLT_EPSILON)) {
+ intersections.fT[0][roots++] = 1;
+ }
+ return roots;
}
protected:
@@ -247,7 +290,7 @@
}
continue;
}
- intersections.fT[0][index] = (x - left) / (right - left);
+ intersections.fT[1][index] = (x - left) / (right - left);
++index;
}
if (flipped) {
@@ -272,7 +315,7 @@
}
continue;
}
- intersections.fT[0][index] = (y - top) / (bottom - top);
+ intersections.fT[1][index] = (y - top) / (bottom - top);
++index;
}
if (flipped) {