Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2013-06-10 16:19:39 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2013-06-10 16:19:39 +0400
commit4a8f71fc1d3707d3d6abcc5d8528a87339d429ba (patch)
treea36d48483d289511eed64f0429fa4dde0410f48a /source/blender/makesrna
parent31e74d00c184960994701950d11287dce13e18df (diff)
Custom Group Node type for extending existing nodes from python scripts. This is a sort of workaround for the lack of APIs in our existing node systems (compositor, cycles, BI, textures). These systems
don't have any way to deal with scripted node types yet, which could in principle by added with pynodes. The NodeCustomGroup type adds a way of scripting nodes by automating node groups which the hardcoded system can then interpret like regular groups. The new NodeCustomGroup type has the basic node_tree pointer property like the regular group node types and also uses the same socket interface system as regular groups. This means that input/output sockets can be mapped to internal nodes in the same way as regular node groups in renderers and the compositor. On top of that, however, the NodeCustomGroup type can be subclassed in python scripts to flesh out scripted node types with own draw functions, properties, updates and so on. NB: Only cycles currently supports this node type and its derivatives, other systems may follow later.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 5d8cc915dda..4433dc45601 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -201,6 +201,7 @@ EnumPropertyItem prop_wave_items[] = {
#include "ED_node.h"
#include "ED_render.h"
+#include "NOD_common.h"
#include "NOD_socket.h"
#include "RE_engine.h"
@@ -2317,6 +2318,25 @@ static void rna_NodeInternal_draw_buttons_ext(ID *id, bNode *node, struct bConte
}
}
+static StructRNA *rna_NodeCustomGroup_register(Main *bmain, ReportList *reports,
+ void *data, const char *identifier,
+ StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
+{
+ bNodeType *nt = rna_Node_register_base(bmain, reports, &RNA_NodeCustomGroup, data, identifier, validate, call, free);
+ if (!nt)
+ return NULL;
+
+ /* this updates the group node instance from the tree's interface */
+ nt->verifyfunc = node_group_verify;
+
+ nodeRegisterType(nt);
+
+ /* update while blender is running */
+ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
+
+ return nt->ext.srna;
+}
+
static void rna_CompositorNode_tag_need_exec(bNode *node)
{
node->need_exec = TRUE;
@@ -2861,6 +2881,19 @@ static void def_group(StructRNA *srna)
RNA_def_property_ui_text(prop, "Interface", "Interface socket data");
}
+static void def_custom_group(BlenderRNA *brna)
+{
+ StructRNA *srna;
+
+ srna = RNA_def_struct(brna, "NodeCustomGroup", "Node");
+ RNA_def_struct_ui_text(srna, "Custom Group", "Base node type for custom registered node group types");
+ RNA_def_struct_sdna(srna, "bNode");
+
+ RNA_def_struct_register_funcs(srna, "rna_NodeCustomGroup_register", "rna_Node_unregister", NULL);
+
+ def_group(srna);
+}
+
static void def_frame(StructRNA *srna)
{
PropertyRNA *prop;
@@ -7306,6 +7339,7 @@ void RNA_def_nodetree(BlenderRNA *brna)
define_specific_node(brna, "ShaderNodeGroup", "ShaderNode", "Group", "", def_group);
define_specific_node(brna, "CompositorNodeGroup", "CompositorNode", "Group", "", def_group);
define_specific_node(brna, "TextureNodeGroup", "TextureNode", "Group", "", def_group);
+ def_custom_group(brna);
/* special socket types */
rna_def_cmp_output_file_slot_file(brna);