diff options
author | Monique Dewanchand <mdewanchand> | 2022-09-01 11:00:53 +0300 |
---|---|---|
committer | Monique <mdewanchand@atmind.nl> | 2022-09-01 11:22:43 +0300 |
commit | 17501c146edc4af8a5e04565dc4d0b30ed5c5323 (patch) | |
tree | 73fe3334ff45b67d45fa1b5a5ae7ff06ec990a5a /source/blender/editors/object | |
parent | f9c249917dbf9c450abf52df1f60b3d587bc106a (diff) |
Cleanup: Remove/replace View Layer macros.
This patch is a cleanup required before refactoring the view layer syncing
process {T73411}.
* Remove FIRSTBASE.
* Remove LASTBASE.
* Remove BASACT.
* Remove OBEDIT_FROM_WORKSPACE.
* Replace OBACT with BKE_view_layer_active_object.
* Replace OBEDIT_FROM_VIEW_LAYER with BKE_view_layer_edit_object.
Reviewed By: mont29
Maniphest Tasks: T73411
Differential Revision: https://developer.blender.org/D15799
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.cc | 22 | ||||
-rw-r--r-- | source/blender/editors/object/object_collection.c | 3 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 12 | ||||
-rw-r--r-- | source/blender/editors/object/object_modes.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.cc | 3 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_select.c | 12 |
8 files changed, 33 insertions, 29 deletions
diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 68fd90adfb3..513ead708e3 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -609,7 +609,7 @@ Object *ED_object_add_type_with_obdata(bContext *C, ViewLayer *view_layer = CTX_data_view_layer(C); { - Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + Object *obedit = BKE_view_layer_edit_object_get(view_layer); if (obedit != nullptr) { ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA); } @@ -629,7 +629,7 @@ Object *ED_object_add_type_with_obdata(bContext *C, ob = BKE_object_add(bmain, view_layer, type, name); } - Base *ob_base_act = BASACT(view_layer); + Base *ob_base_act = view_layer->basact; /* While not getting a valid base is not a good thing, it can happen in convoluted corner cases, * better not crash on it in releases. */ BLI_assert(ob_base_act != nullptr); @@ -990,7 +990,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) } bool newob = false; - Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + Object *obedit = BKE_view_layer_edit_object_get(view_layer); if (obedit == nullptr || obedit->type != OB_MBALL) { obedit = ED_object_add_type(C, OB_MBALL, nullptr, loc, rot, true, local_view_bits); newob = true; @@ -1099,7 +1099,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + Object *obedit = BKE_view_layer_edit_object_get(view_layer); RegionView3D *rv3d = CTX_wm_region_view3d(C); bool newob = false; @@ -3367,7 +3367,7 @@ static int object_convert_exec(bContext *C, wmOperator *op) /* If the original object is active then make this object active */ if (basen) { if (ob == obact) { - /* store new active base to update BASACT */ + /* Store new active base to update view layer. */ basact = basen; } @@ -3441,11 +3441,11 @@ static int object_convert_exec(bContext *C, wmOperator *op) if (basact) { /* active base was changed */ ED_object_base_activate(C, basact); - BASACT(view_layer) = basact; + view_layer->basact = basact; } - else if (BASACT(view_layer)->object->flag & OB_DONE) { - WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, BASACT(view_layer)->object); - WM_event_add_notifier(C, NC_OBJECT | ND_DATA, BASACT(view_layer)->object); + else if (view_layer->basact->object->flag & OB_DONE) { + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, view_layer->basact->object); + WM_event_add_notifier(C, NC_OBJECT | ND_DATA, view_layer->basact->object); } DEG_relations_tag_update(bmain); @@ -3682,7 +3682,7 @@ static int duplicate_exec(bContext *C, wmOperator *op) ED_object_base_select(base, BA_DESELECT); /* new object will become active */ - if (BASACT(view_layer) == base) { + if (view_layer->basact == base) { ob_new_active = ob_new; } } @@ -3894,7 +3894,7 @@ static int object_transform_to_mouse_exec(bContext *C, wmOperator *op) WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_OB)); if (!ob) { - ob = OBACT(view_layer); + ob = BKE_view_layer_active_object_get(view_layer); } if (ob == nullptr) { diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c index 39951c2ab6e..426f33e53ca 100644 --- a/source/blender/editors/object/object_collection.c +++ b/source/blender/editors/object/object_collection.c @@ -16,6 +16,7 @@ #include "BKE_collection.h" #include "BKE_context.h" +#include "BKE_layer.h" #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_object.h" @@ -202,7 +203,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Object *ob = OBACT(view_layer); + Object *ob = BKE_view_layer_active_object_get(view_layer); int single_collection_index = RNA_enum_get(op->ptr, "collection"); Collection *single_collection = collection_object_active_find_index( bmain, scene, ob, single_collection_index); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index abf286afa0c..28ba2b04b6f 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -2314,7 +2314,7 @@ static bool get_new_constraint_target( if ((found == false) && (add)) { Main *bmain = CTX_data_main(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Base *base = BASACT(view_layer); + Base *base = view_layer->basact; Object *obt; /* add new target object */ @@ -2336,7 +2336,7 @@ static bool get_new_constraint_target( } /* restore, BKE_object_add sets active */ - BASACT(view_layer) = base; + view_layer->basact = base; ED_object_base_select(base, BA_SELECT); /* make our new target the new object */ diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index f36181ad96d..fed03b5eabd 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -141,7 +141,7 @@ Object **ED_object_array_in_mode_or_selected(bContext *C, { ScrArea *area = CTX_wm_area(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Object *ob_active = OBACT(view_layer); + Object *ob_active = BKE_view_layer_active_object_get(view_layer); ID *id_pin = NULL; const bool use_objects_in_mode = (ob_active != NULL) && (ob_active->mode & (OB_MODE_EDIT | OB_MODE_POSE)); @@ -701,7 +701,7 @@ bool ED_object_editmode_free_ex(Main *bmain, Object *obedit) bool ED_object_editmode_exit_multi_ex(Main *bmain, Scene *scene, ViewLayer *view_layer, int flag) { - Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + Object *obedit = BKE_view_layer_edit_object_get(view_layer); if (obedit == NULL) { return false; } @@ -841,7 +841,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Object *obact = OBACT(view_layer); + Object *obact = BKE_view_layer_active_object_get(view_layer); const int mode_flag = OB_MODE_EDIT; const bool is_mode_set = (obact->mode & mode_flag) != 0; struct wmMsgBus *mbus = CTX_wm_message_bus(C); @@ -953,7 +953,7 @@ static int posemode_exec(bContext *C, wmOperator *op) } { - Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + Object *obedit = BKE_view_layer_edit_object_get(view_layer); if (obact == obedit) { ED_object_editmode_exit_ex(bmain, scene, obedit, EM_FREEDATA); is_mode_set = false; @@ -1478,7 +1478,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) /* For modes that only use an active object, don't handle the whole selection. */ { ViewLayer *view_layer = CTX_data_view_layer(C); - Object *obact = OBACT(view_layer); + Object *obact = BKE_view_layer_active_object_get(view_layer); if (obact && ((obact->mode & OB_MODE_ALL_PAINT))) { ctx_ob_single_active.ptr.data = obact; BLI_addtail(&ctx_objects, &ctx_ob_single_active); @@ -1551,7 +1551,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) static bool shade_poll(bContext *C) { ViewLayer *view_layer = CTX_data_view_layer(C); - Object *obact = OBACT(view_layer); + Object *obact = BKE_view_layer_active_object_get(view_layer); if (obact != NULL) { /* Doesn't handle edit-data, sculpt dynamic-topology, or their undo systems. */ if (obact->mode & (OB_MODE_EDIT | OB_MODE_SCULPT) || obact->data == NULL || diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c index 0055cdf9ea1..27d8c326d41 100644 --- a/source/blender/editors/object/object_modes.c +++ b/source/blender/editors/object/object_modes.c @@ -191,7 +191,7 @@ bool ED_object_mode_set_ex(bContext *C, eObjectMode mode, bool use_undo, ReportL { wmWindowManager *wm = CTX_wm_manager(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Object *ob = OBACT(view_layer); + Object *ob = BKE_view_layer_active_object_get(view_layer); if (ob == NULL) { return (mode == OB_MODE_OBJECT); } diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index 085ef59ac21..58ddde75844 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -47,6 +47,7 @@ #include "BKE_gpencil_modifier.h" #include "BKE_key.h" #include "BKE_lattice.h" +#include "BKE_layer.h" #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_material.h" @@ -1229,7 +1230,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) /* if cloth/softbody was removed, particle mode could be cleared */ if (mode_orig & OB_MODE_PARTICLE_EDIT) { if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) { - if (ob == OBACT(view_layer)) { + if (ob == BKE_view_layer_active_object_get(view_layer)) { WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, nullptr); } } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index cfbb0a724b7..40dbd6b7bd8 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -263,7 +263,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) else { Object workob; - ob->parent = BASACT(view_layer)->object; + ob->parent = view_layer->basact->object; if (par3 != INDEX_UNSET) { ob->partype = PARVERT3; ob->par1 = par1; @@ -2622,7 +2622,7 @@ static int clear_override_library_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob_iter = todo_object_iter->link; if (BKE_lib_override_library_is_hierarchy_leaf(bmain, &ob_iter->id)) { bool do_remap_active = false; - if (OBACT(view_layer) == ob_iter) { + if (BKE_view_layer_active_object_get(view_layer) == ob_iter) { do_remap_active = true; } BKE_libblock_remap(bmain, diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 6f7fc2efa61..82c39d38d74 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -120,7 +120,7 @@ void ED_object_base_activate_with_mode_exit_if_needed(bContext *C, Base *base) ViewLayer *view_layer = CTX_data_view_layer(C); /* Currently we only need to be concerned with edit-mode. */ - Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer); + Object *obedit = BKE_view_layer_edit_object_get(view_layer); if (obedit) { Object *ob = base->object; if (((ob->mode & OB_MODE_EDIT) == 0) || (obedit->type != ob->type)) { @@ -626,7 +626,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) ED_object_base_deselect_all(view_layer, v3d, SEL_DESELECT); } - ob = OBACT(view_layer); + ob = BKE_view_layer_active_object_get(view_layer); if (ob == NULL) { BKE_report(op->reports, RPT_ERROR, "No active object"); return OPERATOR_CANCELLED; @@ -777,7 +777,8 @@ static bool select_grouped_children(bContext *C, Object *ob, const bool recursiv return changed; } -static bool select_grouped_parent(bContext *C) /* Makes parent active and de-selected OBACT */ +/* Makes parent active and de-selected BKE_view_layer_active_object_get. */ +static bool select_grouped_parent(bContext *C) { ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); @@ -785,7 +786,8 @@ static bool select_grouped_parent(bContext *C) /* Makes parent active and de-sel bool changed = false; if (!basact || !(basact->object->parent)) { - return 0; /* we know OBACT is valid */ + /* We know BKE_view_layer_active_object_get is valid. */ + return 0; } baspar = BKE_view_layer_base_find(view_layer, basact->object->parent); @@ -1021,7 +1023,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op) changed = ED_object_base_deselect_all(view_layer, v3d, SEL_DESELECT); } - ob = OBACT(view_layer); + ob = BKE_view_layer_active_object_get(view_layer); if (ob == NULL) { BKE_report(op->reports, RPT_ERROR, "No active object"); return OPERATOR_CANCELLED; |