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:
Diffstat (limited to 'source/blender/blenkernel/intern/node.cc')
-rw-r--r--source/blender/blenkernel/intern/node.cc53
1 files changed, 30 insertions, 23 deletions
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index b96adce7cca..58003c03f8c 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -367,6 +367,35 @@ static void node_foreach_cache(ID *id,
}
}
+static ID *node_owner_get(Main *bmain, ID *id)
+{
+ if ((id->flag & LIB_EMBEDDED_DATA) == 0) {
+ return id;
+ }
+ BLI_assert((id->tag & LIB_TAG_NO_MAIN) == 0);
+
+ ListBase *lists[] = {&bmain->materials,
+ &bmain->lights,
+ &bmain->worlds,
+ &bmain->textures,
+ &bmain->scenes,
+ &bmain->linestyles,
+ &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) {
+ return id_iter;
+ }
+ }
+ }
+
+ BLI_assert(!"Embedded node tree with no owner. Critical Main inconsistency.");
+ return nullptr;
+}
+
static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *sock)
{
if (sock->default_value == nullptr) {
@@ -916,6 +945,7 @@ IDTypeInfo IDType_ID_NT = {
/* make_local */ nullptr,
/* foreach_id */ node_foreach_id,
/* foreach_cache */ node_foreach_cache,
+ /* owner_get */ node_owner_get,
/* blend_write */ ntree_blend_write,
/* blend_read_data */ ntree_blend_read_data,
@@ -2980,29 +3010,6 @@ bNodeTree *ntreeFromID(ID *id)
return (nodetree != nullptr) ? *nodetree : nullptr;
}
-/* Finds and returns the datablock that privately owns the given tree, or null. */
-ID *BKE_node_tree_find_owner_ID(Main *bmain, struct bNodeTree *ntree)
-{
- ListBase *lists[] = {&bmain->materials,
- &bmain->lights,
- &bmain->worlds,
- &bmain->textures,
- &bmain->scenes,
- &bmain->linestyles,
- &bmain->simulations,
- nullptr};
-
- for (int i = 0; lists[i] != nullptr; i++) {
- LISTBASE_FOREACH (ID *, id, lists[i]) {
- if (ntreeFromID(id) == ntree) {
- return id;
- }
- }
- }
-
- return nullptr;
-}
-
bool ntreeNodeExists(const bNodeTree *ntree, const bNode *testnode)
{
LISTBASE_FOREACH (const bNode *, node, &ntree->nodes) {