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:
authorJoshua Leung <aligorith@gmail.com>2009-02-15 10:00:13 +0300
committerJoshua Leung <aligorith@gmail.com>2009-02-15 10:00:13 +0300
commit394b3fcede01356764bb91883a2f32b08b0a6ca3 (patch)
tree5f2ad941c1619c9dc50056489d0503e94cbc5142 /source/blender/blenkernel
parentc56d635318288fc5f6bf4c9d9fe8f86a645a54f1 (diff)
Keying Sets: Added 'remove selected from active set' (Alt-K) operator in Outliner
* Cleaned up the helper functions for the Outliner operators which deal with Keying Sets * Fixed a few minor bugs in the Keying Sets API that won't show up with the current tools, but may crop up later * Added a new method to find a 'matching' path in a Keying Set. Now adding a new path to a Keying Set will firstly check if there is any similar path already, and skip adding another path.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_animsys.h3
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c60
2 files changed, 60 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index 9da78aa5676..44c8d827e8c 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -10,6 +10,7 @@ struct ListBase;
struct Main;
struct AnimData;
struct KeyingSet;
+struct KS_Path;
/* ************************************* */
/* AnimData API */
@@ -35,6 +36,8 @@ struct KeyingSet *BKE_keyingset_add(struct ListBase *list, const char name[], sh
/* Add a destination to a KeyingSet */
void BKE_keyingset_add_destination(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode);
+struct KS_Path *BKE_keyingset_find_destination(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode);
+
/* Free data for KeyingSet but not set itself */
void BKE_keyingset_free(struct KeyingSet *ks);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 89f4de567f2..0097b30b685 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -167,6 +167,56 @@ AnimData *BKE_copy_animdata (AnimData *adt)
* from Python/scripts so that riggers can automate the creation of KeyingSets for their rigs.
*/
+/* Finding Tools --------------------------- */
+
+/* Find the first path that matches the given criteria */
+// TODO: do we want some method to perform partial matches too?
+KS_Path *BKE_keyingset_find_destination (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode)
+{
+ KS_Path *ksp;
+
+ /* sanity checks */
+ if ELEM(NULL, ks, rna_path)
+ return NULL;
+
+ /* ID is optional for relative KeyingSets, but is necessary for absolute KeyingSets */
+ if (id == NULL) {
+ if (ks->flag & KEYINGSET_ABSOLUTE)
+ return NULL;
+ }
+
+ /* loop over paths in the current KeyingSet, finding the first one where all settings match
+ * (i.e. the first one where none of the checks fail and equal 0)
+ */
+ for (ksp= ks->paths.first; ksp; ksp= ksp->next) {
+ short eq_id=1, eq_path=1, eq_index=1, eq_group=1;
+
+ /* id */
+ if ((ks->flag & KEYINGSET_ABSOLUTE) && (id != ksp->id))
+ eq_id= 0;
+
+ /* path */
+ if ((ksp->rna_path==0) || strcmp(rna_path, ksp->rna_path))
+ eq_path= 0;
+
+ /* index */
+ if (ksp->array_index != array_index)
+ eq_index= 0;
+
+ /* group */
+ if (group_name) {
+ // FIXME: these checks need to be coded... for now, it's not too important though
+ }
+
+ /* if all aspects are ok, return */
+ if (eq_id && eq_path && eq_index && eq_group)
+ return ksp;
+ }
+
+ /* none found */
+ return NULL;
+}
+
/* Defining Tools --------------------------- */
/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
@@ -203,12 +253,16 @@ void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name
if ELEM(NULL, ks, rna_path)
return;
- /* ID is optional, and should only be provided for absolute KeyingSets */
- if (id) {
- if ((ks->flag & KEYINGSET_ABSOLUTE) == 0)
+ /* ID is optional for relative KeyingSets, but is necessary for absolute KeyingSets */
+ if (id == NULL) {
+ if (ks->flag & KEYINGSET_ABSOLUTE)
return;
}
+ /* don't add if there is already a matching KS_Path in the KeyingSet */
+ if (BKE_keyingset_find_destination(ks, id, group_name, rna_path, array_index, groupmode))
+ return;
+
/* allocate a new KeyingSet Path */
ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path");