diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-10-30 20:00:35 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-10-30 20:00:35 +0400 |
commit | f0acdcf13526046236ce561736521100cba58ff1 (patch) | |
tree | 519edbd9f908e2f5c8fea76db1b5e5b12df13ea9 /source/blender/freestyle/intern/stroke/Stroke.cpp | |
parent | 1f252288574f03205f329689693a0f483a894f89 (diff) |
Fix for stroke rendering instability with stroke geometry shaders.
* Stroke::Resample(int nPoints) was not properly working when a wrong
value was returned from Stroke::getLength2D(), resulting in repeated
warning messages "Warning: incorrect points number" during stroke
rendering. The main cause was that stroke geometry shaders did not
update the two-dimensional (2D) length (also referred to as curvilinear
abscissa) after they modified the 2D points of stroke vertices. Now
all stroke geometry shaders make explicit calls for Stroke::UpdateLength()
that has been introduced for recomputing the 2D length. Many thanks to
Josef who reported the problem together with sample .blend files for
reproducing the issue.
* Missing Python wrapper of Stroke::getLength2D() was added.
Diffstat (limited to 'source/blender/freestyle/intern/stroke/Stroke.cpp')
-rwxr-xr-x | source/blender/freestyle/intern/stroke/Stroke.cpp | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index f6cefdfee34..0c852d0e209 100755 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -674,28 +674,7 @@ void Stroke::RemoveVertex(StrokeVertex *iVertex) break; } } - // recompute various values (length, curvilign abscissa) - float curvabsc = 0.f; - it=_Vertices.begin(); - itend=_Vertices.end(); - vertex_container::iterator previous=it; - for(; - (it!=itend); - ++it) - { - if(it != previous) - curvabsc += ((*it)->point2d()-(*previous)->point2d()).norm(); - (*it)->setCurvilinearAbscissa(curvabsc); - previous = it; - } - _Length = curvabsc; - it=_Vertices.begin(); - for(; - (it!=itend); - ++it) - { - (*it)->setStrokeLength(_Length); - } + UpdateLength(); } void Stroke::InsertVertex(StrokeVertex *iVertex, StrokeInternal::StrokeVertexIterator next) @@ -704,10 +683,14 @@ void Stroke::InsertVertex(StrokeVertex *iVertex, StrokeInternal::StrokeVertexIte vertex_container::iterator itnext = next.getIt(); _Vertices.insert(itnext, iVertex); + UpdateLength(); +} + +void Stroke::UpdateLength() +{ // recompute various values (length, curvilign abscissa) float curvabsc = 0.f; - it=_Vertices.begin(); - itend=_Vertices.end(); + vertex_container::iterator it=_Vertices.begin(), itend=_Vertices.end(); vertex_container::iterator previous=it; for(; (it!=itend); |