[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29952] branches/soc-2008-mxcurioni/source /blender/freestyle/intern: Bug fixes from St?\195?\169phane Grabli, one of the coauthors of the

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Mon Jul 5 01:08:37 CEST 2010


Revision: 29952
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29952
Author:   kjym3
Date:     2010-07-05 01:08:37 +0200 (Mon, 05 Jul 2010)

Log Message:
-----------
Bug fixes from St?\195?\169phane Grabli, one of the coauthors of the
original Freestyle:

* Fix for making the stroke construction more robust to nearly
overlapping vertices.

* Fix for a bug in the computation of the occluded surfaces.

These changes make the visibility computation more robust and
the line quality generally higher.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Operators.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/StrokeRep.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Functions0D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Operators.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Operators.cpp	2010-07-04 22:43:51 UTC (rev 29951)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Operators.cpp	2010-07-04 23:08:37 UTC (rev 29952)
@@ -938,10 +938,18 @@
       stroke_vertex = new StrokeVertex(cp);
     current = stroke_vertex->point2d();
     Vec3r vec_tmp(current - previous);
-    currentCurvilignAbscissa += vec_tmp.norm();
-    stroke_vertex->setCurvilinearAbscissa(currentCurvilignAbscissa);
-    stroke->push_back(stroke_vertex);
-    previous = current;
+    real vec_tmp_norm = vec_tmp.norm();
+    if((stroke->strokeVerticesSize() > 0) && (vec_tmp_norm < 1.e-06)){
+      // The point we just created is superimposed with the 
+      // previous one. We remove it to avoid having to deal
+      // with this kind of singularities in the strip creation
+      delete stroke_vertex;
+    }else{
+      currentCurvilignAbscissa += vec_tmp.norm();
+      stroke_vertex->setCurvilinearAbscissa(currentCurvilignAbscissa);
+      stroke->push_back(stroke_vertex);
+      previous = current;
+    }
     ++it;
   } while((it != itend) && (it != itfirst));
 
@@ -959,9 +967,17 @@
       stroke_vertex = new StrokeVertex(cp);
     current = stroke_vertex->point2d();
     Vec3r vec_tmp(current - previous);
-    currentCurvilignAbscissa += vec_tmp.norm();
-    stroke_vertex->setCurvilinearAbscissa(currentCurvilignAbscissa);
-    stroke->push_back(stroke_vertex);
+    real vec_tmp_norm = vec_tmp.norm();
+    if((stroke->strokeVerticesSize() > 0) && (vec_tmp_norm < 1.e-06)){
+      // The point we just created is superimposed with the 
+      // previous one. We remove it to avoid having to deal
+      // with this kind of singularities in the strip creation
+      delete stroke_vertex;
+    }else{
+      currentCurvilignAbscissa += vec_tmp.norm();
+      stroke_vertex->setCurvilinearAbscissa(currentCurvilignAbscissa);
+      stroke->push_back(stroke_vertex);
+    }
   }
   stroke->setLength(currentCurvilignAbscissa);
   return stroke;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/StrokeRep.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/StrokeRep.cpp	2010-07-04 22:43:51 UTC (rev 29951)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/StrokeRep.cpp	2010-07-04 23:08:37 UTC (rev 29952)
@@ -254,7 +254,14 @@
       else 
         _vertices.push_back(new StrokeVertexRep(p-thickness[0]*stripDir));
       ++i;
-		
+
+      if((stripDir+stripDirPrev).norm() <= 1.e-06){
+        // the strip is most likely doing a U-turn, we can't compute the average vector.
+        // We just continue and hope it's ok
+        vPrev = v;
+        continue;
+      }
+      
       // if the angle is obtuse, we simply average the directions to avoid the singularity
       stripDir=stripDir+stripDirPrev;
       if ((dirNorm<ZERO) || (dirPrevNorm<ZERO) || (stripDir.norm() < ZERO)) {

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Functions0D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Functions0D.cpp	2010-07-04 22:43:51 UTC (rev 29951)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/Functions0D.cpp	2010-07-04 23:08:37 UTC (rev 29952)
@@ -38,16 +38,9 @@
     Interface0DIterator prev = it, next = it;
     ++next;
     int count = 1;
-    while((!prev.isBegin()) && (count < 3))
-      { 
-        --prev;
-        ++count;
-      }
-    while((!next.isEnd()) && (count < 3))
-      {
-        ++next;
-        ++count;
-      } 
+    if (!it.isBegin() && !next.isEnd()) {
+      count = 3;
+    } 
     if(count < 3)
       {
         // if we only have 2 vertices
@@ -296,9 +289,13 @@
   int MaterialF0D::operator()(Interface0DIterator& iter) {
     FEdge *fe1, *fe2;
     getFEdges(iter,fe1,fe2);
-    
-    if(fe1 == 0)
+
+    if(fe1 == 0) {
+      // DEBUG
       getFEdges(iter, fe1, fe2);
+      return 1;
+    }
+
     if(fe1->isSmooth())
       result = ((FEdgeSmooth*)fe1)->frs_material();
     else

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-07-04 22:43:51 UTC (rev 29951)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp	2010-07-04 23:08:37 UTC (rev 29952)
@@ -241,8 +241,7 @@
 	  maxIndex = tmpQI;
 	}
       }
-      else
-	FindOccludee(fe, iGrid, epsilon, &aFace, timestamp++);
+      FindOccludee(fe, iGrid, epsilon, &aFace, timestamp++);
 
       if(aFace) { 
 	fe->setaFace(*aFace);
@@ -361,8 +360,7 @@
 	    maxIndex = tmpQI;
 	  }
 	}
-	else
-	  FindOccludee(fe, iGrid, epsilon, &aFace, timestamp++);
+        FindOccludee(fe, iGrid, epsilon, &aFace, timestamp++);
 
         if(aFace)
         { 





More information about the Bf-blender-cvs mailing list