Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2022-08-12 11:39:03 +0300
committerBastien Montagne <bastien@blender.org>2022-08-12 13:37:10 +0300
commit12b36168957dd27c253251555c29e8523b94fbe8 (patch)
tree654af023fc4ae7bc3e6472409140e813efdc9800 /source/blender/blenkernel/intern/node.cc
parent498e26fa0f6486fa2d3bb0029b11eb1dc48a32be (diff)
IDType `get_owner`: add an optional hint about owner ID.
In some cases, there is a chance code already knows who might be the owner of the given ID, in which case it can be more efficient to check it first (especially in cases like embedded node trees or scene collections, where the only other way is to loop over all possible owners currently). Will be used in next commit in some Outliner fix.
Diffstat (limited to 'source/blender/blenkernel/intern/node.cc')
-rw-r--r--source/blender/blenkernel/intern/node.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 86c05d6d085..d50b8662f82 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -404,7 +404,7 @@ static void node_foreach_path(ID *id, BPathForeachPathData *bpath_data)
}
}
-static ID *node_owner_get(Main *bmain, ID *id)
+static ID *node_owner_get(Main *bmain, ID *id, ID *owner_id_hint)
{
if ((id->flag & LIB_EMBEDDED_DATA) == 0) {
return id;
@@ -412,6 +412,12 @@ static ID *node_owner_get(Main *bmain, ID *id)
/* TODO: Sort this NO_MAIN or not for embedded node trees. See T86119. */
// BLI_assert((id->tag & LIB_TAG_NO_MAIN) == 0);
+ bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
+
+ if (owner_id_hint != nullptr && ntreeFromID(owner_id_hint) == ntree) {
+ return owner_id_hint;
+ }
+
ListBase *lists[] = {&bmain->materials,
&bmain->lights,
&bmain->worlds,
@@ -421,7 +427,6 @@ static ID *node_owner_get(Main *bmain, ID *id)
&bmain->simulations,
nullptr};
- bNodeTree *ntree = (bNodeTree *)id;
for (int i = 0; lists[i] != nullptr; i++) {
LISTBASE_FOREACH (ID *, id_iter, lists[i]) {
if (ntreeFromID(id_iter) == ntree) {