[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32394] branches/particles-2010/source/ blender: Added "for" and "while" control nodes.
Christopher Cherrett
ccherrett at openoctave.org
Sun Oct 10 20:58:48 CEST 2010
Can you adjust the while safety limit in the GUI? If you cannot then
how will you determine that for someone?
Lukas Toenne wrote:
> Revision: 32394
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32394
> Author: lukastoenne
> Date: 2010-10-10 10:48:03 +0200 (Sun, 10 Oct 2010)
>
> Log Message:
> -----------
> Added "for" and "while" control nodes. "while" has a safety limit for the number of iterations to avoid infinite loops.
> Fixed the order of restoring pointers in readfile.c: socket list is now relinked before storage data, some nodes may need this.
>
> Modified Paths:
> --------------
> branches/particles-2010/source/blender/blenkernel/BKE_node.h
> branches/particles-2010/source/blender/blenkernel/intern/node.c
> branches/particles-2010/source/blender/blenloader/intern/readfile.c
> branches/particles-2010/source/blender/blenloader/intern/writefile.c
> branches/particles-2010/source/blender/editors/space_node/drawnode.c
> branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
> branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
> branches/particles-2010/source/blender/nodes/SIM_node.h
> branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_for.c
> branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_if.c
>
> Added Paths:
> -----------
> branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_while.c
>
> Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
> ===================================================================
> --- branches/particles-2010/source/blender/blenkernel/BKE_node.h 2010-10-10 07:34:55 UTC (rev 32393)
> +++ branches/particles-2010/source/blender/blenkernel/BKE_node.h 2010-10-10 08:48:03 UTC (rev 32394)
> @@ -536,7 +536,8 @@
> #define SIM_NODE_PASS 603
> #define SIM_NODE_IF 604
> #define SIM_NODE_FOR 605
> -#define SIM_NODE_FILTER 606
> +#define SIM_NODE_WHILE 606
> +#define SIM_NODE_FILTER 607
>
> /* scalar math */
> #define SIM_NODE_SCALAR_ADD 650
>
> Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
> ===================================================================
> --- branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-10-10 07:34:55 UTC (rev 32393)
> +++ branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-10-10 08:48:03 UTC (rev 32394)
> @@ -2323,6 +2323,7 @@
> nodeRegisterType(ntypelist,&sim_node_pass);
> nodeRegisterType(ntypelist,&sim_node_if);
> nodeRegisterType(ntypelist,&sim_node_for);
> + nodeRegisterType(ntypelist,&sim_node_while);
> nodeRegisterType(ntypelist,&sim_node_filter);
>
> nodeRegisterType(ntypelist,&sim_node_scalar_add);
>
> Modified: branches/particles-2010/source/blender/blenloader/intern/readfile.c
> ===================================================================
> --- branches/particles-2010/source/blender/blenloader/intern/readfile.c 2010-10-10 07:34:55 UTC (rev 32393)
> +++ branches/particles-2010/source/blender/blenloader/intern/readfile.c 2010-10-10 08:48:03 UTC (rev 32394)
> @@ -2150,6 +2150,12 @@
> node->typeinfo= NULL;
> }
>
> + link_list(fd,&node->inputs);
> + link_list(fd,&node->outputs);
> +
> + link_list(fd,&node->inpanels);
> + link_list(fd,&node->outpanels);
> +
> node->storage= newdataadr(fd, node->storage);
> if(node->storage) {
> /* could be handlerized at some point */
> @@ -2169,12 +2175,6 @@
> direct_link_node_rna_data(fd, ntree, node);
> }
> }
> -
> - link_list(fd,&node->inputs);
> - link_list(fd,&node->outputs);
> -
> - link_list(fd,&node->inpanels);
> - link_list(fd,&node->outpanels);
> }
> link_list(fd,&ntree->links);
>
>
> Modified: branches/particles-2010/source/blender/blenloader/intern/writefile.c
> ===================================================================
> --- branches/particles-2010/source/blender/blenloader/intern/writefile.c 2010-10-10 07:34:55 UTC (rev 32393)
> +++ branches/particles-2010/source/blender/blenloader/intern/writefile.c 2010-10-10 08:48:03 UTC (rev 32394)
> @@ -492,6 +492,22 @@
> writestruct(wd, DATA, "bNode", 1, node);
>
> for(node= ntree->nodes.first; node; node= node->next) {
> + for(sock= node->inputs.first; sock; sock= sock->next) {
> + writestruct(wd, DATA, "bNodeSocket", 1, sock);
> + if (sock->storage)
> + writestruct(wd, DATA, node->typeinfo->socketstoragename, 1, sock->storage);
> + }
> + for(sock= node->outputs.first; sock; sock= sock->next) {
> + writestruct(wd, DATA, "bNodeSocket", 1, sock);
> + if (sock->storage)
> + writestruct(wd, DATA, node->typeinfo->socketstoragename, 1, sock->storage);
> + }
> +
> + for(panel=node->inpanels.first; panel; panel = panel->next)
> + writestruct(wd, DATA, "bNodeSocketPanel", 1, panel);
> + for(panel=node->outpanels.first; panel; panel = panel->next)
> + writestruct(wd, DATA, "bNodeSocketPanel", 1, panel);
> +
> if(node->storage&& node->type!=NODE_DYNAMIC) {
> /* could be handlerized at some point, now only 1 exception still */
> if(ntree->type==NTREE_SHADER&& (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB))
> @@ -508,23 +524,8 @@
> writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);
> }
>
> - for(sock= node->inputs.first; sock; sock= sock->next) {
> - writestruct(wd, DATA, "bNodeSocket", 1, sock);
> - if (sock->storage)
> - writestruct(wd, DATA, node->typeinfo->socketstoragename, 1, sock->storage);
> - }
> - for(sock= node->outputs.first; sock; sock= sock->next) {
> - writestruct(wd, DATA, "bNodeSocket", 1, sock);
> - if (sock->storage)
> - writestruct(wd, DATA, node->typeinfo->socketstoragename, 1, sock->storage);
> - }
> if (node->type==SIM_NODE_GETDATA || node->type==SIM_NODE_SETDATA)
> write_node_socket_properties(wd, node);
> -
> - for(panel=node->inpanels.first; panel; panel = panel->next)
> - writestruct(wd, DATA, "bNodeSocketPanel", 1, panel);
> - for(panel=node->outpanels.first; panel; panel = panel->next)
> - writestruct(wd, DATA, "bNodeSocketPanel", 1, panel);
> }
>
> for(link= ntree->links.first; link; link= link->next)
>
> Modified: branches/particles-2010/source/blender/editors/space_node/drawnode.c
> ===================================================================
> --- branches/particles-2010/source/blender/editors/space_node/drawnode.c 2010-10-10 07:34:55 UTC (rev 32393)
> +++ branches/particles-2010/source/blender/editors/space_node/drawnode.c 2010-10-10 08:48:03 UTC (rev 32394)
> @@ -1295,6 +1295,14 @@
> simnode_setdata_add_rna_socket_search(layout, node);
> }
>
> +static void node_simulation_buts_while(uiLayout *layout, bContext *C, PointerRNA *ptr)
> +{
> + uiLayout *col;
> +
> + col= uiLayoutColumn(layout, 0);
> + uiItemR(col, ptr, "max_iterations", 0, NULL, 0);
> +}
> +
> /* only once called */
> static void node_simulation_set_butfunc(bNodeType *ntype)
> {
> @@ -1305,6 +1313,9 @@
> case SIM_NODE_SETDATA:
> ntype->uifunc = node_simulation_buts_setdata;
> break;
> + case SIM_NODE_WHILE:
> + ntype->uifunc = node_simulation_buts_while;
> + break;
>
> default:
> ntype->uifunc= NULL;
>
> Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
> ===================================================================
> --- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c 2010-10-10 07:34:55 UTC (rev 32393)
> +++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c 2010-10-10 08:48:03 UTC (rev 32394)
> @@ -2239,6 +2239,17 @@
> RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
> }
>
> +static void def_sim_while(StructRNA *srna)
> +{
> + PropertyRNA *prop;
> +
> + prop = RNA_def_property(srna, "max_iterations", PROP_INT, PROP_UNSIGNED);
> + RNA_def_property_int_sdna(prop, NULL, "custom1");
> + RNA_def_property_int_default(prop, 1000);
> + RNA_def_property_ui_text(prop, "Max. Iterations", "Safety limit for while-loop iterations");
> + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
> +}
> +
> /* -------------------------------------------------------------------------- */
>
> static EnumPropertyItem shader_node_type_items[MaxNodes];
>
> Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
> ===================================================================
> --- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h 2010-10-10 07:34:55 UTC (rev 32393)
> +++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h 2010-10-10 08:48:03 UTC (rev 32394)
> @@ -138,6 +138,7 @@
> DefNode( SimulationNode, SIM_NODE_PASS, 0, "PASS", Pass, "Pass", "" )
> DefNode( SimulationNode, SIM_NODE_IF, 0, "IF", If, "If", "" )
> DefNode( SimulationNode, SIM_NODE_FOR, 0, "FOR", For, "For", "" )
> +DefNode( SimulationNode, SIM_NODE_WHILE, def_sim_while, "WHILE", While, "While", "" )
> DefNode( SimulationNode, SIM_NODE_FILTER, 0, "FILTER", Filter, "Filter", "" )
> DefNode( SimulationNode, SIM_NODE_SCALAR_ADD, 0, "SCALAR_ADD", ScalarAdd, "Add", "" )
> DefNode( SimulationNode, SIM_NODE_SCALAR_SUBTRACT, 0, "SCALAR_SUBTRACT", ScalarSubtract, "Subtract", "" )
>
> Modified: branches/particles-2010/source/blender/nodes/SIM_node.h
> ===================================================================
> --- branches/particles-2010/source/blender/nodes/SIM_node.h 2010-10-10 07:34:55 UTC (rev 32393)
> +++ branches/particles-2010/source/blender/nodes/SIM_node.h 2010-10-10 08:48:03 UTC (rev 32394)
> @@ -44,6 +44,7 @@
> extern bNodeType sim_node_pass;
> extern bNodeType sim_node_if;
> extern bNodeType sim_node_for;
> +extern bNodeType sim_node_while;
> extern bNodeType sim_node_filter;
>
> extern bNodeType sim_node_scalar_add;
>
> Modified: branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_for.c
> ===================================================================
> --- branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_for.c 2010-10-10 07:34:55 UTC (rev 32393)
> +++ branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_for.c 2010-10-10 08:48:03 UTC (rev 32394)
> @@ -29,9 +29,6 @@
> #include "../SIM_util.h"
>
> /* **************** Execute a number of times ******************** */
> -/* This node implements an execution sequence.
> - * It is the central entry point for any simulation.
> - */
>
> static bNodeSocketType inputs[]= {
> { SOCK_INT, 1, "Iterations", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f },
> @@ -44,6 +41,20 @@
> { -1, 0, "" }
> };
>
> +static void enqueue_op(SimExecData *execdata, SimNodeStack *node, SimDataContext *self, int execlevel, int *pushop)
> +{
> + int iterations;
> + SimSocketIterator sockiter;
> +
> + sim_input_begin(execdata, node->instack[0],&sockiter);
> + sim_input_read_int(execdata,&sockiter,&iterations);
> + sim_input_end(execdata,&sockiter);
> + if (execdata->error) return;
> +
> + if (execlevel< iterations)
> + *pushop = 1;
> +}
> +
> bNodeType sim_node_for= {
> /* *next,*prev */ NULL, NULL,
> /* type code */ SIM_NODE_FOR,
> @@ -61,5 +72,12 @@
> /* id */ NULL,
> /* pynode, pydict */ NULL, NULL,
> /* gpufunc */ NULL,
> - /* updatefunc */ NULL
> + /* updatefunc */ NULL,
> + /* socketstoragename */ "",
> + /* initsocketfunc */ NULL,
> + /* copysocketstoragefunc */ NULL,
> + /* freesocketstoragefunc */ NULL,
> + /* generate_source */ NULL,
> + /* enqueue */ NULL,
> + /* enqueue */ enqueue_op
> };
>
> Modified: branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_if.c
> ===================================================================
>
> @@ Diff output truncated at 10240 characters. @@
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
--
Christopher Cherrett
ccherrett at openoctave.org
http://www.openoctave.org
More information about the Bf-blender-cvs
mailing list