diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-08-12 09:53:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-08-12 09:53:12 +0400 |
commit | d1085715a3b52bc31176a6accfa0b4838d99c2ab (patch) | |
tree | df9cc7bc84c5cb31e241c78d266a9c0b05f8461b /source/blender | |
parent | 23e057185370f1aaccf13f86062f3622d25e950a (diff) |
fix for errors evaluating user input when units are disabled
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/unit.c | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 18 |
3 files changed, 22 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 646b62b2d09..4a5e209a634 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -282,10 +282,13 @@ int bUnit_ReplaceString(char *str, char *str_orig, double scale_pref, int system 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 */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index f3d181c560a..0451cd69dff 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1470,12 +1470,16 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) /* 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 @@ void ui_check_but(uiBut *but) 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); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 91ec0365573..837158b9ec8 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -538,12 +538,12 @@ static void rna_def_modifier_build(BlenderRNA *brna) 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 @@ static void rna_def_modifier_wave(BlenderRNA *brna) 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 @@ static void rna_def_modifier_hook(BlenderRNA *brna) 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 @@ static void rna_def_modifier_array(BlenderRNA *brna) 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 @@ static void rna_def_modifier_array(BlenderRNA *brna) 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 @@ static void rna_def_modifier_cast(BlenderRNA *brna) 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.)"); |