Tool System: adjust Smooth/Randomize modal operator behavior
authorCampbell Barton <ideasman42@gmail.com>
Thu, 2 Jan 2020 06:00:17 +0000 (17:00 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 2 Jan 2020 06:18:42 +0000 (17:18 +1100)
Previously the default values were left non-zero to avoid having to
update scripts. However, this meant it wasn't possible to setup
non-modal key bindings for smooth & randomize.

Now these operators follow logic of many other operators where setting
the value executes immediately, leaving unset runs modal.

Existing keymaps & scripts will need to be updated.

Addresses issue raised in f4a4ec84255a.

release/scripts/presets/keyconfig/keymap_data/blender_default.py
release/scripts/startup/bl_ui/space_view3d.py
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/object/object_random.c
source/blender/windowmanager/intern/wm_operator_utils.c

index 173e7e5f332d8c67abfce5876a3517987254c815..36701a7013aff84ea60b37055c9a98c1dc8b8c0e 100644 (file)
@@ -5535,7 +5535,7 @@ def km_3d_view_tool_edit_mesh_smooth(params):
         {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
         {"items": [
             ("mesh.vertices_smooth", {"type": params.tool_tweak, "value": 'ANY'},
-             {"properties": [("factor", 0.0), ("wait_for_input", False)]}),
+             {"properties": [("wait_for_input", False)]}),
         ]},
     )
 
@@ -5686,7 +5686,7 @@ def km_3d_view_tool_edit_curve_randomize(params):
         {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
         {"items": [
             ("transform.vertex_random", {"type": params.tool_tweak, "value": 'ANY'},
-             {"properties": [("offset", 0.0), ("wait_for_input", False)]}),
+             {"properties": [("wait_for_input", False)]}),
         ]},
     )
 
index fee8845d88e5f28ef1426d1dad748066b54f984a..02dc03be127b93a8837005276537dbef460cab20 100644 (file)
@@ -918,7 +918,7 @@ class VIEW3D_MT_transform_base(Menu):
         if context.mode != 'OBJECT':
             layout.operator("transform.vertex_warp", text="Warp")
             layout.operator_context = 'EXEC_DEFAULT'
-            layout.operator("transform.vertex_random", text="Randomize")
+            layout.operator("transform.vertex_random", text="Randomize").offset = 0.1
             layout.operator_context = 'INVOKE_REGION_WIN'
 
 
@@ -3530,8 +3530,8 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
             col.operator("transform.shear", text="Shear")
             col.operator("transform.vert_slide", text="Slide Vertices")
             col.operator_context = 'EXEC_DEFAULT'
-            col.operator("transform.vertex_random", text="Randomize Vertices")
-            col.operator("mesh.vertices_smooth", text="Smooth Vertices")
+            col.operator("transform.vertex_random", text="Randomize Vertices").offset = 0.1
+            col.operator("mesh.vertices_smooth", text="Smooth Vertices").factor = 0.5
             col.operator_context = 'INVOKE_REGION_WIN'
             col.operator("mesh.vertices_smooth_laplacian", text="Smooth Laplacian")
 
@@ -3747,7 +3747,7 @@ class VIEW3D_MT_edit_mesh_vertices(Menu):
 
         layout.operator("transform.vert_slide", text="Slide Vertices")
         layout.operator_context = 'EXEC_DEFAULT'
-        layout.operator("mesh.vertices_smooth", text="Smooth Vertices")
+        layout.operator("mesh.vertices_smooth", text="Smooth Vertices").factor = 0.5
         layout.operator_context = 'INVOKE_REGION_WIN'
 
         layout.separator()
index 59090acf433194e0fe8a4bc2a39b9fad1416f5de..abc0d258e551df73646f6363ac4413283ddb28a0 100644 (file)
@@ -2357,7 +2357,7 @@ void MESH_OT_vertices_smooth(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
   ot->prop = RNA_def_float_factor(
-      ot->srna, "factor", 0.5f, -10.0f, 10.0f, "Smoothing", "Smoothing factor", 0.0f, 1.0f);
+      ot->srna, "factor", 0.0f, -10.0f, 10.0f, "Smoothing", "Smoothing factor", 0.0f, 1.0f);
   RNA_def_int(
       ot->srna, "repeat", 1, 1, 1000, "Repeat", "Number of times to smooth the mesh", 1, 100);
 
index a130e3f37669dec9367dbf517e20c9016767e50e..43aaecb887b7d991f1deed973236adef79a5f805 100644 (file)
@@ -159,7 +159,7 @@ void TRANSFORM_OT_vertex_random(struct wmOperatorType *ot)
 
   /* props */
   ot->prop = RNA_def_float_distance(
-      ot->srna, "offset", 0.1f, -FLT_MAX, FLT_MAX, "Amount", "Distance to offset", -10.0f, 10.0f);
+      ot->srna, "offset", 0.0f, -FLT_MAX, FLT_MAX, "Amount", "Distance to offset", -10.0f, 10.0f);
   RNA_def_float_factor(ot->srna,
                        "uniform",
                        0.0f,
index ce10ea56251b7fb99adfe0419423a6d49b534125..c2af82c007ee9d275dbf49a2291c618dbc676c5a 100644 (file)
@@ -194,6 +194,10 @@ static void op_generic_value_cancel(bContext *UNUSED(C), wmOperator *op)
 
 static int op_generic_value_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
+  if (RNA_property_is_set(op->ptr, op->type->prop)) {
+    return WM_operator_call_notest(C, op);
+  }
+
   ViewLayer *view_layer = CTX_data_view_layer(C);
   uint objects_len;
   Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(