Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_modes.c
| Show First 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | void ED_object_mode_set(bContext *C, eObjectMode mode) | ||||
| wm->op_undo_depth++; | wm->op_undo_depth++; | ||||
| /* needed so we don't do undo pushes. */ | /* needed so we don't do undo pushes. */ | ||||
| ED_object_mode_generic_enter(C, mode); | ED_object_mode_generic_enter(C, mode); | ||||
| wm->op_undo_depth--; | wm->op_undo_depth--; | ||||
| } | } | ||||
| void ED_object_mode_exit(bContext *C, Depsgraph *depsgraph) | void ED_object_mode_exit(bContext *C, Depsgraph *depsgraph) | ||||
| { | { | ||||
| struct Main *bmain = CTX_data_main(C); | |||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| FOREACH_OBJECT_BEGIN (view_layer, ob) { | FOREACH_OBJECT_BEGIN (view_layer, ob) { | ||||
| if (ob->mode & OB_MODE_ALL_MODE_DATA) { | if (ob->mode & OB_MODE_ALL_MODE_DATA) { | ||||
| ED_object_mode_generic_exit(bmain, depsgraph, scene, ob); | ED_object_mode_generic_exit(C, depsgraph, scene, ob); | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_OBJECT_END; | FOREACH_OBJECT_END; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| Show All 22 Lines | bool ED_object_mode_generic_enter(struct bContext *C, eObjectMode object_mode) | ||||
| WM_operator_properties_free(&ptr); | WM_operator_properties_free(&ptr); | ||||
| return (ob->mode == object_mode); | return (ob->mode == object_mode); | ||||
| } | } | ||||
| /** | /** | ||||
| * Use for changing works-paces or changing active object. | * Use for changing works-paces or changing active object. | ||||
| * Caller can check #OB_MODE_ALL_MODE_DATA to test if this needs to be run. | * Caller can check #OB_MODE_ALL_MODE_DATA to test if this needs to be run. | ||||
| */ | */ | ||||
| static bool ed_object_mode_generic_exit_ex(struct Main *bmain, | static bool ed_object_mode_generic_exit_ex(struct bContext *C, | ||||
| struct Depsgraph *depsgraph, | struct Depsgraph *depsgraph, | ||||
| struct Scene *scene, | struct Scene *scene, | ||||
| struct Object *ob, | struct Object *ob, | ||||
| bool only_test) | bool only_test) | ||||
| { | { | ||||
| struct Main *bmain = CTX_data_main(C); | |||||
| BLI_assert((bmain == NULL) == only_test); | BLI_assert((bmain == NULL) == only_test); | ||||
| if (ob->mode & OB_MODE_EDIT) { | if (ob->mode & OB_MODE_EDIT) { | ||||
| if (BKE_object_is_in_editmode(ob)) { | if (BKE_object_is_in_editmode(ob)) { | ||||
| if (only_test) { | if (only_test) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA); | ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA); | ||||
| } | } | ||||
| Show All 25 Lines | static bool ed_object_mode_generic_exit_ex(struct bContext *C, | ||||
| else if (ob->mode & OB_MODE_POSE) { | else if (ob->mode & OB_MODE_POSE) { | ||||
| if (ob->pose != NULL) { | if (ob->pose != NULL) { | ||||
| if (only_test) { | if (only_test) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| ED_object_posemode_exit_ex(bmain, ob); | ED_object_posemode_exit_ex(bmain, ob); | ||||
| } | } | ||||
| } | } | ||||
| else if (ob->mode & OB_MODE_TEXTURE_PAINT) { | |||||
| if (only_test) { | |||||
| return true; | |||||
| } | |||||
| ED_object_texture_paint_mode_exit_ex(C, ob); | |||||
| } | |||||
| else if (ob->mode & OB_MODE_PARTICLE_EDIT) { | |||||
| if (only_test) { | |||||
| return true; | |||||
| } | |||||
| ED_object_particle_edit_mode_exit_ex(C, ob); | |||||
| } | |||||
natecraddock: Other branches here have an additional if (ob-> ... ) condition. I couldn't identify anything… | |||||
| else if (ob->type == OB_GPENCIL) { | else if (ob->type == OB_GPENCIL) { | ||||
| /* Accounted for above. */ | /* Accounted for above. */ | ||||
| BLI_assert((ob->mode & OB_MODE_OBJECT) == 0); | BLI_assert((ob->mode & OB_MODE_OBJECT) == 0); | ||||
| if (only_test) { | if (only_test) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| ED_object_gpencil_exit(bmain, ob); | ED_object_gpencil_exit(bmain, ob); | ||||
| } | } | ||||
| else { | else { | ||||
| if (only_test) { | if (only_test) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| BLI_assert((ob->mode & OB_MODE_ALL_MODE_DATA) == 0); | BLI_assert((ob->mode & OB_MODE_ALL_MODE_DATA) == 0); | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| void ED_object_mode_generic_exit(struct Main *bmain, | void ED_object_mode_generic_exit(struct bContext *C, | ||||
| struct Depsgraph *depsgraph, | struct Depsgraph *depsgraph, | ||||
| struct Scene *scene, | struct Scene *scene, | ||||
| struct Object *ob) | struct Object *ob) | ||||
| { | { | ||||
| ed_object_mode_generic_exit_ex(bmain, depsgraph, scene, ob, false); | ed_object_mode_generic_exit_ex(C, depsgraph, scene, ob, false); | ||||
| } | |||||
| bool ED_object_mode_generic_has_data(struct Depsgraph *depsgraph, struct Object *ob) | |||||
| { | |||||
| return ed_object_mode_generic_exit_ex(NULL, depsgraph, NULL, ob, true); | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
Other branches here have an additional if (ob-> ... ) condition. I couldn't identify anything to check for texture paint or particle edit, but I may have missed something.
Also, this function has the only_test parameter which I don't think is ever used in the code. If it's not important I'll clean it up in a separate commit.