Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2015-07-23 14:14:19 +0300
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2015-07-23 14:29:23 +0300
commit0e2bbd090481591952816f7f20994218056700a4 (patch)
tree8b47bdc66ed2e449e842bc38c150bf76e489b21b /release/scripts/freestyle
parent6ee2f79f33589e86795b95a523d6f6e63262c728 (diff)
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).
Diffstat (limited to 'release/scripts/freestyle')
-rw-r--r--release/scripts/freestyle/modules/freestyle/shaders.py14
1 files changed, 12 insertions, 2 deletions
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