diff --git a/release/scripts/ui/properties_render.py b/release/scripts/ui/properties_render.py index 010c835c5d9..e94d17a0a18 100644 --- a/release/scripts/ui/properties_render.py +++ b/release/scripts/ui/properties_render.py @@ -197,6 +197,12 @@ class RENDER_PT_freestyle(RenderButtonsPanel): col.prop(freestyle, "mode", text="Control Mode") if freestyle.mode == "EDITOR": + col.label(text="Edge Detection Options:") + col.prop(freestyle, "crease_angle") + col.prop(freestyle, "sphere_radius") + sub = col.row() + sub.prop(freestyle, "dkr_epsilon") + sub.active = any(lineset.select_suggestive_contour for lineset in freestyle.linesets) lineset = freestyle.active_lineset @@ -220,31 +226,10 @@ class RENDER_PT_freestyle(RenderButtonsPanel): if lineset: col.prop(lineset, "name") + col.prop(lineset, "select_by_visibility") + col.prop(lineset, "select_by_edge_types") - row = col.row() - row.prop(lineset, "selection_negation", expand=True) - row = col.row() - row.prop(lineset, "selection_combination", expand=True) - - row = col.row() - sub = row.column() - sub.prop(lineset, "select_silhouette") - sub.prop(lineset, "select_border") - sub.prop(lineset, "select_crease") - sub.prop(lineset, "select_ridge") - sub.prop(lineset, "select_valley") - sub.prop(lineset, "select_suggestive_contour") - sub.prop(lineset, "select_material_boundary") - sub = row.column() - sub.prop(lineset, "select_contour") - sub.prop(lineset, "select_external_contour") - sub.prop(lineset, "select_visibility") - col.prop(lineset, "crease_angle") - col.prop(lineset, "sphere_radius") - if lineset.select_suggestive_contour: - col.label(text="Suggestive Contours:") - col.prop(lineset, "dkr_epsilon") - if lineset.select_visibility: + if lineset.select_by_visibility: col.label(text="Visibility:") sub = col.row(align=True) sub.prop(lineset, "visibility", expand=True) @@ -253,6 +238,26 @@ class RENDER_PT_freestyle(RenderButtonsPanel): sub.prop(lineset, "qi_start") sub.prop(lineset, "qi_end") + if lineset.select_by_edge_types: + col.label(text="Edge Types:") + row = col.row() + row.prop(lineset, "edge_type_negation", expand=True) + row = col.row() + row.prop(lineset, "edge_type_combination", expand=True) + + row = col.row() + sub = row.column() + sub.prop(lineset, "select_silhouette") + sub.prop(lineset, "select_border") + sub.prop(lineset, "select_crease") + sub.prop(lineset, "select_ridge") + sub.prop(lineset, "select_valley") + sub.prop(lineset, "select_suggestive_contour") + sub.prop(lineset, "select_material_boundary") + sub = row.column() + sub.prop(lineset, "select_contour") + sub.prop(lineset, "select_external_contour") + else: # freestyle.mode == "SCRIPT" col.prop(freestyle, "crease_angle") diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 13e5fcc7715..b208aa13d4f 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -373,12 +373,10 @@ extern "C" { lineset->linestyle = FRS_new_linestyle("LineStyle", NULL); lineset->flags |= FREESTYLE_LINESET_ENABLED; lineset->selection = 0; - lineset->crease_angle = 134.43f; - lineset->sphere_radius = 1.0f; - lineset->dkr_epsilon = 0.001f; lineset->qi = FREESTYLE_QI_VISIBLE; lineset->qi_start = 0; lineset->qi_end = 100; + lineset->edge_types = 0; lineset->objects.first = lineset->objects.last = NULL; if (lineset_index > 0) sprintf(lineset->name, "LineSet %i", lineset_index+1); diff --git a/source/blender/makesdna/DNA_freestyle_types.h b/source/blender/makesdna/DNA_freestyle_types.h index 19a16ab8868..e415d580c4d 100644 --- a/source/blender/makesdna/DNA_freestyle_types.h +++ b/source/blender/makesdna/DNA_freestyle_types.h @@ -16,20 +16,23 @@ /* FreestyleLineSet::flags */ #define FREESTYLE_LINESET_CURRENT 1 #define FREESTYLE_LINESET_ENABLED 2 -#define FREESTYLE_LINESET_SEL_NOT 4 -#define FREESTYLE_LINESET_SEL_OR 8 +#define FREESTYLE_LINESET_FE_NOT 4 +#define FREESTYLE_LINESET_FE_OR 8 /* FreestyleLineSet::selection */ -#define FREESTYLE_SEL_SILHOUETTE 1 -#define FREESTYLE_SEL_BORDER 2 -#define FREESTYLE_SEL_CREASE 4 -#define FREESTYLE_SEL_RIDGE 8 -#define FREESTYLE_SEL_VALLEY 16 -#define FREESTYLE_SEL_SUGGESTIVE_CONTOUR 32 -#define FREESTYLE_SEL_MATERIAL_BOUNDARY 64 -#define FREESTYLE_SEL_CONTOUR 128 -#define FREESTYLE_SEL_EXTERNAL_CONTOUR 256 -#define FREESTYLE_SEL_VISIBILITY 512 +#define FREESTYLE_SEL_VISIBILITY 1 +#define FREESTYLE_SEL_EDGE_TYPES 2 + +/* FreestyleLineSet::fedge_types */ +#define FREESTYLE_FE_SILHOUETTE 1 +#define FREESTYLE_FE_BORDER 2 +#define FREESTYLE_FE_CREASE 4 +#define FREESTYLE_FE_RIDGE 8 +#define FREESTYLE_FE_VALLEY 16 +#define FREESTYLE_FE_SUGGESTIVE_CONTOUR 32 +#define FREESTYLE_FE_MATERIAL_BOUNDARY 64 +#define FREESTYLE_FE_CONTOUR 128 +#define FREESTYLE_FE_EXTERNAL_CONTOUR 512 /* FreestyleLineSet::qi */ #define FREESTYLE_QI_VISIBLE 1 @@ -46,14 +49,12 @@ typedef struct FreestyleLineSet { char name[32]; /* line set name */ int flags; - int selection; /* feature edge selection */ - float crease_angle; - float sphere_radius; - float dkr_epsilon; + int selection; /* selection criteria */ short qi; /* quantitative invisibility */ - short pad; + short pad1; int qi_start, qi_end; + int edge_types; /* feature edge types */ FreestyleLineStyle *linestyle; /* line style */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 8bdf2c243f1..2e4b0ee1c66 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1535,14 +1535,14 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem selection_negation_items[] = { - {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges satisfying the given selection criteria."}, - {FREESTYLE_LINESET_SEL_NOT, "EXCLUSIVE", 0, "Exclusive", "Select feature edges not satisfying the given selection criteria."}, + static EnumPropertyItem negation_items[] = { + {0, "INCLUSIVE", 0, "Inclusive", "Select feature edges satisfying the given edge type conditions."}, + {FREESTYLE_LINESET_FE_NOT, "EXCLUSIVE", 0, "Exclusive", "Select feature edges not satisfying the given edge type conditions."}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem selection_combination_items[] = { - {0, "AND", 0, "Logical AND", "Combine selection criteria by logical AND (logical conjunction)."}, - {FREESTYLE_LINESET_SEL_OR, "OR", 0, "Logical OR", "Combine selection criteria by logical OR (logical disjunction)."}, + static EnumPropertyItem combination_items[] = { + {0, "AND", 0, "Logical AND", "Combine feature edge type conditions by logical AND (logical conjunction)."}, + {FREESTYLE_LINESET_FE_OR, "OR", 0, "Logical OR", "Combine feature edge type conditions by logical OR (logical disjunction)."}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem freestyle_ui_mode_items[] = { @@ -1551,9 +1551,9 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem visibility_items[] ={ - {FREESTYLE_QI_VISIBLE, "VISIBLE", 0, "Visible", "Select visible edges."}, - {FREESTYLE_QI_HIDDEN, "HIDDEN", 0, "Hidden", "Select hidden edges."}, - {FREESTYLE_QI_RANGE, "RANGE", 0, "QI Range", "Select edges within a range of quantitative invisibility (QI) values."}, + {FREESTYLE_QI_VISIBLE, "VISIBLE", 0, "Visible", "Select visible feature edges."}, + {FREESTYLE_QI_HIDDEN, "HIDDEN", 0, "Hidden", "Select hidden feature edges."}, + {FREESTYLE_QI_RANGE, "RANGE", 0, "QI Range", "Select feature edges within a range of quantitative invisibility (QI) values."}, {0, NULL, 0, NULL, NULL}}; /* FreestyleLineSet */ @@ -1581,16 +1581,26 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Enabled", "Enable or disable the line set."); RNA_def_property_update(prop, NC_SCENE, NULL); - prop= RNA_def_property(srna, "selection_negation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags"); - RNA_def_property_enum_items(prop, selection_negation_items); - RNA_def_property_ui_text(prop, "Selection Negation", "Set the negation operation for selection criteria."); + prop= RNA_def_property(srna, "select_by_visibility", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_VISIBILITY); + RNA_def_property_ui_text(prop, "Selection by Visibility", "Select feature edges based on visibility."); RNA_def_property_update(prop, NC_SCENE, NULL); - prop= RNA_def_property(srna, "selection_combination", PROP_ENUM, PROP_NONE); + prop= RNA_def_property(srna, "select_by_edge_types", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_EDGE_TYPES); + RNA_def_property_ui_text(prop, "Selection by Edge Types", "Select feature edges based on edge types."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "edge_type_negation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags"); - RNA_def_property_enum_items(prop, selection_combination_items); - RNA_def_property_ui_text(prop, "Selection Combination", "Set the combination operation for selection criteria."); + RNA_def_property_enum_items(prop, negation_items); + RNA_def_property_ui_text(prop, "Edge Type Negation", "Set the negation operation for conditions on feature edge types."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "edge_type_combination", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags"); + RNA_def_property_enum_items(prop, combination_items); + RNA_def_property_ui_text(prop, "Edge Type Combination", "Set the combination operation for conditions on feature edge types."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); @@ -1599,77 +1609,54 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Target Objects", "A list of objects on which stylized lines are drawn."); prop= RNA_def_property(srna, "select_silhouette", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_SILHOUETTE); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_SILHOUETTE); RNA_def_property_ui_text(prop, "Silhouette", "Select silhouette edges."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "select_border", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_BORDER); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_BORDER); RNA_def_property_ui_text(prop, "Border", "Select border edges."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "select_crease", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_CREASE); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_CREASE); RNA_def_property_ui_text(prop, "Crease", "Select crease edges."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "select_ridge", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_RIDGE); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_RIDGE); RNA_def_property_ui_text(prop, "Ridge", "Select ridges."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "select_valley", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_VALLEY); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_VALLEY); RNA_def_property_ui_text(prop, "Valley", "Select valleys."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "select_suggestive_contour", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_SUGGESTIVE_CONTOUR); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_SUGGESTIVE_CONTOUR); RNA_def_property_ui_text(prop, "Suggestive Contour", "Select suggestive contours."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "select_material_boundary", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_MATERIAL_BOUNDARY); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_MATERIAL_BOUNDARY); RNA_def_property_ui_text(prop, "Material Boundary", "Select edges at material boundaries."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "select_contour", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_CONTOUR); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_CONTOUR); RNA_def_property_ui_text(prop, "Contour", "Select contours."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "select_external_contour", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_EXTERNAL_CONTOUR); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", FREESTYLE_FE_EXTERNAL_CONTOUR); RNA_def_property_ui_text(prop, "External Contour", "Select external contours."); RNA_def_property_update(prop, NC_SCENE, NULL); - prop= RNA_def_property(srna, "select_visibility", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "selection", FREESTYLE_SEL_VISIBILITY); - RNA_def_property_ui_text(prop, "Visibility", "Select edges based on visibility."); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop= RNA_def_property(srna, "crease_angle", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "crease_angle"); - RNA_def_property_range(prop, 0.0, 180.0); - RNA_def_property_ui_text(prop, "Crease Angle", "Angular threshold in degrees (between 0 and 180) for detecting crease edges."); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop= RNA_def_property(srna, "sphere_radius", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "sphere_radius"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Sphere Radius", "Sphere radius for computing curvatures."); - RNA_def_property_update(prop, NC_SCENE, NULL); - - prop= RNA_def_property(srna, "dkr_epsilon", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dkr_epsilon"); - RNA_def_property_range(prop, 0.0, 1000.0); - RNA_def_property_ui_text(prop, "Kr Derivative Epsilon", "Kr derivative epsilon for computing suggestive contours."); - RNA_def_property_update(prop, NC_SCENE, NULL); - prop= RNA_def_property(srna, "visibility", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "qi"); RNA_def_property_enum_items(prop, visibility_items); - RNA_def_property_ui_text(prop, "Visibility", "Select edges based on visibility."); + RNA_def_property_ui_text(prop, "Visibility", "Determine how to use visibility for feature edge selection."); RNA_def_property_update(prop, NC_SCENE, NULL); prop= RNA_def_property(srna, "qi_start", PROP_INT, PROP_UNSIGNED);