[Bf-blender-cvs] [0621c13b3e6] master: Add proper handling of liboverrides to Scene deep copy.

Bastien Montagne noreply at git.blender.org
Wed Jun 10 19:45:58 CEST 2020


Commit: 0621c13b3e60284e0116c4c3aeb11b175f903d52
Author: Bastien Montagne
Date:   Wed Jun 10 19:44:59 2020 +0200
Branches: master
https://developer.blender.org/rB0621c13b3e60284e0116c4c3aeb11b175f903d52

Add proper handling of liboverrides to Scene deep copy.

Followup to rB74ec37b70cbc8dc2, also missed a case in collection
deepcopy then.

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

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

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

diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 675e86b1584..290b181f172 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -389,6 +389,10 @@ static Collection *collection_duplicate_recursive(Main *bmain,
   LISTBASE_FOREACH_MUTABLE (CollectionChild *, child, &collection_old->children) {
     Collection *child_collection_old = child->collection;
 
+    if (is_collection_liboverride && ID_IS_LINKED(child_collection_old)) {
+      continue;
+    }
+
     collection_duplicate_recursive(
         bmain, collection_new, child_collection_old, do_hierarchy, do_objects, do_obdata);
     collection_child_remove(collection_new, child_collection_old);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index b6b478f727e..7cf424f53e0 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -751,6 +751,7 @@ void BKE_scene_copy_data_eevee(Scene *sce_dst, const Scene *sce_src)
 
 Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
 {
+  const bool is_scene_liboverride = ID_IS_OVERRIDE_LIBRARY(sce);
   Scene *sce_copy;
 
   /* TODO this should/could most likely be replaced by call to more generic code at some point...
@@ -833,6 +834,9 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
         LISTBASE_FOREACH (
             FreestyleLineSet *, lineset, &view_layer_dst->freestyle_config.linesets) {
           if (lineset->linestyle) {
+            if (is_scene_liboverride && ID_IS_LINKED(lineset->linestyle)) {
+              continue;
+            }
             id_us_min(&lineset->linestyle->id);
             BKE_id_copy_ex(
                 bmain, (ID *)lineset->linestyle, (ID **)&lineset->linestyle, LIB_ID_COPY_ACTIONS);
@@ -842,14 +846,19 @@ Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type)
 
       /* Full copy of world (included animations) */
       if (sce_copy->world) {
-        id_us_min(&sce_copy->world->id);
-        BKE_id_copy_ex(bmain, (ID *)sce_copy->world, (ID **)&sce_copy->world, LIB_ID_COPY_ACTIONS);
+        if (!is_scene_liboverride || !ID_IS_LINKED(sce_copy->world)) {
+          id_us_min(&sce_copy->world->id);
+          BKE_id_copy_ex(
+              bmain, (ID *)sce_copy->world, (ID **)&sce_copy->world, LIB_ID_COPY_ACTIONS);
+        }
       }
 
       /* Full copy of GreasePencil. */
       if (sce_copy->gpd) {
-        id_us_min(&sce_copy->gpd->id);
-        BKE_id_copy_ex(bmain, (ID *)sce_copy->gpd, (ID **)&sce_copy->gpd, LIB_ID_COPY_ACTIONS);
+        if (!is_scene_liboverride || !ID_IS_LINKED(sce_copy->gpd)) {
+          id_us_min(&sce_copy->gpd->id);
+          BKE_id_copy_ex(bmain, (ID *)sce_copy->gpd, (ID **)&sce_copy->gpd, LIB_ID_COPY_ACTIONS);
+        }
       }
 
       /* Deep-duplicate collections and objects (using preferences' settings for which sub-data to



More information about the Bf-blender-cvs mailing list