[Bf-blender-cvs] [2262e18269b] master: Cleanup: LibOverride: group logically utils static functions.

Bastien Montagne noreply at git.blender.org
Tue Feb 2 17:27:25 CET 2021


Commit: 2262e18269bf93a5b93ad0f36020cef69b728f43
Author: Bastien Montagne
Date:   Mon Feb 1 17:39:00 2021 +0100
Branches: master
https://developer.blender.org/rB2262e18269bf93a5b93ad0f36020cef69b728f43

Cleanup: LibOverride: group logically utils static functions.

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

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

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

diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 7ccf53546b8..9e8e515e1a3 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -368,6 +368,46 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain)
   return success;
 }
 
+/* Tag all IDs in dependency relationships within an override hierarchy/group.
+ *
+ * Note: this is typically called to complete `lib_override_linked_group_tag()`.
+ * Note: BMain's relations mapping won't be valid anymore after that call.
+ */
+static bool lib_override_hierarchy_dependencies_recursive_tag(Main *bmain,
+                                                              ID *id,
+                                                              const uint tag,
+                                                              const uint missing_tag)
+{
+  MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id);
+  BLI_assert(entry != NULL);
+
+  if (entry->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED) {
+    /* This ID has already been processed. */
+    return (*(uint *)&id->tag & tag) != 0;
+  }
+  /* This way we won't process again that ID, should we encounter it again through another
+   * relationship hierarchy. */
+  entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED;
+
+  for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL;
+       to_id_entry = to_id_entry->next) {
+    if ((to_id_entry->usage_flag & IDWALK_CB_LOOPBACK) != 0) {
+      /* Never consider 'loop back' relationships ('from', 'parents', 'owner' etc. pointers) as
+       * actual dependencies. */
+      continue;
+    }
+    /* We only consider IDs from the same library. */
+    ID *to_id = *to_id_entry->id_pointer.to;
+    if (to_id != NULL && to_id->lib == id->lib) {
+      if (lib_override_hierarchy_dependencies_recursive_tag(bmain, to_id, tag, missing_tag)) {
+        id->tag |= tag;
+      }
+    }
+  }
+
+  return (*(uint *)&id->tag & tag) != 0;
+}
+
 typedef struct LibOverrideGroupTagData {
   ID *id_root;
   uint tag;
@@ -422,46 +462,6 @@ static int lib_override_linked_group_tag_cb(LibraryIDLinkCallbackData *cb_data)
   return IDWALK_RET_NOP;
 }
 
-/* Tag all IDs in dependency relationships within an override hierarchy/group.
- *
- * Note: this is typically called to complete `lib_override_linked_group_tag()`.
- * Note: BMain's relations mapping won't be valid anymore after that call.
- */
-static bool lib_override_hierarchy_dependencies_recursive_tag(Main *bmain,
-                                                              ID *id,
-                                                              const uint tag,
-                                                              const uint missing_tag)
-{
-  MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->relations_from_pointers, id);
-  BLI_assert(entry != NULL);
-
-  if (entry->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED) {
-    /* This ID has already been processed. */
-    return (*(uint *)&id->tag & tag) != 0;
-  }
-  /* This way we won't process again that ID, should we encounter it again through another
-   * relationship hierarchy. */
-  entry->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED;
-
-  for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL;
-       to_id_entry = to_id_entry->next) {
-    if ((to_id_entry->usage_flag & IDWALK_CB_LOOPBACK) != 0) {
-      /* Never consider 'loop back' relationships ('from', 'parents', 'owner' etc. pointers) as
-       * actual dependencies. */
-      continue;
-    }
-    /* We only consider IDs from the same library. */
-    ID *to_id = *to_id_entry->id_pointer.to;
-    if (to_id != NULL && to_id->lib == id->lib) {
-      if (lib_override_hierarchy_dependencies_recursive_tag(bmain, to_id, tag, missing_tag)) {
-        id->tag |= tag;
-      }
-    }
-  }
-
-  return (*(uint *)&id->tag & tag) != 0;
-}
-
 /* This will tag at least all 'boundary' linked IDs for a potential override group.
  *
  * Note that you will then need to call #lib_override_hierarchy_dependencies_recursive_tag to



More information about the Bf-blender-cvs mailing list