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
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')
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c15
-rw-r--r--source/blender/nodes/composite/node_composite_util.c55
-rw-r--r--source/blender/nodes/composite/node_composite_util.h2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_composite.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_splitViewer.c2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_viewer.c2
-rw-r--r--source/blender/nodes/intern/node_exec.c16
-rw-r--r--source/blender/nodes/intern/node_util.c61
-rw-r--r--source/blender/nodes/intern/node_util.h11
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c6
-rw-r--r--source/blender/nodes/shader/node_shader_util.c63
-rw-r--r--source/blender/nodes/shader/node_shader_util.h3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_lamp.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_material.c4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_output_world.c4
-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
21 files changed, 310 insertions, 50 deletions
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 1a1d744fb1b..d6a1c50162b 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -228,7 +228,11 @@ bNodeTreeType ntreeType_Composite = {
/* local_sync */ local_sync,
/* local_merge */ local_merge,
/* update */ update,
- /* update_node */ update_node
+ /* update_node */ update_node,
+ /* validate_link */ NULL,
+ /* mutefunc */ node_compo_pass_on,
+ /* mutelinksfunc */ node_mute_get_links,
+ /* gpumutefunc */ NULL
};
@@ -356,13 +360,8 @@ static void *exec_composite_node(void *nodeexec_v)
node_get_stack(node, thd->stack, nsin, nsout);
- if((node->flag & NODE_MUTED) && (!node_only_value(node))) {
- /* viewers we execute, for feedback to user */
- if(ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
- node->typeinfo->execfunc(thd->rd, node, nsin, nsout);
- else
- node_compo_pass_on(node, 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)
node->typeinfo->execfunc(thd->rd, node, nsin, nsout);
else if (node->typeinfo->newexecfunc)
diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c
index ddd55790436..99a36691b10 100644
--- a/source/blender/nodes/composite/node_composite_util.c
+++ b/source/blender/nodes/composite/node_composite_util.c
@@ -131,44 +131,29 @@ void compbuf_set_node(CompBuf *cbuf, bNode *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(bNode *node, bNodeStack **nsin, bNodeStack **nsout)
+void node_compo_pass_on(void *UNUSED(data), int UNUSED(thread), struct bNode *node, void *UNUSED(nodedata),
+ struct bNodeStack **in, struct bNodeStack **out)
{
- CompBuf *valbuf= NULL, *colbuf= NULL, *vecbuf= NULL;
- bNodeSocket *sock;
- int a;
-
- /* connect the first value buffer in with first value out */
- /* connect the first RGBA buffer in with first RGBA out */
-
- /* test the inputs */
- for(a=0, sock= node->inputs.first; sock; sock= sock->next, a++) {
- if(nsin[a]->data) {
- CompBuf *cbuf= nsin[a]->data;
- if(cbuf->type==1 && valbuf==NULL) valbuf= cbuf;
- if(cbuf->type==3 && vecbuf==NULL) vecbuf= cbuf;
- if(cbuf->type==4 && colbuf==NULL) colbuf= cbuf;
- }
- }
-
- /* outputs */
- if(valbuf || colbuf || vecbuf) {
- for(a=0, sock= node->outputs.first; sock; sock= sock->next, a++) {
- if(nsout[a]->hasoutput) {
- if(sock->type==SOCK_FLOAT && valbuf) {
- nsout[a]->data= pass_on_compbuf(valbuf);
- valbuf= NULL;
- }
- if(sock->type==SOCK_VECTOR && vecbuf) {
- nsout[a]->data= pass_on_compbuf(vecbuf);
- vecbuf= NULL;
- }
- if(sock->type==SOCK_RGBA && colbuf) {
- nsout[a]->data= pass_on_compbuf(colbuf);
- colbuf= NULL;
- }
- }
+ 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);
}
diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h
index 9cac4c477eb..bb606f4202e 100644
--- a/source/blender/nodes/composite/node_composite_util.h
+++ b/source/blender/nodes/composite/node_composite_util.h
@@ -124,7 +124,7 @@ 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(struct bNode *node, struct bNodeStack **nsin, struct bNodeStack **nsout);
+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 828dd8fcfc7..a5f90d31643 100644
--- a/source/blender/nodes/composite/nodes/node_composite_composite.c
+++ b/source/blender/nodes/composite/nodes/node_composite_composite.c
@@ -105,6 +105,8 @@ void register_node_type_cmp_composite(bNodeTreeType *ttype)
node_type_socket_templates(&ntype, cmp_node_composite_in, NULL);
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);
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 c801c34e8b5..bc8bc7c84d1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c
@@ -159,6 +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);
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 46051caced2..6a0c074cdb3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_viewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c
@@ -141,6 +141,8 @@ 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);
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index b6374aeb386..1def0c31983 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -276,7 +276,13 @@ void ntreeExecNodes(bNodeTreeExec *exec, void *callerdata, int thread)
node = nodeexec->node;
if(node->need_exec) {
node_get_stack(node, exec->stack, nsin, nsout);
- if(node->typeinfo->execfunc)
+ /* Handle muted nodes...
+ * If the mute func is not set, assume the node should never be muted,
+ * and hence execute it!
+ */
+ if((node->flag & NODE_MUTED) && node->typeinfo->mutefunc)
+ node->typeinfo->mutefunc(callerdata, thread, node, nodeexec->data, nsin, nsout);
+ else if(node->typeinfo->execfunc)
node->typeinfo->execfunc(callerdata, node, nsin, nsout);
else if (node->typeinfo->newexecfunc)
node->typeinfo->newexecfunc(callerdata, thread, node, nodeexec->data, nsin, nsout);
@@ -298,7 +304,13 @@ void ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call
node = nodeexec->node;
if(node->need_exec) {
node_get_stack(node, nts->stack, nsin, nsout);
- if(node->typeinfo->execfunc)
+ /* Handle muted nodes...
+ * If the mute func is not set, assume the node should never be muted,
+ * and hence execute it!
+ */
+ if((node->flag & NODE_MUTED) && node->typeinfo->mutefunc)
+ node->typeinfo->mutefunc(callerdata, thread, node, nodeexec->data, nsin, nsout);
+ else if(node->typeinfo->execfunc)
node->typeinfo->execfunc(callerdata, node, nsin, nsout);
else if (node->typeinfo->newexecfunc)
node->typeinfo->newexecfunc(callerdata, thread, node, nodeexec->data, nsin, nsout);
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index da85dd0a5ea..dabad10f568 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -97,3 +97,64 @@ const char *node_filter_label(bNode *node)
RNA_enum_name(node_filter_items, node->custom1, &name);
return name;
}
+
+/* Returns a list of mapping of some input bNodeStack, GPUNodeStack or bNodeSocket
+ * to one or more outputs of the same type.
+ * *ntree or (**nsin, **nsout) or (*gnsin, *gnsout) must not be NULL. */
+ListBase node_mute_get_links(bNodeTree *ntree, bNode *node, bNodeStack **nsin, bNodeStack **nsout,
+ GPUNodeStack *gnsin, GPUNodeStack *gnsout)
+{
+ static int types[] = { SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA };
+ bNodeLink link = {NULL};
+ ListBase ret;
+ LinkInOutsMuteNode *lnk;
+ int in, out, i;
+
+ ret.first = ret.last = NULL;
+
+ /* Security check! */
+ if(!(ntree || (nsin && nsout) || (gnsin && gnsout)))
+ return ret;
+
+ /* Connect the first input of each type with first output of the same type. */
+
+ link.fromnode = link.tonode = node;
+ for (i=0; i < 3; ++i) {
+ /* find input socket */
+ for (in=0, link.fromsock=node->inputs.first; link.fromsock; in++, link.fromsock=link.fromsock->next) {
+ if (link.fromsock->type==types[i] && (ntree ? nodeCountSocketLinks(ntree, link.fromsock) : nsin ? nsin[in]->hasinput : gnsin[in].hasinput))
+ break;
+ }
+ if (link.fromsock) {
+ for (out=0, link.tosock=node->outputs.first; link.tosock; out++, link.tosock=link.tosock->next) {
+ if (link.tosock->type==types[i] && (ntree ? nodeCountSocketLinks(ntree, link.tosock) : nsout ? nsout[out]->hasoutput : gnsout[out].hasoutput))
+ break;
+ }
+ if (link.tosock) {
+ if(nsin && nsout) {
+ lnk = MEM_mallocN(sizeof(LinkInOutsMuteNode), "Muting node: new in to outs link.");
+ lnk->in = nsin[in];
+ lnk->outs = nsout[out];
+ lnk->num_outs = 1;
+ BLI_addtail(&ret, lnk);
+ }
+ else if(gnsin && gnsout) {
+ lnk = MEM_mallocN(sizeof(LinkInOutsMuteNode), "Muting node: new in to outs link.");
+ lnk->in = &gnsin[in];
+ lnk->outs = &gnsout[out];
+ lnk->num_outs = 1;
+ BLI_addtail(&ret, lnk);
+ }
+ else {
+ lnk = MEM_mallocN(sizeof(LinkInOutsMuteNode), "Muting node: new in to outs link.");
+ lnk->in = link.fromsock;
+ lnk->outs = link.tosock;
+ lnk->num_outs = 1;
+ BLI_addtail(&ret, lnk);
+ }
+ }
+ }
+ }
+
+ return ret;
+}
diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h
index d127a49cb4b..7ca090394c3 100644
--- a/source/blender/nodes/intern/node_util.h
+++ b/source/blender/nodes/intern/node_util.h
@@ -41,6 +41,8 @@
#include "NOD_socket.h"
+#include "GPU_material.h" /* For Shader muting GPU code... */
+
struct bNodeTree;
struct bNode;
@@ -59,6 +61,15 @@ const char *node_math_label(struct bNode *node);
const char *node_vect_math_label(struct bNode *node);
const char *node_filter_label(struct bNode *node);
+typedef struct LinkInOutsMuteNode
+{
+ struct LinkInOutsMuteNode *next, *prev;
+ void *in, *outs;
+ unsigned int num_outs; /* If > 1, outs is an array of pointers that need to be freed too! */
+} LinkInOutsMuteNode;
+ListBase node_mute_get_links(struct bNodeTree *ntree, struct bNode *node, struct bNodeStack **nsin,
+ struct bNodeStack **nsout, struct GPUNodeStack *gnsin, struct GPUNodeStack *gnsout);
+
#endif
// this is needed for inlining behaviour
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 6c7667c6729..b3144ff6830 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -134,7 +134,11 @@ bNodeTreeType ntreeType_Shader = {
/* local_sync */ local_sync,
/* local_merge */ NULL,
/* update */ update,
- /* update_node */ NULL
+ /* update_node */ NULL,
+ /* validate_link */ NULL,
+ /* mute node */ node_shader_pass_on,
+ /* mute links node */ node_mute_get_links,
+ /* gpu mute node */ gpu_shader_pass_on
};
/* GPU material from shader nodes */
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index d601c205682..87585c35e6a 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -78,6 +78,54 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
/* ******************* execute and parse ************ */
+/* Used for muted nodes, just copy the vec data from input to output… */
+void node_shader_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++) {
+ copy_v4_v4((((bNodeStack*)(lnk->outs))+i)->vec, ((bNodeStack*)(lnk->in))->vec);
+ }
+ /* If num_outs > 1, lnk->outs was an allocated table of pointers... */
+ if(i > 1)
+ MEM_freeN(lnk->outs);
+ }
+ BLI_freelistN(&links);
+}
+
+int gpu_shader_pass_on(struct GPUMaterial *mat, struct bNode *node, void *UNUSED(nodedata),
+ struct GPUNodeStack *in, struct GPUNodeStack *out)
+{
+ ListBase links;
+ LinkInOutsMuteNode *lnk;
+
+ if(node->typeinfo->mutelinksfunc == NULL)
+ return 0;
+
+ /* Get default muting links (as GPUNodeStack pointers). */
+ links = node->typeinfo->mutelinksfunc(NULL, node, NULL, NULL, in, out);
+
+ for(lnk = links.first; lnk; lnk = lnk->next) {
+ GPU_stack_link_mute(mat, "copy_raw", lnk);
+ /* If num_outs > 1, lnk->outs was an allocated table of pointers... */
+ if(lnk->num_outs > 1)
+ MEM_freeN(lnk->outs);
+ }
+
+ BLI_freelistN(&links);
+ return 1;
+}
+
/* go over all used Geometry and Texture nodes, and return a texco flag */
/* no group inside needed, this function is called for groups too */
void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mode)
@@ -214,7 +262,11 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
gs->name = "";
gs->hasinput= ns->hasinput && ns->data;
- gs->hasoutput= ns->hasoutput && ns->data;
+ /* XXX Commented out the ns->data check here, as it seems it’s not alwas set,
+ * even though there *is* a valid connection/output... But that might need
+ * further investigation.
+ */
+ gs->hasoutput= ns->hasoutput /*&& ns->data*/;
gs->sockettype= ns->sockettype;
}
@@ -293,7 +345,14 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs)
doit = 1;
if (doit) {
- if(node->typeinfo->gpufunc) {
+ if((node->flag & NODE_MUTED) && node->typeinfo->gpumutefunc) {
+ node_get_stack(node, stack, nsin, nsout);
+ gpu_stack_from_data_list(gpuin, &node->inputs, nsin);
+ gpu_stack_from_data_list(gpuout, &node->outputs, nsout);
+ if(node->typeinfo->gpumutefunc(mat, node, nodeexec->data, gpuin, gpuout))
+ data_from_gpu_stack_list(&node->outputs, nsout, gpuout);
+ }
+ else if(node->typeinfo->gpufunc) {
node_get_stack(node, stack, nsin, nsout);
gpu_stack_from_data_list(gpuin, &node->inputs, nsin);
gpu_stack_from_data_list(gpuout, &node->outputs, nsout);
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index 48e54d9d0b4..d345f3fb310 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -128,4 +128,7 @@ void node_shader_gpu_tex_mapping(struct GPUMaterial *mat, struct bNode *node, st
void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs);
+void node_shader_pass_on(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out);
+int gpu_shader_pass_on(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out);
+
#endif
diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c
index 8be634367a5..5bc61859a0a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output.c
@@ -89,5 +89,9 @@ void register_node_type_sh_output(bNodeTreeType *ttype)
node_type_exec(&ntype, node_shader_exec_output);
node_type_gpu(&ntype, gpu_shader_output);
+ /* Do not allow muting output node. */
+ node_type_mute(&ntype, NULL, NULL);
+ node_type_gpu_mute(&ntype, NULL);
+
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
index 3fe4862e8c8..cf2542c948c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c
@@ -48,5 +48,9 @@ void register_node_type_sh_output_lamp(bNodeTreeType *ttype)
node_type_exec(&ntype, NULL);
node_type_gpu(&ntype, NULL);
+ /* Do not allow muting output node. */
+ node_type_mute(&ntype, NULL, NULL);
+ node_type_gpu_mute(&ntype, NULL);
+
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c
index 15a201f9f21..298df3bb66f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c
@@ -61,5 +61,9 @@ void register_node_type_sh_output_material(bNodeTreeType *ttype)
node_type_exec(&ntype, NULL);
node_type_gpu(&ntype, node_shader_gpu_output_material);
+ /* Do not allow muting output node. */
+ node_type_mute(&ntype, NULL, NULL);
+ node_type_gpu_mute(&ntype, NULL);
+
nodeRegisterType(ttype, &ntype);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.c
index 6283c28c485..711f591c192 100644
--- a/source/blender/nodes/shader/nodes/node_shader_output_world.c
+++ b/source/blender/nodes/shader/nodes/node_shader_output_world.c
@@ -49,5 +49,9 @@ void register_node_type_sh_output_world(bNodeTreeType *ttype)
node_type_exec(&ntype, NULL);
node_type_gpu(&ntype, NULL);
+ /* Do not allow muting output node. */
+ node_type_mute(&ntype, NULL, NULL);
+ node_type_gpu_mute(&ntype, NULL);
+
nodeRegisterType(ttype, &ntype);
}
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);
}