diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-01-03 14:58:19 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-01-03 14:58:19 +0300 |
commit | f7857ec81b960b361c81d6619dfaf28f4e8d7ae0 (patch) | |
tree | 6bf4886af55eb8f9acb5a7bdbb7d9440b11228b2 /source/blender/makesrna/intern/rna_key.c | |
parent | e7ed8a3be09bb2f30d03e28410cb42099ebfb940 (diff) |
2.4x <-> 2.5 Regression Fixes: Shapekey Problems
This commit partially fixes the problems with Shapekeys from older
files, as seen from the Regression suite (relative.blend and
dolphin.blend in particular).
In older files, keyblock->slidermax was never truly set to 1.0 even
though the UI may have shown such a value (which was bizzarely being
sourced from somewhere else). Hence, after loading the files in 2.5,
the shapekeys wouldn't animate, as the value would get clamped between
0 and 0.
To fix this, I've added a version patch which corrects these
situations in old files, and I've adjusted the slider-RNA code so that
it is not possible to set up such clamping anymore.
TODO:
The fixes detailed here only make it possible for these files to work
again in 2.5. However, I haven't been able to find a way to get the
files to actually work in 2.5 without manually changing the active
shapekey (per object) after loading the files with these patches
applied. Possibly it's just some depsgraph magic needed, unless
there's still some other evil voodoo in the shapekey code
Diffstat (limited to 'source/blender/makesrna/intern/rna_key.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_key.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 47a14c3dac7..d4021dc1cec 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -97,6 +97,47 @@ static void rna_ShapeKey_value_range(PointerRNA *ptr, float *min, float *max) *max= data->slidermax; } +/* epsilon for how close one end of shapekey range can get to the other */ +#define SHAPEKEY_SLIDER_TOL 0.001 + +static void rna_ShapeKey_slider_min_range(PointerRNA *ptr, float *min, float *max) +{ + KeyBlock *data= (KeyBlock*)ptr->data; + + *min= -10.0f; + *max= data->slidermax - SHAPEKEY_SLIDER_TOL; +} + +static void rna_ShapeKey_slider_min_set(PointerRNA *ptr, float value) +{ + KeyBlock *data= (KeyBlock*)ptr->data; + float min, max; + + rna_ShapeKey_slider_min_range(ptr, &min, &max); + CLAMP(value, min, max); + data->slidermin = value; +} + +static void rna_ShapeKey_slider_max_range(PointerRNA *ptr, float *min, float *max) +{ + KeyBlock *data= (KeyBlock*)ptr->data; + + *min= data->slidermin + SHAPEKEY_SLIDER_TOL; + *max= 10.0f; +} + +static void rna_ShapeKey_slider_max_set(PointerRNA *ptr, float value) +{ + KeyBlock *data= (KeyBlock*)ptr->data; + float min, max; + + rna_ShapeKey_slider_max_range(ptr, &min, &max); + CLAMP(value, min, max); + data->slidermax = value; +} + +#undef SHAPEKEY_SLIDER_TOL + PointerRNA rna_object_shapekey_index_get(ID *id, int value) { Key *key= rna_ShapeKey_find_key(id); @@ -446,12 +487,14 @@ static void rna_def_keyblock(BlenderRNA *brna) prop= RNA_def_property(srna, "slider_min", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "slidermin"); RNA_def_property_range(prop, -10.0f, 10.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_slider_min_set", "rna_ShapeKey_slider_min_range"); RNA_def_property_ui_text(prop, "Slider Min", "Minimum for slider"); prop= RNA_def_property(srna, "slider_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "slidermax"); RNA_def_property_range(prop, -10.0f, 10.0f); RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ShapeKey_slider_max_set", "rna_ShapeKey_slider_max_range"); RNA_def_property_ui_text(prop, "Slider Max", "Maximum for slider"); prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); |