From f211f702787c7e564ea3e4661e9f44835ba94045 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Wed, 24 Jan 2024 18:46:13 -0800 Subject: [PATCH 1/3] UI: Add automasking icon toggling for sculpt mode Applies changes to the icons for both 3D sculpting and Grease Pencil sculpting. Ref \#102585 --- scripts/startup/bl_ui/space_view3d.py | 4 +-- .../makesrna/intern/rna_sculpt_paint.cc | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 40ce95d0dd4..5f2e7c02245 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -949,7 +949,7 @@ class VIEW3D_HT_header(Header): layout.popover( panel="VIEW3D_PT_gpencil_sculpt_automasking", text="", - icon='MOD_MASK', + icon_value=tool_settings.gpencil_sculpt.automasking_icon ) elif object_mode == 'SCULPT': @@ -975,7 +975,7 @@ class VIEW3D_HT_header(Header): layout.popover( panel="VIEW3D_PT_sculpt_automasking", text="", - icon='MOD_MASK', + icon_value=tool_settings.sculpt.automasking_icon ) elif object_mode == 'VERTEX_PAINT': diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.cc b/source/blender/makesrna/intern/rna_sculpt_paint.cc index 226042522fa..171a26fe309 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.cc +++ b/source/blender/makesrna/intern/rna_sculpt_paint.cc @@ -559,6 +559,20 @@ static char *rna_GPencilSculptSettings_path(const PointerRNA * /*ptr*/) return BLI_strdup("tool_settings.gpencil_sculpt"); } +static int rna_GPencilSculptSettings_automasking_icon_get(PointerRNA *ptr) +{ + const GP_Sculpt_Settings *gp_sculpt = (const GP_Sculpt_Settings *)ptr->data; + /* clang-format off */ + const bool is_automasking = (gp_sculpt->flag & (GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE | + GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_STROKE | + GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_STROKE | + GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_ACTIVE | + GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_ACTIVE)) != 0; + /* clang-format on */ + + return is_automasking ? ICON_CLIPUV_DEHLT : ICON_CLIPUV_HLT; +} + static char *rna_GPencilSculptGuide_path(const PointerRNA * /*ptr*/) { return BLI_strdup("tool_settings.gpencil_sculpt.guide"); @@ -589,6 +603,12 @@ static void rna_Sculpt_automasking_cavity_set(PointerRNA *ptr, bool val) sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL; } } + +static int rna_Sculpt_automasking_icon_get(PointerRNA *ptr) +{ + const Sculpt *sd = (const Sculpt *)ptr->data; + return sd->automasking_flags == 0 ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT; +} #else static void rna_def_paint_curve(BlenderRNA *brna) @@ -992,6 +1012,11 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Orientation", "Object whose Z axis defines orientation of gravity"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); + + prop = RNA_def_property(srna, "automasking_icon", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_Sculpt_automasking_icon_get", nullptr, nullptr); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Visibility Icon", ""); } static void rna_def_uv_sculpt(BlenderRNA *brna) @@ -1668,6 +1693,12 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna) RNA_def_property_float_default(prop, 0.1f); RNA_def_property_ui_text(prop, "Threshold", "Threshold for stroke intersections"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + + prop = RNA_def_property(srna, "automasking_icon", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs( + prop, "rna_GPencilSculptSettings_automasking_icon_get", nullptr, nullptr); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Visibility Icon", ""); } static void rna_def_curves_sculpt(BlenderRNA *brna) -- 2.30.2 From c620db071710c90f78a7a6218b73056c5b8f9218 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Tue, 30 Jan 2024 16:09:07 -0800 Subject: [PATCH 2/3] WIP --- scripts/startup/bl_ui/space_view3d.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 38adf949034..118d48646b7 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -949,7 +949,7 @@ class VIEW3D_HT_header(Header): layout.popover( panel="VIEW3D_PT_gpencil_sculpt_automasking", text="", - icon_value=tool_settings.gpencil_sculpt.automasking_icon + icon=VIEW3D_HT_header._gpencil_sculpt_automasking_icon(tool_settings.gpencil_sculpt) ) elif object_mode == 'SCULPT': @@ -975,7 +975,7 @@ class VIEW3D_HT_header(Header): layout.popover( panel="VIEW3D_PT_sculpt_automasking", text="", - icon_value=tool_settings.sculpt.automasking_icon + icon=VIEW3D_HT_header._sculpt_automasking_icon(tool_settings.sculpt) ) elif object_mode == 'VERTEX_PAINT': @@ -1080,6 +1080,15 @@ class VIEW3D_HT_header(Header): # sub.enabled = shading.type != 'RENDERED' sub.popover(panel="VIEW3D_PT_shading", text="") + @staticmethod + def _sculpt_automasking_icon(sculpt): + return + + @staticmethod + def _gpencil_sculpt_automasking_icon(gpencil_sculpt): + + return + class VIEW3D_MT_editor_menus(Menu): bl_label = "" -- 2.30.2 From 50e1defad6f9d5d907ea2de8134a292d0b7cf09e Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Wed, 31 Jan 2024 13:41:04 -0800 Subject: [PATCH 3/3] Remove automasking RNA properties in favor of python code --- scripts/startup/bl_ui/space_view3d.py | 18 +++++++++-- .../makesrna/intern/rna_sculpt_paint.cc | 31 ------------------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 118d48646b7..9be6ba7cd82 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -1082,12 +1082,26 @@ class VIEW3D_HT_header(Header): @staticmethod def _sculpt_automasking_icon(sculpt): - return + automask_enabled = (sculpt.use_automasking_topology or + sculpt.use_automasking_face_sets or + sculpt.use_automasking_boundary_edges or + sculpt.use_automasking_boundary_face_sets or + sculpt.use_automasking_cavity or + sculpt.use_automasking_cavity_inverted or + sculpt.use_automasking_start_normal or + sculpt.use_automasking_view_normal) + + return "CLIPUV_DEHLT" if automask_enabled else "CLIPUV_HLT" @staticmethod def _gpencil_sculpt_automasking_icon(gpencil_sculpt): + automask_enabled = (gpencil_sculpt.use_automasking_stroke or + gpencil_sculpt.use_automasking_layer_stroke or + gpencil_sculpt.use_automasking_material_stroke or + gpencil_sculpt.use_automasking_material_active or + gpencil_sculpt.use_automasking_layer_active) - return + return "CLIPUV_DEHLT" if automask_enabled else "CLIPUV_HLT" class VIEW3D_MT_editor_menus(Menu): diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.cc b/source/blender/makesrna/intern/rna_sculpt_paint.cc index c345e4256ea..e2eeb24431b 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.cc +++ b/source/blender/makesrna/intern/rna_sculpt_paint.cc @@ -559,20 +559,6 @@ static char *rna_GPencilSculptSettings_path(const PointerRNA * /*ptr*/) return BLI_strdup("tool_settings.gpencil_sculpt"); } -static int rna_GPencilSculptSettings_automasking_icon_get(PointerRNA *ptr) -{ - const GP_Sculpt_Settings *gp_sculpt = (const GP_Sculpt_Settings *)ptr->data; - /* clang-format off */ - const bool is_automasking = (gp_sculpt->flag & (GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE | - GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_STROKE | - GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_STROKE | - GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_ACTIVE | - GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_ACTIVE)) != 0; - /* clang-format on */ - - return is_automasking ? ICON_CLIPUV_DEHLT : ICON_CLIPUV_HLT; -} - static char *rna_GPencilSculptGuide_path(const PointerRNA * /*ptr*/) { return BLI_strdup("tool_settings.gpencil_sculpt.guide"); @@ -603,12 +589,6 @@ static void rna_Sculpt_automasking_cavity_set(PointerRNA *ptr, bool val) sd->automasking_flags &= ~BRUSH_AUTOMASKING_CAVITY_NORMAL; } } - -static int rna_Sculpt_automasking_icon_get(PointerRNA *ptr) -{ - const Sculpt *sd = (const Sculpt *)ptr->data; - return sd->automasking_flags == 0 ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT; -} #else static void rna_def_paint_curve(BlenderRNA *brna) @@ -1023,11 +1003,6 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Orientation", "Object whose Z axis defines orientation of gravity"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); - - prop = RNA_def_property(srna, "automasking_icon", PROP_INT, PROP_NONE); - RNA_def_property_int_funcs(prop, "rna_Sculpt_automasking_icon_get", nullptr, nullptr); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Visibility Icon", ""); } static void rna_def_uv_sculpt(BlenderRNA *brna) @@ -1704,12 +1679,6 @@ static void rna_def_gpencil_sculpt(BlenderRNA *brna) RNA_def_property_float_default(prop, 0.1f); RNA_def_property_ui_text(prop, "Threshold", "Threshold for stroke intersections"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - - prop = RNA_def_property(srna, "automasking_icon", PROP_INT, PROP_NONE); - RNA_def_property_int_funcs( - prop, "rna_GPencilSculptSettings_automasking_icon_get", nullptr, nullptr); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Visibility Icon", ""); } static void rna_def_curves_sculpt(BlenderRNA *brna) -- 2.30.2