[Bf-blender-cvs] [cab8626cf25] sculpt-dev: Sculpt: lasso and box project gestures

Pablo Dobarro noreply at git.blender.org
Wed Dec 16 21:36:53 CET 2020


Commit: cab8626cf250235fbf222525a0f248aca2f581e9
Author: Pablo Dobarro
Date:   Tue Dec 15 21:33:49 2020 +0100
Branches: sculpt-dev
https://developer.blender.org/rBcab8626cf250235fbf222525a0f248aca2f581e9

Sculpt: lasso and box project gestures

===================================================================

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/editors/sculpt_paint/paint_mask.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/windowmanager/intern/wm_operators.c

===================================================================

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 5a5957b8bf1..8d558a303da 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -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),
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 273c2c07448..507a9d0c036 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -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,
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index ca54e45a165..214962bf7b2 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -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);
+}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 17f87b11699..37ac2015992 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -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);
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 08fda37373a..b0a208446ad 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -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);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index a5b5f082c41..69a32608ec8 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -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");



More information about the Bf-blender-cvs mailing list