diff options
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 18 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 12 |
4 files changed, 26 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 8bf2f4bb849..41e41eab78f 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -212,6 +212,7 @@ void nodeGroupSocketUseFlags(struct bNodeTree *ngroup); void nodeGroupCopy(struct bNode *gnode); struct bNodeSocket *nodeGroupAddSocket(struct bNodeTree *ngroup, const char *name, int type, int in_out); +struct bNodeSocket *nodeGroupExposeSocket(struct bNodeTree *ngroup, struct bNodeSocket *sock, int in_out); void nodeGroupExposeAllSockets(struct bNodeTree *ngroup); void nodeGroupRemoveSocket(struct bNodeTree *ngroup, struct bNodeSocket *gsock, int in_out); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 93d0a45ae94..d645bcd8329 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -476,7 +476,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) BLI_addtail(&ngroup->links, link); } else if(link->tonode && (link->tonode->flag & NODE_SELECT)) { - gsock = nodeGroupAddSocket(ngroup, link->tosock->name, link->tosock->type, SOCK_IN); + gsock = nodeGroupExposeSocket(ngroup, link->tosock, SOCK_IN); link->tosock->link = nodeAddLink(ngroup, NULL, gsock, link->tonode, link->tosock); link->tosock = node_add_group_socket(&gnode->inputs, gsock); link->tonode = gnode; @@ -487,7 +487,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) if (gsock->link && gsock->link->fromsock==link->fromsock) break; if (!gsock) { - gsock = nodeGroupAddSocket(ngroup, link->fromsock->name, link->fromsock->type, SOCK_OUT); + gsock = nodeGroupExposeSocket(ngroup, link->fromsock, SOCK_OUT); gsock->link = nodeAddLink(ngroup, link->fromnode, link->fromsock, NULL, gsock); link->fromsock = node_add_group_socket(&gnode->outputs, gsock); } @@ -836,6 +836,7 @@ bNodeSocket *nodeGroupAddSocket(bNodeTree *ngroup, const char *name, int type, i strncpy(gsock->name, name, sizeof(gsock->name)); gsock->type = type; + gsock->ns.sockettype = type; gsock->ns.min = INT_MIN; gsock->ns.max = INT_MAX; zero_v4(gsock->ns.vec); @@ -855,6 +856,14 @@ bNodeSocket *nodeGroupAddSocket(bNodeTree *ngroup, const char *name, int type, i return gsock; } +bNodeSocket *nodeGroupExposeSocket(bNodeTree *ngroup, bNodeSocket *sock, int in_out) +{ + bNodeSocket *gsock= nodeGroupAddSocket(ngroup, sock->name, sock->type, in_out); + /* initialize the default socket value */ + QUATCOPY(gsock->ns.vec, sock->ns.vec); + return gsock; +} + void nodeGroupExposeAllSockets(bNodeTree *ngroup) { bNode *node; @@ -864,13 +873,16 @@ void nodeGroupExposeAllSockets(bNodeTree *ngroup) for (sock=node->inputs.first; sock; sock=sock->next) { if (!sock->link && !(sock->flag & SOCK_HIDDEN)) { gsock = nodeGroupAddSocket(ngroup, sock->name, sock->type, SOCK_IN); + /* initialize the default socket value */ + QUATCOPY(gsock->ns.vec, sock->ns.vec); sock->link = nodeAddLink(ngroup, NULL, gsock, node, sock); } } for (sock=node->outputs.first; sock; sock=sock->next) { - printf("\t\tOutput '%s': #links=%d, hidden=%d\n", sock->name, nodeCountSocketLinks(ngroup, sock), (sock->flag & SOCK_HIDDEN)); if (nodeCountSocketLinks(ngroup, sock)==0 && !(sock->flag & SOCK_HIDDEN)) { gsock = nodeGroupAddSocket(ngroup, sock->name, sock->type, SOCK_OUT); + /* initialize the default socket value */ + QUATCOPY(gsock->ns.vec, sock->ns.vec); gsock->link = nodeAddLink(ngroup, node, sock, NULL, gsock); } } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index ed13198e129..bd3c36a05c3 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2141,11 +2141,11 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) else if (outside_group_rect(snode) && (link->tonode || link->fromnode)) { /* automatically add new group socket */ if (link->tonode && link->tosock) { - link->fromsock = nodeGroupAddSocket(snode->edittree, link->tosock->name, link->tosock->type, SOCK_IN); + link->fromsock = nodeGroupExposeSocket(snode->edittree, link->tosock, SOCK_IN); link->fromnode = NULL; } else if (link->fromnode && link->fromsock) { - link->tosock = nodeGroupAddSocket(snode->edittree, link->fromsock->name, link->fromsock->type, SOCK_OUT); + link->tosock = nodeGroupExposeSocket(snode->edittree, link->fromsock, SOCK_OUT); link->tonode = NULL; } } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index a20ced776e5..b8ff41a7948 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -659,7 +659,7 @@ static bNodeSocket *rna_NodeTree_output_new(bNodeTree *ntree, ReportList *UNUSED return gsock; } -static bNodeSocket *rna_NodeTree_input_expose(bNodeTree *ntree, ReportList *reports, bNodeSocket *sock) +static bNodeSocket *rna_NodeTree_input_expose(bNodeTree *ntree, ReportList *reports, bNodeSocket *sock, int add_link) { bNode *node; bNodeSocket *gsock; @@ -672,7 +672,8 @@ static bNodeSocket *rna_NodeTree_input_expose(bNodeTree *ntree, ReportList *repo else { /* XXX should check if tree is a group here! no good way to do this currently. */ gsock = nodeGroupAddSocket(ntree, sock->name, sock->type, SOCK_IN); - nodeAddLink(ntree, NULL, gsock, node, sock); + if (add_link) + nodeAddLink(ntree, NULL, gsock, node, sock); nodeGroupVerify(ntree); /* update group node socket links*/ WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); @@ -681,7 +682,7 @@ static bNodeSocket *rna_NodeTree_input_expose(bNodeTree *ntree, ReportList *repo return NULL; } -static bNodeSocket *rna_NodeTree_output_expose(bNodeTree *ntree, ReportList *reports, bNodeSocket *sock) +static bNodeSocket *rna_NodeTree_output_expose(bNodeTree *ntree, ReportList *reports, bNodeSocket *sock, int add_link) { bNode *node; bNodeSocket *gsock; @@ -694,7 +695,8 @@ static bNodeSocket *rna_NodeTree_output_expose(bNodeTree *ntree, ReportList *rep else { /* XXX should check if tree is a group here! no good way to do this currently. */ gsock = nodeGroupAddSocket(ntree, sock->name, sock->type, SOCK_OUT); - nodeAddLink(ntree, node, sock, NULL, gsock); + if (add_link) + nodeAddLink(ntree, node, sock, NULL, gsock); nodeGroupVerify(ntree); /* update group node socket links*/ WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); @@ -2749,6 +2751,8 @@ static void rna_def_group_sockets_api(BlenderRNA *brna, PropertyRNA *cprop, int RNA_def_function_ui_description(func, "Expose an internal socket in the group tree."); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_pointer(func, "sock", "NodeSocket", "Socket", "Internal node socket to expose"); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "add_link", TRUE, "Add Link", "If TRUE, adds a link to the internal socket"); /* return value */ parm= RNA_def_pointer(func, "socket", "NodeSocket", "", "New socket."); RNA_def_function_return(func, parm); |