Fix T70331 Node group passthrough is broken

This commit is contained in:
Clément Foucault 2019-10-02 15:47:36 +02:00
parent f8f28dc784
commit 3734ae5d54
Notes: blender-bot 2023-02-14 11:01:33 +01:00
Referenced by issue #70331, Node group passthrough  is broken
2 changed files with 56 additions and 56 deletions

View File

@ -241,6 +241,8 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
node->flag |= NODE_SELECT;
}
bNodeLink *glinks_first = ntree->links.last;
/* Add internal links to the ntree */
for (link = wgroup->links.first; link; link = linkn) {
linkn = link->next;
@ -248,6 +250,8 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
BLI_addtail(&ntree->links, link);
}
bNodeLink *glinks_last = ntree->links.last;
/* and copy across the animation,
* note that the animation data's action can be NULL here */
if (wgroup->adt) {
@ -280,70 +284,64 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
BKE_id_free(bmain, wgroup);
/* restore external links to and from the gnode */
/* note: the nodes have been copied to intermediate wgroup first (so need to use new_node),
* then transferred to ntree (new_node pointers remain valid).
*/
/* input links */
for (link = ngroup->links.first; link; link = link->next) {
if (link->fromnode->type == NODE_GROUP_INPUT) {
const char *identifier = link->fromsock->identifier;
int num_external_links = 0;
if (glinks_first != NULL) {
for (link = glinks_first->next; link != glinks_last->next; link = link->next) {
if (link->fromnode->type == NODE_GROUP_INPUT) {
const char *identifier = link->fromsock->identifier;
int num_external_links = 0;
/* find external links to this input */
for (tlink = ntree->links.first; tlink; tlink = tlink->next) {
if (tlink->tonode == gnode && STREQ(tlink->tosock->identifier, identifier)) {
nodeAddLink(ntree,
tlink->fromnode,
tlink->fromsock,
link->tonode->new_node,
link->tosock->new_sock);
num_external_links++;
}
}
/* if group output is not externally linked,
* convert the constant input value to ensure somewhat consistent behavior */
if (num_external_links == 0) {
/* XXX TODO bNodeSocket *sock = node_group_find_input_socket(gnode, identifier);
BLI_assert(sock);*/
/* XXX TODO
* nodeSocketCopy(ntree, link->tosock->new_sock, link->tonode->new_node,
* ntree, sock, gnode);*/
}
}
}
/* output links */
for (link = ntree->links.first; link; link = link->next) {
if (link->fromnode == gnode) {
const char *identifier = link->fromsock->identifier;
int num_internal_links = 0;
/* find internal links to this output */
for (tlink = ngroup->links.first; tlink; tlink = tlink->next) {
/* only use active output node */
if (tlink->tonode->type == NODE_GROUP_OUTPUT && (tlink->tonode->flag & NODE_DO_OUTPUT)) {
if (STREQ(tlink->tosock->identifier, identifier)) {
nodeAddLink(ntree,
tlink->fromnode->new_node,
tlink->fromsock->new_sock,
link->tonode,
link->tosock);
num_internal_links++;
/* find external links to this input */
for (tlink = ntree->links.first; tlink != glinks_first->next; tlink = tlink->next) {
if (tlink->tonode == gnode && STREQ(tlink->tosock->identifier, identifier)) {
nodeAddLink(ntree, tlink->fromnode, tlink->fromsock, link->tonode, link->tosock);
num_external_links++;
}
}
/* if group output is not externally linked,
* convert the constant input value to ensure somewhat consistent behavior */
if (num_external_links == 0) {
/* XXX TODO bNodeSocket *sock = node_group_find_input_socket(gnode, identifier);
BLI_assert(sock);*/
/* XXX TODO
* nodeSocketCopy(ntree, link->tosock->new_sock, link->tonode->new_node,
* ntree, sock, gnode);*/
}
}
}
/* if group output is not internally linked,
* convert the constant output value to ensure somewhat consistent behavior */
if (num_internal_links == 0) {
/* XXX TODO bNodeSocket *sock = node_group_find_output_socket(gnode, identifier);
BLI_assert(sock);*/
/* Also iterate over new links to cover passthrough links. */
glinks_last = ntree->links.last;
/* XXX TODO
* nodeSocketCopy(ntree, link->tosock, link->tonode, ntree, sock, gnode); */
/* output links */
for (link = ntree->links.first; link != glinks_first->next; link = link->next) {
if (link->fromnode == gnode) {
const char *identifier = link->fromsock->identifier;
int num_internal_links = 0;
/* find internal links to this output */
for (tlink = glinks_first->next; tlink != glinks_last->next; tlink = tlink->next) {
/* only use active output node */
if (tlink->tonode->type == NODE_GROUP_OUTPUT && (tlink->tonode->flag & NODE_DO_OUTPUT)) {
if (STREQ(tlink->tosock->identifier, identifier)) {
nodeAddLink(ntree, tlink->fromnode, tlink->fromsock, link->tonode, link->tosock);
num_internal_links++;
}
}
}
/* if group output is not internally linked,
* convert the constant output value to ensure somewhat consistent behavior */
if (num_internal_links == 0) {
/* XXX TODO bNodeSocket *sock = node_group_find_output_socket(gnode, identifier);
BLI_assert(sock);*/
/* XXX TODO
* nodeSocketCopy(ntree, link->tosock, link->tonode, ntree, sock, gnode); */
}
}
}
}

View File

@ -441,6 +441,8 @@ static void flatten_group_do(bNodeTree *ntree, bNode *gnode)
}
}
}
/* Also iterate over the new links to cover passthrough links. */
glinks_last = ntree->links.last;
/* output links */
for (tlink = ntree->links.first; tlink != glinks_first->next; tlink = tlink->next) {
if (tlink->fromnode == gnode) {