diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-17 02:39:39 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-17 02:39:39 +0400 |
commit | 0d9c98c4bbfbc8c70c4772086dd09a51d01921ef (patch) | |
tree | 7ea39e803e66e0a688168910bda10383dfdc8f8b /source | |
parent | 031a58dc027a7e6c4e630e64584d68b08fb52e2c (diff) |
Fix for a crash due to a bug in the handling of singularity in stroke creation,
where additions of a small offset (to prevent vertices from being at the same point)
were not properly done when vertices were shifted in the reverse order.
A problem report by Vicente Carro through personal communications, thanks a lot!
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/freestyle/intern/stroke/Operators.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp index df2c3dad175..b9213b86acb 100644 --- a/source/blender/freestyle/intern/stroke/Operators.cpp +++ b/source/blender/freestyle/intern/stroke/Operators.cpp @@ -1113,8 +1113,9 @@ static Stroke *createStroke(Interface1D& inter) if (!vprevious.isBegin()) --vprevious; - // collect a set of overlapping vertices (except the first one) + // collect a set of overlapping vertices std::vector<Interface0D *> overlapping_vertices; + overlapping_vertices.push_back(&(*v)); do { overlapping_vertices.push_back(&(*vnext)); current = next; @@ -1140,43 +1141,37 @@ static Stroke *createStroke(Interface1D& inter) delete stroke; return NULL; } + current = overlapping_vertices.front()->getPoint2D(); Vec2r dir(target - current); real dist = dir.norm(); real len = 1.0e-3; // default offset length int nvert = overlapping_vertices.size(); if (dist < len * nvert) { - len = dist / (nvert + 1); + len = dist / nvert; } dir.normalize(); Vec2r offset(dir * len); -#if 0 - if (G.debug & G_DEBUG_FREESTYLE) { - cout << "#vert " << nvert << " len " << len << " reverse? " << reverse << endl; - } -#endif // add the offset to the overlapping vertices StrokeVertex *sv; - std::vector<Interface0D *>::iterator it = overlapping_vertices.begin(), - itend = overlapping_vertices.end(); + std::vector<Interface0D *>::iterator it = overlapping_vertices.begin(); if (!reverse) { - int n = 1; - for (; it != itend; ++it) { + for (int n = 1; n < nvert; n++) { sv = dynamic_cast<StrokeVertex*>(*it); sv->setPoint(sv->getPoint() + offset * n); - ++n; + ++it; } } else { - int n = nvert; - for (; it != itend; ++it) { + int last = nvert - 1; + for (int n = 0; n < last; n++) { sv = dynamic_cast<StrokeVertex*>(*it); - sv->setPoint(sv->getPoint() + offset * n); - --n; + sv->setPoint(sv->getPoint() + offset * (last - n)); + ++it; } } if (vnext.isEnd()) - break; + break; } ++v; ++vnext; |