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 f4a4ec8425.
This commit is contained in:
@@ -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)]}),
|
||||
]},
|
||||
)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user