diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-06-16 10:47:54 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-06-16 10:47:54 +0400 |
commit | 0a998decb66820eae4704220988fdc76adc341d4 (patch) | |
tree | 0851941ea28004251cd967ffb88dd102232c8f71 /source/blender/makesrna/intern/rna_access.c | |
parent | 051dedeeec50ca317c4ded0e0fe6ba3b18dee377 (diff) |
fix [#27673] Value sliders >1 do not represent numerical ratios right
the soft limits for array buttons not take into account the min/max of all array elements
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index ab11f88e0f6..8fbee8ea740 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1643,6 +1643,43 @@ void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values) memset(values, 0, sizeof(int)*prop->totarraylength); } +void RNA_property_int_get_array_range(PointerRNA *ptr, PropertyRNA *prop, int values[2]) +{ + const int array_len= RNA_property_array_length(ptr, prop); + + if(array_len <= 0) { + values[0]= 0; + values[1]= 0; + } + else if (array_len == 1) { + RNA_property_int_get_array(ptr, prop, values); + values[1]= values[0]; + } + else { + int arr_stack[32]; + int *arr; + int i; + + if(array_len > 32) { + arr= MEM_mallocN(sizeof(int) * array_len, "RNA_property_int_get_array_range"); + } + else { + arr= arr_stack; + } + + RNA_property_int_get_array(ptr, prop, arr); + values[0]= values[1]= arr[0]; + for(i= 1; i < array_len; i++) { + values[0]= MIN2(values[0], arr[i]); + values[1]= MAX2(values[1], arr[i]); + } + + if(arr != arr_stack) { + MEM_freeN(arr); + } + } +} + int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index) { int tmp[RNA_MAX_ARRAY_LENGTH]; @@ -1839,6 +1876,43 @@ void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *val memset(values, 0, sizeof(float)*prop->totarraylength); } +void RNA_property_float_get_array_range(PointerRNA *ptr, PropertyRNA *prop, float values[2]) +{ + const int array_len= RNA_property_array_length(ptr, prop); + + if(array_len <= 0) { + values[0]= 0.0f; + values[1]= 0.0f; + } + else if (array_len == 1) { + RNA_property_float_get_array(ptr, prop, values); + values[1]= values[0]; + } + else { + float arr_stack[32]; + float *arr; + int i; + + if(array_len > 32) { + arr= MEM_mallocN(sizeof(float) * array_len, "RNA_property_float_get_array_range"); + } + else { + arr= arr_stack; + } + + RNA_property_float_get_array(ptr, prop, arr); + values[0]= values[1]= arr[0]; + for(i= 1; i < array_len; i++) { + values[0]= MIN2(values[0], arr[i]); + values[1]= MAX2(values[1], arr[i]); + } + + if(arr != arr_stack) { + MEM_freeN(arr); + } + } +} + float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index) { float tmp[RNA_MAX_ARRAY_LENGTH]; |