diff options
-rw-r--r-- | release/scripts/freestyle/style_modules/parameter_editor.py | 21 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/properties_render.py | 24 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/linestyle.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_linestyle_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_linestyle.c | 15 |
5 files changed, 52 insertions, 13 deletions
diff --git a/release/scripts/freestyle/style_modules/parameter_editor.py b/release/scripts/freestyle/style_modules/parameter_editor.py index 3e98d2dcd7a..421ca058a53 100644 --- a/release/scripts/freestyle/style_modules/parameter_editor.py +++ b/release/scripts/freestyle/style_modules/parameter_editor.py @@ -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 diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index c21308873a3..94c5c5c9b40 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -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() + 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 - subcol = sub.column() - subcol.prop(linestyle, "use_max_angle", text="Max Angle") - subsub = subcol.split() + 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, "material_boundary") + 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 diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index a16135e521f..3afdef79231 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -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; diff --git a/source/blender/makesdna/DNA_linestyle_types.h b/source/blender/makesdna/DNA_linestyle_types.h index aa28ecac77d..4ae3183e454 100644 --- a/source/blender/makesdna/DNA_linestyle_types.h +++ b/source/blender/makesdna/DNA_linestyle_types.h @@ -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; diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c index 407566ea09c..62287f2c882 100644 --- a/source/blender/makesrna/intern/rna_linestyle.c +++ b/source/blender/makesrna/intern/rna_linestyle.c @@ -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); |