diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-02-22 04:39:56 +0300 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-02-22 04:39:56 +0300 |
commit | ecd76d99d64d76846f9f1ed24c54a82b6e9ad041 (patch) | |
tree | c58c376e7c82cbb42838630c3a109cdf16019b84 /source/blender/freestyle/intern/stroke/Operators.cpp | |
parent | 70aa63306ad3ec1402275ed623b745d06d14db18 (diff) |
Consolidation of stroke drawing.
Fixed a complicated bug that caused a failure of CurvePoint::getFEdge()
which had affected a number of C/Python API functions such as MaterialF0D.
The current view map building procedure may generate ViewEdges whose
two-dimensional (2D) length is almost or exactly zero. Such a zero-length
ViewEdge is possibly chained with other ViewEdges to form a stroke. When
the stroke is finally generated by Operators::create(), an attempt to remove
redundant vertices at the same 2D point is made. This possibly breaks the
links of ViewEdges on top of which the stroke has been built, and eventually
result in a fatal error of CurvePoint::getFEdge() when API functions that
rely on this method are called from within a style module.
The present fix addresses this issue by automatically removing zero-length
ViewEdges (and Chains of them) before stroke drawing is started and after
splitting is performed (e.g., using Operators::sequentialSplit()).
Diffstat (limited to 'source/blender/freestyle/intern/stroke/Operators.cpp')
-rwxr-xr-x | source/blender/freestyle/intern/stroke/Operators.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp index 4f6fb08fa0e..72380656322 100755 --- a/source/blender/freestyle/intern/stroke/Operators.cpp +++ b/source/blender/freestyle/intern/stroke/Operators.cpp @@ -464,7 +464,19 @@ int Operators::sequentialSplit(UnaryPredicate0D& pred, delete (*cit); } _current_chains_set.clear(); +#if 0 _current_chains_set = splitted_chains; +#else + for (cit = splitted_chains.begin(), citend = splitted_chains.end(); + cit != citend; + ++cit) { + if ((*cit)->getLength2D() < M_EPSILON) { + delete (*cit); + continue; + } + _current_chains_set.push_back(*cit); + } +#endif splitted_chains.clear(); if (!_current_chains_set.empty()) @@ -554,7 +566,19 @@ int Operators::sequentialSplit(UnaryPredicate0D& startingPred, UnaryPredicate0D& delete (*cit); } _current_chains_set.clear(); +#if 0 _current_chains_set = splitted_chains; +#else + for (cit = splitted_chains.begin(), citend = splitted_chains.end(); + cit != citend; + ++cit) { + if ((*cit)->getLength2D() < M_EPSILON) { + delete (*cit); + continue; + } + _current_chains_set.push_back(*cit); + } +#endif splitted_chains.clear(); if (!_current_chains_set.empty()) @@ -711,7 +735,19 @@ int Operators::recursiveSplit(UnaryFunction0D<double>& func, UnaryPredicate1D& p } _current_chains_set.clear(); +#if 0 _current_chains_set = newChains; +#else + for (cit = newChains.begin(), citend = newChains.end(); + cit != citend; + ++cit) { + if ((*cit)->getLength2D() < M_EPSILON) { + delete (*cit); + continue; + } + _current_chains_set.push_back(*cit); + } +#endif newChains.clear(); if (!_current_chains_set.empty()) @@ -868,7 +904,19 @@ int Operators::recursiveSplit(UnaryFunction0D<double>& func, UnaryPredicate0D& p } _current_chains_set.clear(); +#if 0 _current_chains_set = newChains; +#else + for (cit = newChains.begin(), citend = newChains.end(); + cit != citend; + ++cit) { + if ((*cit)->getLength2D() < M_EPSILON) { + delete (*cit); + continue; + } + _current_chains_set.push_back(*cit); + } +#endif newChains.clear(); if (!_current_chains_set.empty()) @@ -944,6 +992,13 @@ Stroke* createStroke(Interface1D& inter) { // previous one. We remove it to avoid having to deal // with this kind of singularities in the strip creation delete stroke_vertex; + /* + * This seems a wrong place to clean stroke topology, since just + * deleting this `stroke_vertex' possibly breaks the continuity of + * the underlying series of FEdges on top of which the stroke has + * been built. Such a break of linked FEdges will cause a failure + * of CurvePoint::getFEdge(). (22 Feb 2011, T.K.) + */ }else{ currentCurvilignAbscissa += vec_tmp.norm(); stroke_vertex->setCurvilinearAbscissa(currentCurvilignAbscissa); @@ -1037,9 +1092,19 @@ void Operators::reset() { ++it) delete *it; _current_chains_set.clear(); +#if 0 _current_view_edges_set.insert(_current_view_edges_set.begin(), vm->ViewEdges().begin(), vm->ViewEdges().end()); +#else + ViewMap::viewedges_container& vedges = vm->ViewEdges(); + ViewMap::viewedges_container::iterator ve=vedges.begin(), veend=vedges.end(); + for (; ve != veend; ++ve) { + if ((*ve)->getLength2D() < M_EPSILON) + continue; + _current_view_edges_set.push_back(*ve); + } +#endif _current_set = &_current_view_edges_set; _current_strokes_set.clear(); } |