diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-08-29 13:20:55 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-08-29 13:55:03 +0300 |
commit | c1582667cabe025bd3a1ee4a3db27e2b3fd9e42a (patch) | |
tree | a5c30c895723b3edad465ae986acc111791be740 /source/blender/blenkernel/intern/node.c | |
parent | 9ca03ba4104429b4304ec012feb98ea6d923cb04 (diff) |
Add utility function to copy default values from one tree to another
The trees should match in nodes layout completely.
Diffstat (limited to 'source/blender/blenkernel/intern/node.c')
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index f0b5fc9c610..1c24d72759e 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3804,3 +3804,33 @@ void BKE_nodetree_remove_layer_n(bNodeTree *ntree, Scene *scene, const int layer } } } + +static void node_copy_default_values_list(ListBase *sockets_dst, + const ListBase *sockets_src) +{ + bNodeSocket *sock_dst = sockets_dst->first; + const bNodeSocket *sock_src = sockets_src->first; + while (sock_dst != NULL) { + node_socket_copy_default_value(sock_dst, sock_src); + sock_dst = sock_dst->next; + sock_src = sock_src->next; + } +} + +static void node_copy_default_values(bNode *node_dst, const bNode *node_src) +{ + node_copy_default_values_list(&node_dst->inputs, &node_src->inputs); + node_copy_default_values_list(&node_dst->outputs, &node_src->outputs); +} + +void BKE_nodetree_copy_default_values(bNodeTree *ntree_dst, + const bNodeTree *ntree_src) +{ + bNode *node_dst = ntree_dst->nodes.first; + const bNode *node_src = ntree_src->nodes.first; + while (node_dst != NULL) { + node_copy_default_values(node_dst, node_src); + node_dst = node_dst->next; + node_src = node_src->next; + } +} |