[Bf-blender-cvs] [0e2bbd0] master: Freestyle: Fix for round/square stroke caps causing line thinning.

Tamito Kajiyama noreply at git.blender.org
Thu Jul 23 13:32:50 CEST 2015


Commit: 0e2bbd090481591952816f7f20994218056700a4
Author: Tamito Kajiyama
Date:   Thu Jul 23 20:14:19 2015 +0900
Branches: master
https://developer.blender.org/rB0e2bbd090481591952816f7f20994218056700a4

Freestyle: Fix for round/square stroke caps causing line thinning.

This is a regression introduced in rBce729677db3e and rBb408d8af31c9.

RoundCapShader and SquareCapsShader had to remove (almost) overlapping
stroke vertices to avoid sudden thinning of line thickness.  For instance,
the test .blend file from https://developer.blender.org/T36425#231460
suffered from the reported line thinning (although T36425 was originally
caused by a different bug).

===================================================================

M	release/scripts/freestyle/modules/freestyle/shaders.py

===================================================================

diff --git a/release/scripts/freestyle/modules/freestyle/shaders.py b/release/scripts/freestyle/modules/freestyle/shaders.py
index 127db3f..633def3 100644
--- a/release/scripts/freestyle/modules/freestyle/shaders.py
+++ b/release/scripts/freestyle/modules/freestyle/shaders.py
@@ -139,6 +139,7 @@ from freestyle.predicates import (
 from freestyle.utils import (
     bound,
     BoundingBox,
+    pairwise,
     phase_to_direction,
     )
 
@@ -1131,6 +1132,13 @@ class pyBluePrintDirectedSquaresShader(StrokeShader):
 # -- various (used in the parameter editor) -- #
 
 
+def iter_stroke_vertices(stroke, epsilon=1e-6):
+    yield stroke[0]
+    for prev, svert in pairwise(stroke):
+        if (prev.point - svert.point).length > epsilon:
+            yield svert
+
+
 class RoundCapShader(StrokeShader):
     def round_cap_thickness(self, x):
         x = max(0.0, min(x, 1.0))
@@ -1138,7 +1146,8 @@ class RoundCapShader(StrokeShader):
 
     def shade(self, stroke):
         # save the location and attribute of stroke vertices
-        buffer = tuple((Vector(sv.point), StrokeAttribute(sv.attribute)) for sv in stroke)
+        buffer = tuple((Vector(sv.point), StrokeAttribute(sv.attribute))
+                       for sv in iter_stroke_vertices(stroke))
         nverts = len(buffer)
         if nverts < 2:
             return
@@ -1186,7 +1195,8 @@ class RoundCapShader(StrokeShader):
 class SquareCapShader(StrokeShader):
     def shade(self, stroke):
         # save the location and attribute of stroke vertices
-        buffer = tuple((Vector(sv.point), StrokeAttribute(sv.attribute)) for sv in stroke)
+        buffer = tuple((Vector(sv.point), StrokeAttribute(sv.attribute))
+                       for sv in iter_stroke_vertices(stroke))
         nverts = len(buffer)
         if nverts < 2:
             return




More information about the Bf-blender-cvs mailing list