[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38041] branches/soc-2008-mxcurioni/ release/scripts/freestyle/style_modules/parameter_editor.py: Fixed cap shaders that failed with zero length strokes.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Sat Jul 2 18:27:53 CEST 2011


Revision: 38041
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38041
Author:   kjym3
Date:     2011-07-02 16:27:52 +0000 (Sat, 02 Jul 2011)
Log Message:
-----------
Fixed cap shaders that failed with zero length strokes.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py

Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py	2011-07-02 16:07:35 UTC (rev 38040)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py	2011-07-02 16:27:52 UTC (rev 38041)
@@ -333,8 +333,13 @@
 
 def iter_stroke_vertices(stroke):
     it = stroke.strokeVerticesBegin()
+    prev_p = None
     while not it.isEnd():
-        yield it.getObject()
+        sv = it.getObject()
+        p = sv.getPoint()
+        if prev_p is None or (prev_p - p).length > 1e-6:
+            yield sv
+            prev_p = p
         it.increment()
 
 class RoundCapShader(StrokeShader):
@@ -346,6 +351,8 @@
         buffer = []
         for sv in iter_stroke_vertices(stroke):
             buffer.append((sv.getPoint(), sv.attribute()))
+        if len(buffer) < 2:
+            return
         # calculate the number of additional vertices to form caps
         R, L = stroke[0].attribute().getThicknessRL()
         caplen_beg = (R + L) / 2.0
@@ -394,6 +401,8 @@
         buffer = []
         for sv in iter_stroke_vertices(stroke):
             buffer.append((sv.getPoint(), sv.attribute()))
+        if len(buffer) < 2:
+            return
         # calculate the number of additional vertices to form caps
         R, L = stroke[0].attribute().getThicknessRL()
         caplen_beg = (R + L) / 2.0




More information about the Bf-blender-cvs mailing list