[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53974] branches/soc-2008-mxcurioni: Fix for Stroke.Resample(float iSampling) and Stroke.UpdateLength() using

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Tue Jan 22 02:46:17 CET 2013


Revision: 53974
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53974
Author:   kjym3
Date:     2013-01-22 01:46:16 +0000 (Tue, 22 Jan 2013)
Log Message:
-----------
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().

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48510

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/shaders.py
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Stroke.cpp

Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/shaders.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/shaders.py	2013-01-21 19:33:58 UTC (rev 53973)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/shaders.py	2013-01-22 01:46:16 UTC (rev 53974)
@@ -577,6 +577,7 @@
 		return "pySamplingShader"
 	def shade(self, stroke):
 		stroke.Resample(float(self._sampling)) 
+		stroke.UpdateLength()
 
 class pyBackboneStretcherShader(StrokeShader):
 	def __init__(self, l):

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp	2013-01-21 19:33:58 UTC (rev 53973)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp	2013-01-22 01:46:16 UTC (rev 53974)
@@ -580,6 +580,7 @@
 int SamplingShader::shade(Stroke& stroke) const
 {
 	stroke.Resample(_sampling);
+	stroke.UpdateLength();
 	return 0;
 }
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Stroke.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Stroke.cpp	2013-01-21 19:33:58 UTC (rev 53973)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Stroke.cpp	2013-01-22 01:46:16 UTC (rev 53974)
@@ -605,6 +605,7 @@
 	//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 @@
 	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 @@
 
 		//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::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);
 	}
 }




More information about the Bf-blender-cvs mailing list