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/texture/node_texture_util.c | |
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/texture/node_texture_util.c')
-rw-r--r-- | source/blender/nodes/texture/node_texture_util.c | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c index 06ee4b0a53d..c3d298d1ecd 100644 --- a/source/blender/nodes/texture/node_texture_util.c +++ b/source/blender/nodes/texture/node_texture_util.c @@ -143,98 +143,6 @@ void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn, TexC dg->type = out->sockettype; } -/* Used for muted nodes, just pass the TexDelegate data from input to output… - * XXX That *%!?¿§ callback TextureDelegate system is a nightmare here! - * So I have to use an ugly hack (checking inputs twice!)… Yuk! - * I’d be very happy if someone can imagine a better solution - * (without changing the whole stuff). - * WARNING: These are only suitable for default muting behavior. If you want a custom - * one for your texnode, you must not use them! - */ -static void passonvalfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - bNodeSocket *sock; - int i; - - /* test the inputs */ - for(i=0, sock = node->inputs.first; sock; sock = sock->next, i++) { - if(sock->link && sock->type==SOCK_FLOAT && in) { - out[0] = tex_input_value(in[i], p, thread); - break; - } - } -} - -static void passonvecfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - bNodeSocket *sock; - int i; - - /* test the inputs */ - for(i=0, sock = node->inputs.first; sock; sock = sock->next, i++) { - if(sock->link && sock->type==SOCK_VECTOR && in) { - tex_input_vec(out, in[i], p, thread); - break; - } - } -} - -static void passoncolfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - bNodeSocket *sock; - int i; - - /* test the inputs */ - for(i=0, sock = node->inputs.first; sock; sock = sock->next, i++) { - if(sock->link && sock->type==SOCK_RGBA && in) { - tex_input_rgba(out, in[i], p, thread); - break; - } - } -} - -void node_tex_pass_on(void *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) { - /* XXX This breaks the generality of the system. - * Again, unfortunately, I see no other way to do due to tex nodes behavior... - */ - void (*passonfn)(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread); - switch(((bNodeStack*)(lnk->in))->sockettype) { - case SOCK_FLOAT: - passonfn = passonvalfn; - break; - case SOCK_VECTOR: - passonfn = passonvecfn; - break; - case SOCK_RGBA: - passonfn = passoncolfn; - break; - default: - passonfn = NULL; - } - for(i = 0; i < lnk->num_outs; i++) { - if(((bNodeStack*)(lnk->in))->data && passonfn) - tex_output(node, in, ((bNodeStack*)(lnk->outs))+i, passonfn, data); - } - /* If num_outs > 1, lnk->outs was an allocated table of pointers... */ - if(i > 1) - MEM_freeN(lnk->outs); - } - BLI_freelistN(&links); -} - void ntreeTexCheckCyclics(struct bNodeTree *ntree) { bNode *node; |