[Bf-blender-cvs] [4ed6b891d59] master: Fix T63173: Dragging hidden collection inside a visible one unhides it

Dalai Felinto noreply at git.blender.org
Mon May 27 16:39:43 CEST 2019


Commit: 4ed6b891d5990c3e182d20f6c58b200be1a49cc6
Author: Dalai Felinto
Date:   Fri May 24 16:13:22 2019 -0300
Branches: master
https://developer.blender.org/rB4ed6b891d5990c3e182d20f6c58b200be1a49cc6

Fix T63173: Dragging hidden collection inside a visible one unhides it

Same for holdout, indirect only and exclude.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D4945

===================================================================

M	source/blender/blenkernel/intern/collection.c

===================================================================

diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 68392bf0d03..e8d82ade7d3 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -1250,8 +1250,43 @@ bool BKE_collection_move(Main *bmain,
     }
   }
 
+  /* Make sure we store the flag of the layer collections before we remove and re-create them.
+   * Otherwise they will get lost and everything will be copied from the new parent collection. */
+  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) {
+
+      LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
+          view_layer, collection);
+
+      if (layer_collection == NULL) {
+        continue;
+      }
+
+      BLI_ghash_insert(view_layer_hash, view_layer, POINTER_FROM_INT(layer_collection->flag));
+    }
+  }
+
+  /* Create and remove layer collections. */
   BKE_main_collection_sync(bmain);
 
+  /* Restore back the original layer collection flags. */
+  GHashIterator gh_iter;
+  GHASH_ITER (gh_iter, view_layer_hash) {
+    ViewLayer *view_layer = BLI_ghashIterator_getKey(&gh_iter);
+
+    LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
+        view_layer, collection);
+
+    if (layer_collection) {
+      layer_collection->flag = POINTER_AS_INT(BLI_ghashIterator_getValue(&gh_iter));
+    }
+  }
+
+  BLI_ghash_free(view_layer_hash, NULL, NULL);
+
   return true;
 }



More information about the Bf-blender-cvs mailing list