Commit: 24fe659224b281ceca64f71f372f12f5905f6a77
Author: Bastien Montagne
Date:   Wed Aug 31 14:44:55 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB24fe659224b281ceca64f71f372f12f5905f6a77

LibOverride: Replace linked objects by their overrides when created from 3DView.

From the 3DView code has basically no knowledge of collection hierarchy,
so we can either not remap any local usage of linked objects that are
being overridden, or remap them in all their local collections.

The second behavior makes most sense in the vast majority of cases.

Note that this was only an issue when directly linking and overriding
objects, not when doing so through collections.

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

M       source/blender/editors/object/object_relations.c

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

diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index 22f777c0846..a33cc60cddc 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2356,6 +2356,25 @@ static int make_override_library_exec(bContext *C, 
wmOperator *op)
 
   BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
 
+  /* For the time being, replace selected linked objects by their overrides in 
all collections.
+   * While this may not be the absolute best behavior in all cases, in most 
common one this should
+   * match the expected result. */
+  if (user_overrides_objects_uids != NULL) {
+    LISTBASE_FOREACH (Collection *, coll_iter, &bmain->collections) {
+      if (ID_IS_LINKED(coll_iter)) {
+        continue;
+      }
+      LISTBASE_FOREACH (CollectionObject *, coll_ob_iter, &coll_iter->gobject) 
{
+        if (BLI_gset_haskey(user_overrides_objects_uids,
+                            
POINTER_FROM_UINT(coll_ob_iter->ob->id.session_uuid))) {
+          /* Tag for remapping when creating overrides. */
+          coll_iter->id.tag |= LIB_TAG_DOIT;
+          break;
+        }
+      }
+    }
+  }
+
   ID *id_root_override;
   const bool success = BKE_lib_override_library_create(bmain,
                                                        scene,

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to