diff options
author | Bastien Montagne <bastien@blender.org> | 2020-07-21 13:13:25 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-07-21 13:18:08 +0300 |
commit | 629726177a20e196dbfda9867281bbdb365b699b (patch) | |
tree | 3748ae8e092098a9399bf76c7e3629c55ea6f15e /source | |
parent | 0bfec04cd5541551fea45d0f021e2df0aca80d2f (diff) |
Cleanup: `layer_collection_sync`: use proper naming.
Previous ones were extremely confusing and innacurate (probably
inherited from older versions of scene collections?).
Also, use named fields in struct initialization, much much safer and
cleaner than anonymous, positionned-based thing.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index f03bf60817f..5bedc86f25d 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -695,8 +695,8 @@ int BKE_layer_collection_findindex(ViewLayer *view_layer, const LayerCollection * stores state like selection. */ static void layer_collection_sync(ViewLayer *view_layer, - const ListBase *lb_scene, - ListBase *lb_layer, + const ListBase *lb_collections, + ListBase *lb_layer_collections, ListBase *new_object_bases, short parent_exclude, short parent_restrict, @@ -708,11 +708,11 @@ static void layer_collection_sync(ViewLayer *view_layer, * linking we can only sync after the fact. */ /* Remove layer collections that no longer have a corresponding scene collection. */ - for (LayerCollection *lc = lb_layer->first; lc;) { + for (LayerCollection *lc = lb_layer_collections->first; lc;) { /* Note ID remap can set lc->collection to NULL when deleting collections. */ LayerCollection *lc_next = lc->next; Collection *collection = (lc->collection) ? - BLI_findptr(lb_scene, + BLI_findptr(lb_collections, lc->collection, offsetof(CollectionChild, collection)) : NULL; @@ -724,7 +724,7 @@ static void layer_collection_sync(ViewLayer *view_layer, /* Free recursively. */ layer_collection_free(view_layer, lc); - BLI_freelinkN(lb_layer, lc); + BLI_freelinkN(lb_layer_collections, lc); } lc = lc_next; @@ -733,12 +733,13 @@ static void layer_collection_sync(ViewLayer *view_layer, /* Add layer collections for any new scene collections, and ensure order is the same. */ ListBase new_lb_layer = {NULL, NULL}; - LISTBASE_FOREACH (const CollectionChild *, child, lb_scene) { + LISTBASE_FOREACH (const CollectionChild *, child, lb_collections) { Collection *collection = child->collection; - LayerCollection *lc = BLI_findptr(lb_layer, collection, offsetof(LayerCollection, collection)); + LayerCollection *lc = BLI_findptr( + lb_layer_collections, collection, offsetof(LayerCollection, collection)); if (lc) { - BLI_remlink(lb_layer, lc); + BLI_remlink(lb_layer_collections, lc); BLI_addtail(&new_lb_layer, lc); } else { @@ -845,8 +846,8 @@ static void layer_collection_sync(ViewLayer *view_layer, } /* Replace layer collection list with new one. */ - *lb_layer = new_lb_layer; - BLI_assert(BLI_listbase_count(lb_scene) == BLI_listbase_count(lb_layer)); + *lb_layer_collections = new_lb_layer; + BLI_assert(BLI_listbase_count(lb_collections) == BLI_listbase_count(lb_layer_collections)); } /** @@ -876,9 +877,9 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer) } /* Generate new layer connections and object bases when collections changed. */ - CollectionChild child = {NULL, NULL, scene->master_collection}; - const ListBase collections = {&child, &child}; - ListBase new_object_bases = {NULL, NULL}; + CollectionChild child = {.next = NULL, .prev = NULL, .collection = scene->master_collection}; + const ListBase collections = {.first = &child, .last = &child}; + ListBase new_object_bases = {.first = NULL, .last = NULL}; const short parent_exclude = 0, parent_restrict = 0, parent_layer_restrict = 0; layer_collection_sync(view_layer, |