[Bf-blender-cvs] [1179ce6] master: Code cleanup: Replace magic constants with defines

Sergey Sharybin noreply at git.blender.org
Tue Nov 4 12:57:19 CET 2014


Commit: 1179ce6f11a6fe4a4b6a32b6ddad50c94cd54a59
Author: Sergey Sharybin
Date:   Tue Nov 4 16:28:16 2014 +0500
Branches: master
https://developer.blender.org/rB1179ce6f11a6fe4a4b6a32b6ddad50c94cd54a59

Code cleanup: Replace magic constants with defines

>From quich search didn't see where the flags are used apart from
RNA currently, but i might have missed something.

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

M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/intern/rna_nodetree.c

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

diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index e0d25e7..656e24d 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -985,6 +985,13 @@ typedef struct NodeSunBeams {
 #define SHD_NORMAL_MAP_BLENDER_OBJECT	3
 #define SHD_NORMAL_MAP_BLENDER_WORLD	4
 
+/* math node clamp */
+#define SHD_MATH_CLAMP		1
+
+/* mix rgb node flags */
+#define SHD_MIXRGB_USE_ALPHA	1
+#define SHD_MIXRGB_CLAMP	2
+
 /* subsurface */
 enum {
 	SHD_SUBSURFACE_COMPATIBLE		= 0, // Deprecated
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index e90de36..9ced016 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -3051,7 +3051,7 @@ static void def_math(StructRNA *srna)
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
 	prop = RNA_def_property(srna, "use_clamp", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1);
+	RNA_def_property_boolean_sdna(prop, NULL, "custom2", SHD_MATH_CLAMP);
 	RNA_def_property_ui_text(prop, "Clamp", "Clamp result of the node to 0..1 range");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
@@ -3132,12 +3132,12 @@ static void def_mix_rgb(StructRNA *srna)
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 	
 	prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1);
+	RNA_def_property_boolean_sdna(prop, NULL, "custom2", SHD_MIXRGB_USE_ALPHA);
 	RNA_def_property_ui_text(prop, "Alpha", "Include alpha of second input in this operation");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
 	prop = RNA_def_property(srna, "use_clamp", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "custom2", 2);
+	RNA_def_property_boolean_sdna(prop, NULL, "custom2", SHD_MIXRGB_CLAMP);
 	RNA_def_property_ui_text(prop, "Clamp", "Clamp result of the node to 0..1 range");
 	RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }




More information about the Bf-blender-cvs mailing list