[Bf-blender-cvs] [82702db] master: Expose shading node shading compatibility to the RNA

Sergey Sharybin noreply at git.blender.org
Thu Jan 22 09:52:54 CET 2015


Commit: 82702db4078768eb4b9a59050b17ab1b537eb48a
Author: Sergey Sharybin
Date:   Thu Jan 22 13:48:20 2015 +0500
Branches: master
https://developer.blender.org/rB82702db4078768eb4b9a59050b17ab1b537eb48a

Expose shading node shading compatibility to the RNA

This way it is possible to probe shading compatibility of a given node from
python, making things like versioning code much easier to perform.

it's only valid for shading nodes, for other nodes the property also exists
but reads as an empty enum.

To access this compatibilities:

  node.shading_compatibility

===================================================================

M	source/blender/makesrna/intern/rna_nodetree.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 32a844c..ed3896b 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -7109,7 +7109,13 @@ static void rna_def_node(BlenderRNA *brna)
 	static EnumPropertyItem dummy_static_type_items[] = {
 		{NODE_CUSTOM, "CUSTOM", 0, "Custom", "Custom Node"},
 		{0, NULL, 0, NULL, NULL}};
-	
+
+	static EnumPropertyItem node_shading_compatibilities[] = {
+		{NODE_OLD_SHADING, "OLD_SHADING", 0, "Old Shading", "Old shading system compatibility"},
+		{NODE_NEW_SHADING, "NEW_SHADING", 0, "New Shading", "New shading system compatibility"},
+		{0, NULL, 0, NULL, NULL}
+	};
+
 	srna = RNA_def_struct(brna, "Node", NULL);
 	RNA_def_struct_ui_text(srna, "Node", "Node in a node tree");
 	RNA_def_struct_sdna(srna, "bNode");
@@ -7249,6 +7255,12 @@ static void rna_def_node(BlenderRNA *brna)
 	parm = RNA_def_boolean(func, "result", false, "Result", "");
 	RNA_def_function_return(func, parm);
 
+	prop = RNA_def_property(srna, "shading_compatibility", PROP_ENUM, PROP_NONE);
+	RNA_def_property_flag(prop, PROP_ENUM_FLAG);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_enum_sdna(prop, NULL, "typeinfo->compatibility");
+	RNA_def_property_enum_items(prop, node_shading_compatibilities);
+
 	/* registration */
 	prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
 	RNA_def_property_string_sdna(prop, NULL, "typeinfo->idname");




More information about the Bf-blender-cvs mailing list