forked from bartvdbraak/blender
Updates on the Parameter Editor mode:
* Added a new chain splitting option for dividing chains into pieces having a given curvilinear 2D length. * Rearranged the UI controls of chain splitting options according to the actual order of processing. * Made changes for converting each view edge into a chain in the case of not using chaining.
This commit is contained in:
parent
8a182d41b1
commit
32db495e50
@ -818,6 +818,23 @@ class Curvature2DAngleThresholdUP0D(UnaryPredicate0D):
|
||||
return True
|
||||
return False
|
||||
|
||||
class Length2DThresholdUP0D(UnaryPredicate0D):
|
||||
def __init__(self, length_limit):
|
||||
UnaryPredicate0D.__init__(self)
|
||||
self._length_limit = length_limit
|
||||
self._t = 0.0
|
||||
def getName(self):
|
||||
return "Length2DThresholdUP0D"
|
||||
def __call__(self, inter):
|
||||
t = inter.t() # curvilinear abscissa
|
||||
if t < self._t:
|
||||
self._t = 0.0
|
||||
return False
|
||||
if t - self._t < self._length_limit:
|
||||
return False
|
||||
self._t = t
|
||||
return True
|
||||
|
||||
# Seed for random number generation
|
||||
|
||||
class Seed:
|
||||
@ -939,6 +956,8 @@ def process(layer_name, lineset_name):
|
||||
Operators.bidirectionalChain(pySketchyChainSilhouetteIterator(linestyle.rounds))
|
||||
else:
|
||||
Operators.bidirectionalChain(pySketchyChainingIterator(linestyle.rounds))
|
||||
else:
|
||||
Operators.chain(ChainPredicateIterator(FalseUP1D(), FalseBP1D()), NotUP1D(upred))
|
||||
# split chains
|
||||
if linestyle.material_boundary:
|
||||
Operators.sequentialSplit(MaterialBoundaryUP0D())
|
||||
@ -946,6 +965,8 @@ def process(layer_name, lineset_name):
|
||||
min_angle = linestyle.min_angle if linestyle.use_min_angle else None
|
||||
max_angle = linestyle.max_angle if linestyle.use_max_angle else None
|
||||
Operators.sequentialSplit(Curvature2DAngleThresholdUP0D(min_angle, max_angle))
|
||||
if linestyle.use_split_length:
|
||||
Operators.sequentialSplit(Length2DThresholdUP0D(linestyle.split_length), 1.0)
|
||||
# select chains
|
||||
if linestyle.use_min_length or linestyle.use_max_length:
|
||||
min_length = linestyle.min_length if linestyle.use_min_length else None
|
||||
|
@ -598,30 +598,34 @@ class RENDER_PT_freestyle_linestyle(RenderButtonsPanel, Panel):
|
||||
# Splitting
|
||||
col = layout.column()
|
||||
col.label(text="Splitting:")
|
||||
sub = col.row()
|
||||
subcol = sub.column()
|
||||
subcol.prop(linestyle, "use_min_angle", text="Min Angle")
|
||||
subsub = subcol.split()
|
||||
subsub.prop(linestyle, "min_angle", text="")
|
||||
subsub.enabled = linestyle.use_min_angle
|
||||
subcol = sub.column()
|
||||
subcol.prop(linestyle, "use_max_angle", text="Max Angle")
|
||||
subsub = subcol.split()
|
||||
subsub.prop(linestyle, "max_angle", text="")
|
||||
subsub.enabled = linestyle.use_max_angle
|
||||
row = col.row()
|
||||
row.prop(linestyle, "material_boundary")
|
||||
row = col.row()
|
||||
sub = row.column()
|
||||
sub.prop(linestyle, "use_min_angle", text="Min 2D Angle")
|
||||
subsub = sub.split()
|
||||
subsub.prop(linestyle, "min_angle", text="")
|
||||
subsub.enabled = linestyle.use_min_angle
|
||||
sub = row.column()
|
||||
sub.prop(linestyle, "use_max_angle", text="Max 2D Angle")
|
||||
subsub = sub.split()
|
||||
subsub.prop(linestyle, "max_angle", text="")
|
||||
subsub.enabled = linestyle.use_max_angle
|
||||
col.prop(linestyle, "use_split_length", text="2D Length")
|
||||
row = col.row()
|
||||
row.prop(linestyle, "split_length", text="")
|
||||
row.enabled = linestyle.use_split_length
|
||||
# Selection
|
||||
col = layout.column()
|
||||
col.label(text="Selection:")
|
||||
sub = col.row()
|
||||
subcol = sub.column()
|
||||
subcol.prop(linestyle, "use_min_length", text="Min Length")
|
||||
subcol.prop(linestyle, "use_min_length", text="Min 2D Length")
|
||||
subsub = subcol.split()
|
||||
subsub.prop(linestyle, "min_length", text="")
|
||||
subsub.enabled = linestyle.use_min_length
|
||||
subcol = sub.column()
|
||||
subcol.prop(linestyle, "use_max_length", text="Max Length")
|
||||
subcol.prop(linestyle, "use_max_length", text="Max 2D Length")
|
||||
subsub = subcol.split()
|
||||
subsub.prop(linestyle, "max_length", text="")
|
||||
subsub.enabled = linestyle.use_max_length
|
||||
|
@ -79,6 +79,7 @@ static void default_linestyle_settings(FreestyleLineStyle *linestyle)
|
||||
linestyle->max_angle = 0.0f;
|
||||
linestyle->min_length = 0.0f;
|
||||
linestyle->max_length = 10000.0f;
|
||||
linestyle->split_length = 100;
|
||||
|
||||
linestyle->color_modifiers.first = linestyle->color_modifiers.last = NULL;
|
||||
linestyle->alpha_modifiers.first = linestyle->alpha_modifiers.last = NULL;
|
||||
@ -140,6 +141,7 @@ FreestyleLineStyle *FRS_copy_linestyle(FreestyleLineStyle *linestyle)
|
||||
new_linestyle->max_angle = linestyle->max_angle;
|
||||
new_linestyle->min_length = linestyle->min_length;
|
||||
new_linestyle->max_length = linestyle->max_length;
|
||||
new_linestyle->split_length = linestyle->split_length;
|
||||
new_linestyle->dash1 = linestyle->dash1;
|
||||
new_linestyle->gap1 = linestyle->gap1;
|
||||
new_linestyle->dash2 = linestyle->dash2;
|
||||
|
@ -360,6 +360,7 @@ typedef struct LineStyleThicknessModifier_Calligraphy {
|
||||
#define LS_NO_CHAINING 64
|
||||
#define LS_MIN_2D_ANGLE 128
|
||||
#define LS_MAX_2D_ANGLE 256
|
||||
#define LS_SPLIT_LENGTH 512
|
||||
|
||||
/* FreestyleLineStyle::chaining */
|
||||
#define LS_CHAINING_PLAIN 1
|
||||
@ -379,11 +380,11 @@ typedef struct FreestyleLineStyle {
|
||||
int flag, caps;
|
||||
int chaining;
|
||||
unsigned int rounds;
|
||||
float split_length;
|
||||
float min_angle, max_angle; /* for splitting */
|
||||
float min_length, max_length;
|
||||
unsigned short dash1, gap1, dash2, gap2, dash3, gap3;
|
||||
int panel; /* for UI */
|
||||
int pad1;
|
||||
|
||||
ListBase color_modifiers;
|
||||
ListBase alpha_modifiers;
|
||||
|
@ -823,6 +823,17 @@ static void rna_def_linestyle(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Same Object", "If true, only feature edges of the same object are joined");
|
||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "use_split_length", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_SPLIT_LENGTH);
|
||||
RNA_def_property_ui_text(prop, "Use Split Length", "Enable chain splitting by curvilinear 2D length");
|
||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "split_length", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "split_length");
|
||||
RNA_def_property_range(prop, 0.0f, 10000.0f);
|
||||
RNA_def_property_ui_text(prop, "Split Length", "Curvilinear 2D length for chain splitting");
|
||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "use_min_angle", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_MIN_2D_ANGLE);
|
||||
RNA_def_property_ui_text(prop, "Use Min 2D Angle", "Split chains at points with angles smaller than the minimum 2D angle");
|
||||
@ -853,7 +864,7 @@ static void rna_def_linestyle(BlenderRNA *brna)
|
||||
prop= RNA_def_property(srna, "min_length", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "min_length");
|
||||
RNA_def_property_range(prop, 0.0f, 10000.0f);
|
||||
RNA_def_property_ui_text(prop, "Min 2D Length", "Minimum 2D length for the selection of chains");
|
||||
RNA_def_property_ui_text(prop, "Min 2D Length", "Minimum curvilinear 2D length for the selection of chains");
|
||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "use_max_length", PROP_BOOLEAN, PROP_NONE);
|
||||
@ -864,7 +875,7 @@ static void rna_def_linestyle(BlenderRNA *brna)
|
||||
prop= RNA_def_property(srna, "max_length", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "max_length");
|
||||
RNA_def_property_range(prop, 0.0f, 10000.0f);
|
||||
RNA_def_property_ui_text(prop, "Max 2D Length", "Maximum 2D length for the selection of chains");
|
||||
RNA_def_property_ui_text(prop, "Max 2D Length", "Maximum curvilinear 2D length for the selection of chains");
|
||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "material_boundary", PROP_BOOLEAN, PROP_NONE);
|
||||
|
Loading…
Reference in New Issue
Block a user