diff options
-rw-r--r-- | source/blender/nodes/intern/node_exec.c | 45 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_exec.h | 2 |
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); |