From a6a5ce4f7b5c2bde71715b11052d2ce30a34cb6d Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Thu, 11 Feb 2010 23:26:22 +0000 Subject: More consolidation of the view map creation. Made an attempt to fix "2D intersection out of range" warnings. These warnings may cause "3D intersection out of range" warnings, which often lead to a crash. --- source/blender/freestyle/intern/geometry/GeomUtils.cpp | 5 +++-- source/blender/freestyle/intern/geometry/GeomUtils.h | 3 ++- source/blender/freestyle/intern/geometry/SweepLine.h | 14 ++++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'source/blender/freestyle/intern/geometry') diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp index 88aafeed598..2169bce0364 100755 --- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp +++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp @@ -152,7 +152,8 @@ namespace GeomUtils { const Vec2r& p3, const Vec2r& p4, real& t, - real& u) { + real& u, + real epsilon) { real a1, a2, b1, b2, c1, c2; // Coefficients of line eqns real r1, r2, r3, r4; // 'Sign' values real denom, num; // Intermediate values @@ -189,7 +190,7 @@ namespace GeomUtils { // Line segments intersect: compute intersection point. denom = a1 * b2 - a2 * b1; - if (fabs(denom) < M_EPSILON) + if (fabs(denom) < epsilon) return (COLINEAR); real d1, d2, e1; diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.h b/source/blender/freestyle/intern/geometry/GeomUtils.h index 53c94c22f8b..787376108e1 100755 --- a/source/blender/freestyle/intern/geometry/GeomUtils.h +++ b/source/blender/freestyle/intern/geometry/GeomUtils.h @@ -94,7 +94,8 @@ namespace GeomUtils { intersection_test intersect2dSeg2dSegParametric(const Vec2r& p1, const Vec2r& p2, // first segment const Vec2r& p3, const Vec2r& p4, // second segment real& t, // I = P1 + t * P1P2) - real& u); // I = P3 + u * P3P4 + real& u, // I = P3 + u * P3P4 + real epsilon = M_EPSILON); /*! check whether a 2D segment intersect a 2D region or not */ LIB_GEOMETRY_EXPORT diff --git a/source/blender/freestyle/intern/geometry/SweepLine.h b/source/blender/freestyle/intern/geometry/SweepLine.h index 386ba3a7388..cf4c86d006d 100755 --- a/source/blender/freestyle/intern/geometry/SweepLine.h +++ b/source/blender/freestyle/intern/geometry/SweepLine.h @@ -226,8 +226,9 @@ public: inline void process(Point& p, vector*>& segments, - binary_rule,Segment >& binrule - //binary_rule,Segment >& binrule = binary_rule,Segment >() + binary_rule,Segment >& binrule, + //binary_rule,Segment >& binrule = binary_rule,Segment >(), + real epsilon = M_EPSILON ) { // first we remove the segments that need to be removed and then @@ -247,13 +248,14 @@ public: s!=send; s++) { - add((*s), binrule); + add((*s), binrule, epsilon); } } inline void add(Segment* S, - binary_rule,Segment >& binrule - //binary_rule,Segment >& binrule = binary_rule, Segment >() + binary_rule,Segment >& binrule, + //binary_rule,Segment >& binrule = binary_rule, Segment >(), + real epsilon ) { real t,u; @@ -298,7 +300,7 @@ public: if(S->CommonVertex(*currentS, CP)) continue; // the two edges have a common vertex->no need to check - if(GeomUtils::intersect2dSeg2dSegParametric(v0, v1, v2, v3, t, u) == GeomUtils::DO_INTERSECT) + if(GeomUtils::intersect2dSeg2dSegParametric(v0, v1, v2, v3, t, u, epsilon) == GeomUtils::DO_INTERSECT) { // create the intersection Intersection > * inter = new Intersection >(S,t,currentS,u); -- cgit v1.2.3