From c116ed473e2c3c5d3e842e53415bf5646b2b03d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 13 Dec 2024 10:45:48 +0100 Subject: [PATCH] Anim: explicity handle node trees when rebuilding action slot user cache Instead of using `BKE_library_foreach_ID_link()` as a way to find embedded IDs in a generic way, explicitly just get the embedded node tree. That's the only animatable embeddable ID anyway. And calling `BKE_library_foreach_ID_link()` can have some unwanted side-effects (especially when the rebuilding happens while already using a similar function to loop over IDs). Pull Request: https://projects.blender.org/blender/blender/pulls/131807 --- .../blender/animrig/intern/action_runtime.cc | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/source/blender/animrig/intern/action_runtime.cc b/source/blender/animrig/intern/action_runtime.cc index 55329afada5..e12167b917e 100644 --- a/source/blender/animrig/intern/action_runtime.cc +++ b/source/blender/animrig/intern/action_runtime.cc @@ -13,6 +13,7 @@ #include "BKE_lib_query.hh" #include "BKE_main.hh" #include "BKE_nla.hh" +#include "BKE_node.hh" #include "BLI_set.hh" @@ -68,21 +69,6 @@ void rebuild_slot_user_cache(Main &bmain) return true; }; - auto visit_linked_id = [&](LibraryIDLinkCallbackData *cb_data) -> int { - ID *id = *cb_data->id_pointer; - if (!id) { - /* Can happen when the 'foreach' code visits a nullptr. */ - return IDWALK_RET_NOP; - } - - if (!visit_id(id)) { - /* When we hit an ID that was already visited, the recursion can stop. */ - return IDWALK_RET_STOP_RECURSION; - } - - return IDWALK_RET_NOP; - }; - /* Loop over all IDs to cache their slot usage. */ ListBase *ids_of_idtype; ID *id; @@ -102,16 +88,13 @@ void rebuild_slot_user_cache(Main &bmain) } /* Process embedded IDs, as these are not listed in bmain, but still can - * have their own Action+Slot. */ - BKE_library_foreach_ID_link( - &bmain, - id, - visit_linked_id, - nullptr, - IDWALK_READONLY | IDWALK_RECURSE | - /* This is more about "we don't care" than "must be ignored". We don't pass an owner - * ID, and it's not used in the callback either, so don't bother looking it up. */ - IDWALK_IGNORE_MISSING_OWNER_ID); + * have their own Action+Slot. Unfortunately there is no generic looper + * for embedded IDs. At this moment the only animatable embedded ID is a + * node tree. */ + bNodeTree *node_tree = bke::node_tree_from_id(id); + if (node_tree) { + visit_id(&node_tree->id); + } } FOREACH_MAIN_LISTBASE_ID_END; }