Object: use undo-group for object.switch_object
object.switch_object no longer adds multiple undo steps from a user perspective.
This commit is contained in:
parent
8d2576fd29
commit
3cc6b423b1
|
@ -445,37 +445,41 @@ static int object_switch_object_invoke(bContext *C, wmOperator *op, const wmEven
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (!ED_object_mode_set_ex(C, OB_MODE_OBJECT, true, op->reports)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
int retval = OPERATOR_CANCELLED;
|
||||
|
||||
Object *ob_dst_orig = DEG_get_original_object(ob_dst);
|
||||
Base *base = BKE_view_layer_base_find(view_layer, ob_dst_orig);
|
||||
BKE_view_layer_base_deselect_all(view_layer);
|
||||
BKE_view_layer_base_select_and_set_active(view_layer, base);
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
|
||||
ED_undo_group_begin(C);
|
||||
|
||||
/* FIXME: Do a single undo push. */
|
||||
ED_undo_push(C, "Change Active");
|
||||
if (ED_object_mode_set_ex(C, OB_MODE_OBJECT, true, op->reports)) {
|
||||
Object *ob_dst_orig = DEG_get_original_object(ob_dst);
|
||||
Base *base = BKE_view_layer_base_find(view_layer, ob_dst_orig);
|
||||
BKE_view_layer_base_deselect_all(view_layer);
|
||||
BKE_view_layer_base_select_and_set_active(view_layer, base);
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
|
||||
|
||||
ob_dst_orig = DEG_get_original_object(ob_dst);
|
||||
ED_object_mode_set_ex(C, last_mode, true, op->reports);
|
||||
ED_undo_push(C, "Change Active");
|
||||
|
||||
/* Update the viewport rotation origin to the mouse cursor. */
|
||||
if (last_mode & OB_MODE_ALL_PAINT) {
|
||||
float global_loc[3];
|
||||
if (ED_view3d_autodist_simple(ar, event->mval, global_loc, 0, NULL)) {
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
copy_v3_v3(ups->average_stroke_accum, global_loc);
|
||||
ups->average_stroke_counter = 1;
|
||||
ups->last_stroke_valid = true;
|
||||
ob_dst_orig = DEG_get_original_object(ob_dst);
|
||||
ED_object_mode_set_ex(C, last_mode, true, op->reports);
|
||||
|
||||
/* Update the viewport rotation origin to the mouse cursor. */
|
||||
if (last_mode & OB_MODE_ALL_PAINT) {
|
||||
float global_loc[3];
|
||||
if (ED_view3d_autodist_simple(ar, event->mval, global_loc, 0, NULL)) {
|
||||
UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
|
||||
copy_v3_v3(ups->average_stroke_accum, global_loc);
|
||||
ups->average_stroke_counter = 1;
|
||||
ups->last_stroke_valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
||||
WM_toolsystem_update_from_context_view3d(C);
|
||||
retval = OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
||||
WM_toolsystem_update_from_context_view3d(C);
|
||||
ED_undo_group_end(C);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void OBJECT_OT_switch_object(wmOperatorType *ot)
|
||||
|
|
Loading…
Reference in New Issue