diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-05-22 17:49:19 -0400 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-05-22 17:49:19 -0400 |
| commit | 3f7d12d9a17d540a9ef74c46a03432a0285ab0c8 (patch) | |
| tree | 11506e6244c6e382d570470fd296118d9eb1a1ae | |
| parent | 9455ae5c8b98aa2b76265b4b2449127934605147 (diff) | |
Clean up cases and add others...still edge cases left
| -rw-r--r-- | sigmodr/widgets/mapeditor/WorldMapPlacement.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/sigmodr/widgets/mapeditor/WorldMapPlacement.cpp b/sigmodr/widgets/mapeditor/WorldMapPlacement.cpp index e8a502fa..369142bd 100644 --- a/sigmodr/widgets/mapeditor/WorldMapPlacement.cpp +++ b/sigmodr/widgets/mapeditor/WorldMapPlacement.cpp @@ -137,27 +137,18 @@ static CollisionInfo findCollisions(const QPolygon& polygon1, const QPolygon& po QPoint prevPoint2 = polygon2.last(); foreach (const QPoint& point2, polygon2) { - if (point1 == prevPoint2) - { - QPoint nextPoint1 = polygon1[(polygon1.indexOf(point1) + 1) % polygon1.size()]; - Resolutions flags = 0; - if (concaveTurnDirection(prevPoint1, point1, nextPoint1) != Invalid) - flags |= Delete; - if (((point2.x() == prevPoint2.x()) && (prevPoint2.x() == nextPoint1.x())) || ((point2.y() == prevPoint2.y()) && (prevPoint2.y() == nextPoint1.y()))) - flags |= Include; - data[point1] = NextTarget(flags, point1); - break; - } - else if ((((point2.x() == point1.x()) && between(point1.y(), prevPoint2.y(), point2.y())) || ((point2.y() == point1.y()) && between(point1.x(), prevPoint2.x(), point2.x())))) - { + if (nextPoint1 == prevPoint2) + data[point1] = NextTarget(Include, collinear(point1, nextPoint1, point2) ? point2 : prevPoint2); + else if (inOrder(prevPoint2, point1, point2) && inOrder(prevPoint2, nextPoint1, point2)) data[point1] = NextTarget(Include, point2); + else if (inOrder(point1, prevPoint2, nextPoint1) && inOrder(point1, point2, nextPoint1)) + data[point1] = NextTarget(Include, point2); + else if (inOrder(prevPoint2, point1, point2)) + data[point1] = NextTarget(Include, point2); + else if (inOrder(point1, prevPoint2, nextPoint1)) + data[point1] = NextTarget(Include, prevPoint2); + if (data.contains(point1)) break; - } - else if ((((point1.x() == prevPoint2.x()) && between(prevPoint2.y(), prevPoint1.y(), point1.y())) || ((point1.y() == prevPoint2.y()) && between(point1.x(), prevPoint1.x(), point1.x())))) - { - data[point1] = NextTarget(Include, polygon2[(polygon2.indexOf(prevPoint2) + polygon2.size() - 2) % polygon2.size()]); - break; - } prevPoint2 = point2; } point1 = nextPoint1; |
