diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-02-12 02:26:22 +0300 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-02-12 02:26:22 +0300 |
commit | a6a5ce4f7b5c2bde71715b11052d2ce30a34cb6d (patch) | |
tree | 12a40adc00acaa2a2e20795d8bf5dca134feb5ae /source | |
parent | ed266e868cee7e922f028227ee22492d7e830253 (diff) |
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.
Diffstat (limited to 'source')
4 files changed, 14 insertions, 10 deletions
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<Segment<T,Point>*>& segments, - binary_rule<Segment<T,Point>,Segment<T,Point> >& binrule - //binary_rule<Segment<T,Point>,Segment<T,Point> >& binrule = binary_rule<Segment<T,Point>,Segment<T,Point> >() + binary_rule<Segment<T,Point>,Segment<T,Point> >& binrule, + //binary_rule<Segment<T,Point>,Segment<T,Point> >& binrule = binary_rule<Segment<T,Point>,Segment<T,Point> >(), + 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<T,Point>* S, - binary_rule<Segment<T,Point>,Segment<T,Point> >& binrule - //binary_rule<Segment<T,Point>,Segment<T,Point> >& binrule = binary_rule<Segment<T,Point>, Segment<T,Point> >() + binary_rule<Segment<T,Point>,Segment<T,Point> >& binrule, + //binary_rule<Segment<T,Point>,Segment<T,Point> >& binrule = binary_rule<Segment<T,Point>, Segment<T,Point> >(), + 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<Segment<T,Point> > * inter = new Intersection<Segment<T,Point> >(S,t,currentS,u); diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index 585d44d9c28..157478c3a5e 100755 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -911,7 +911,7 @@ void ViewMapBuilder::ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsi Vec3r evt((*sv)->point2D()); silhouette_binary_rule sbr; - SL.process(evt, vsegments, sbr); + SL.process(evt, vsegments, sbr, epsilon); if(progressBarDisplay) { counter--; |