From 495f8e435b677f28913cd2adc8caa8d3d766dd17 Mon Sep 17 00:00:00 2001 From: "caryclark@google.com" Date: Thu, 31 May 2012 13:13:11 +0000 Subject: shape ops work in progress git-svn-id: http://skia.googlecode.com/svn/trunk@4089 2bbb7eff-a529-9590-31e7-b0007b416f81 --- experimental/Intersection/LineIntersection.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'experimental/Intersection/LineIntersection.cpp') diff --git a/experimental/Intersection/LineIntersection.cpp b/experimental/Intersection/LineIntersection.cpp index 40e046cff5..b505761877 100644 --- a/experimental/Intersection/LineIntersection.cpp +++ b/experimental/Intersection/LineIntersection.cpp @@ -56,9 +56,10 @@ int intersect(const _Line& a, const _Line& b, double aRange[2], double bRange[2] aRange[0] = bMin <= aMin ? 0 : (bMin - aMin) / (aMax - aMin); aRange[1] = bMax >= aMax ? 1 : (bMax - aMin) / (aMax - aMin); } + int bIn = (aPtr[0] - aPtr[2]) * (bPtr[0] - bPtr[2]) < 0; if (bRange) { - bRange[0] = aMin <= bMin ? 0 : (aMin - bMin) / (bMax - bMin); - bRange[1] = aMax >= bMax ? 1 : (aMax - bMin) / (bMax - bMin); + bRange[bIn] = aMin <= bMin ? 0 : (aMin - bMin) / (bMax - bMin); + bRange[!bIn] = aMax >= bMax ? 1 : (aMax - bMin) / (bMax - bMin); } return 1 + ((aRange[0] != aRange[1]) || (bRange[0] != bRange[1])); } -- cgit v1.2.3