Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Tönne <lukas.toenne@gmail.com>2014-04-23 14:00:28 +0400
committerLukas Tönne <lukas.toenne@gmail.com>2014-04-23 14:01:33 +0400
commit513066e8ad6f8d0f15822feef62b1fc7fdfd3928 (patch)
treeb0d0bc8a532754f060bac1ffd1db972af4a0fc7e /source/blender/nodes
parentc605711c6b21a7f41c063b93335c6d57b671af19 (diff)
Fix T39849: Adding links directly between node group input/output
extension sockets would create additional extension sockets instead of simply ignoring them.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/intern/node_common.c52
1 files changed, 38 insertions, 14 deletions
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index af9108b2559..5a255f3093f 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -384,7 +384,7 @@ void node_group_input_verify(bNodeTree *ntree, bNode *node, ID *id)
static void node_group_input_update(bNodeTree *ntree, bNode *node)
{
bNodeSocket *extsock = node->outputs.last;
- bNodeLink *link;
+ bNodeLink *link, *linknext, *exposelink;
/* Adding a tree socket and verifying will remove the extension socket!
* This list caches the existing links from the extension socket
* so they can be recreated after verification.
@@ -393,26 +393,37 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
/* find links from the extension socket and store them */
BLI_listbase_clear(&tmplinks);
- for (link = ntree->links.first; link; link = link->next) {
+ for (link = ntree->links.first; link; link = linknext) {
+ linknext = link->next;
if (nodeLinkIsHidden(link))
continue;
+
if (link->fromsock == extsock) {
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link");
*tlink = *link;
BLI_addtail(&tmplinks, tlink);
+
+ nodeRemLink(ntree, link);
}
}
- if (tmplinks.first) {
- bNodeSocket *gsock, *newsock;
+ /* find valid link to expose */
+ exposelink = NULL;
+ for (link = tmplinks.first; link; link = link->next) {
/* XXX Multiple sockets can be connected to the extension socket at once,
* in that case the arbitrary first link determines name and type.
* This could be improved by choosing the "best" type among all links,
* whatever that means.
*/
- bNodeLink *exposelink = tmplinks.first;
+ if (link->tosock->type != SOCK_CUSTOM) {
+ exposelink = link;
+ break;
+ }
+ }
+
+ if (exposelink) {
+ bNodeSocket *gsock, *newsock;
- /* XXX what if connecting virtual to virtual socket?? */
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->tonode, exposelink->tosock);
node_group_input_verify(ntree, node, (ID *)ntree);
@@ -423,8 +434,9 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
nodeAddLink(ntree, node, newsock, link->tonode, link->tosock);
}
- BLI_freelistN(&tmplinks);
}
+
+ BLI_freelistN(&tmplinks);
}
void register_node_type_group_input(void)
@@ -471,7 +483,7 @@ void node_group_output_verify(bNodeTree *ntree, bNode *node, ID *id)
static void node_group_output_update(bNodeTree *ntree, bNode *node)
{
bNodeSocket *extsock = node->inputs.last;
- bNodeLink *link;
+ bNodeLink *link, *linknext, *exposelink;
/* Adding a tree socket and verifying will remove the extension socket!
* This list caches the existing links to the extension socket
* so they can be recreated after verification.
@@ -480,24 +492,36 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
/* find links to the extension socket and store them */
BLI_listbase_clear(&tmplinks);
- for (link = ntree->links.first; link; link = link->next) {
+ for (link = ntree->links.first; link; link = linknext) {
+ linknext = link->next;
if (nodeLinkIsHidden(link))
continue;
+
if (link->tosock == extsock) {
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link");
*tlink = *link;
BLI_addtail(&tmplinks, tlink);
+
+ nodeRemLink(ntree, link);
}
}
- if (tmplinks.first) {
- bNodeSocket *gsock, *newsock;
+ /* find valid link to expose */
+ exposelink = NULL;
+ for (link = tmplinks.first; link; link = link->next) {
/* XXX Multiple sockets can be connected to the extension socket at once,
* in that case the arbitrary first link determines name and type.
* This could be improved by choosing the "best" type among all links,
* whatever that means.
*/
- bNodeLink *exposelink = tmplinks.first;
+ if (link->fromsock->type != SOCK_CUSTOM) {
+ exposelink = link;
+ break;
+ }
+ }
+
+ if (exposelink) {
+ bNodeSocket *gsock, *newsock;
/* XXX what if connecting virtual to virtual socket?? */
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->fromnode, exposelink->fromsock);
@@ -509,9 +533,9 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
for (link = tmplinks.first; link; link = link->next) {
nodeAddLink(ntree, link->fromnode, link->fromsock, node, newsock);
}
-
- BLI_freelistN(&tmplinks);
}
+
+ BLI_freelistN(&tmplinks);
}
void register_node_type_group_output(void)