From 3850557073a156fed94455eb3d7a9b3aad340880 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 2 Sep 2019 14:31:19 +0200 Subject: Cleanup: get rid of BKE_collection_master() useless accessor. In its current version that was a totally useless extra layer of crap that we can totally avoid. Plus name was bad too. --- source/blender/blenkernel/BKE_collection.h | 3 +-- source/blender/blenkernel/intern/collection.c | 19 +++++++------------ source/blender/blenkernel/intern/context.c | 2 +- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenkernel/intern/rigidbody.c | 2 +- source/blender/blenloader/intern/versioning_280.c | 2 +- source/blender/editors/object/object_edit.c | 2 +- source/blender/editors/object/object_relations.c | 4 ++-- .../editors/space_outliner/outliner_collections.c | 8 ++++---- .../editors/space_outliner/outliner_dragdrop.c | 4 ++-- .../blender/editors/space_outliner/outliner_tools.c | 4 ++-- .../blender_interface/BlenderStrokeRenderer.cpp | 2 +- 12 files changed, 24 insertions(+), 30 deletions(-) diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index 757b1c64db3..6847efc8eb3 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -76,7 +76,6 @@ struct Collection *BKE_collection_copy_master(struct Main *bmain, /* Master Collection for Scene */ -struct Collection *BKE_collection_master(const struct Scene *scene); struct Collection *BKE_collection_master_add(void); struct Scene *BKE_collection_master_scene_search(const struct Main *bmain, const struct Collection *master_collection); @@ -225,7 +224,7 @@ void BKE_scene_objects_iterator_end(struct BLI_Iterator *iter); bool is_scene_collection = (_scene) != NULL; \ \ if (_scene) { \ - _instance_next = BKE_collection_master(_scene); \ + _instance_next = _scene->master_collection; \ } \ else { \ _instance_next = (_bmain)->collections.first; \ diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 06710b40569..0c84dded53d 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -506,11 +506,6 @@ Collection *BKE_collection_master_add() return master_collection; } -Collection *BKE_collection_master(const Scene *scene) -{ - return scene->master_collection; -} - Scene *BKE_collection_master_scene_search(const Main *bmain, const Collection *master_collection) { BLI_assert((master_collection->flag & COLLECTION_IS_MASTER) != 0); @@ -587,7 +582,7 @@ bool BKE_collection_has_object_recursive(Collection *collection, Object *ob) static Collection *collection_next_find(Main *bmain, Scene *scene, Collection *collection) { - if (scene && collection == BKE_collection_master(scene)) { + if (scene && collection == scene->master_collection) { return bmain->collections.first; } else { @@ -604,7 +599,7 @@ Collection *BKE_collection_object_find(Main *bmain, collection = collection_next_find(bmain, scene, collection); } else if (scene) { - collection = BKE_collection_master(scene); + collection = scene->master_collection; } else { collection = bmain->collections.first; @@ -746,7 +741,7 @@ void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, O if (!is_instantiated) { /* In case we could not find any non-linked collections in which instantiate our ob_dst, * fallback to scene's master collection... */ - collection_object_add(bmain, BKE_collection_master(scene), ob_dst, 0, true); + collection_object_add(bmain, scene->master_collection, ob_dst, 0, true); } BKE_main_collection_sync(bmain); @@ -888,7 +883,7 @@ void BKE_collections_child_remove_nulls(Main *bmain, Collection *collection) collection_null_children_remove(collection); } for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) { - collection_null_children_remove(BKE_collection_master(scene)); + collection_null_children_remove(scene->master_collection); } for (collection = bmain->collections.first; collection != NULL; @@ -896,7 +891,7 @@ void BKE_collections_child_remove_nulls(Main *bmain, Collection *collection) collection_missing_parents_remove(collection); } for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) { - collection_missing_parents_remove(BKE_collection_master(scene)); + collection_missing_parents_remove(scene->master_collection); } } else { @@ -1172,7 +1167,7 @@ static Collection *collection_from_index_recursive(Collection *collection, Collection *BKE_collection_from_index(Scene *scene, const int index) { int index_current = 0; - Collection *master_collection = BKE_collection_master(scene); + Collection *master_collection = scene->master_collection; return collection_from_index_recursive(master_collection, index, &index_current); } @@ -1366,7 +1361,7 @@ static void scene_collections_array(Scene *scene, Collection ***collections_arra return; } - collection = BKE_collection_master(scene); + collection = scene->master_collection; BLI_assert(collection != NULL); scene_collection_callback(collection, scene_collections_count, tot); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index f536f21c3e5..bcf6bb338ff 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -1053,7 +1053,7 @@ Collection *CTX_data_collection(const bContext *C) /* fallback */ Scene *scene = CTX_data_scene(C); - return BKE_collection_master(scene); + return scene->master_collection; } enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ae091f32fbf..7ea395e9386 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3871,7 +3871,7 @@ int BKE_object_scenes_users_get(Main *bmain, Object *ob) { int num_scenes = 0; for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) { - if (BKE_collection_has_object_recursive(BKE_collection_master(scene), ob)) { + if (BKE_collection_has_object_recursive(scene->master_collection, ob)) { num_scenes++; } } diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index ec73406c14c..514f000d73d 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1452,7 +1452,7 @@ void BKE_rigidbody_remove_object(Main *bmain, Scene *scene, Object *ob) /* Some users seems to find it funny to use a view-layer instancing collection * as RBW collection... Despite this being a bad (ab)use of the system, avoid losing objects * when we remove them from RB simulation. */ - BKE_collection_object_add(bmain, BKE_collection_master(scene), ob); + BKE_collection_object_add(bmain, scene->master_collection, ob); } BKE_collection_object_remove(bmain, rbw->group, ob, false); } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 00c0ed561f7..ae98d3e0e15 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -406,7 +406,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) } /* Create collections from layers. */ - Collection *collection_master = BKE_collection_master(scene); + Collection *collection_master = scene->master_collection; Collection *collections[20] = {NULL}; for (int layer = 0; layer < 20; layer++) { diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0c2b5292716..33c7ffefb8b 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1691,7 +1691,7 @@ static int move_to_collection_invoke(bContext *C, wmOperator *op, const wmEvent return move_to_collection_exec(C, op); } - Collection *master_collection = BKE_collection_master(scene); + Collection *master_collection = scene->master_collection; /* We need the data to be allocated so it's available during menu drawing. * Technically we could use wmOperator->customdata. However there is no free callback diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index df684bfc210..06c360ed1cd 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1434,7 +1434,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - Collection *collection_to = BKE_collection_master(scene_to); + Collection *collection_to = scene_to->master_collection; CTX_DATA_BEGIN (C, Base *, base, selected_bases) { BKE_collection_object_add(bmain, collection_to, base->object); } @@ -1771,7 +1771,7 @@ static void single_object_users( Main *bmain, Scene *scene, View3D *v3d, const int flag, const bool copy_collections) { /* duplicate all the objects of the scene (and matching collections, if required). */ - Collection *master_collection = BKE_collection_master(scene); + Collection *master_collection = scene->master_collection; single_object_users_collection(bmain, scene, master_collection, flag, copy_collections, true); /* duplicate collections that consist entirely of duplicated objects */ diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c index 4740c412083..309446db83b 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.c @@ -89,7 +89,7 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te) } else if (ELEM(tselem->type, TSE_SCENE_COLLECTION_BASE, TSE_VIEW_COLLECTION_BASE)) { Scene *scene = (Scene *)tselem->id; - return BKE_collection_master(scene); + return scene->master_collection; } else if (tselem->type == 0 && te->idcode == ID_GR) { return (Collection *)tselem->id; @@ -199,7 +199,7 @@ static int collection_new_exec(bContext *C, wmOperator *op) } if (data.collection == NULL || ID_IS_LINKED(data.collection)) { - data.collection = BKE_collection_master(scene); + data.collection = scene->master_collection; } if (ID_IS_LINKED(scene)) { @@ -514,14 +514,14 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op) * This can happen when a whole scene is linked e.g. */ if (parent != NULL && ID_IS_LINKED(parent)) { Scene *scene = CTX_data_scene(C); - parent = ID_IS_LINKED(scene) ? NULL : BKE_collection_master(scene); + parent = ID_IS_LINKED(scene) ? NULL : scene->master_collection; } else if (parent != NULL && (parent->flag & COLLECTION_IS_MASTER) != 0) { Scene *scene = BKE_collection_master_scene_search(bmain, parent); BLI_assert(scene != NULL); if (ID_IS_LINKED(scene)) { scene = CTX_data_scene(C); - parent = ID_IS_LINKED(scene) ? NULL : BKE_collection_master(scene); + parent = ID_IS_LINKED(scene) ? NULL : scene->master_collection; } } diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index 6031ba5cffc..6e30157d216 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -537,7 +537,7 @@ static int scene_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent Collection *collection; if (scene != CTX_data_scene(C)) { /* when linking to an inactive scene link to the master collection */ - collection = BKE_collection_master(scene); + collection = scene->master_collection; } else { collection = CTX_data_collection(C); @@ -967,7 +967,7 @@ static int outliner_item_drag_drop_invoke(bContext *C, } else { Scene *scene = CTX_data_scene(C); - parent = BKE_collection_master(scene); + parent = scene->master_collection; } WM_drag_add_ID(drag, id, &parent->id); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 002926c55d2..a2d988f1142 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -299,7 +299,7 @@ static void unlink_collection_cb(bContext *C, } else if (GS(tsep->id->name) == ID_SCE) { Scene *scene = (Scene *)tsep->id; - Collection *parent = BKE_collection_master(scene); + Collection *parent = scene->master_collection; id_fake_user_set(&collection->id); BKE_collection_child_remove(bmain, parent, collection); DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); @@ -338,7 +338,7 @@ static void unlink_object_cb(bContext *C, } else if (GS(tsep->id->name) == ID_SCE) { Scene *scene = (Scene *)tsep->id; - Collection *parent = BKE_collection_master(scene); + Collection *parent = scene->master_collection; BKE_collection_object_remove(bmain, parent, ob, true); DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); DEG_relations_tag_update(bmain); diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index 984a2d01a68..98da8e8f6d3 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -865,7 +865,7 @@ Object *BlenderStrokeRenderer::NewMesh() const BLI_snprintf(name, MAX_ID_NAME, "0%08xME", mesh_id); ob->data = BKE_mesh_add(freestyle_bmain, name); - Collection *collection_master = BKE_collection_master(freestyle_scene); + Collection *collection_master = freestyle_scene->master_collection; BKE_collection_object_add(freestyle_bmain, collection_master, ob); DEG_graph_tag_relations_update(freestyle_depsgraph); -- cgit v1.2.3