diff options
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 93 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sculpt_paint.c | 83 |
3 files changed, 136 insertions, 42 deletions
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 66dcbab3a35..1bff91ca84e 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -92,6 +92,19 @@ static const EnumPropertyItem rna_enum_brush_texture_slot_map_texture_mode_items #endif /* clang-format off */ +/* Note: we don't actually turn these into a single enum bitmask property, + * instead we construct individual boolean properties. */ +const EnumPropertyItem RNA_automasking_flags[] = { + {BRUSH_AUTOMASKING_TOPOLOGY, "use_automasking_topology", 0,"Topology", "Affect only vertices connected to the active vertex under the brush"}, + {BRUSH_AUTOMASKING_FACE_SETS, "use_automasking_face_sets", 0,"Face Sets", "Affect only vertices that share Face Sets with the active vertex"}, + {BRUSH_AUTOMASKING_BOUNDARY_EDGES, "use_automasking_boundary_edges", 0,"Mesh Boundary Auto-Masking", "Do not affect non manifold boundary edges"}, + {BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS, "use_automasking_boundary_face_sets", 0,"Face Sets Boundary Automasking", "Do not affect vertices that belong to a Face Set boundary"}, + {BRUSH_AUTOMASKING_CAVITY_NORMAL, "use_automasking_cavity", 0,"Cavity Mask", "Do not affect vertices on peaks, based on the surface curvature"}, + {BRUSH_AUTOMASKING_CAVITY_INVERTED, "use_automasking_cavity_inverted", 0,"Inverted Cavity Mask", "Do not affect vertices within crevices, based on the surface curvature"}, + {BRUSH_AUTOMASKING_CAVITY_USE_CURVE, "use_automasking_custom_cavity_curve", 0,"Custom Cavity Curve", "Use custom curve"}, + {0, NULL, 0, NULL, NULL} +}; + const EnumPropertyItem rna_enum_brush_sculpt_tool_items[] = { {SCULPT_TOOL_DRAW, "DRAW", ICON_BRUSH_SCULPT_DRAW, "Draw", ""}, {SCULPT_TOOL_DRAW_SHARP, "DRAW_SHARP", ICON_BRUSH_SCULPT_DRAW, "Draw Sharp", ""}, @@ -1084,6 +1097,32 @@ static const EnumPropertyItem *rna_BrushTextureSlot_map_mode_itemf(bContext *C, # undef rna_enum_brush_texture_slot_map_sculpt_mode_items } +static void rna_Brush_automasking_invert_cavity_set(PointerRNA *ptr, bool val) +{ + Brush *brush = (Brush *)ptr->data; + + if (val) { + brush->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL; + brush->automasking_flags |= BRUSH_AUTOMASKING_CAVITY_INVERTED; + } + else { + brush->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_INVERTED; + } +} + +static void rna_Brush_automasking_cavity_set(PointerRNA *ptr, bool val) +{ + Brush *brush = (Brush *)ptr->data; + + if (val) { + brush->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_INVERTED; + brush->automasking_flags |= BRUSH_AUTOMASKING_CAVITY_NORMAL; + } + else { + brush->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL; + } +} + #else static void rna_def_brush_texture_slot(BlenderRNA *brna) @@ -3192,32 +3231,44 @@ static void rna_def_brush(BlenderRNA *brna) "When locked keep using the plane origin of surface where stroke was initiated"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_automasking_topology", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_TOPOLOGY); - RNA_def_property_ui_text(prop, - "Topology Auto-Masking", - "Affect only vertices connected to the active vertex under the brush"); - RNA_def_property_update(prop, 0, "rna_Brush_update"); + const EnumPropertyItem *entry = RNA_automasking_flags; + do { + prop = RNA_def_property(srna, entry->identifier, PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", entry->value); + RNA_def_property_ui_text(prop, entry->name, entry->description); - prop = RNA_def_property(srna, "use_automasking_face_sets", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_FACE_SETS); - RNA_def_property_ui_text(prop, - "Face Sets Auto-Masking", - "Affect only vertices that share Face Sets with the active vertex"); + if (entry->value == BRUSH_AUTOMASKING_CAVITY_NORMAL) { + RNA_def_property_boolean_funcs(prop, NULL, "rna_Brush_automasking_cavity_set"); + } + else if (entry->value == BRUSH_AUTOMASKING_CAVITY_INVERTED) { + RNA_def_property_boolean_funcs(prop, NULL, "rna_Brush_automasking_invert_cavity_set"); + } + + RNA_def_property_update(prop, 0, "rna_Brush_update"); + } while ((++entry)->identifier); + + + prop = RNA_def_property(srna, "automasking_cavity_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "automasking_cavity_factor"); + RNA_def_property_ui_text(prop, "Cavity Factor", "The contrast of the cavity mask"); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3); + RNA_def_property_range(prop, 0.0f, 5.0f); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_automasking_boundary_edges", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_EDGES); - RNA_def_property_ui_text( - prop, "Mesh Boundary Auto-Masking", "Do not affect non manifold boundary edges"); + prop = RNA_def_property(srna, "automasking_cavity_blur_steps", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "automasking_cavity_blur_steps"); + RNA_def_property_ui_text(prop, "Blur Steps", "The number of times the cavity mask is blurred."); + RNA_def_property_range(prop, 0.0f, 25.0f); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop = RNA_def_property(srna, "use_automasking_boundary_face_sets", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna( - prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS); - RNA_def_property_ui_text(prop, - "Face Sets Boundary Automasking", - "Do not affect vertices that belong to a Face Set boundary"); + prop = RNA_def_property(srna, "automasking_cavity_curve", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "automasking_cavity_curve"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Cavity Curve", "Curve used for the sensitivity"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_update(prop, 0, "rna_Brush_update"); prop = RNA_def_property(srna, "use_scene_spacing", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 3d5c1810558..8e652753ec0 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -24,7 +24,7 @@ struct AssetLibraryReference; struct FreestyleSettings; struct ID; struct IDOverrideLibrary; -struct IDOverrideLibraryPropertyOperation; +struct IDOverrideLibraryenOperation; struct IDProperty; struct Main; struct Object; diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index a4298c8c3aa..60f2b289af0 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -9,6 +9,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -33,6 +34,8 @@ #include "bmesh.h" +extern const EnumPropertyItem RNA_automasking_flags[]; + const EnumPropertyItem rna_enum_particle_edit_hair_brush_items[] = { {PE_BRUSH_COMB, "COMB", 0, "Comb", "Comb hairs"}, {PE_BRUSH_SMOOTH, "SMOOTH", 0, "Smooth", "Smooth hairs"}, @@ -598,6 +601,31 @@ static char *rna_GPencilSculptGuide_path(const PointerRNA *UNUSED(ptr)) return BLI_strdup("tool_settings.gpencil_sculpt.guide"); } +static void rna_Sculpt_automasking_invert_cavity_set(PointerRNA *ptr, bool val) +{ + Sculpt *sd = (Sculpt *)ptr->data; + + if (val) { + sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL; + sd->automasking_flags |= BRUSH_AUTOMASKING_CAVITY_INVERTED; + } + else { + sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_INVERTED; + } +} + +static void rna_Sculpt_automasking_cavity_set(PointerRNA *ptr, bool val) +{ + Sculpt *sd = (Sculpt *)ptr->data; + + if (val) { + sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_INVERTED; + sd->automasking_flags |= BRUSH_AUTOMASKING_CAVITY_NORMAL; + } + else { + sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL; + } +} #else static void rna_def_paint_curve(BlenderRNA *brna) @@ -883,32 +911,47 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); - prop = RNA_def_property(srna, "use_automasking_topology", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_TOPOLOGY); - RNA_def_property_ui_text(prop, - "Topology Auto-Masking", - "Affect only vertices connected to the active vertex under the brush"); + const EnumPropertyItem *entry = RNA_automasking_flags; + do { + prop = RNA_def_property(srna, entry->identifier, PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", entry->value); + RNA_def_property_ui_text(prop, entry->name, entry->description); + + if (entry->value == BRUSH_AUTOMASKING_CAVITY_NORMAL) { + RNA_def_property_boolean_funcs(prop, NULL, "rna_Sculpt_automasking_cavity_set"); + } + else if (entry->value == BRUSH_AUTOMASKING_CAVITY_INVERTED) { + RNA_def_property_boolean_funcs(prop, NULL, "rna_Sculpt_automasking_invert_cavity_set"); + } + + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + } while ((++entry)->identifier); + + prop = RNA_def_property(srna, "automasking_cavity_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "automasking_cavity_factor"); + RNA_def_property_ui_text(prop, "Cavity Factor", "The contrast of the cavity mask"); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3); + RNA_def_property_range(prop, 0.0f, 5.0f); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "use_automasking_face_sets", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_FACE_SETS); - RNA_def_property_ui_text(prop, - "Face Sets Auto-Masking", - "Affect only vertices that share Face Sets with the active vertex"); + prop = RNA_def_property(srna, "automasking_cavity_blur_steps", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "automasking_cavity_blur_steps"); + RNA_def_property_ui_text(prop, "Blur Steps", "The number of times the cavity mask is blurred"); + RNA_def_property_range(prop, 0.0f, 25.0f); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "use_automasking_boundary_edges", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_EDGES); - RNA_def_property_ui_text( - prop, "Mesh Boundary Auto-Masking", "Do not affect non manifold boundary edges"); + prop = RNA_def_property(srna, "automasking_cavity_curve", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "automasking_cavity_curve"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Cavity Curve", "Curve used for the sensitivity"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); - prop = RNA_def_property(srna, "use_automasking_boundary_face_sets", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna( - prop, NULL, "automasking_flags", BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS); - RNA_def_property_ui_text(prop, - "Face Sets Boundary Auto-Masking", - "Do not affect vertices that belong to a Face Set boundary"); + prop = RNA_def_property(srna, "automasking_cavity_curve_op", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "automasking_cavity_curve_op"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Cavity Curve", "Curve used for the sensitivity"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "symmetrize_direction", PROP_ENUM, PROP_NONE); |