diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-02-27 21:38:16 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-02-27 21:38:16 +0400 |
commit | 050428049f1f10ac2c8b6ccf7d775c6d9dcfe2ba (patch) | |
tree | 36987af8cfe4c4401bdab6b5a99ea3097fa056fd /source/blender/nodes/composite | |
parent | d55c1d59f91a919c8d4b935136454200adb0b8e8 (diff) |
Implements a new operator for detaching nodes. In the process i overhauled the node muting system as well.
There are a number of features that use a kind of "internal linking" in nodes:
1. muting
2. delete + reconnect (restore link to/from node after delete)
3. the new detach operator (same as 2, but don't delete the node)
The desired behavior in all cases is the same: find a sensible mapping of inputs-to-outputs of a node. In the case of muting these links are displayed in red on the node itself. For the other operators they are used to relink connections, such that one gets the best possible ongoing link between previous up- and downstream nodes.
Muting previously used a complicated callback system to ensure consistent behavior in the editor as well as execution in compositor, shader cpu/gpu and texture nodes. This has been greatly simplified by moving the muting step into the node tree localization functions. Any muted node is now bypassed using the generalized nodeInternalRelink function and then removed from the local tree. This way the internal execution system doesn't have to deal with muted nodes at all, as if they are non-existent.
The same function is also used by the delete_reconnect and the new links_detach operators (which work directly in the editor node tree). Detaching nodes is currently keymapped as a translation variant (macro operator): pressing ALTKEY + moving node first detaches and then continues with regular transform operator. The default key is ALT+DKEY though, instead ALT+GKEY, since the latter is already used for the ungroup operator.
Diffstat (limited to 'source/blender/nodes/composite')
7 files changed, 28 insertions, 56 deletions
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 8257b850010..0ebed7105f0 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -121,9 +121,9 @@ static void update_node(bNodeTree *ntree, bNode *node) } /* local tree then owns all compbufs */ -static void localize(bNodeTree *UNUSED(localtree), bNodeTree *ntree) +static void localize(bNodeTree *localtree, bNodeTree *ntree) { - bNode *node; + bNode *node, *node_next; bNodeSocket *sock; for(node= ntree->nodes.first; node; node= node->next) { @@ -150,6 +150,26 @@ static void localize(bNodeTree *UNUSED(localtree), bNodeTree *ntree) sock->new_sock->new_sock= sock; } } + + /* replace muted nodes by internal links */ + for (node= localtree->nodes.first; node; node= node_next) { + node_next = node->next; + + if (node->flag & NODE_MUTED) { + /* make sure the update tag isn't lost when removing the muted node. + * propagate this to all downstream nodes. + */ + if (node->need_exec) { + bNodeLink *link; + for (link=localtree->links.first; link; link=link->next) + if (link->fromnode==node && link->tonode) + link->tonode->need_exec = 1; + } + + nodeInternalRelink(localtree, node); + nodeFreeNode(localtree, node); + } + } } static void local_sync(bNodeTree *localtree, bNodeTree *ntree) @@ -230,9 +250,7 @@ bNodeTreeType ntreeType_Composite = { /* update */ update, /* update_node */ update_node, /* validate_link */ NULL, - /* mutefunc */ node_compo_pass_on, - /* mutelinksfunc */ node_mute_get_links, - /* gpumutefunc */ NULL + /* internal_connect */ node_internal_connect_default }; @@ -360,9 +378,7 @@ static void *exec_composite_node(void *nodeexec_v) node_get_stack(node, thd->stack, nsin, nsout); - if((node->flag & NODE_MUTED) && node->typeinfo->mutefunc) - node->typeinfo->mutefunc(thd->rd, 0, node, nodeexec->data, nsin, nsout); - else if(node->typeinfo->execfunc) + if(node->typeinfo->execfunc) node->typeinfo->execfunc(thd->rd, node, nsin, nsout); else if (node->typeinfo->newexecfunc) node->typeinfo->newexecfunc(thd->rd, 0, node, nodeexec->data, nsin, nsout); diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index 45f490729e8..f51cd008904 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -130,32 +130,6 @@ void compbuf_set_node(CompBuf *cbuf, bNode *node) if (cbuf) cbuf->node = node; } -/* used for disabling node (similar code in node_draw.c for disable line and node_edit for untangling nodes) */ -void node_compo_pass_on(void *UNUSED(data), int UNUSED(thread), struct bNode *node, void *UNUSED(nodedata), - struct bNodeStack **in, struct bNodeStack **out) -{ - ListBase links; - LinkInOutsMuteNode *lnk; - int i; - - if(node->typeinfo->mutelinksfunc == NULL) - return; - - /* Get default muting links (as bNodeStack pointers). */ - links = node->typeinfo->mutelinksfunc(NULL, node, in, out, NULL, NULL); - - for(lnk = links.first; lnk; lnk = lnk->next) { - for(i = 0; i < lnk->num_outs; i++) { - if(((bNodeStack*)(lnk->in))->data) - (((bNodeStack*)(lnk->outs))+i)->data = pass_on_compbuf((CompBuf*)((bNodeStack*)(lnk->in))->data); - } - /* If num_outs > 1, lnk->outs was an allocated table of pointers... */ - if(i > 1) - MEM_freeN(lnk->outs); - } - BLI_freelistN(&links); -} - CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, int type) { diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h index 5e63750e131..3efdf76f233 100644 --- a/source/blender/nodes/composite/node_composite_util.h +++ b/source/blender/nodes/composite/node_composite_util.h @@ -124,7 +124,6 @@ CompBuf *pass_on_compbuf(CompBuf *cbuf); void free_compbuf(CompBuf *cbuf); void print_compbuf(char *str, CompBuf *cbuf); void compbuf_set_node(struct CompBuf *cbuf, struct bNode *node); -void node_compo_pass_on(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out); CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, int type); CompBuf *scalefast_compbuf(CompBuf *inbuf, int newx, int newy); diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c index a5f90d31643..73a84676caa 100644 --- a/source/blender/nodes/composite/nodes/node_composite_composite.c +++ b/source/blender/nodes/composite/nodes/node_composite_composite.c @@ -106,7 +106,7 @@ void register_node_type_cmp_composite(bNodeTreeType *ttype) node_type_size(&ntype, 80, 60, 200); node_type_exec(&ntype, node_composit_exec_composite); /* Do not allow muting for this node. */ - node_type_mute(&ntype, NULL, NULL); + node_type_internal_connect(&ntype, NULL); nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index 02df603f494..66075f1bba4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -97,13 +97,6 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack * } } -static void node_composit_mute_output_file(void *UNUSED(data), int UNUSED(thread), - struct bNode *UNUSED(node), void *UNUSED(nodedata), - struct bNodeStack **UNUSED(in), struct bNodeStack **UNUSED(out)) -{ - /* nothing to do here */ -} - static void node_composit_init_output_file(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *ntemp) { RenderData *rd = &ntemp->scene->r; @@ -129,7 +122,6 @@ void register_node_type_cmp_output_file(bNodeTreeType *ttype) node_type_init(&ntype, node_composit_init_output_file); node_type_storage(&ntype, "NodeImageFile", node_free_standard_storage, node_copy_standard_storage); node_type_exec(&ntype, node_composit_exec_output_file); - node_type_mute(&ntype, node_composit_mute_output_file, NULL); nodeRegisterType(ttype, &ntype); } @@ -261,13 +253,6 @@ static void exec_output_multi_file(void *data, bNode *node, bNodeStack **in, bNo } } -static void mute_output_multi_file(void *UNUSED(data), int UNUSED(thread), - struct bNode *UNUSED(node), void *UNUSED(nodedata), - struct bNodeStack **UNUSED(in), struct bNodeStack **UNUSED(out)) -{ - /* nothing to do here */ -} - void register_node_type_cmp_output_multi_file(bNodeTreeType *ttype) { static bNodeType ntype; @@ -278,7 +263,6 @@ void register_node_type_cmp_output_multi_file(bNodeTreeType *ttype) node_type_init(&ntype, init_output_multi_file); node_type_storage(&ntype, "NodeImageMultiFile", free_output_multi_file, copy_output_multi_file); node_type_exec(&ntype, exec_output_multi_file); - node_type_mute(&ntype, mute_output_multi_file, 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 bc8bc7c84d1..16356098fe6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -159,8 +159,8 @@ void register_node_type_cmp_splitviewer(bNodeTreeType *ttype) node_type_init(&ntype, node_composit_init_splitviewer); node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); node_type_exec(&ntype, node_composit_exec_splitviewer); - /* Do not allow muting this node. */ - node_type_mute(&ntype, NULL, NULL); + /* Do not allow muting for this node. */ + node_type_internal_connect(&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 6a0c074cdb3..f1a6cae62ab 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -141,8 +141,7 @@ void register_node_type_cmp_viewer(bNodeTreeType *ttype) node_type_init(&ntype, node_composit_init_viewer); node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); node_type_exec(&ntype, node_composit_exec_viewer); - /* Do not allow muting this node. */ - node_type_mute(&ntype, NULL, NULL); + node_type_internal_connect(&ntype, NULL); nodeRegisterType(ttype, &ntype); } |