[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43051] trunk/blender/source/blender/ makesrna/intern: rna api - set hard min/ max for colors which are float properties but internally use chars to 0/1.

Campbell Barton ideasman42 at gmail.com
Sun Jan 1 10:39:54 CET 2012


Revision: 43051
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43051
Author:   campbellbarton
Date:     2012-01-01 09:39:43 +0000 (Sun, 01 Jan 2012)
Log Message:
-----------
rna api - set hard min/max for colors which are float properties but internally use chars to 0/1.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/makesrna.c
    trunk/blender/source/blender/makesrna/intern/rna_define.c

Modified: trunk/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/makesrna.c	2012-01-01 09:19:22 UTC (rev 43050)
+++ trunk/blender/source/blender/makesrna/intern/makesrna.c	2012-01-01 09:39:43 UTC (rev 43051)
@@ -448,11 +448,9 @@
 
 static int rna_color_quantize(PropertyRNA *prop, PropertyDefRNA *dp)
 {
-	if(prop->type == PROP_FLOAT && (prop->subtype==PROP_COLOR || prop->subtype==PROP_COLOR_GAMMA))
-		if(strcmp(dp->dnatype, "float") != 0 && strcmp(dp->dnatype, "double") != 0)
-			return 1;
-	
-	return 0;
+	return ( (prop->type == PROP_FLOAT) &&
+	         (prop->subtype==PROP_COLOR || prop->subtype==PROP_COLOR_GAMMA) &&
+	         (IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0) );
 }
 
 static const char *rna_function_string(void *func)

Modified: trunk/blender/source/blender/makesrna/intern/rna_define.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_define.c	2012-01-01 09:19:22 UTC (rev 43050)
+++ trunk/blender/source/blender/makesrna/intern/rna_define.c	2012-01-01 09:39:43 UTC (rev 43051)
@@ -1628,6 +1628,7 @@
 void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
 {
 	PropertyDefRNA *dp;
+	FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
 	StructRNA *srna= DefRNA.laststruct;
 
 	if(!DefRNA.preprocess) {
@@ -1652,6 +1653,11 @@
 				}
 			}
 		}
+
+		if(dp->dnatype && strcmp(dp->dnatype, "char") == 0) {
+			fprop->hardmin= fprop->softmin= 0.0f;
+			fprop->hardmax= fprop->softmax= 1.0f;
+		}
 	}
 
 	rna_def_property_sdna(prop, structname, propname);



More information about the Bf-blender-cvs mailing list