diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-06-21 02:55:18 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-06-21 02:55:18 +0400 |
commit | 207911bdb3e5ba3e110cc7107186af988d2d10e8 (patch) | |
tree | 88684071e2813d52f8dc700b593d7644b2be88c8 /source/blender/makesrna/intern/rna_access.c | |
parent | adb81a0351c0854ee8529ae7a66ef9c907790ee5 (diff) | |
parent | 768184753abb5a69e278bfe6207fe070b2e0ffc7 (diff) |
Merge with trunk r37677
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 91f88a26987..a632c5c646e 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]; |