Freestyle: New options for sorting to arrange the stacking order of lines.
Line styles now have a set of new options for rearranging the stacking order of lines. This gives artists more control to determine which lines should be drawn on top of others. Two available sort keys are the distance from camera and curvilinear 2D length. Since the distance of a line from camera may vary over vertices, another option called integration type is used to compute the sort key for a line from the values computed at individual vertices. Available integration types are MEAN, MIN, MAX, FIRST and LAST (see the tool tips for more detail).
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
from freestyle.types import (
|
||||
BinaryPredicate1D,
|
||||
IntegrationType,
|
||||
Interface0DIterator,
|
||||
Nature,
|
||||
Noise,
|
||||
@@ -51,6 +52,8 @@ from freestyle.predicates import (
|
||||
ExternalContourUP1D,
|
||||
FalseBP1D,
|
||||
FalseUP1D,
|
||||
Length2DBP1D,
|
||||
NotBP1D,
|
||||
NotUP1D,
|
||||
OrUP1D,
|
||||
QuantitativeInvisibilityUP1D,
|
||||
@@ -58,6 +61,7 @@ from freestyle.predicates import (
|
||||
TrueUP1D,
|
||||
WithinImageBoundaryUP1D,
|
||||
pyNatureUP1D,
|
||||
pyZBP1D,
|
||||
)
|
||||
from freestyle.shaders import (
|
||||
BackboneStretcherShader,
|
||||
@@ -1163,6 +1167,14 @@ class StrokeCleaner(StrokeShader):
|
||||
stroke.update_length()
|
||||
|
||||
|
||||
integration_types = {
|
||||
'MEAN': IntegrationType.MEAN,
|
||||
'MIN': IntegrationType.MIN,
|
||||
'MAX': IntegrationType.MAX,
|
||||
'FIRST': IntegrationType.FIRST,
|
||||
'LAST': IntegrationType.LAST}
|
||||
|
||||
|
||||
# main function for parameter processing
|
||||
|
||||
def process(layer_name, lineset_name):
|
||||
@@ -1291,6 +1303,16 @@ def process(layer_name, lineset_name):
|
||||
length_min = linestyle.length_min if linestyle.use_length_min else None
|
||||
length_max = linestyle.length_max if linestyle.use_length_max else None
|
||||
Operators.select(LengthThresholdUP1D(length_min, length_max))
|
||||
# sort selected chains
|
||||
if linestyle.use_sorting:
|
||||
integration = integration_types.get(linestyle.integration_type, IntegrationType.MEAN)
|
||||
if linestyle.sort_key == 'DISTANCE_FROM_CAMERA':
|
||||
bpred = pyZBP1D(integration)
|
||||
elif linestyle.sort_key == '2D_LENGTH':
|
||||
bpred = Length2DBP1D()
|
||||
if linestyle.sort_order == 'REVERSE':
|
||||
bpred = NotBP1D(bpred)
|
||||
Operators.sort(bpred)
|
||||
# prepare a list of stroke shaders
|
||||
shaders_list = []
|
||||
###
|
||||
|
Reference in New Issue
Block a user