diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-08-16 11:31:02 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-08-16 11:35:26 +0300 |
commit | 18ce2bfac63046acb484857498caf0af7178c094 (patch) | |
tree | 7c2006e61268102c071e3612897cb00befa6e7d4 /source/blender/blenkernel/intern/scene.c | |
parent | dbd300ab208d5fdc36983b26b96db5829b208d87 (diff) |
Depsgraph/Layers: Keep original visibility when doing full scene copy
Originally we were not respecting the original visibility flags of the
collections. However this is required for Copy-on-write (CoW).
Remember to update the svn lib tests folder. I had to update some of the
json files there.
Also adding a new unittest for this particular issue:
Test render_layer_scene_copy_f
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 5760e13b800..5d974192241 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -204,8 +204,24 @@ static SceneCollection *scene_collection_from_new_tree(SceneCollection *sc_refer return NULL; } +static void layer_collections_sync_flags(ListBase *layer_collections_dst, const ListBase *layer_collections_src) +{ + LayerCollection *layer_collection_dst = (LayerCollection *)layer_collections_dst->first; + const LayerCollection *layer_collection_src = (const LayerCollection *)layer_collections_src->first; + while (layer_collection_dst != NULL) { + layer_collection_dst->flag = layer_collection_src->flag; + layer_collections_sync_flags(&layer_collection_dst->layer_collections, + &layer_collection_src->layer_collections); + /* TODO(sergey/dfelinto): Overrides. */ + layer_collection_dst = layer_collection_dst->next; + layer_collection_src = layer_collection_src->next; + } +} + + /* recreate the LayerCollection tree */ -static void layer_collections_recreate(SceneLayer *sl_dst, ListBase *lb_src, SceneCollection *mc_dst, SceneCollection *mc_src) +static void layer_collections_recreate( + SceneLayer *sl_dst, ListBase *lb_src, SceneCollection *mc_dst, SceneCollection *mc_src) { for (LayerCollection *lc_src = lb_src->first; lc_src; lc_src = lc_src->next) { SceneCollection *sc_dst = scene_collection_from_new_tree(lc_src->scene_collection, mc_dst, mc_src); @@ -269,8 +285,12 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons BLI_listbase_clear(&sl_dst->layer_collections); BLI_listbase_clear(&sl_dst->object_bases); BLI_listbase_clear(&sl_dst->drawdata); + layer_collections_recreate(sl_dst, &sl_src->layer_collections, mc_dst, mc_src); + /* Now we handle the syncing for visibility, selectability, ... */ + layer_collections_sync_flags(&sl_dst->layer_collections, &sl_src->layer_collections); + Object *active_ob = OBACT_NEW(sl_src); for (Base *base_src = sl_src->object_bases.first, *base_dst = sl_dst->object_bases.first; base_src; |