diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-10-17 02:54:08 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-10-17 02:54:08 +0400 |
commit | b53505f5e11771b2e500fb9f812a4cd649a5d715 (patch) | |
tree | 1433bb8a00545559b085f331696bfe878daf3069 /source/blender/freestyle | |
parent | 2d25a12bbdc4dde23810e23726b29841bf13c2cd (diff) |
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.
Diffstat (limited to 'source/blender/freestyle')
-rwxr-xr-x | source/blender/freestyle/intern/stroke/Chain.cpp | 27 | ||||
-rwxr-xr-x | source/blender/freestyle/intern/stroke/Chain.h | 7 |
2 files changed, 19 insertions, 15 deletions
diff --git a/source/blender/freestyle/intern/stroke/Chain.cpp b/source/blender/freestyle/intern/stroke/Chain.cpp index dd3c4723cff..bf61a3b32cb 100755 --- a/source/blender/freestyle/intern/stroke/Chain.cpp +++ b/source/blender/freestyle/intern/stroke/Chain.cpp @@ -50,16 +50,14 @@ void Chain::push_viewedge_back(ViewEdge *iViewEdge, bool orientation) 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 @@ void Chain::push_viewedge_back(ViewEdge *iViewEdge, bool orientation) 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 @@ void Chain::push_viewedge_front(ViewEdge *iViewEdge, bool orientation) 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 @@ void Chain::push_viewedge_front(ViewEdge *iViewEdge, bool orientation) 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 @@ void Chain::push_viewedge_front(ViewEdge *iViewEdge, bool orientation) Curve::push_vertex_front(*v); //_Length += (current-previous).norm(); } + + if (!_fedgeB) + _fedgeB = (orientation) ? iViewEdge->fedgeB() : iViewEdge->fedgeA(); } diff --git a/source/blender/freestyle/intern/stroke/Chain.h b/source/blender/freestyle/intern/stroke/Chain.h index 711ae16a1a0..0dc3dd21a28 100755 --- a/source/blender/freestyle/intern/stroke/Chain.h +++ b/source/blender/freestyle/intern/stroke/Chain.h @@ -42,13 +42,14 @@ class Chain : public Curve 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 |