[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22393] branches/blender2.5/blender/source /blender: fix for errors evaluating user input when units are disabled

Campbell Barton ideasman42 at gmail.com
Wed Aug 12 07:53:12 CEST 2009


Revision: 22393
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22393
Author:   campbellbarton
Date:     2009-08-12 07:53:12 +0200 (Wed, 12 Aug 2009)

Log Message:
-----------
fix for errors evaluating user input when units are disabled

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/intern/unit.c
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_modifier.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/unit.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/unit.c	2009-08-12 05:20:16 UTC (rev 22392)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/unit.c	2009-08-12 05:53:12 UTC (rev 22393)
@@ -282,10 +282,13 @@
 	char str_tmp[256];
 	int change= 0;
 	
-	if(usys==NULL || usys->units[0].name==NULL)
+	strcpy(str, str_orig);
+
+	if(usys==NULL || usys->units[0].name==NULL) {
 		return 0;
+	}
 
-	strcpy(str, str_orig);
+	scale_pref= 1.0/scale_pref;
 	
 	for(unit= usys->units; unit->name; unit++) {
 		/* incase there are multiple instances */

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-08-12 05:20:16 UTC (rev 22392)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-08-12 05:53:12 UTC (rev 22393)
@@ -1470,12 +1470,16 @@
 		/* number editing */
 		double value;
 
-		/* XXX 2.50 missing python api */
 #ifndef DISABLE_PYTHON
 		{
 			char str_unit_convert[256];
-			
-			bUnit_ReplaceString(str_unit_convert, str, 1.0/ui_get_but_scale_unit(but, 1.0), U.unit_system, RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)));
+			int change= -1;
+			if(U.unit_system != USER_UNIT_NONE) {
+				bUnit_ReplaceString(str_unit_convert, str, ui_get_but_scale_unit(but, 1.0), U.unit_system, RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)));
+			}
+			else {
+				strcpy(str_unit_convert, str);
+			}
 
 			if(BPY_button_eval(C, str_unit_convert, &value)) {
 				value = ui_get_but_val(but); /* use its original value */
@@ -1832,7 +1836,7 @@
 			else if(U.unit_system != USER_UNIT_NONE && but->rnaprop && RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop))) {
 				char new_str[256];
 
-				if(U.unit_scale_length==0.0) U.unit_scale_length= 1.0; // XXX do_versions
+				if(U.unit_scale_length<0.0001) U.unit_scale_length= 1.0; // XXX do_versions
 
 				ui_get_but_string_unit(but, new_str, value, TRUE);
 				sprintf(but->drawstr, "%s%s", but->str, new_str);

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_modifier.c	2009-08-12 05:20:16 UTC (rev 22392)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_modifier.c	2009-08-12 05:53:12 UTC (rev 22393)
@@ -538,12 +538,12 @@
 	RNA_def_struct_sdna(srna, "BuildModifierData");
 	RNA_def_struct_ui_icon(srna, ICON_MOD_BUILD);
 
-	prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_TIME);
 	RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
 	RNA_def_property_ui_text(prop, "Start", "Specify the start frame of the effect.");
 	RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update");
 
-	prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_TIME);
 	RNA_def_property_range(prop, 1, MAXFRAMEF);
 	RNA_def_property_ui_text(prop, "Length", "Specify the total time the build effect requires");
 	RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update");
@@ -708,21 +708,21 @@
 	RNA_def_property_ui_text(prop, "Damping Time",  "");
 	RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update");
 
-	prop= RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_DISTANCE);
 	RNA_def_property_float_sdna(prop, NULL, "falloff");
 	RNA_def_property_range(prop, 0, FLT_MAX);
 	RNA_def_property_ui_range(prop, 0, 100, 100, 2);
 	RNA_def_property_ui_text(prop, "Falloff Radius",  "");
 	RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update");
 
-	prop= RNA_def_property(srna, "start_position_x", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "start_position_x", PROP_FLOAT, PROP_DISTANCE);
 	RNA_def_property_float_sdna(prop, NULL, "startx");
 	RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
 	RNA_def_property_ui_range(prop, -100, 100, 100, 2);
 	RNA_def_property_ui_text(prop, "Start Position X",  "");
 	RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update");
 
-	prop= RNA_def_property(srna, "start_position_y", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "start_position_y", PROP_FLOAT, PROP_DISTANCE);
 	RNA_def_property_float_sdna(prop, NULL, "starty");
 	RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
 	RNA_def_property_ui_range(prop, -100, 100, 100, 2);
@@ -853,7 +853,7 @@
 	RNA_def_struct_sdna(srna, "HookModifierData");
 	RNA_def_struct_ui_icon(srna, ICON_HOOK);
 
-	prop= RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_DISTANCE);
 	RNA_def_property_range(prop, 0, FLT_MAX);
 	RNA_def_property_ui_range(prop, 0, 100, 100, 2);
 	RNA_def_property_ui_text(prop, "Falloff",  "If not zero, the distance from the hook where influence ends.");
@@ -953,7 +953,7 @@
 	RNA_def_property_ui_text(prop, "Count",  "Number of duplicates to make.");
 	RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update");
 
-	prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "length", PROP_FLOAT, PROP_DISTANCE);
 	RNA_def_property_range(prop, 0, INT_MAX);
 	RNA_def_property_ui_range(prop, 0, 10000, 10, 2);
 	RNA_def_property_ui_text(prop, "Length", "Length to fit array within.");
@@ -998,7 +998,7 @@
 	RNA_def_property_ui_text(prop, "Merge Vertices", "Merge vertices in first and last duplicates.");
 	RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update");
 
-	prop= RNA_def_property(srna, "merge_distance", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "merge_distance", PROP_FLOAT, PROP_DISTANCE);
 	RNA_def_property_float_sdna(prop, NULL, "merge_dist");
 	RNA_def_property_range(prop, 0, FLT_MAX);
 	RNA_def_property_ui_range(prop, 0, 1, 1, 4);
@@ -1280,7 +1280,7 @@
 	RNA_def_property_ui_text(prop, "Factor", "");
 	RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update");
 
-	prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE);
 	RNA_def_property_range(prop, 0, FLT_MAX);
 	RNA_def_property_ui_range(prop, 0, 100, 10, 2);
 	RNA_def_property_ui_text(prop, "Radius", "Only deform vertices within this distance from the center of the effect (leave as 0 for infinite.)");





More information about the Bf-blender-cvs mailing list