[Bf-blender-cvs] [928d6448958] master: Append: Fix appended objects potentially auto-instantiated in more than one collection.

Bastien Montagne noreply at git.blender.org
Fri Oct 1 12:25:01 CEST 2021


Commit: 928d644895887fd8864531e21570546c07d9c53f
Author: Bastien Montagne
Date:   Fri Oct 1 12:13:29 2021 +0200
Branches: master
https://developer.blender.org/rB928d644895887fd8864531e21570546c07d9c53f

Append: Fix appended objects potentially auto-instantiated in more than one collection.

Related to T87189.

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

M	source/blender/blenloader/intern/readfile.c

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index cdae043d01c..c7c5a8b8a0d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4506,7 +4506,10 @@ static void add_loose_objects_to_scene(Main *mainvar,
   /* Give all objects which are LIB_TAG_INDIRECT a base,
    * or for a collection when *lib has been set. */
   LISTBASE_FOREACH (Object *, ob, &mainvar->objects) {
-    bool do_it = (ob->id.tag & LIB_TAG_DOIT) != 0;
+    /* NOTE: Even if this is a directly linked object and is tagged for instantiation, it might
+     * have already been instantiated through one of its owner collections, in which case we do not
+     * want to re-instantiate it in the active collection here. */
+    bool do_it = (ob->id.tag & LIB_TAG_DOIT) != 0 && !BKE_scene_object_find(scene, ob);
     if (do_it ||
         ((ob->id.tag & LIB_TAG_INDIRECT) != 0 && (ob->id.tag & LIB_TAG_PRE_EXISTING) == 0)) {
       if (do_append) {



More information about the Bf-blender-cvs mailing list