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-02-27 21:38:16 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-02-27 21:38:16 +0400
commit050428049f1f10ac2c8b6ccf7d775c6d9dcfe2ba (patch)
tree36987af8cfe4c4401bdab6b5a99ea3097fa056fd /source/blender/nodes/texture
parentd55c1d59f91a919c8d4b935136454200adb0b8e8 (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')
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c21
-rw-r--r--source/blender/nodes/texture/node_texture_util.c92
-rw-r--r--source/blender/nodes/texture/node_texture_util.h2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_output.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_viewer.c2
5 files changed, 19 insertions, 100 deletions
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 1e171bd8a46..2795cbd3e5a 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -77,6 +77,21 @@ static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCa
func(calldata, NODE_CLASS_LAYOUT, IFACE_("Layout"));
}
+static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree))
+{
+ bNode *node, *node_next;
+
+ /* replace muted nodes by internal links */
+ for (node= localtree->nodes.first; node; node= node_next) {
+ node_next = node->next;
+
+ if (node->flag & NODE_MUTED) {
+ nodeInternalRelink(localtree, node);
+ nodeFreeNode(localtree, node);
+ }
+ }
+}
+
static void local_sync(bNodeTree *localtree, bNodeTree *ntree)
{
bNode *lnode;
@@ -107,15 +122,13 @@ bNodeTreeType ntreeType_Texture = {
/* free_node_cache */ NULL,
/* foreach_nodetree */ foreach_nodetree,
/* foreach_nodeclass */ foreach_nodeclass,
- /* localize */ NULL,
+ /* localize */ localize,
/* local_sync */ local_sync,
/* local_merge */ NULL,
/* update */ NULL,
/* update_node */ NULL,
/* validate_link */ NULL,
- /* mute node */ node_tex_pass_on,
- /* mute links node */ node_mute_get_links,
- /* gpu mute node */ NULL
+ /* internal_connect */ node_internal_connect_default
};
int ntreeTexTagAnimated(bNodeTree *ntree)
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;
diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h
index a0b219804b9..c9a5a02e277 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -119,6 +119,4 @@ void tex_do_preview(bNode *node, float *coord, float *col);
void params_from_cdata(TexParams *out, TexCallData *in);
-void node_tex_pass_on(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out);
-
#endif
diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c
index 829cd06dfc0..36b31a864a5 100644
--- a/source/blender/nodes/texture/nodes/node_texture_output.c
+++ b/source/blender/nodes/texture/nodes/node_texture_output.c
@@ -169,7 +169,7 @@ void register_node_type_tex_output(bNodeTreeType *ttype)
node_type_exec(&ntype, exec);
/* Do not allow muting output. */
- node_type_mute(&ntype, NULL, NULL);
+ node_type_internal_connect(&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 a588f13f18f..401e72761e3 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_mute(&ntype, NULL, NULL);
+ node_type_internal_connect(&ntype, NULL);
nodeRegisterType(ttype, &ntype);
}