[Bf-blender-cvs] [a5db981b0ea] master: Fix T76346: Moving objects in outliner doesn't update local collections

Dalai Felinto noreply at git.blender.org
Wed Sep 9 16:58:14 CEST 2020


Commit: a5db981b0ea044313239c3cc2ee92d19a8f682ea
Author: Dalai Felinto
Date:   Wed Sep 9 11:38:44 2020 +0200
Branches: master
https://developer.blender.org/rBa5db981b0ea044313239c3cc2ee92d19a8f682ea

Fix T76346: Moving objects in outliner doesn't update local collections

The fix involves going over ALL the possible combinations of viewlayers
and viewports and re-sync.
I tested this with multiple windows, multiple scenes and multiple
viewlayers.

Since (for now?) the operation of syncing the local layer collections is
not too expensive, this is not so bad. In theory we could improve this
by checking if the collection the object was moved to and from is in the
scene before iterating over it. I don't think it is worthy though.

Thanks Arun Parolikkal for the initial attempt on D8342.
Final patch reviewed by Brecht Van Lommel.

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

M	source/blender/blenkernel/BKE_layer.h
M	source/blender/blenkernel/intern/layer.c

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

diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 52503f08153..b903545bd3b 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -99,6 +99,7 @@ void BKE_main_collection_sync(const struct Main *bmain);
 void BKE_scene_collection_sync(const struct Scene *scene);
 void BKE_layer_collection_sync(const struct Scene *scene, struct ViewLayer *view_layer);
 void BKE_layer_collection_local_sync(struct ViewLayer *view_layer, const struct View3D *v3d);
+void BKE_layer_collection_local_sync_all(struct Main *bmain);
 
 void BKE_main_collection_sync_remap(const struct Main *bmain);
 
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 4da59ff302d..2f1ad2559f9 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -931,6 +931,8 @@ void BKE_main_collection_sync(const Main *bmain)
   for (const Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
     BKE_scene_collection_sync(scene);
   }
+
+  BKE_layer_collection_local_sync_all(bmain);
 }
 
 void BKE_main_collection_sync_remap(const Main *bmain)
@@ -1245,6 +1247,28 @@ void BKE_layer_collection_local_sync(ViewLayer *view_layer, const View3D *v3d)
   }
 }
 
+/**
+ * Sync the local collection for all the viewports.
+ */
+void BKE_layer_collection_local_sync_all(Main *bmain)
+{
+  LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+    LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
+      LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+        LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+          if (area->spacetype != SPACE_VIEW3D) {
+            continue;
+          }
+          View3D *v3d = area->spacedata.first;
+          if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
+            BKE_layer_collection_local_sync(view_layer, v3d);
+          }
+        }
+      }
+    }
+  }
+}
+
 /**
  * Isolate the collection locally
  *



More information about the Bf-blender-cvs mailing list