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-11 15:19:42 +0300
committerJoshua Leung <aligorith@gmail.com>2009-02-11 15:19:42 +0300
commit7d3c88772b4cdf9cec8966390e84bdd21802395f (patch)
tree9b3545b7c16ff34b7dcc25b1b59348221f1d9b29 /source/blender/blenkernel/intern/anim_sys.c
parentba32199b23fb1b745109d7b25b8d7c6cdf903cd1 (diff)
Keying Sets: Initial commit of skeleton code
When fully implemented, these will be the clearest demonstration of 'Everything is Animateable', as they will allow users to define an arbitary group of settings through selecting items in the Datablocks (RNA-Viewer) View of the Outliner to define custom 'sets'. Such Keying Sets are known as the 'absolute' ones, which are created for a custom purpose. Of course, 'builtin' Keying Sets will still be provided. Such built-in ones will not work on any particular paths, but will use context info to maintain the legacy method of inserting keyframes (via IKEY menu). Currently, KeyingSets cannot be created/edited through the UI, though the backend code is in place to do this.
Diffstat (limited to 'source/blender/blenkernel/intern/anim_sys.c')
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index a7e65a9c585..55597b635c9 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -158,6 +158,118 @@ AnimData *BKE_copy_animdata (AnimData *adt)
return dadt;
}
+/* *********************************** */
+/* KeyingSet API */
+
+/* NOTES:
+ * It is very likely that there will be two copies of the api - one for internal use,
+ * and one 'operator' based wrapper of the internal API, which should allow for access
+ * from Python/scripts so that riggers can automate the creation of KeyingSets for their rigs.
+ */
+
+/* Defining Tools --------------------------- */
+
+/* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */
+KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, short keyingflag)
+{
+ KeyingSet *ks;
+
+ /* allocate new KeyingSet */
+ ks= MEM_callocN(sizeof(KeyingSet), "KeyingSet");
+
+ BLI_snprintf(ks->name, 64, name);
+
+ ks->flag= flag;
+ ks->keyingflag= keyingflag;
+
+ /* add KeyingSet to list */
+ BLI_addtail(list, ks);
+
+ /* return new KeyingSet for further editing */
+ return ks;
+}
+
+/* Add a destination to a KeyingSet. Nothing is returned for now...
+ * Checks are performed to ensure that destination is appropriate for the KeyingSet in question
+ */
+void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int flag)
+{
+ KS_Path *ksp;
+
+ /* sanity checks */
+ 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)
+ return;
+ }
+
+ /* allocate a new KeyingSet Path */
+ ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path");
+
+ /* just store absolute info */
+ if (ks->flag & KEYINGSET_ABSOLUTE) {
+ ksp->id= id;
+ BLI_snprintf(ksp->group, 64, group_name);
+ }
+
+ /* just copy path info */
+ // XXX no checks are performed for templates yet
+ // should array index be checked too?
+ ksp->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
+ ksp->array_index= array_index;
+
+ /* store flags */
+ ksp->flag= flag;
+
+ /* add KeyingSet path to KeyingSet */
+ BLI_addtail(&ks->paths, ksp);
+}
+
+
+/* Freeing Tools --------------------------- */
+
+/* Free data for KeyingSet but not set itself */
+void BKE_keyingset_free (KeyingSet *ks)
+{
+ KS_Path *ksp, *kspn;
+
+ /* sanity check */
+ if (ks == NULL)
+ return;
+
+ /* free each path as we go to avoid looping twice */
+ for (ksp= ks->paths.first; ksp; ksp= kspn) {
+ kspn= ksp->next;
+
+ /* free RNA-path info */
+ MEM_freeN(ksp->rna_path);
+
+ /* free path itself */
+ BLI_freelinkN(&ks->paths, ks);
+ }
+}
+
+/* Free all the KeyingSets in the given list */
+void BKE_keyingsets_free (ListBase *list)
+{
+ KeyingSet *ks, *ksn;
+
+ /* sanity check */
+ if (list == NULL)
+ return;
+
+ /* loop over KeyingSets freeing them
+ * - BKE_keyingset_free() doesn't free the set itself, but it frees its sub-data
+ */
+ for (ks= list->first; ks; ks= ksn) {
+ ksn= ks->next;
+ BKE_keyingset_free(ks);
+ BLI_freelinkN(list, ks);
+ }
+}
/* ***************************************** */
/* Evaluation Data-Setting Backend */