diff options
-rw-r--r-- | release/scripts/freestyle/style_modules/shaders.py | 1 | ||||
-rw-r--r-- | source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp | 1 | ||||
-rw-r--r-- | source/blender/freestyle/intern/stroke/Stroke.cpp | 14 |
3 files changed, 9 insertions, 7 deletions
diff --git a/release/scripts/freestyle/style_modules/shaders.py b/release/scripts/freestyle/style_modules/shaders.py index 70941477a7b..f05042f8332 100644 --- a/release/scripts/freestyle/style_modules/shaders.py +++ b/release/scripts/freestyle/style_modules/shaders.py @@ -577,6 +577,7 @@ class pySamplingShader(StrokeShader): return "pySamplingShader" def shade(self, stroke): stroke.Resample(float(self._sampling)) + stroke.UpdateLength() class pyBackboneStretcherShader(StrokeShader): def __init__(self, l): diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp index fd070a59699..dd6e6dc317e 100644 --- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp +++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp @@ -580,6 +580,7 @@ int BackboneStretcherShader::shade(Stroke& stroke) const int SamplingShader::shade(Stroke& stroke) const { stroke.Resample(_sampling); + stroke.UpdateLength(); return 0; } diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index 96e3b7aac48..7e6aa62ac59 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -605,6 +605,7 @@ void Stroke::Resample(float iSampling) //real curvilinearLength = 0.0f; vertex_container newVertices; real t = 0.0f; + const real limit = 0.99; StrokeVertex *newVertex = NULL; StrokeInternal::StrokeVertexIterator it = strokeVerticesBegin(); StrokeInternal::StrokeVertexIterator next = it; @@ -612,9 +613,9 @@ void Stroke::Resample(float iSampling) StrokeInternal::StrokeVertexIterator itend = strokeVerticesEnd(); while ((it != itend) && (next != itend)) { newVertices.push_back(&(*it)); - Vec3r a((it)->point2d()); - Vec3r b((next)->point2d()); - Vec3r vec_tmp(b - a); + Vec2r a((it)->getPoint()); + Vec2r b((next)->getPoint()); + Vec2r vec_tmp(b - a); real norm_var = vec_tmp.norm(); if (norm_var <= _sampling) { //curvilinearLength += norm_var; @@ -625,7 +626,6 @@ void Stroke::Resample(float iSampling) //curvilinearLength += _sampling; t = _sampling / norm_var; - float limit = 0.99f; while (t < limit) { newVertex = new StrokeVertex(&(*it), &(*next), t); //newVertex->setCurvilinearAbscissa(curvilinearLength); @@ -673,17 +673,17 @@ void Stroke::InsertVertex(StrokeVertex *iVertex, StrokeInternal::StrokeVertexIte void Stroke::UpdateLength() { - // recompute various values (length, curvilign abscissa) + // recompute curvilinear abscissa and stroke length float curvabsc = 0.0f; vertex_container::iterator it = _Vertices.begin(), itend = _Vertices.end(); vertex_container::iterator previous = it; for (; it != itend; ++it) { - curvabsc += ((*it)->point2d() - (*previous)->point2d()).norm(); + curvabsc += ((*it)->getPoint() - (*previous)->getPoint()).norm(); (*it)->setCurvilinearAbscissa(curvabsc); previous = it; } _Length = curvabsc; - for (; it != itend; ++it) { + for (it = _Vertices.begin(); it != itend; ++it) { (*it)->setStrokeLength(_Length); } } |