diff options
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index d39df4cc6a3..83a6949430e 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -106,10 +106,10 @@ static void collection_copy_data(Main *bmain, ID *id_dst, const ID *id_src, cons BLI_listbase_clear(&collection_dst->children); BLI_listbase_clear(&collection_dst->parents); - for (CollectionChild *child = collection_src->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection_src->children) { collection_child_add(collection_dst, child->collection, flag, false); } - for (CollectionObject *cob = collection_src->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection_src->gobject) { collection_object_add(bmain, collection_dst, cob->ob, flag, false); } } @@ -223,9 +223,8 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy) } else { /* Link child collections into parent collection. */ - for (CollectionChild *child = collection->children.first; child; child = child->next) { - for (CollectionParent *cparent = collection->parents.first; cparent; - cparent = cparent->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { + LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { Collection *parent = cparent->collection; collection_child_add(parent, child->collection, 0, true); } @@ -234,8 +233,7 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy) CollectionObject *cob = collection->gobject.first; while (cob != NULL) { /* Link child object into parent collections. */ - for (CollectionParent *cparent = collection->parents.first; cparent; - cparent = cparent->next) { + LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { Collection *parent = cparent->collection; collection_object_add(bmain, parent, cob->ob, 0, true); } @@ -305,7 +303,7 @@ static Collection *collection_duplicate_recursive(Main *bmain, if (do_objects) { /* We can loop on collection_old's objects, that list is currently identical the collection_new * objects, and won't be changed here. */ - for (CollectionObject *cob = collection_old->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection_old->gobject) { Object *ob_old = cob->ob; Object *ob_new = (Object *)ob_old->id.newid; @@ -321,7 +319,7 @@ static Collection *collection_duplicate_recursive(Main *bmain, /* We can loop on collection_old's children, * that list is currently identical the collection_new' children, and won't be changed here. */ - for (CollectionChild *child = collection_old->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection_old->children) { Collection *child_collection_old = child->collection; collection_duplicate_recursive( @@ -440,7 +438,7 @@ static void collection_object_cache_fill(ListBase *lb, Collection *collection, i { int child_restrict = collection->flag | parent_restrict; - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { Base *base = BLI_findptr(lb, cob->ob, offsetof(Base, object)); if (base == NULL) { @@ -460,7 +458,7 @@ static void collection_object_cache_fill(ListBase *lb, Collection *collection, i } } - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { collection_object_cache_fill(lb, child->collection, child_restrict); } } @@ -487,7 +485,7 @@ static void collection_object_cache_free(Collection *collection) collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE; BLI_freelistN(&collection->object_cache); - for (CollectionParent *parent = collection->parents.first; parent; parent = parent->next) { + LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) { collection_object_cache_free(parent->collection); } } @@ -645,8 +643,7 @@ static void collection_tag_update_parent_recursive(Main *bmain, DEG_id_tag_update_ex(bmain, &collection->id, flag); - for (CollectionParent *collection_parent = collection->parents.first; collection_parent; - collection_parent = collection_parent->next) { + LISTBASE_FOREACH (CollectionParent *, collection_parent, &collection->parents) { if (collection_parent->collection->flag & COLLECTION_IS_MASTER) { /* We don't care about scene/master collection here. */ continue; @@ -952,7 +949,7 @@ bool BKE_collection_is_in_scene(Collection *collection) return true; } - for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) { + LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { if (BKE_collection_is_in_scene(cparent->collection)) { return true; } @@ -977,7 +974,7 @@ bool BKE_collection_find_cycle(Collection *new_ancestor, Collection *collection) return true; } - for (CollectionParent *parent = new_ancestor->parents.first; parent; parent = parent->next) { + LISTBASE_FOREACH (CollectionParent *, parent, &new_ancestor->parents) { if (BKE_collection_find_cycle(parent->collection, collection)) { return true; } @@ -993,7 +990,7 @@ static CollectionChild *collection_find_child(Collection *parent, Collection *co static bool collection_find_child_recursive(Collection *parent, Collection *collection) { - for (CollectionChild *child = parent->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &parent->children) { if (child->collection == collection) { return true; } @@ -1168,7 +1165,7 @@ static Collection *collection_from_index_recursive(Collection *collection, (*index_current)++; - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { Collection *nested = collection_from_index_recursive(child->collection, index, index_current); if (nested != NULL) { return nested; @@ -1197,7 +1194,7 @@ static bool collection_objects_select(ViewLayer *view_layer, Collection *collect return false; } - for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { + LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { Base *base = BKE_view_layer_base_find(view_layer, cob->ob); if (base) { @@ -1216,7 +1213,7 @@ static bool collection_objects_select(ViewLayer *view_layer, Collection *collect } } - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { if (collection_objects_select(view_layer, collection, deselect)) { changed = true; } @@ -1289,8 +1286,7 @@ bool BKE_collection_move(Main *bmain, GHash *view_layer_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { - for (ViewLayer *view_layer = scene->view_layers.first; view_layer; - view_layer = view_layer->next) { + LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection( view_layer, collection); @@ -1352,7 +1348,7 @@ static void scene_collection_callback(Collection *collection, { callback(collection, data); - for (CollectionChild *child = collection->children.first; child; child = child->next) { + LISTBASE_FOREACH (CollectionChild *, child, &collection->children) { scene_collection_callback(child->collection, callback, data); } } |