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:
authorBastien Montagne <montagne29@wanadoo.fr>2011-11-20 20:38:23 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2011-11-20 20:38:23 +0400
commit6673c76e78742c64ccd0afa7a9d1f598a8022878 (patch)
tree5304bf79c57391c4dcc561746e770e006ba45e18 /source/blender/nodes/texture
parentbbf8315313a9e221ba398bbe06e342bd949c973b (diff)
Muting node patch: second part. Also fix [#27636] Muting shading nodes is ignored
Now, compositing, shading and texture nodes have a consistent muting system, with default behaving as previous (for compo), and which can be optionaly customized by each node. Shader nodes are also GLSL muted. However, Cycles is currently unaware of muted nodes, will try to address this…
Diffstat (limited to 'source/blender/nodes/texture')
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c6
-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.c3
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_viewer.c3
5 files changed, 105 insertions, 1 deletions
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index e863e9f6e0f..1e171bd8a46 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -111,7 +111,11 @@ bNodeTreeType ntreeType_Texture = {
/* local_sync */ local_sync,
/* local_merge */ NULL,
/* update */ NULL,
- /* update_node */ NULL
+ /* update_node */ NULL,
+ /* validate_link */ NULL,
+ /* mute node */ node_tex_pass_on,
+ /* mute links node */ node_mute_get_links,
+ /* gpu mute node */ NULL
};
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 c3d298d1ecd..06ee4b0a53d 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -143,6 +143,98 @@ 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 766cc73c330..5095a9799e4 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -119,4 +119,6 @@ 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 dc96f5abcb5..0ed6d232b81 100644
--- a/source/blender/nodes/texture/nodes/node_texture_output.c
+++ b/source/blender/nodes/texture/nodes/node_texture_output.c
@@ -168,5 +168,8 @@ void register_node_type_tex_output(bNodeTreeType *ttype)
node_type_storage(&ntype, "TexNodeOutput", node_free_standard_storage, copy);
node_type_exec(&ntype, exec);
+ /* Do not allow muting output. */
+ node_type_mute(&ntype, NULL, 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 4b4a9fdb4eb..a588f13f18f 100644
--- a/source/blender/nodes/texture/nodes/node_texture_viewer.c
+++ b/source/blender/nodes/texture/nodes/node_texture_viewer.c
@@ -65,5 +65,8 @@ void register_node_type_tex_viewer(bNodeTreeType *ttype)
node_type_size(&ntype, 100, 60, 150);
node_type_exec(&ntype, exec);
+ /* Do not allow muting viewer node. */
+ node_type_mute(&ntype, NULL, NULL);
+
nodeRegisterType(ttype, &ntype);
}