diff options
author | Miguel Porces <cmporces> | 2019-03-16 20:48:22 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-16 22:36:35 +0300 |
commit | 9e152f919f2f86cbe3530c6adc34373ebc703904 (patch) | |
tree | e3434b83601c03e659b4a1bfd4ae5027f58fa3f5 /source/blender/nodes/shader | |
parent | 5797a5fc65c87b69460d910a82d219b5e3ea12ad (diff) |
Python API: add Python-defined node groups for shaders and compositing.
This was already supported for Cycles shader nodes, but now also works for
Eevee and compositing nodes. Instead of a generic NodeCustomGroup, now
there is ShaderNodeCustomGroup and CompositorNodeCustomGroup that can be
subclassed and registered.
Differential Revision: https://developer.blender.org/D4370
Diffstat (limited to 'source/blender/nodes/shader')
-rw-r--r-- | source/blender/nodes/shader/node_shader_tree.c | 7 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_common.c | 8 |
2 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 50bec047222..a4356dabfc0 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -290,7 +290,7 @@ static bNode *ntree_shader_output_node_from_group(bNodeTree *ntree, int target) /* Search if node groups do not contain valid output nodes (recursively). */ for (bNode *node = ntree->nodes.first; node; node = node->next) { - if (!ELEM(node->type, NODE_GROUP)) { + if (!ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) { continue; } if (node->id != NULL) { @@ -453,7 +453,7 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree) for (group_node = localtree->nodes.first; group_node; group_node = group_node->next) { - if (group_node->type != NODE_GROUP || group_node->id == NULL) + if (!(ELEM(group_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) || group_node->id == NULL) continue; /* Do it recursively. */ @@ -674,7 +674,7 @@ static void ntree_shader_link_builtin_normal(bNodeTree *ntree, /* Don't connect node itself! */ continue; } - if (node->type == NODE_GROUP && node->id) { + if ((ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) && node->id) { /* Special re-linking for group nodes. */ ntree_shader_link_builtin_group_normal(ntree, node, @@ -765,6 +765,7 @@ static bool ntree_tag_bsdf_cb(bNode *fromnode, bNode *UNUSED(tonode), void *user switch (fromnode->type) { case NODE_GROUP: + case NODE_CUSTOM_GROUP: /* Recursive */ if (fromnode->id != NULL) { bNodeTree *ntree = (bNodeTree *)fromnode->id; diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index c238a3d946d..0c2b8d939f5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -239,3 +239,11 @@ void register_node_type_sh_group(void) nodeRegisterType(&ntype); } + +void register_node_type_sh_custom_group(bNodeType *ntype) +{ + ntype->insert_link = node_insert_link_default; + ntype->update_internal_links = node_update_internal_links_default; + node_type_exec(ntype, group_initexec, group_freeexec, group_execute); + node_type_gpu(ntype, gpu_group_execute); +} |