diff options
Diffstat (limited to 'source/blender/editors/object/object_edit.c')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index ca57ab76c57..12400209866 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -312,29 +312,26 @@ void OBJECT_OT_hide_render_set(wmOperatorType *ot) /* ******************* toggle editmode operator ***************** */ -void ED_object_exit_editmode(bContext *C, int flag) +/** + * Load EditMode data back into the object, + * optionally freeing the editmode data. + */ +static bool ED_object_editmode_load_ex(Object *obedit, const bool freedata) { - /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */ + if (obedit == NULL) { + return false; + } - Scene *scene = CTX_data_scene(C); - Object *obedit = CTX_data_edit_object(C); - int freedata = flag & EM_FREEDATA; - - if (obedit == NULL) return; - - if (flag & EM_WAITCURSOR) waitcursor(1); if (obedit->type == OB_MESH) { Mesh *me = obedit->data; - -// if (EM_texFaceCheck()) - + if (me->edit_btmesh->bm->totvert > MESH_MAX_VERTS) { error("Too many vertices"); - return; + return false; } - + EDBM_mesh_load(obedit); - + if (freedata) { EDBM_mesh_free(me->edit_btmesh); MEM_freeN(me->edit_btmesh); @@ -367,6 +364,29 @@ void ED_object_exit_editmode(bContext *C, int flag) if (freedata) free_editMball(obedit); } + return true; +} + +bool ED_object_editmode_load(Object *obedit) +{ + return ED_object_editmode_load_ex(obedit, false); +} + +void ED_object_editmode_exit(bContext *C, int flag) +{ + /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */ + /* Note! if 'EM_FREEDATA' isn't in the flag, use ED_object_editmode_load directly */ + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + const bool freedata = (flag & EM_FREEDATA) != 0; + + if (flag & EM_WAITCURSOR) waitcursor(1); + + if (ED_object_editmode_load_ex(obedit, freedata) == false) { + if (flag & EM_WAITCURSOR) waitcursor(0); + return; + } + /* freedata only 0 now on file saves and render */ if (freedata) { ListBase pidlist; @@ -390,17 +410,17 @@ void ED_object_exit_editmode(bContext *C, int flag) if (flag & EM_DO_UNDO) ED_undo_push(C, "Editmode"); - - if (flag & EM_WAITCURSOR) waitcursor(0); - + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene); obedit->mode &= ~OB_MODE_EDIT; } + + if (flag & EM_WAITCURSOR) waitcursor(0); } -void ED_object_enter_editmode(bContext *C, int flag) +void ED_object_editmode_enter(bContext *C, int flag) { Scene *scene = CTX_data_scene(C); Base *base = NULL; @@ -537,9 +557,9 @@ static int editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ToolSettings *toolsettings = CTX_data_tool_settings(C); if (!CTX_data_edit_object(C)) - ED_object_enter_editmode(C, EM_WAITCURSOR); + ED_object_editmode_enter(C, EM_WAITCURSOR); else - ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */ + ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */ ED_space_image_uv_sculpt_update(CTX_wm_manager(C), toolsettings); @@ -589,7 +609,7 @@ static int posemode_exec(bContext *C, wmOperator *UNUSED(op)) if (base->object->type == OB_ARMATURE) { if (base->object == CTX_data_edit_object(C)) { - ED_object_exit_editmode(C, EM_FREEDATA | EM_DO_UNDO); + ED_object_editmode_exit(C, EM_FREEDATA | EM_DO_UNDO); ED_armature_enter_posemode(C, base); } else if (base->object->mode & OB_MODE_POSE) |