diff options
-rw-r--r-- | source/blender/editors/include/ED_object.h | 26 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 57 |
2 files changed, 39 insertions, 44 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 8e844d327e2..efa779c29a1 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -125,12 +125,12 @@ enum { EM_IGNORE_LAYER = (1 << 3), EM_NO_CONTEXT = (1 << 4), }; -void ED_object_editmode_exit_ex( +bool ED_object_editmode_exit_ex( struct Scene *scene, struct Object *obedit, int flag); -void ED_object_editmode_exit(struct bContext *C, int flag); +bool ED_object_editmode_exit(struct bContext *C, int flag); -void ED_object_editmode_enter_ex(struct Scene *scene, struct Object *ob, int flag); -void ED_object_editmode_enter(struct bContext *C, int flag); +bool ED_object_editmode_enter_ex(struct Scene *scene, struct Object *ob, int flag); +bool ED_object_editmode_enter(struct bContext *C, int flag); bool ED_object_editmode_load(struct Object *obedit); bool ED_object_editmode_calc_active_center(struct Object *obedit, const bool select_only, float r_center[3]); @@ -232,17 +232,20 @@ enum { MODIFIER_APPLY_SHAPE }; -struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, - struct Object *ob, const char *name, int type); +struct ModifierData *ED_object_modifier_add( + struct ReportList *reports, struct Main *bmain, struct Scene *scene, + struct Object *ob, const char *name, int type); bool ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain, struct Object *ob, struct ModifierData *md); void ED_object_modifier_clear(struct Main *bmain, struct Object *ob); int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md); int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md); -int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene, - struct ViewLayer *view_layer, struct Object *ob, struct ModifierData *md); -int ED_object_modifier_apply(struct ReportList *reports, struct Depsgraph *depsgraph, struct Scene *scene, - struct Object *ob, struct ModifierData *md, int mode); +int ED_object_modifier_convert( + struct ReportList *reports, struct Main *bmain, struct Scene *scene, + struct ViewLayer *view_layer, struct Object *ob, struct ModifierData *md); +int ED_object_modifier_apply( + struct ReportList *reports, struct Depsgraph *depsgraph, struct Scene *scene, + struct Object *ob, struct ModifierData *md, int mode); int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md); bool ED_object_iter_other( @@ -262,7 +265,8 @@ const struct EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( bool *r_free, const unsigned int selection_mask); -void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object); +void ED_object_check_force_modifiers( + struct Main *bmain, struct Scene *scene, struct Object *object); /* object_facemap_ops.c */ void ED_object_facemap_face_add(struct Object *ob, struct bFaceMap *fmap, int facenum); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 57d929ceccb..65fe578a602 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -272,7 +272,7 @@ bool ED_object_editmode_load(Object *obedit) * \param flag: * - If #EM_FREEDATA isn't in the flag, use ED_object_editmode_load directly. */ -void ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag) +bool ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag) { const bool freedata = (flag & EM_FREEDATA) != 0; @@ -285,7 +285,7 @@ void ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag) obedit->mode &= ~OB_MODE_EDIT; } if (flag & EM_WAITCURSOR) waitcursor(0); - return; + return true; } /* freedata only 0 now on file saves and render */ @@ -300,7 +300,7 @@ void ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag) pid->cache->flag |= PTCACHE_OUTDATED; } BLI_freelistN(&pidlist); - + BKE_ptcache_object_reset(scene, obedit, PTCACHE_RESET_OUTDATED); /* also flush ob recalc, doesn't take much overhead, but used for particles */ @@ -308,34 +308,37 @@ void ED_object_editmode_exit_ex(Scene *scene, Object *obedit, int flag) WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene); - obedit->mode &= ~OB_MODE_EDIT; } if (flag & EM_WAITCURSOR) waitcursor(0); + + return (obedit->mode & OB_MODE_EDIT) == 0; } -void ED_object_editmode_exit(bContext *C, int flag) +bool ED_object_editmode_exit(bContext *C, int flag) { Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); - ED_object_editmode_exit_ex(scene, obedit, flag); + return ED_object_editmode_exit_ex(scene, obedit, flag); } -void ED_object_editmode_enter_ex(Scene *scene, Object *ob, int flag) +bool ED_object_editmode_enter_ex(Scene *scene, Object *ob, int flag) { bool ok = false; - if (ELEM(NULL, ob, ob->data)) return; - if (ID_IS_LINKED(ob)) return; + if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob)) { + return false; + } /* this checks actual object->data, for cases when other scenes have it in editmode context */ - if (BKE_object_is_in_editmode(ob)) - return; - + if (BKE_object_is_in_editmode(ob)) { + return true; + } + if (BKE_object_obdata_is_libdata(ob)) { error_libdata(); - return; + return false; } if (flag & EM_WAITCURSOR) waitcursor(1); @@ -361,22 +364,8 @@ void ED_object_editmode_enter_ex(Scene *scene, Object *ob, int flag) WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MESH, NULL); } else if (ob->type == OB_ARMATURE) { - bArmature *arm = ob->data; - if (!arm) return; - /* - * The function BKE_object_obdata_is_libdata make a problem here, the - * check for ob->proxy return 0 and let blender enter to edit mode - * this causes a crash when you try leave the edit mode. - * The problem is that i can't remove the ob->proxy check from - * BKE_object_obdata_is_libdata that prevent the bugfix #6614, so - * i add this little hack here. - */ - if (ID_IS_LINKED(arm)) { - error_libdata(); - return; - } ok = 1; - ED_armature_to_edit(arm); + ED_armature_to_edit(ob->data); /* to ensure all goes in restposition and without striding */ DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* XXX: should this be OB_RECALC_DATA? */ @@ -418,9 +407,11 @@ void ED_object_editmode_enter_ex(Scene *scene, Object *ob, int flag) } if (flag & EM_WAITCURSOR) waitcursor(0); + + return (ob->mode & OB_MODE_EDIT) != 0; } -void ED_object_editmode_enter(bContext *C, int flag) +bool ED_object_editmode_enter(bContext *C, int flag) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -432,10 +423,10 @@ void ED_object_editmode_enter(bContext *C, int flag) else { ob = view_layer->basact->object; } - if (ob == NULL) return; - if (ID_IS_LINKED(ob)) return; - - ED_object_editmode_enter_ex(scene, ob, flag); + if ((ob == NULL) || ID_IS_LINKED(ob)) { + return false; + } + return ED_object_editmode_enter_ex(scene, ob, flag); } static int editmode_toggle_exec(bContext *C, wmOperator *op) |