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/blenkernel | |
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/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 6 |
3 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 951962d26f1..80b0f9a023f 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -618,6 +618,7 @@ bool BKE_node_is_connected_to_output(struct bNodeTree *ntree, struct bNode *node #define NODE_REROUTE 6 #define NODE_GROUP_INPUT 7 #define NODE_GROUP_OUTPUT 8 +#define NODE_CUSTOM_GROUP 9 void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 90b25e8fd49..88a96ff098e 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1038,7 +1038,7 @@ static int count_texture_nodes_recursive(bNodeTree *nodetree) if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) { tex_nodes++; } - else if (node->type == NODE_GROUP && node->id) { + else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) { /* recurse into the node group and see if it contains any textures */ tex_nodes += count_texture_nodes_recursive((bNodeTree *)node->id); } @@ -1073,7 +1073,7 @@ static void fill_texpaint_slots_recursive(bNodeTree *nodetree, bNode *active_nod } (*index)++; } - else if (node->type == NODE_GROUP && node->id) { + else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) { /* recurse into the node group and see if it contains any textures */ fill_texpaint_slots_recursive((bNodeTree *)node->id, active_node, ma, index); } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 57dcbcbebf8..d4dd74a0e2d 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1804,7 +1804,7 @@ static void free_localized_node_groups(bNodeTree *ntree) return; for (node = ntree->nodes.first; node; node = node->next) { - if (node->type == NODE_GROUP && node->id) { + if ((ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) && node->id) { bNodeTree *ngroup = (bNodeTree *)node->id; ntreeFreeTree(ngroup); MEM_freeN(ngroup); @@ -2046,7 +2046,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) LIB_ID_COPY_NO_ANIMDATA)); for (node = ltree->nodes.first; node; node = node->next) { - if (node->type == NODE_GROUP && node->id) { + if ((ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) && node->id) { node->id = (ID *)ntreeLocalize((bNodeTree *)node->id); } } @@ -2369,7 +2369,7 @@ bool ntreeHasTree(const bNodeTree *ntree, const bNodeTree *lookup) return true; for (node = ntree->nodes.first; node; node = node->next) - if (node->type == NODE_GROUP && node->id) + if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && node->id) if (ntreeHasTree((bNodeTree *)node->id, lookup)) return true; |