diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-01-22 05:46:16 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-01-22 05:46:16 +0400 |
commit | 1db5b6d283c4fde266738363dc6bffc59fb71df2 (patch) | |
tree | 449e846e5a70f14cad913b414419fecdd31a6a22 /source/blender | |
parent | 806e7273700dc6a9410a0d9ee262e6475830f9cf (diff) |
Fix for Stroke.Resample(float iSampling) and Stroke.UpdateLength() using
StrokeVertex.point2d() instead of .getPoint(). It is noted that .point2d()
returns a 3-dimensional vector representing a 2D-projected point, with the z
component indicating a normalized depth of the original 3D point, whereas
.getPoint() returns a plain 2-dimensional vector. This fix should have been
done in revision 48510...
Also made fix for callers of Stroke.Resample() not calling stroke.UpdateLength().
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp | 1 | ||||
-rw-r--r-- | source/blender/freestyle/intern/stroke/Stroke.cpp | 14 |
2 files changed, 8 insertions, 7 deletions
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); } } |