[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41073] branches/soc-2008-mxcurioni/source /blender/freestyle/intern/stroke: Another attempt to fix the failure of SVertex:: getFEdge due to a discontinuity

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Mon Oct 17 00:54:09 CEST 2011


Revision: 41073
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41073
Author:   kjym3
Date:     2011-10-16 22:54:08 +0000 (Sun, 16 Oct 2011)
Log Message:
-----------
Another attempt to fix the failure of SVertex::getFEdge due to a discontinuity
of underlying FEdges introduced by chaining operations.  The material of a
smooth FEdge is identified by the material index of the FEdge and the array
of materials in the SShape to which the first SVertex (i.e., vertexA) of the
FEdge belong.  The present fix makes sure that the material index refers to the
intended array of materials, to avoid inconsistent reference and out-of-index
errors that lead to a crash.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Chain.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Chain.h

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Chain.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Chain.cpp	2011-10-16 22:07:55 UTC (rev 41072)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Chain.cpp	2011-10-16 22:54:08 UTC (rev 41073)
@@ -50,16 +50,14 @@
     else
       --v;
     // Ensure the continuity of underlying FEdges
-    CurvePoint *cp = _Vertices.back();
-    SVertex *sv_last = cp->B();
-    if (!sv_last) sv_last = cp->A();
-    SVertex *sv_curr = (*v);
-    FEdge *fe = (orientation) ? iViewEdge->fedgeA() : iViewEdge->fedgeB();
-    FEdge *fe2 = fe->duplicate();
-    fe2->setVertexA(sv_last);
-    fe2->setVertexB(sv_curr);
-    sv_last->AddFEdge(fe2);
-    sv_curr->AddFEdge(fe2);
+    CurvePoint *cp = _Vertices.back(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.f);
+    SVertex *sv_first = (*vfirst);
+    FEdge *fe = _fedgeB->duplicate();
+    fe->setVertexB(sv_first);
+    fe->vertexA()->shape()->AddEdge(fe);
+    fe->vertexA()->AddFEdge(fe);
+    fe->vertexB()->AddFEdge(fe);
+    cp->setA(sv_first);
   }
   else
     previous = (*v)->point2d(); 
@@ -81,6 +79,8 @@
     Curve::push_vertex_back(*v);
     //_Length += (current-previous).norm();
   }
+
+  _fedgeB = (orientation) ? iViewEdge->fedgeB() : iViewEdge->fedgeA();
 } 
 
 void Chain::push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
@@ -111,9 +111,8 @@
     else
       --v;
     // Ensure the continuity of underlying FEdges
-    CurvePoint *cp = _Vertices.front();
+    CurvePoint *cp = _Vertices.front(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.f);
     SVertex *sv_last = cp->A();
-    if (!sv_last) sv_last = cp->B();
     SVertex *sv_curr = (*v);
     FEdge *fe = (orientation) ? iViewEdge->fedgeA() : iViewEdge->fedgeB();
     FEdge *fe2 = fe->duplicate();
@@ -121,6 +120,7 @@
     fe2->setVertexB(sv_last);
     sv_last->AddFEdge(fe2);
     sv_curr->AddFEdge(fe2);
+    sv_curr->shape()->AddEdge(fe2);
   }
   else
     previous = (*v)->point2d(); 
@@ -142,6 +142,9 @@
     Curve::push_vertex_front(*v);
     //_Length += (current-previous).norm();
   }
+
+  if (!_fedgeB)
+	_fedgeB = (orientation) ? iViewEdge->fedgeB() : iViewEdge->fedgeA();
 }
 
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Chain.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Chain.h	2011-10-16 22:07:55 UTC (rev 41072)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Chain.h	2011-10-16 22:54:08 UTC (rev 41073)
@@ -42,13 +42,14 @@
 protected:
   // tmp
   Id * _splittingId;
+  FEdge *_fedgeB; // the last FEdge of the ViewEdge passed to the last call for push_viewedge_back().
 public:
   /*! Defult constructor. */
-  Chain() : Curve() {_splittingId=0;}
+  Chain() : Curve() {_splittingId=0;_fedgeB=0;}
   /*! Builds a chain from its Id. */
-  Chain(const Id& id) : Curve(id) {_splittingId=0;}
+  Chain(const Id& id) : Curve(id) {_splittingId=0;_fedgeB=0;}
   /*! Copy Constructor */
-  Chain(const Chain& iBrother) : Curve(iBrother) {_splittingId=iBrother._splittingId;}
+  Chain(const Chain& iBrother) : Curve(iBrother) {_splittingId=iBrother._splittingId;_fedgeB=iBrother._fedgeB;}
   /*! Destructor. */
   virtual ~Chain() {
     // only the last splitted deletes this id




More information about the Bf-blender-cvs mailing list