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).
This commit is contained in:
Tamito Kajiyama 2015-07-23 20:14:19 +09:00
parent 6ee2f79f33
commit 0e2bbd0904
Notes: blender-bot 2023-02-14 08:51:02 +01:00
Referenced by issue #45538, Blender crashes my moving modifier downward in stack
1 changed files with 12 additions and 2 deletions

View File

@ -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