Fix T54339: Shapekey Max value doesn't clamp existing value

Update the "current value" of the Shape Key blend amount when value is
not within the min/max range. New function `rna_ShapeKey_update_minmax`
used to update and clamp the current value.

Reviewed By: mano-wii, lichtwerk, #animation_rigging, sybren

Maniphest Tasks: T54339

Differential Revision: https://developer.blender.org/D11071
This commit is contained in:
Pratik Borhade 2021-05-10 15:47:32 +02:00 committed by Sybren A. Stüvel
parent 6cd4bb9435
commit 1b0890ccda
Notes: blender-bot 2023-02-14 06:06:35 +01:00
Referenced by issue #54339, Shapekey Max value doesn't clamp existing value
2 changed files with 13 additions and 1 deletions

@ -1 +1 @@
Subproject commit 4cb833e84acfd2be5fa08ce75118ce9cb60643b8
Subproject commit af6356139616749c952ff5dfc6bf6dfa668e3325

View File

@ -699,6 +699,16 @@ static void rna_Key_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *p
}
}
static void rna_ShapeKey_update_minmax(Main *bmain, Scene *scene, PointerRNA *ptr)
{
KeyBlock *data = (KeyBlock *)ptr->data;
if (IN_RANGE_INCL(data->curval, data->slidermin, data->slidermax)) {
return;
}
CLAMP(data->curval, data->slidermin, data->slidermax);
rna_Key_update_data(bmain, scene, ptr);
}
static KeyBlock *rna_ShapeKeyData_find_keyblock(Key *key, float *point)
{
KeyBlock *kb;
@ -955,6 +965,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
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");
RNA_def_property_update(prop, 0, "rna_ShapeKey_update_minmax");
prop = RNA_def_property(srna, "slider_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "slidermax");
@ -963,6 +974,7 @@ static void rna_def_keyblock(BlenderRNA *brna)
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");
RNA_def_property_update(prop, 0, "rna_ShapeKey_update_minmax");
prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "data", "totelem");