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.c')
-rw-r--r--source/blender/blenkernel/intern/node.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index c656931d18b..75f899dd597 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -72,6 +72,8 @@
#include "NOD_shader.h"
#include "NOD_texture.h"
+#define NODE_DEFAULT_MAX_WIDTH 700
+
/* Fallback types for undefined tree, nodes, sockets */
bNodeTreeType NodeTreeTypeUndefined;
bNodeType NodeTypeUndefined;
@@ -1151,6 +1153,11 @@ void nodeDetachNode(struct bNode *node)
}
}
+void ntreeInitDefault(bNodeTree *ntree)
+{
+ ntree_set_typeinfo(ntree, NULL);
+}
+
bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
{
bNodeTree *ntree;
@@ -1965,7 +1972,16 @@ bNodeTree *ntreeFromID(ID *id)
}
}
-void ntreeMakeLocal(bNodeTree *ntree)
+static void extern_local_ntree(bNodeTree *ntree)
+{
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->id) {
+ id_lib_extern(node->id);
+ }
+ }
+}
+
+void ntreeMakeLocal(bNodeTree *ntree, bool id_in_mainlist)
{
Main *bmain = G.main;
bool lib = false, local = false;
@@ -1977,7 +1993,8 @@ void ntreeMakeLocal(bNodeTree *ntree)
if (ntree->id.lib == NULL) return;
if (ntree->id.us == 1) {
- id_clear_lib_data(bmain, (ID *)ntree);
+ id_clear_lib_data_ex(bmain, (ID *)ntree, id_in_mainlist);
+ extern_local_ntree(ntree);
return;
}
@@ -1997,7 +2014,8 @@ void ntreeMakeLocal(bNodeTree *ntree)
/* if all users are local, we simply make tree local */
if (local && !lib) {
- id_clear_lib_data(bmain, (ID *)ntree);
+ id_clear_lib_data_ex(bmain, (ID *)ntree, id_in_mainlist);
+ extern_local_ntree(ntree);
}
else if (local && lib) {
/* this is the mixed case, we copy the tree and assign it to local users */
@@ -2012,8 +2030,8 @@ void ntreeMakeLocal(bNodeTree *ntree)
if (node->id == (ID *)ntree) {
if (owner_id->lib == NULL) {
node->id = (ID *)newtree;
- newtree->id.us++;
- ntree->id.us--;
+ id_us_plus(&newtree->id);
+ id_us_min(&ntree->id);
}
}
}
@@ -2101,8 +2119,10 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
adt->action = ladt->action = action_backup;
adt->tmpact = ladt->tmpact = tmpact_backup;
- if (action_backup) action_backup->id.us++;
- if (tmpact_backup) tmpact_backup->id.us++;
+ if (action_backup)
+ id_us_plus(&action_backup->id);
+ if (tmpact_backup)
+ id_us_plus(&tmpact_backup->id);
}
/* end animdata uglyness */
@@ -3405,20 +3425,24 @@ void node_type_size_preset(struct bNodeType *ntype, eNodeSizePreset size)
{
switch (size) {
case NODE_SIZE_DEFAULT:
- node_type_size(ntype, 140, 100, 320);
+ node_type_size(ntype, 140, 100, NODE_DEFAULT_MAX_WIDTH);
break;
case NODE_SIZE_SMALL:
- node_type_size(ntype, 100, 80, 320);
+ node_type_size(ntype, 100, 80, NODE_DEFAULT_MAX_WIDTH);
break;
case NODE_SIZE_MIDDLE:
- node_type_size(ntype, 150, 120, 320);
+ node_type_size(ntype, 150, 120, NODE_DEFAULT_MAX_WIDTH);
break;
case NODE_SIZE_LARGE:
- node_type_size(ntype, 240, 140, 320);
+ node_type_size(ntype, 240, 140, NODE_DEFAULT_MAX_WIDTH);
break;
}
}
+/**
+ * \warning Nodes defining a storage type _must_ allocate this for new nodes.
+ * Otherwise nodes will reload as undefined (T46619).
+ */
void node_type_storage(bNodeType *ntype,
const char *storagename,
void (*freefunc)(struct bNode *node),