[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35576] branches/particles-2010/source/ blender: Fixes for loop node socket copying.
Lukas Toenne
lukas.toenne at googlemail.com
Wed Mar 16 16:56:59 CET 2011
Revision: 35576
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35576
Author: lukastoenne
Date: 2011-03-16 15:56:59 +0000 (Wed, 16 Mar 2011)
Log Message:
-----------
Fixes for loop node socket copying. Loop nodes won't work with the current texture node system of constructing delegates. This needs a general fix.
Modified Paths:
--------------
branches/particles-2010/source/blender/blenkernel/intern/node.c
branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_common.c
branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_common.c
branches/particles-2010/source/blender/nodes/intern/TEX_nodes/TEX_common.c
branches/particles-2010/source/blender/nodes/intern/node_common.c
branches/particles-2010/source/blender/nodes/intern/node_common.h
Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c 2011-03-16 15:44:17 UTC (rev 35575)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c 2011-03-16 15:56:59 UTC (rev 35576)
@@ -155,7 +155,7 @@
sock->storage = NULL;
zero_v4(sock->ns.vec);
- sock->ns.min = FLT_MIN;
+ sock->ns.min = -FLT_MAX; /* _not_ FLT_MIN, that would be the smallest possible float > 0 */
sock->ns.max = FLT_MAX;
sock->ns.ival = 0;
sock->ns.imin = INT_MIN;
Modified: branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_common.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_common.c 2011-03-16 15:44:17 UTC (rev 35575)
+++ branches/particles-2010/source/blender/nodes/intern/CMP_nodes/CMP_common.c 2011-03-16 15:56:59 UTC (rev 35576)
@@ -138,10 +138,11 @@
ns->vec[0] = (float)iteration;
ns->vec[1]=ns->vec[2]=ns->vec[3] = 0.0f;
- loop_init_iteration(exec->nodetree, exec->stack, iteration);
+ if (iteration > 0)
+ loop_init_iteration(exec->nodetree, exec->stack);
ntree_exec(exec, data, thread);
}
- group_copy_outputs(node, out, exec->stack);
+ loop_copy_outputs(node, in, out, exec->stack);
}
void register_node_type_forloop_composite(ListBase *lb)
@@ -189,13 +190,14 @@
iteration = 0;
group_copy_inputs(node, in, exec->stack);
while (condition && iteration < node->custom1) {
- loop_init_iteration(exec->nodetree, exec->stack, iteration);
+ if (iteration > 0)
+ loop_init_iteration(exec->nodetree, exec->stack);
ntree_exec(exec, data, thread);
condition = (ns->vec[0] > 0.0f);
++iteration;
}
- group_copy_outputs(node, out, exec->stack);
+ loop_copy_outputs(node, in, out, exec->stack);
}
void register_node_type_whileloop_composite(ListBase *lb)
Modified: branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_common.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_common.c 2011-03-16 15:44:17 UTC (rev 35575)
+++ branches/particles-2010/source/blender/nodes/intern/SHD_nodes/SHD_common.c 2011-03-16 15:56:59 UTC (rev 35576)
@@ -134,10 +134,11 @@
ns->vec[0] = (float)iteration;
ns->vec[1]=ns->vec[2]=ns->vec[3] = 0.0f;
- loop_init_iteration(exec->nodetree, nts->stack, iteration);
+ if (iteration > 0)
+ loop_init_iteration(exec->nodetree, nts->stack);
ntreeExecThreadNodes(exec, nts, data, thread);
}
- group_copy_outputs(node, out, nts->stack);
+ loop_copy_outputs(node, in, out, exec->stack);
ntreeReleaseThreadStack(nts);
}
@@ -190,13 +191,14 @@
iteration = 0;
group_copy_inputs(node, in, nts->stack);
while (condition && iteration < node->custom1) {
- loop_init_iteration(exec->nodetree, nts->stack, iteration);
+ if (iteration > 0)
+ loop_init_iteration(exec->nodetree, nts->stack);
ntreeExecThreadNodes(exec, nts, data, thread);
condition = (ns->vec[0] > 0.0f);
++iteration;
}
- group_copy_outputs(node, out, nts->stack);
+ loop_copy_outputs(node, in, out, exec->stack);
ntreeReleaseThreadStack(nts);
}
Modified: branches/particles-2010/source/blender/nodes/intern/TEX_nodes/TEX_common.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/TEX_nodes/TEX_common.c 2011-03-16 15:44:17 UTC (rev 35575)
+++ branches/particles-2010/source/blender/nodes/intern/TEX_nodes/TEX_common.c 2011-03-16 15:56:59 UTC (rev 35576)
@@ -153,10 +153,11 @@
ns->vec[0] = (float)iteration;
ns->vec[1]=ns->vec[2]=ns->vec[3] = 0.0f;
- loop_init_iteration(exec->nodetree, nts->stack, iteration);
+ if (iteration > 0)
+ loop_init_iteration(exec->nodetree, nts->stack);
ntreeExecThreadNodes(exec, nts, data, thread);
}
- group_copy_outputs(node, out, nts->stack);
+ loop_copy_outputs(node, in, out, exec->stack);
ntreeReleaseThreadStack(nts);
}
@@ -209,13 +210,14 @@
iteration = 0;
group_copy_inputs(node, in, nts->stack);
while (condition && iteration < node->custom1) {
- loop_init_iteration(exec->nodetree, nts->stack, iteration);
+ if (iteration > 0)
+ loop_init_iteration(exec->nodetree, nts->stack);
ntreeExecThreadNodes(exec, nts, data, thread);
condition = (ns->vec[0] > 0.0f);
++iteration;
}
- group_copy_outputs(node, out, nts->stack);
+ loop_copy_outputs(node, in, out, exec->stack);
ntreeReleaseThreadStack(nts);
}
Modified: branches/particles-2010/source/blender/nodes/intern/node_common.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/node_common.c 2011-03-16 15:44:17 UTC (rev 35575)
+++ branches/particles-2010/source/blender/nodes/intern/node_common.c 2011-03-16 15:56:59 UTC (rev 35576)
@@ -387,7 +387,7 @@
strncpy(gsock->name, name, sizeof(gsock->name));
gsock->type = type;
- gsock->ns.min = FLT_MIN;
+ gsock->ns.min = -FLT_MAX; /* _not_ FLT_MIN, that would be the smallest possible float > 0 */
gsock->ns.max = FLT_MAX;
zero_v4(gsock->ns.vec);
gsock->ns.data = NULL;
@@ -773,7 +773,7 @@
loop_sync(ngroup, SOCK_IN);
}
-void loop_init_iteration(bNodeTree *ngroup, bNodeStack *gstack, int iteration)
+void loop_init_iteration(bNodeTree *ngroup, bNodeStack *gstack)
{
bNodeSocket *gin, *gout;
bNodeStack *nsin, *nsout;
@@ -782,26 +782,50 @@
gout = ngroup->outputs.first;
/* Move the results from the previous iteration back to the input sockets. */
- if (iteration > 0) {
- while (gin && gout) {
- /* skip static (non-looping) sockets */
- while (gin && (gin->flag & SOCK_STATIC))
- gin=gin->next;
- while (gout && (gout->flag & SOCK_STATIC))
- gout=gout->next;
+ while (gin && gout) {
+ /* skip static (non-looping) sockets */
+ while (gin && (gin->flag & SOCK_STATIC))
+ gin=gin->next;
+ while (gout && (gout->flag & SOCK_STATIC))
+ gout=gout->next;
+
+ if (gin && gout) {
+ nsin = node_get_socket_stack(gstack, gin);
+ nsout = node_get_socket_stack(gstack, gout);
- if (gin && gout) {
- nsin = node_get_socket_stack(gstack, gin);
- nsout = node_get_socket_stack(gstack, gout);
-
- *nsin = *nsout;
-
- /* input takes ownership of data */
- nsout->data = NULL;
-
- gin=gin->next;
- gout=gout->next;
+ *nsin = *nsout;
+ /* input takes ownership of data */
+ nsout->data = NULL;
+
+ gin=gin->next;
+ gout=gout->next;
+ }
+ }
+}
+
+void loop_copy_outputs(bNode *node, bNodeStack **in, bNodeStack **out, bNodeStack *gstack)
+{
+ bNodeSocket *sock, *insock;
+ bNodeStack *ns;
+ int a, i, mindex;
+ insock = node->inputs.first;
+ i = 0;
+ for (sock=node->outputs.first, a=0; sock && insock; sock=sock->next, ++a, insock=insock->next) {
+ mindex = GET_INT_FROM_POINTER(sock->storage);
+ /* skip to mirrored socket (assumes sockets are in sync!) */
+ while (insock && insock->own_index!=mindex) {
+ insock=insock->next;
+ ++i;
+ }
+ if (sock->groupsock) {
+ if (sock->groupsock->link || !insock) {
+ ns = node_get_socket_stack(gstack, sock->groupsock);
+ *(out[a]) = *ns;
}
+ else {
+ /* unlinked loop outputs use the input value directly */
+ *(out[a]) = *(in[i]);
+ }
}
}
}
Modified: branches/particles-2010/source/blender/nodes/intern/node_common.h
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/node_common.h 2011-03-16 15:44:17 UTC (rev 35575)
+++ branches/particles-2010/source/blender/nodes/intern/node_common.h 2011-03-16 15:56:59 UTC (rev 35576)
@@ -55,6 +55,7 @@
void group_copy_inputs(struct bNode *node, struct bNodeStack **in, struct bNodeStack *gstack);
void group_copy_outputs(struct bNode *node, struct bNodeStack **out, struct bNodeStack *gstack);
-void loop_init_iteration(struct bNodeTree *ngroup, struct bNodeStack *gstack, int iteration);
+void loop_copy_outputs(struct bNode *node, struct bNodeStack **in, struct bNodeStack **out, struct bNodeStack *gstack);
+void loop_init_iteration(struct bNodeTree *ngroup, struct bNodeStack *gstack);
#endif
More information about the Bf-blender-cvs
mailing list