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:
authorLukas Toenne <lukas.toenne@googlemail.com>2012-10-25 20:49:06 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-10-25 20:49:06 +0400
commit09ed97afc5b20767a67d598fa3ede70892b5d647 (patch)
treea15cd34777f011f0c43ed8c2cede6d28a80e0554 /source/blender/nodes
parent7107b8eef843a19cabeab1e3d2e68cb3c1cba345 (diff)
Internal node links are now cached in a per-node list, instead of being generated as a transient list that is returned from the callback and had to be freed by the caller. These internal links are used for muted nodes, disconnect operators and reroute nodes, to effectively replace the node with direct input-to-output links.
Storing this list in the node has the advantage of requiring far fewer calls to the potentially expensive internal_connect callback. This was called on every node redraw ... Also it will allow Cycles to properly use the internal links for muted nodes, which ensures consistent behavior. The previous method was not applicable in Cycles because transient list return values are not supported well in the RNA and particularly the C++ API implementation.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_composite.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_splitViewer.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_viewer.c2
-rw-r--r--source/blender/nodes/intern/node_common.c13
-rw-r--r--source/blender/nodes/intern/node_exec.c10
-rw-r--r--source/blender/nodes/intern/node_util.c13
-rw-r--r--source/blender/nodes/intern/node_util.h2
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_lamp.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_material.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_world.c2
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_output.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_viewer.c2
16 files changed, 23 insertions, 39 deletions
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 2d65d083131..9a7e587ff56 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -273,7 +273,7 @@ bNodeTreeType ntreeType_Composite = {
/* update */ update,
/* update_node */ update_node,
/* validate_link */ NULL,
- /* internal_connect */ node_internal_connect_default
+ /* update_internal_links */ node_update_internal_links_default
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c
index edbb627265d..cb932b6a8de 100644
--- a/source/blender/nodes/composite/nodes/node_composite_composite.c
+++ b/source/blender/nodes/composite/nodes/node_composite_composite.c
@@ -110,7 +110,7 @@ void register_node_type_cmp_composite(bNodeTreeType *ttype)
#endif
/* Do not allow muting for this node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
index 70c1bf8f23f..73cf039c6df 100644
--- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
@@ -167,7 +167,7 @@ void register_node_type_cmp_splitviewer(bNodeTreeType *ttype)
#endif
/* Do not allow muting for this node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c
index 6321b1def4d..938f75cf3f5 100644
--- a/source/blender/nodes/composite/nodes/node_composite_viewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c
@@ -149,7 +149,7 @@ void register_node_type_cmp_viewer(bNodeTreeType *ttype)
node_type_exec(&ntype, node_composit_exec_viewer);
#endif
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index 0a7f619d13c..86ef8a14c12 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -385,16 +385,13 @@ void register_node_type_frame(bNodeTreeType *ttype)
/* **************** REROUTE ******************** */
/* simple, only a single input and output here */
-static ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node)
+static void node_reroute_update_internal_links(bNodeTree *ntree, bNode *node)
{
bNodeLink *link;
- ListBase ret;
-
- ret.first = ret.last = NULL;
/* Security check! */
if (!ntree)
- return ret;
+ return;
link = MEM_callocN(sizeof(bNodeLink), "internal node link");
link->fromnode = node;
@@ -403,9 +400,7 @@ static ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node)
link->tosock = node->outputs.first;
/* internal link is always valid */
link->flag |= NODE_LINK_VALID;
- BLI_addtail(&ret, link);
-
- return ret;
+ BLI_addtail(&node->internal_links, link);
}
static void node_reroute_init(bNodeTree *ntree, bNode *node, bNodeTemplate *UNUSED(ntemp))
@@ -424,7 +419,7 @@ void register_node_type_reroute(bNodeTreeType *ttype)
node_type_base(ttype, ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT, 0);
node_type_init(ntype, node_reroute_init);
- node_type_internal_connect(ntype, node_reroute_internal_connect);
+ node_type_internal_links(ntype, node_reroute_update_internal_links);
ntype->needs_free = 1;
nodeRegisterType(ttype, ntype);
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index 3040e8589fd..3cc7ebf9337 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -177,15 +177,9 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree)
for (sock=node->inputs.first; sock; sock=sock->next)
node_init_input_index(sock, &index);
- if ((node->flag & NODE_MUTED || node->type == NODE_REROUTE)
- && node->typeinfo->internal_connect) {
-
- ListBase internal_links = node->typeinfo->internal_connect(ntree, node);
-
+ if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
for (sock=node->outputs.first; sock; sock=sock->next)
- node_init_output_index(sock, &index, &internal_links);
-
- BLI_freelistN(&internal_links);
+ node_init_output_index(sock, &index, &node->internal_links);
}
else {
for (sock=node->outputs.first; sock; sock=sock->next)
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index 27258c45fe5..342c366fb48 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -109,18 +109,15 @@ const char *node_filter_label(bNode *node)
return IFACE_(name);
}
-ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node)
+void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
{
- ListBase ret;
bNodeSocket *fromsock_first=NULL, *tosock_first=NULL; /* used for fallback link if no other reconnections are found */
int datatype;
int num_links_in = 0, num_links_out = 0, num_reconnect = 0;
- ret.first = ret.last = NULL;
-
/* Security check! */
if (!ntree)
- return ret;
+ return;
for (datatype=0; datatype < NUM_SOCKET_TYPES; ++datatype) {
bNodeSocket *fromsock, *tosock;
@@ -170,7 +167,7 @@ ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node)
ilink->tosock = tosock;
/* internal link is always valid */
ilink->flag |= NODE_LINK_VALID;
- BLI_addtail(&ret, ilink);
+ BLI_addtail(&node->internal_links, ilink);
++num_reconnect;
}
@@ -188,8 +185,6 @@ ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node)
ilink->tosock = tosock_first;
/* internal link is always valid */
ilink->flag |= NODE_LINK_VALID;
- BLI_addtail(&ret, ilink);
+ BLI_addtail(&node->internal_links, ilink);
}
-
- return ret;
}
diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h
index 95104df5fed..3134baa283c 100644
--- a/source/blender/nodes/intern/node_util.h
+++ b/source/blender/nodes/intern/node_util.h
@@ -62,7 +62,7 @@ const char *node_math_label(struct bNode *node);
const char *node_vect_math_label(struct bNode *node);
const char *node_filter_label(struct bNode *node);
-ListBase node_internal_connect_default(struct bNodeTree *ntree, struct bNode *node);
+void node_update_internal_links_default(struct bNodeTree *ntree, struct bNode *node);
#endif
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index ad907c317f8..76bc3b12690 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -153,7 +153,7 @@ bNodeTreeType ntreeType_Shader = {
/* update */ update,
/* update_node */ NULL,
/* validate_link */ NULL,
- /* internal_connect */ node_internal_connect_default
+ /* update_internal_links */ node_update_internal_links_default
};
/* GPU material from shader nodes */
diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c
index 8d8c1a903a5..6f7f900aecd 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output.c
@@ -92,7 +92,7 @@ void register_node_type_sh_output(bNodeTreeType *ttype)
node_type_gpu(&ntype, gpu_shader_output);
/* Do not allow muting output node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
index f24f5a85ff0..ce406a8f5a1 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
@@ -49,7 +49,7 @@ void register_node_type_sh_output_lamp(bNodeTreeType *ttype)
node_type_gpu(&ntype, NULL);
/* Do not allow muting output node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c
index 03b0559fd8e..f185e13010b 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c
@@ -62,7 +62,7 @@ void register_node_type_sh_output_material(bNodeTreeType *ttype)
node_type_gpu(&ntype, node_shader_gpu_output_material);
/* Do not allow muting output node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.c
index 624805cd39f..953197ab2cd 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_world.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_world.c
@@ -50,7 +50,7 @@ void register_node_type_sh_output_world(bNodeTreeType *ttype)
node_type_gpu(&ntype, NULL);
/* Do not allow muting output node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 1bfd88d3af7..ba94531c259 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -134,7 +134,7 @@ bNodeTreeType ntreeType_Texture = {
/* update */ update,
/* update_node */ NULL,
/* validate_link */ NULL,
- /* internal_connect */ node_internal_connect_default
+ /* update_internal_links */ node_update_internal_links_default
};
int ntreeTexTagAnimated(bNodeTree *ntree)
diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c
index 5867dc03050..2f5efe8c45e 100644
--- a/source/blender/nodes/texture/nodes/node_texture_output.c
+++ b/source/blender/nodes/texture/nodes/node_texture_output.c
@@ -170,7 +170,7 @@ void register_node_type_tex_output(bNodeTreeType *ttype)
node_type_exec(&ntype, exec);
/* Do not allow muting output. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.c b/source/blender/nodes/texture/nodes/node_texture_viewer.c
index bc31bef59d8..5cb8d8c438c 100644
--- a/source/blender/nodes/texture/nodes/node_texture_viewer.c
+++ b/source/blender/nodes/texture/nodes/node_texture_viewer.c
@@ -66,7 +66,7 @@ void register_node_type_tex_viewer(bNodeTreeType *ttype)
node_type_exec(&ntype, exec);
/* Do not allow muting viewer node. */
- node_type_internal_connect(&ntype, NULL);
+ node_type_internal_links(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}