Revision: 30487 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30487 Author: lukastoenne Date: 2010-07-19 09:54:37 +0200 (Mon, 19 Jul 2010)
Log Message: ----------- Nested node execution for simulation nodes. 'Operator'-nodes can now be executed by other nodes during tree execution. Does not work with group nodes yet. 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/editors/space_node/node_draw.c branches/particles-2010/source/blender/makesdna/DNA_node_types.h 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/SIM_nodes/SIM_debugprint.c branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_if.c branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_program.c branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_subprogram.c branches/particles-2010/source/blender/nodes/intern/SIM_util.c branches/particles-2010/source/blender/nodes/intern/SIM_util.h branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c branches/particles-2010/source/blender/nodes/intern/node_util.h Added Paths: ----------- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_pass.c Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h =================================================================== --- branches/particles-2010/source/blender/blenkernel/BKE_node.h 2010-07-19 07:29:52 UTC (rev 30486) +++ branches/particles-2010/source/blender/blenkernel/BKE_node.h 2010-07-19 07:54:37 UTC (rev 30487) @@ -44,6 +44,7 @@ struct bNodeLink; struct bNodeSocket; struct bNodeStack; +struct bNodeOperatorContext; struct uiLayout; struct rctf; struct RenderData; @@ -472,12 +473,15 @@ #define SIM_NODE_SUBPROGRAM 602 #define SIM_NODE_IF 603 #define SIM_NODE_TIMESTEP 604 +#define SIM_NODE_PASS 605 #define SIM_NODE_DEBUGPRINT 699 /* API */ void ntreeSimulationExecTree(struct SimulationContext *sim, int thread); +/* Note: this function should only be called from within other nodes execution functions! */ +void ntreeSimulationExecOperator(struct SimulationContext *sim, struct bNodeOperatorContext *ctx); /**/ Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c =================================================================== --- branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-07-19 07:29:52 UTC (rev 30486) +++ branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-07-19 07:54:37 UTC (rev 30487) @@ -168,6 +168,8 @@ sock->ns.min= stype->min; sock->ns.max= stype->max; + sock->stype = stype; + if(lb) BLI_addtail(lb, sock); @@ -194,6 +196,8 @@ sock->ns.min= stype->min; sock->ns.max= stype->max; + sock->stype = stype; + if(lb) { if (next_sock) BLI_insertlinkbefore(lb, next_sock, sock); @@ -235,6 +239,7 @@ sock->ns.min= stype->min; sock->ns.max= stype->max; sock->tosock= stype->internsock; + sock->stype = stype; /* non-list sockets may only have one of each type */ if ((stype->flag & SOCK_LIST) == 0) { @@ -245,12 +250,6 @@ return; } else { - if (r_verified->last) - sock->list_index = ((bNodeSocket*)r_verified->last)->list_index + 1; - else { - sock->list_index = 0; - } - socknext = sock->next; BLI_remlink(lb, sock); @@ -263,16 +262,6 @@ else sock= sock->next; } - -#if 0 - if(!r_verified->first) { - r_verified->first = r_verified->last = node_add_socket_type(NULL, stype); - } - else if (list_socket && ((bNodeSocket*)r_verified->last)->link) { - /* add an unlinked socket for extending the list */ - node_add_socket_type(r_verified, stype); - } -#endif } static void verify_socket_list(bNodeTree *ntree, ListBase *lb, bNodeSocketType *stype_first) @@ -466,7 +455,7 @@ inputs[a].internsock= sock; a++; } - if (sock->next && sock->next->list_index <= sock->list_index) + if (!sock->next || sock->next->stype != sock->stype) stype++; } } @@ -493,7 +482,7 @@ outputs[a].internsock= sock; a++; } - if (!sock->next || sock->next->list_index < 0) + if (!sock->next || sock->next->stype != sock->stype) stype++; } } @@ -849,51 +838,38 @@ } /* ************** Add stuff ********** */ -/* XXX the list socket updates are done in a brute-force way for now: iterate over all nodes and sockets in a tree. - * Ideally it should be done atomically for target node + socket, which requires storing the previous socket for the modal linking operator */ void ntreeUpdateListSockets(bNodeTree *ntree) { bNode *node; bNodeSocketType *stype; bNodeSocket *sock, *next_sock; - int ttype=0, tsock=0; - for (node = ntree->nodes.first; node; node = node->next) { /* nodes are presumed fully verified, stype and socket list are in sync */ stype= node->typeinfo->inputs; sock= node->inputs.first; while (sock) { - /* XXX needs a more generic way of allowing list sockets - phonybone */ if (stype->flag & SOCK_LIST) { - int list_index = 0; /* step through all sockets of this type (i.e. the list) */ -// while (sock && sock->to_index==stype->own_index && strncmp(sock->name, stype->name, NODE_MAXSTR)==0) { - while (sock && sock->type==stype->type) { + while (sock && sock->stype == stype) { if (!sock->link) { next_sock = sock->next; node_rem_socket(ntree, &node->inputs, sock); sock = next_sock; } else { - sock->list_index = list_index; - ++list_index; sock = sock->next; } - ++tsock; } /* add an unlinked last socket, so the list can be extended */ node_insert_before_socket_type(&node->inputs, sock, stype); } else { -// while (sock && sock->to_index==stype->own_index && strncmp(sock->name, stype->name, NODE_MAXSTR)==0) { - while (sock && sock->type==stype->type) { - sock->list_index = -1; + while (sock && sock->stype == stype) { sock = sock->next; - ++tsock; } } + ++stype; - ++ttype; } } } @@ -2525,6 +2501,7 @@ nodeRegisterType(ntypelist, &sim_node_program); nodeRegisterType(ntypelist, &sim_node_subprogram); nodeRegisterType(ntypelist, &sim_node_if); + nodeRegisterType(ntypelist, &sim_node_pass); nodeRegisterType(ntypelist, &sim_node_timestep); nodeRegisterType(ntypelist, &sim_node_debugprint); } Modified: branches/particles-2010/source/blender/editors/space_node/node_draw.c =================================================================== --- branches/particles-2010/source/blender/editors/space_node/node_draw.c 2010-07-19 07:29:52 UTC (rev 30486) +++ branches/particles-2010/source/blender/editors/space_node/node_draw.c 2010-07-19 07:54:37 UTC (rev 30487) @@ -842,8 +842,10 @@ NULL, 0, 0, 0, 0, ""); } else if(sock->type==SOCK_FLOAT) { - uiDefBut(node->block, LABEL, 0, sock->name, (short)(sock->locx+7), (short)(sock->locy-9.0f), - (short)(node->width-NODE_DY), NODE_DY, NULL, 0, 0, 0, 0, ""); + bt=uiDefButR(node->block, NUM, B_NODE_EXEC, sock->name, + (short)sock->locx+NODE_DYS, (short)(sock->locy)-9, (short)node->width-NODE_DY, 17, + &ptr, "default_value", 0, sock->ns.min, sock->ns.max, -1, -1, NULL); + uiButSetFunc(bt, node_sync_cb, snode, node); } else if(sock->type==SOCK_INT) { uiDefBut(node->block, LABEL, 0, sock->name, (short)(sock->locx+7), (short)(sock->locy-9.0f), Modified: branches/particles-2010/source/blender/makesdna/DNA_node_types.h =================================================================== --- branches/particles-2010/source/blender/makesdna/DNA_node_types.h 2010-07-19 07:29:52 UTC (rev 30486) +++ branches/particles-2010/source/blender/makesdna/DNA_node_types.h 2010-07-19 07:54:37 UTC (rev 30487) @@ -38,6 +38,7 @@ struct SpaceNode; struct bNodeLink; struct bNodeType; +struct bNodeSocketType; struct bNodeGroup; struct AnimData; struct bGPdata; @@ -46,6 +47,15 @@ #define NODE_MAXSTR 32 +/* Defines execution context for nodes in an operator socket. + * This allows calling node executions from within a node tree or group node. + */ +typedef struct bNodeOperatorContext { + struct bNodeTree *ntree; + struct bNode *node; + struct bNodeStack *stack; +} bNodeOperatorContext; + typedef struct bNodeStack { float vec[4]; float min, max; /* min/max for values (UI writes it, execute might use it) */ @@ -54,6 +64,7 @@ short hasoutput; /* when output is linked, tagged before executing */ short datatype; /* type of data pointer */ short sockettype; /* type of socket stack comes from, to remap linking different sockets */ + bNodeOperatorContext ctx; /* context for execution, only used for operator sockets */ } bNodeStack; /* ns->datatype, shadetree only */ @@ -70,19 +81,19 @@ short limit, stack_index; /* limit for dependency sort, stack_index for exec */ short intern; /* intern = tag for group nodes */ short stack_index_ext; /* for groups, to find the caller stack index */ - short list_index; /* for list sockets */ - short pad1; - float locx, locy; /* internal data to retrieve relations and groups */ int own_index, to_index; /* group socket identifiers, to find matching pairs after reading files */ + char pad[4]; + struct bNodeSocket *tosock; /* group-node sockets point to the internal group counterpart sockets, set after read file */ struct bNodeLink *link; /* a link pointer, set in nodeSolveOrder() */ + struct bNodeSocketType *stype; /* socket type, used for list sockets */ } bNodeSocket; /* sock->type */ Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h =================================================================== --- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h 2010-07-19 07:29:52 UTC (rev 30486) +++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h 2010-07-19 07:54:37 UTC (rev 30487) @@ -136,5 +136,6 @@ DefNode( SimulationNode, SIM_NODE_PROGRAM, 0, "PROGRAM", Program, "Program", "" ) DefNode( SimulationNode, SIM_NODE_SUBPROGRAM, 0, "SUBPROGRAM", SubProgram, "SubProgram", "" ) DefNode( SimulationNode, SIM_NODE_IF, 0, "IF", If, "If", "" ) +DefNode( SimulationNode, SIM_NODE_PASS, 0, "PASS", Pass, "Pass", "" ) DefNode( SimulationNode, SIM_NODE_TIMESTEP, 0, "TIMESTEP", TimeStep, "Time Step", "" ) DefNode( SimulationNode, SIM_NODE_DEBUGPRINT, 0, "DEBUGPRINT", DebugPrint, "Debug Print", "" ) Modified: branches/particles-2010/source/blender/nodes/SIM_node.h =================================================================== --- branches/particles-2010/source/blender/nodes/SIM_node.h 2010-07-19 07:29:52 UTC (rev 30486) +++ branches/particles-2010/source/blender/nodes/SIM_node.h 2010-07-19 07:54:37 UTC (rev 30487) @@ -39,6 +39,7 @@ extern bNodeType sim_node_timestep; extern bNodeType sim_node_debugprint; +extern bNodeType sim_node_pass; extern bNodeType sim_node_program; extern bNodeType sim_node_subprogram; extern bNodeType sim_node_if; Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_debugprint.c =================================================================== @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs