WIP: Sculpt: Add operators to Mask, Face Sets, and Paint menus #105410

Draft
Tarek-Yasser wants to merge 23 commits from Tarek-Yasser/blender:102427_continued into main

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

View File

@ -3220,17 +3220,32 @@ class VIEW3D_MT_sculpt(Menu):
def draw(self, _context):
layout = self.layout
layout.operator("transform.translate")
layout.operator("transform.rotate")
layout.operator("transform.resize", text="Scale")
layout.separator()
props = layout.operator("paint.hide_show", text="Box Hide")
props.action = 'HIDE'
props = layout.operator("paint.hide_show", text="Box Show")
props.action = 'SHOW'
layout.separator()
props = layout.operator("sculpt.face_set_change_visibility", text="Toggle Visibility")
props.mode = 'TOGGLE'
props = layout.operator("sculpt.face_set_change_visibility", text="Hide Active Face Set")
props.mode = 'HIDE_ACTIVE'
props = layout.operator("paint.hide_show", text="Show All")
props.action = 'SHOW'
props.area = 'ALL'
props = layout.operator("paint.hide_show", text="Box Show")
props.action = 'SHOW'
props.area = 'INSIDE'
props = layout.operator("paint.hide_show", text="Box Hide")
props.action = 'HIDE'
props.area = 'INSIDE'
props = layout.operator("sculpt.face_set_change_visibility", text="Invert Visible")
props.mode = 'INVERT'
props = layout.operator("paint.hide_show", text="Hide Masked")
props.action = 'HIDE'
@ -3238,10 +3253,55 @@ class VIEW3D_MT_sculpt(Menu):
layout.separator()
props = layout.operator("sculpt.trim_box_gesture", text="Box Trim")
props.trim_mode = 'DIFFERENCE'
layout.operator("sculpt.trim_lasso_gesture", text="Lasso Trim")
props.trim_mode = 'DIFFERENCE'
props = layout.operator("sculpt.trim_box_gesture", text="Box Add")
props.trim_mode = 'JOIN'
layout.operator("sculpt.trim_lasso_gesture", text="Lasso Add")
props.trim_mode = 'JOIN'
layout.operator("sculpt.project_line_gesture", text="Line Project")
layout.separator()
# Fair Positions
props = layout.operator("sculpt.face_set_edit", text="Fair Positions")
props.mode = 'FAIR_POSITIONS'
# Fair Tangency
props = layout.operator("sculpt.face_set_edit", text="Fair Tangency")
props.mode = 'FAIR_TANGENCY'
layout.separator()
sculpt_filters_types = [
('SMOOTH', "Smooth"),
('SURFACE_SMOOTH', "Surface Smooth"),
('INFLATE', "Inflate"),
('RELAX', "Relax Topology"),
('RELAX_FACE_SETS', "Relax Face Sets"),
('SHARPEN', "Sharpen"),
('ENHANCE_DETAILS', "Enhance Details"),
('ERASE_DISCPLACEMENT', "Erase Multires Displacement"),
('RANDOM', "Randomize")
]
for filter_type, ui_name in sculpt_filters_types:
props = layout.operator("sculpt.mesh_filter", text=ui_name)
props.type = filter_type
layout.separator()
layout.menu("VIEW3D_MT_sculpt_set_pivot", text="Set Pivot")
layout.separator()
# Rebuild BVH
layout.operator("sculpt.optimize")
layout.separator()

View File

@ -981,7 +981,7 @@ void SCULPT_OT_face_sets_change_visibility(wmOperatorType *ot)
ot->invoke = sculpt_face_sets_change_visibility_invoke;
ot->poll = SCULPT_mode_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_DEPENDS_ON_CURSOR;
RNA_def_enum(ot->srna,
"mode",

View File

@ -13,6 +13,8 @@
#include "BLI_math_vector_types.hh"
#include "BLI_task.h"
#include "BLT_translation.h"
#include "DNA_meshdata_types.h"
#include "BKE_brush.h"
@ -803,6 +805,9 @@ static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *
SculptSession *ss = ob->sculpt;
const eSculptMeshFilterType filter_type = eSculptMeshFilterType(RNA_enum_get(op->ptr, "type"));
WM_cursor_modal_set(CTX_wm_window(C), WM_CURSOR_EW_SCROLL);
ED_workspace_status_text(C, TIP_("LMB: Confirm"));
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
float initial_strength = ss->filter_cache->start_filter_strength;
sculpt_mesh_filter_end(C, op);
@ -812,6 +817,8 @@ static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *
RNA_float_set(op->ptr, "strength", initial_strength);
}
ED_workspace_status_text(C, NULL); // Clear status bar
WM_cursor_modal_restore(CTX_wm_window(C));
return OPERATOR_FINISHED;
}
@ -1049,7 +1056,7 @@ void SCULPT_OT_mesh_filter(wmOperatorType *ot)
ot->exec = sculpt_mesh_filter_exec;
ot->ui = sculpt_mesh_ui_exec;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR_X | OPTYPE_BLOCKING;
/* RNA. */
SCULPT_mesh_filter_properties(ot);