[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26824] branches/soc-2008-mxcurioni/source /blender/freestyle/intern: More consolidation of the view map creation.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Fri Feb 12 00:26:22 CET 2010


Revision: 26824
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26824
Author:   kjym3
Date:     2010-02-12 00:26:22 +0100 (Fri, 12 Feb 2010)

Log Message:
-----------
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.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/GeomUtils.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/GeomUtils.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/SweepLine.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/GeomUtils.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/GeomUtils.cpp	2010-02-11 23:13:47 UTC (rev 26823)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/GeomUtils.cpp	2010-02-11 23:26:22 UTC (rev 26824)
@@ -152,7 +152,8 @@
 						  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 @@
 
     // 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;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/GeomUtils.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/GeomUtils.h	2010-02-11 23:13:47 UTC (rev 26823)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/GeomUtils.h	2010-02-11 23:26:22 UTC (rev 26824)
@@ -94,7 +94,8 @@
   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

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/SweepLine.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/SweepLine.h	2010-02-11 23:13:47 UTC (rev 26823)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/SweepLine.h	2010-02-11 23:26:22 UTC (rev 26824)
@@ -226,8 +226,9 @@
   
   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 @@
     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 @@
       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);

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp	2010-02-11 23:13:47 UTC (rev 26823)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp	2010-02-11 23:26:22 UTC (rev 26824)
@@ -911,7 +911,7 @@
 
     Vec3r evt((*sv)->point2D());
     silhouette_binary_rule sbr;
-    SL.process(evt, vsegments, sbr);
+    SL.process(evt, vsegments, sbr, epsilon);
 
     if(progressBarDisplay) {  
       counter--;





More information about the Bf-blender-cvs mailing list