UI: Gray out Scene Auto-Masking option if equivalent Brush option is used #102971 #106126

Open
Henry-Chang wants to merge 11 commits from Henry-Chang/blender:gray-out-automasking into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 29 additions and 5 deletions
Showing only changes of commit 5b9616e1f8 - Show all commits

View File

@ -7896,7 +7896,7 @@ class VIEW3D_PT_sculpt_automasking(Panel):
if is_cavity_active:
subrow = row.column(align=True)
subrow.enabled = not brush.use_automasking_cavity and not brush.use_automasking_cavity_inverted
props = subrow.operator("sculpt.mask_from_cavity", text="Create Mask")
props = subrow.operator("sculpt.scene_mask_from_cavity", text="Create Mask")
props.settings_source = "SCENE"
subcol = col.column(align=True)
@ -7926,8 +7926,8 @@ class VIEW3D_PT_sculpt_automasking(Panel):
col.prop(sculpt, "use_automasking_view_occlusion", text="Occlusion")
subcol = col.column(align=True)
subcol.active = not sculpt.use_automasking_view_occlusion
subcol.prop(sculpt, "automasking_view_normal_limit", text="Limit")
subcol.prop(sculpt, "automasking_view_normal_falloff", text="Falloff")
subcol.prop(sculpt, "automasking_scene_view_normal_limit", text="Limit")
subcol.prop(sculpt, "automasking_scene_view_normal_falloff", text="Falloff")
col = layout.column()
col.active = not brush.use_automasking_start_normal

View File

@ -2078,6 +2078,8 @@ void BKE_sculpt_toolsettings_data_ensure(Scene *scene)
sd->automasking_start_normal_limit = 20.0f / 180.0f * M_PI;
sd->automasking_start_normal_falloff = 0.25f;
sd->automasking_scene_view_normal_limit = 90.0f / 180.0f * M_PI;
Review

Why is this change done here, it seems unrelated to the patch?

Why is this change done here, it seems unrelated to the patch?
Review

Wait I see that these properties were introduced just now. Then my question is, what are these properties doing? That's not immediately clear to me.

Wait I see that these properties were introduced just now. Then my question is, what are these properties doing? That's not immediately clear to me.
Review

This is due specifically to the Occlusion toggle in View Normal setting. When Occlusion is selected, it will make the Limit and Falloff scroll bars in Brush Panel inactive. If the disabled_info is set at the RNA level, a "Disabled:" message would erroneously show up when hovering over View Normal Limit and View Normal Falloff in the Brush Panel. This would not be needed if disabled_info is set at the Python layout definition level.

This is due specifically to the Occlusion toggle in View Normal setting. When Occlusion is selected, it will make the Limit and Falloff scroll bars in Brush Panel inactive. If the disabled_info is set at the RNA level, a "Disabled:" message would erroneously show up when hovering over View Normal Limit and View Normal Falloff in the Brush Panel. This would not be needed if disabled_info is set at the Python layout definition level.
sd->automasking_scene_view_normal_falloff = 0.25f;
sd->automasking_view_normal_limit = 90.0f / 180.0f * M_PI;
sd->automasking_view_normal_falloff = 0.25f;
}

View File

@ -1243,7 +1243,7 @@ static void SCULPT_OT_mask_from_cavity(wmOperatorType *ot)
/* api callbacks */
ot->exec = sculpt_bake_cavity_exec;
ot->poll = SCULPT_mode_poll_cavity_automask;
ot->poll = SCULPT_mode_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -1290,6 +1290,13 @@ static void SCULPT_OT_mask_from_cavity(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "invert", false, "Cavity (Inverted)", "");
}
static void SCULPT_OT_scene_mask_from_cavity(wmOperatorType *ot)
{
SCULPT_OT_mask_from_cavity(ot);
ot->idname = "SCULPT_OT_scene_mask_from_cavity";
ot->poll = SCULPT_mode_poll_cavity_automask;
}
static int sculpt_reveal_all_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
@ -1424,6 +1431,7 @@ void ED_operatortypes_sculpt(void)
WM_operatortype_append(SCULPT_OT_mask_init);
WM_operatortype_append(SCULPT_OT_expand);
WM_operatortype_append(SCULPT_OT_scene_mask_from_cavity);
WM_operatortype_append(SCULPT_OT_mask_from_cavity);
WM_operatortype_append(SCULPT_OT_reveal_all);
}

View File

@ -1089,6 +1089,7 @@ typedef struct Sculpt {
float automasking_start_normal_limit, automasking_start_normal_falloff;
float automasking_view_normal_limit, automasking_view_normal_falloff;
float automasking_scene_view_normal_limit, automasking_scene_view_normal_falloff;
struct CurveMapping *automasking_cavity_curve;
/** For use by operators. */

View File

@ -984,12 +984,25 @@ static void rna_def_sculpt(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "automasking_view_normal_limit");
RNA_def_property_range(prop, 0.0001f, M_PI);
RNA_def_property_ui_text(prop, "View Normal Limit", "The range of angles that will be affected");
RNA_def_property_editable_func(prop, "rna_Scene_automasking_view_normal_editable");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "automasking_view_normal_falloff", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "automasking_view_normal_falloff");
RNA_def_property_range(prop, 0.0001f, 1.0f);
RNA_def_property_ui_text(
prop, "View Normal Falloff", "Extend the angular range with a falloff gradient");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "automasking_scene_view_normal_limit", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "automasking_scene_view_normal_limit");
RNA_def_property_range(prop, 0.0001f, M_PI);
RNA_def_property_ui_text(prop, "View Normal Limit", "The range of angles that will be affected");
RNA_def_property_editable_func(prop, "rna_Scene_automasking_view_normal_editable");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
prop = RNA_def_property(srna, "automasking_scene_view_normal_falloff", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "automasking_scene_view_normal_falloff");
RNA_def_property_range(prop, 0.0001f, 1.0f);
RNA_def_property_ui_text(
prop, "View Normal Falloff", "Extend the angular range with a falloff gradient");
RNA_def_property_editable_func(prop, "rna_Scene_automasking_view_normal_editable");