diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2011-02-22 23:49:34 +0300 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2011-02-22 23:49:34 +0300 |
commit | e7750aa6ed4c448d4a39cf399b02f6b86c676816 (patch) | |
tree | 002815cce369a6f4ca0d79398f2d465609095471 /source/blender/blenkernel | |
parent | 692b711bf40f500c38fdc310ada7db0eacf21b8a (diff) |
Convenience fix: Exposing internal sockets now copies the default input value to the group sockets. The "expose" function on group inputs/outputs has an optional parameter "add_link", which can be used to prevent the automatic linking.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 18 |
2 files changed, 16 insertions, 3 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); } } |