Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern/rna_key.c')
-rw-r--r--source/blender/makesrna/intern/rna_key.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c
index 8c7e684b422..47accb86d8f 100644
--- a/source/blender/makesrna/intern/rna_key.c
+++ b/source/blender/makesrna/intern/rna_key.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
+#include "RNA_access.h"
#include "RNA_define.h"
#include "rna_internal.h"
@@ -96,30 +97,49 @@ static void rna_ShapeKey_value_range(PointerRNA *ptr, float *min, float *max)
*max= data->slidermax;
}
-static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr)
+PointerRNA rna_object_shapekey_index_get(ID *id, int value)
{
- Key *key= rna_ShapeKey_find_key(ptr->id.data);
- KeyBlock *kb= (KeyBlock*)ptr->data, *kbrel;
+ Key *key= rna_ShapeKey_find_key(id);
+ KeyBlock *kb= NULL;
+ PointerRNA ptr;
int a;
- if(key && kb->relative < key->totkey)
- for(a=0, kbrel=key->block.first; kbrel; kbrel=kbrel->next, a++)
- if(a == kb->relative)
- return rna_pointer_inherit_refine(ptr, &RNA_ShapeKey, kbrel);
+ if(key && value < key->totkey)
+ for(a=0, kb=key->block.first; kb; kb=kb->next, a++)
+ if(a == value)
+ break;
+
+ RNA_pointer_create(id, &RNA_ShapeKey, kb, &ptr);
- return rna_pointer_inherit_refine(ptr, NULL, NULL);
+ return ptr;
}
-static void rna_ShapeKey_relative_key_set(PointerRNA *ptr, PointerRNA value)
+int rna_object_shapekey_index_set(ID *id, PointerRNA value, int current)
{
- Key *key= rna_ShapeKey_find_key(ptr->id.data);
- KeyBlock *kb= (KeyBlock*)ptr->data, *kbrel;
+ Key *key= rna_ShapeKey_find_key(id);
+ KeyBlock *kb;
int a;
if(key)
- for(a=0, kbrel=key->block.first; kbrel; kbrel=kbrel->next, a++)
- if(kbrel == value.data)
- kb->relative= a;
+ for(a=0, kb=key->block.first; kb; kb=kb->next, a++)
+ if(kb == value.data)
+ return a;
+
+ return current;
+}
+
+static PointerRNA rna_ShapeKey_relative_key_get(PointerRNA *ptr)
+{
+ KeyBlock *kb= (KeyBlock*)ptr->data;
+
+ return rna_object_shapekey_index_get(ptr->id.data, kb->relative);
+}
+
+static void rna_ShapeKey_relative_key_set(PointerRNA *ptr, PointerRNA value)
+{
+ KeyBlock *kb= (KeyBlock*)ptr->data;
+
+ kb->relative= rna_object_shapekey_index_set(ptr->id.data, value, kb->relative);
}
static void rna_ShapeKeyPoint_co_get(PointerRNA *ptr, float *values)