Sculpt: lasso and box project gestures
This commit is contained in:
parent
19cb01aa21
commit
cab8626cf2
|
@ -6458,6 +6458,26 @@ def km_3d_view_tool_sculpt_line_project(params):
|
|||
]},
|
||||
)
|
||||
|
||||
def km_3d_view_tool_sculpt_lasso_project(params):
|
||||
return (
|
||||
"3D View Tool: Sculpt, Lasso Project",
|
||||
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
|
||||
{"items": [
|
||||
("sculpt.project_lasso_gesture", {"type": params.tool_tweak, "value": 'ANY'},
|
||||
None),
|
||||
]},
|
||||
)
|
||||
|
||||
def km_3d_view_tool_sculpt_box_project(params):
|
||||
return (
|
||||
"3D View Tool: Sculpt, Box Project",
|
||||
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
|
||||
{"items": [
|
||||
("sculpt.project_box_gesture", {"type": params.tool_tweak, "value": 'ANY'},
|
||||
None),
|
||||
]},
|
||||
)
|
||||
|
||||
|
||||
def km_3d_view_tool_sculpt_mesh_filter(params):
|
||||
return (
|
||||
|
@ -7065,6 +7085,8 @@ def generate_keymaps(params=None):
|
|||
km_3d_view_tool_sculpt_lasso_trim(params),
|
||||
km_3d_view_tool_sculpt_line_mask(params),
|
||||
km_3d_view_tool_sculpt_line_project(params),
|
||||
km_3d_view_tool_sculpt_lasso_project(params),
|
||||
km_3d_view_tool_sculpt_box_project(params),
|
||||
km_3d_view_tool_sculpt_mesh_filter(params),
|
||||
km_3d_view_tool_sculpt_cloth_filter(params),
|
||||
km_3d_view_tool_sculpt_color_filter(params),
|
||||
|
|
|
@ -1347,6 +1347,26 @@ class _defs_sculpt:
|
|||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn
|
||||
def project_lasso():
|
||||
return dict(
|
||||
idname="builtin.lasso_project",
|
||||
label="Lasso Project",
|
||||
icon="ops.sculpt.lasso_project",
|
||||
widget=None,
|
||||
keymap=(),
|
||||
)
|
||||
|
||||
@ToolDef.from_fn
|
||||
def project_box():
|
||||
return dict(
|
||||
idname="builtin.box_project",
|
||||
label="Box Project",
|
||||
icon="ops.sculpt.box_project",
|
||||
widget=None,
|
||||
keymap=(),
|
||||
)
|
||||
|
||||
@ToolDef.from_fn
|
||||
def mesh_filter():
|
||||
def draw_settings(_context, layout, tool):
|
||||
|
@ -2714,7 +2734,11 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
|||
_defs_sculpt.trim_box,
|
||||
_defs_sculpt.trim_lasso,
|
||||
),
|
||||
(
|
||||
_defs_sculpt.project_line,
|
||||
_defs_sculpt.project_box,
|
||||
_defs_sculpt.project_lasso,
|
||||
),
|
||||
None,
|
||||
_defs_sculpt.mesh_filter,
|
||||
_defs_sculpt.cloth_filter,
|
||||
|
|
|
@ -1571,7 +1571,15 @@ static void sculpt_gesture_init_project_properties(SculptGestureContext *sgconte
|
|||
SculptGestureProjectOperation *project_operation = (SculptGestureProjectOperation *)
|
||||
sgcontext->operation;
|
||||
|
||||
project_operation->deformation_mode = RNA_enum_get(op->ptr, "deformation_mode");
|
||||
if (sgcontext->shape_type == SCULPT_GESTURE_SHAPE_LINE) {
|
||||
project_operation->deformation_mode = RNA_enum_get(op->ptr, "deformation_mode");
|
||||
}
|
||||
else {
|
||||
/* All gesture shapes that are not a line need to be deformed by fairing as they can't be
|
||||
* projected to a plane. */
|
||||
project_operation->deformation_mode = SCULPT_GESTURE_PROJECT_DEFORM_FAIR;
|
||||
}
|
||||
|
||||
project_operation->operation.sculpt_gesture_begin = sculpt_gesture_project_begin;
|
||||
project_operation->operation.sculpt_gesture_apply_for_symmetry_pass =
|
||||
sculpt_gesture_project_apply_for_symmetry_pass;
|
||||
|
@ -1743,6 +1751,44 @@ static int project_gesture_line_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int project_gesture_lasso_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
SculptSession *ss = ob->sculpt;
|
||||
if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
|
||||
/* Fairing operations are not supported in Multires. */
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
SculptGestureContext *sgcontext = sculpt_gesture_init_from_lasso(C, op);
|
||||
if (!sgcontext) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
sculpt_gesture_init_project_properties(sgcontext, op);
|
||||
sculpt_gesture_apply(C, sgcontext);
|
||||
sculpt_gesture_context_free(sgcontext);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int project_gesture_box_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
SculptSession *ss = ob->sculpt;
|
||||
if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
|
||||
/* Fairing operations are not supported in Multires. */
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
SculptGestureContext *sgcontext = sculpt_gesture_init_from_box(C, op);
|
||||
if (!sgcontext) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
sculpt_gesture_init_project_properties(sgcontext, op);
|
||||
sculpt_gesture_apply(C, sgcontext);
|
||||
sculpt_gesture_context_free(sgcontext);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Mask Lasso Gesture";
|
||||
|
@ -1902,3 +1948,45 @@ void SCULPT_OT_project_line_gesture(wmOperatorType *ot)
|
|||
|
||||
sculpt_project_gesture_operator_properties(ot);
|
||||
}
|
||||
|
||||
void SCULPT_OT_project_lasso_gesture(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Project Lasso Gesture";
|
||||
ot->idname = "SCULPT_OT_project_lasso_gesture";
|
||||
ot->description = "Project by fairing the geometry to the curve defined by the lasso gesture";
|
||||
|
||||
ot->invoke = WM_gesture_lasso_invoke;
|
||||
ot->modal = WM_gesture_lasso_modal;
|
||||
ot->exec = project_gesture_lasso_exec;
|
||||
|
||||
ot->poll = SCULPT_mode_poll;
|
||||
|
||||
ot->flag = OPTYPE_REGISTER;
|
||||
|
||||
/* Properties. */
|
||||
WM_operator_properties_gesture_lasso(ot);
|
||||
sculpt_gesture_operator_properties(ot);
|
||||
|
||||
sculpt_project_gesture_operator_properties(ot);
|
||||
}
|
||||
|
||||
void SCULPT_OT_project_box_gesture(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "Project Box Gesture";
|
||||
ot->idname = "SCULPT_OT_project_box_gesture";
|
||||
ot->description = "Project by fairing the geometry to the box defined by the gesture";
|
||||
|
||||
ot->invoke = WM_gesture_box_invoke;
|
||||
ot->modal = WM_gesture_box_modal;
|
||||
ot->exec = project_gesture_box_exec;
|
||||
|
||||
ot->poll = SCULPT_mode_poll;
|
||||
|
||||
ot->flag = OPTYPE_REGISTER;
|
||||
|
||||
/* Properties. */
|
||||
WM_operator_properties_border(ot);
|
||||
sculpt_gesture_operator_properties(ot);
|
||||
|
||||
sculpt_project_gesture_operator_properties(ot);
|
||||
}
|
||||
|
|
|
@ -9787,6 +9787,8 @@ void ED_operatortypes_sculpt(void)
|
|||
WM_operatortype_append(SCULPT_OT_trim_box_gesture);
|
||||
WM_operatortype_append(SCULPT_OT_trim_lasso_gesture);
|
||||
WM_operatortype_append(SCULPT_OT_project_line_gesture);
|
||||
WM_operatortype_append(SCULPT_OT_project_lasso_gesture);
|
||||
WM_operatortype_append(SCULPT_OT_project_box_gesture);
|
||||
|
||||
WM_operatortype_append(SCULPT_OT_sample_color);
|
||||
WM_operatortype_append(SCULPT_OT_loop_to_vertex_colors);
|
||||
|
|
|
@ -1160,6 +1160,8 @@ void SCULPT_OT_trim_lasso_gesture(struct wmOperatorType *ot);
|
|||
void SCULPT_OT_trim_box_gesture(struct wmOperatorType *ot);
|
||||
|
||||
void SCULPT_OT_project_line_gesture(struct wmOperatorType *ot);
|
||||
void SCULPT_OT_project_lasso_gesture(struct wmOperatorType *ot);
|
||||
void SCULPT_OT_project_box_gesture(struct wmOperatorType *ot);
|
||||
|
||||
/* Face Sets. */
|
||||
void SCULPT_OT_face_sets_randomize_colors(struct wmOperatorType *ot);
|
||||
|
|
|
@ -3874,6 +3874,7 @@ static void gesture_box_modal_keymap(wmKeyConfig *keyconf)
|
|||
WM_modalkeymap_assign(keymap, "MASK_OT_select_box");
|
||||
WM_modalkeymap_assign(keymap, "PAINT_OT_mask_box_gesture");
|
||||
WM_modalkeymap_assign(keymap, "SCULPT_OT_face_set_box_gesture");
|
||||
WM_modalkeymap_assign(keymap, "SCULPT_OT_project_box_gesture");
|
||||
WM_modalkeymap_assign(keymap, "SCULPT_OT_trim_box_gesture");
|
||||
WM_modalkeymap_assign(keymap, "VIEW2D_OT_zoom_border");
|
||||
WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border");
|
||||
|
|
Loading…
Reference in New Issue