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-24 16:57:48 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-10-24 16:57:48 +0400
commit2af81d4a5ec9e7898ce92584a220074cc4549130 (patch)
treed3eab235cf572ac3ee561358eefab6540e1aa581 /source/blender/nodes/intern
parent0a3e0b816c6600bdad2c0f1cecc71109696a5735 (diff)
Fix #32835, Reroute node on shading nodes connection gives wrong renders.
Problem here is that muted nodes and reroute nodes are supposed to be removed from the execution node tree during the localize function. However, this is function is apparently only used during preview renders and must be considered a hack (is there anything that is not a hack in BI?) Now the mute/reroute check happens in the node tree exec functions still used by BI and the legacy compositor and texture nodes. It uses the same internal_connect function from nodes to assign input stack indices directly to outputs (which also avoids overhead). Localize function also still does this. Cycles/Tile should also implement muting/reroute in their intermediate node layers by using this function, then it could be removed from localize too.
Diffstat (limited to 'source/blender/nodes/intern')
-rw-r--r--source/blender/nodes/intern/node_exec.c45
-rw-r--r--source/blender/nodes/intern/node_exec.h2
2 files changed, 37 insertions, 10 deletions
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index d63a13fad00..3040e8589fd 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -69,7 +69,7 @@ void node_get_stack(bNode *node, bNodeStack *stack, bNodeStack **in, bNodeStack
}
}
-void node_init_input_index(bNodeSocket *sock, int *index)
+static void node_init_input_index(bNodeSocket *sock, int *index)
{
if (sock->link && sock->link->fromsock) {
sock->stack_index = sock->link->fromsock->stack_index;
@@ -79,9 +79,24 @@ void node_init_input_index(bNodeSocket *sock, int *index)
}
}
-void node_init_output_index(bNodeSocket *sock, int *index)
+static void node_init_output_index(bNodeSocket *sock, int *index, ListBase *internal_links)
{
- sock->stack_index = (*index)++;
+ if (internal_links) {
+ bNodeLink *link;
+ /* copy the stack index from internally connected input to skip the node */
+ for (link = internal_links->first; link; link = link->next) {
+ if (link->tosock == sock) {
+ sock->stack_index = link->fromsock->stack_index;
+ break;
+ }
+ }
+ /* if not internally connected, assign a new stack index anyway to avoid bad stack access */
+ if (!link)
+ sock->stack_index = (*index)++;
+ }
+ else {
+ sock->stack_index = (*index)++;
+ }
}
/* basic preparation of socket stacks */
@@ -133,7 +148,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree)
bNodeExec *nodeexec;
bNodeSocket *sock, *gsock;
bNodeStack *ns;
- int index= 0;
+ int index;
bNode **nodelist;
int totnodes, n;
@@ -148,10 +163,11 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree)
/* backpointer to node tree */
exec->nodetree = ntree;
+ /* set stack indices */
+ index = 0;
/* group inputs essentially work as outputs */
for (gsock=ntree->inputs.first; gsock; gsock = gsock->next)
- node_init_output_index(gsock, &index);
- /* set stack indexes */
+ node_init_output_index(gsock, &index, NULL);
for (n=0; n < totnodes; ++n) {
node = nodelist[n];
@@ -160,8 +176,21 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree)
/* init node socket stack indexes */
for (sock=node->inputs.first; sock; sock=sock->next)
node_init_input_index(sock, &index);
- for (sock=node->outputs.first; sock; sock=sock->next)
- node_init_output_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);
+
+ for (sock=node->outputs.first; sock; sock=sock->next)
+ node_init_output_index(sock, &index, &internal_links);
+
+ BLI_freelistN(&internal_links);
+ }
+ else {
+ for (sock=node->outputs.first; sock; sock=sock->next)
+ node_init_output_index(sock, &index, NULL);
+ }
}
/* group outputs essentially work as inputs */
for (gsock=ntree->outputs.first; gsock; gsock = gsock->next)
diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h
index 1003206e96a..e985795de71 100644
--- a/source/blender/nodes/intern/node_exec.h
+++ b/source/blender/nodes/intern/node_exec.h
@@ -73,8 +73,6 @@ typedef struct bNodeThreadStack {
struct bNodeStack *node_get_socket_stack(struct bNodeStack *stack, struct bNodeSocket *sock);
void node_get_stack(struct bNode *node, struct bNodeStack *stack, struct bNodeStack **in, struct bNodeStack **out);
-void node_init_input_index(struct bNodeSocket *sock, int *index);
-void node_init_output_index(struct bNodeSocket *sock, int *index);
struct bNodeTreeExec *ntree_exec_begin(struct bNodeTree *ntree);
void ntree_exec_end(struct bNodeTreeExec *exec);