diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 24 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_group.c | 2 |
3 files changed, 26 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index fb6096cd82f..8a107aac538 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -554,6 +554,9 @@ struct bNode *BKE_node_copy_ex(struct bNodeTree *ntree, struct bNode *BKE_node_copy_store_new_pointers(struct bNodeTree *ntree, struct bNode *node_src, const int flag); +struct bNodeTree *ntreeCopyTree_ex_new_pointers(const struct bNodeTree *ntree, + struct Main *bmain, + const bool do_id_user); struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index e1f7a346b1c..62357b7f878 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1099,9 +1099,8 @@ bNode *BKE_node_copy_ex(bNodeTree *ntree, const bNode *node_src, const int flag) return node_dst; } -bNode *BKE_node_copy_store_new_pointers(bNodeTree *ntree, bNode *node_src, const int flag) +static void node_set_new_pointers(bNode *node_src, bNode *new_node) { - bNode *new_node = BKE_node_copy_ex(ntree, node_src, flag); /* Store mapping to the node itself. */ node_src->new_node = new_node; /* Store mapping to inputs. */ @@ -1120,9 +1119,30 @@ bNode *BKE_node_copy_store_new_pointers(bNodeTree *ntree, bNode *node_src, const new_output_sock = new_output_sock->next; output_sock_src = output_sock_src->next; } +} + +bNode *BKE_node_copy_store_new_pointers(bNodeTree *ntree, bNode *node_src, const int flag) +{ + bNode *new_node = BKE_node_copy_ex(ntree, node_src, flag); + node_set_new_pointers(node_src, new_node); return new_node; } +bNodeTree *ntreeCopyTree_ex_new_pointers(const bNodeTree *ntree, + Main *bmain, + const bool do_id_user) +{ + bNodeTree *new_ntree = ntreeCopyTree_ex(ntree, bmain, do_id_user); + bNode *new_node = new_ntree->nodes.first; + bNode *node_src = ntree->nodes.first; + while (new_node != NULL) { + node_set_new_pointers(node_src, new_node); + new_node = new_node->next; + node_src = node_src->next; + } + return new_ntree; +} + /* also used via rna api, so we check for proper input output direction */ bNodeLink *nodeAddLink( bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock) diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index a0729a15db7..3fd03bac874 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -197,7 +197,7 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) * - ngroup (i.e. the source NodeTree) is left unscathed * - temp copy. don't change ID usercount */ - wgroup = ntreeCopyTree_ex(ngroup, bmain, false); + wgroup = ntreeCopyTree_ex_new_pointers(ngroup, bmain, false); /* Add the nodes into the ntree */ for (node = wgroup->nodes.first; node; node = nextnode) { |