From c8653e516dfaa8ba37638d6da0ea8ee747fadaac Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 22 Jul 2020 17:05:28 +0200 Subject: LibOverride: Optimize/fix new generic 'relation-based' make override code. This commit mostly avoids following 'loop back' ID pointers, since those should never define an actual relationship. --- source/blender/blenkernel/intern/lib_override.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 8e662892d30..9c543e99d74 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -362,7 +362,11 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain) static bool lib_override_hierarchy_recursive_tag(Main *bmain, ID *id, const uint tag) { - MainIDRelationsEntry *entry = BLI_ghash_lookup(bmain->relations->id_user_to_used, id); + void **entry_vp = BLI_ghash_lookup_p(bmain->relations->id_user_to_used, id); + if (entry_vp == NULL) { + /* Already processed. */ + return (id->tag & tag) != 0; + } /* This way we won't process again that ID should we encounter it again through another * relationship hierarchy. @@ -370,7 +374,12 @@ static bool lib_override_hierarchy_recursive_tag(Main *bmain, ID *id, const uint */ BKE_main_relations_ID_remove(bmain, id); - for (; entry != NULL; entry = entry->next) { + for (MainIDRelationsEntry *entry = *entry_vp; entry != NULL; entry = entry->next) { + if ((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. */ if (entry->id_pointer != NULL && (*entry->id_pointer)->lib == id->lib) { if (lib_override_hierarchy_recursive_tag(bmain, *entry->id_pointer, tag)) { -- cgit v1.2.3