From 0e2bbd090481591952816f7f20994218056700a4 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Thu, 23 Jul 2015 20:14:19 +0900 Subject: 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). --- release/scripts/freestyle/modules/freestyle/shaders.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'release/scripts') diff --git a/release/scripts/freestyle/modules/freestyle/shaders.py b/release/scripts/freestyle/modules/freestyle/shaders.py index 127db3fcd4b..633def38b5b 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 -- cgit v1.2.3