[Bf-blender-cvs] [d868990] object_nodes: A new base type for object nodes.
Lukas Tönne
noreply at git.blender.org
Tue Nov 24 09:42:31 CET 2015
Commit: d8689902248ff68c9cd50380182f53d51a8ad04d
Author: Lukas Tönne
Date: Fri Jul 17 13:25:07 2015 +0200
Branches: object_nodes
https://developer.blender.org/rBd8689902248ff68c9cd50380182f53d51a8ad04d
A new base type for object nodes.
This includes a generic 'id' pointer for a single ID datablock pointer
in the node. The ID type can be defined using the `bl_id_property_type`
registerable attribute.
===================================================================
M release/scripts/modules/bpy_types.py
M source/blender/blenkernel/BKE_node.h
M source/blender/makesrna/RNA_access.h
M source/blender/makesrna/intern/rna_nodetree.c
===================================================================
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 92dbd2d..d9c286e 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -838,3 +838,11 @@ class TextureNode(NodeInternal):
@classmethod
def poll(cls, ntree):
return ntree.bl_idname == 'TextureNodeTree'
+
+
+class ObjectNode(NodeInternal):
+ __slots__ = ()
+
+ @classmethod
+ def poll(cls, ntree):
+ return ntree.bl_idname == 'ObjectNodeTree'
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index b97bf20..8b11fb0 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -157,6 +157,7 @@ typedef struct bNodeType {
bNodeSocketTemplate *inputs, *outputs;
char storagename[64]; /* struct name for DNA */
+ int id_property_type; /* static type of the ID property, if used */
/* Main draw function for the node */
void (*draw_nodetype)(const struct bContext *C, struct ARegion *ar, struct SpaceNode *snode,
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 406bab0..c93c3cf0 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -434,6 +434,7 @@ extern StructRNA RNA_NoiseTexture;
extern StructRNA RNA_NorController;
extern StructRNA RNA_Object;
extern StructRNA RNA_ObjectBase;
+extern StructRNA RNA_ObjectNode;
extern StructRNA RNA_ObstacleFluidSettings;
extern StructRNA RNA_OceanModifier;
extern StructRNA RNA_OceanTexData;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 51e6114..9a77aa8 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1465,6 +1465,35 @@ static StructRNA *rna_TextureNode_register(
return nt->ext.srna;
}
+static StructRNA *rna_ObjectNode_id_typef(PointerRNA *ptr)
+{
+ bNode *node = ptr->data;
+ return ID_code_to_RNA_type(node->typeinfo->id_property_type);
+}
+
+static int rna_ObjectNode_id_editable(PointerRNA *ptr)
+{
+ bNode *node = ptr->data;
+ return (node->typeinfo->id_property_type) ? PROP_EDITABLE : 0;
+}
+
+static StructRNA *rna_ObjectNode_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_ObjectNode, data, identifier, validate, call, free);
+ if (!nt)
+ return NULL;
+
+ nodeRegisterType(nt);
+
+ /* update while blender is running */
+ WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
+
+ return nt->ext.srna;
+}
+
static IDProperty *rna_Node_idprops(PointerRNA *ptr, bool create)
{
bNode *node = ptr->data;
@@ -6668,6 +6697,33 @@ static void rna_def_texture_node(BlenderRNA *brna)
RNA_def_struct_register_funcs(srna, "rna_TextureNode_register", "rna_Node_unregister", NULL);
}
+static void rna_def_object_node(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "ObjectNode", "NodeInternal");
+ RNA_def_struct_ui_text(srna, "Object Node", "Object component node");
+ RNA_def_struct_sdna(srna, "bNode");
+ RNA_def_struct_register_funcs(srna, "rna_ObjectNode_register", "rna_Node_unregister", NULL);
+
+ prop = RNA_def_property(srna, "bl_id_property_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "typeinfo->id_property_type");
+ RNA_def_property_enum_items(prop, id_type_items);
+ RNA_def_property_enum_default(prop, ID_OB);
+ RNA_def_property_flag(prop, PROP_REGISTER);
+ RNA_def_property_ui_text(prop, "ID Property Type", "Type of ID-block that is used as the id property");
+
+ /* ID */
+ prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ID");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_editable_func(prop, "rna_ObjectNode_id_editable");
+ RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_ObjectNode_id_typef", NULL);
+ RNA_def_property_ui_text(prop, "ID", "");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+}
+
/* -------------------------------------------------------------------------- */
static void rna_def_node_socket(BlenderRNA *brna)
@@ -8161,6 +8217,7 @@ void RNA_def_nodetree(BlenderRNA *brna)
rna_def_shader_node(brna);
rna_def_compositor_node(brna);
rna_def_texture_node(brna);
+ rna_def_object_node(brna);
rna_def_nodetree(brna);
More information about the Bf-blender-cvs
mailing list