[Bf-blender-cvs] [86832ececcb] master: Tool System: adjust Smooth/Randomize modal operator behavior

Campbell Barton noreply at git.blender.org
Thu Jan 2 07:19:51 CET 2020


Commit: 86832ececcb9d5ed8fa05a02415f7c31905eae4a
Author: Campbell Barton
Date:   Thu Jan 2 17:00:17 2020 +1100
Branches: master
https://developer.blender.org/rB86832ececcb9d5ed8fa05a02415f7c31905eae4a

Tool System: adjust Smooth/Randomize modal operator behavior

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.

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

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

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 173e7e5f332..36701a7013a 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -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)]}),
         ]},
     )
 
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index fee8845d88e..02dc03be127 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -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()
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 59090acf433..abc0d258e55 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -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);
 
diff --git a/source/blender/editors/object/object_random.c b/source/blender/editors/object/object_random.c
index a130e3f3766..43aaecb887b 100644
--- a/source/blender/editors/object/object_random.c
+++ b/source/blender/editors/object/object_random.c
@@ -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,
diff --git a/source/blender/windowmanager/intern/wm_operator_utils.c b/source/blender/windowmanager/intern/wm_operator_utils.c
index ce10ea56251..c2af82c007e 100644
--- a/source/blender/windowmanager/intern/wm_operator_utils.c
+++ b/source/blender/windowmanager/intern/wm_operator_utils.c
@@ -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(



More information about the Bf-blender-cvs mailing list