diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-06-01 12:00:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-06-01 12:00:23 +0300 |
commit | 19f3f6cd85cf8e928f73382127cc66ac69550ae8 (patch) | |
tree | ac1c1f5c86d7ff871ac41c4431715a667020480c /source | |
parent | 9936e23b859d879078a5cb5aacd11fe71a5b2f5d (diff) | |
parent | c204e3348c858a5b1c02af14eb832695a5521b75 (diff) |
Merge branch 'blender-v2.83-release'
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 53a557c5871..e603be492bf 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1478,7 +1478,6 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) bool use_submode = STREQ(op->idname, "OBJECT_OT_mode_set_with_submode"); Object *ob = CTX_data_active_object(C); eObjectMode mode = RNA_enum_get(op->ptr, "mode"); - eObjectMode restore_mode = ob->mode; const bool toggle = RNA_boolean_get(op->ptr, "toggle"); /* by default the operator assume is a mesh, but if gp object change mode */ @@ -1492,33 +1491,49 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) if (toggle == false) { if (ob->mode != mode) { - if (mode != OB_MODE_OBJECT) { - /* Enter new mode. */ - ED_object_mode_toggle(C, mode); + if (mode == OB_MODE_OBJECT) { + ED_object_mode_compat_set(C, ob, OB_MODE_OBJECT, op->reports); } else { - ED_object_mode_compat_set(C, ob, mode, op->reports); + /* Enter new mode. */ + ED_object_mode_toggle(C, mode); } } } else { - /* Exit current mode if it's not the mode we're setting */ - if (mode != OB_MODE_OBJECT) { - /* Enter new mode. */ - ED_object_mode_toggle(C, mode); - } - + const eObjectMode restore_mode = ob->mode; /* Special case for Object mode! */ - if ((mode == OB_MODE_OBJECT) && (restore_mode == OB_MODE_OBJECT) && - (ob->restore_mode != OB_MODE_OBJECT)) { - ED_object_mode_toggle(C, ob->restore_mode); - } - else if (ob->mode == mode) { - /* For toggling, store old mode so we know what to go back to */ - ob->restore_mode = restore_mode; + if (mode == OB_MODE_OBJECT) { + if (ob->mode != OB_MODE_OBJECT) { + /* Set object mode if the object is not already in object mode. */ + if (ED_object_mode_compat_set(C, ob, OB_MODE_OBJECT, op->reports)) { + ob->restore_mode = restore_mode; + } + } + else { + if (ob->restore_mode != OB_MODE_OBJECT) { + ED_object_mode_toggle(C, ob->restore_mode); + } + } } - else if ((ob->restore_mode != OB_MODE_OBJECT) && (ob->restore_mode != mode)) { - ED_object_mode_toggle(C, ob->restore_mode); + else { + if (ob->mode != mode) { + ED_object_mode_toggle(C, mode); + if (ob->mode == mode) { + /* For toggling, store old mode so we know what to go back to. */ + ob->restore_mode = restore_mode; + } + } + else { + if (ob->restore_mode != OB_MODE_OBJECT) { + /* Toggle directly into the restore mode. */ + ED_object_mode_toggle(C, ob->restore_mode); + } + else { + /* Enter new mode. */ + ED_object_mode_toggle(C, mode); + } + } } } |