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>2010-03-16 09:18:49 +0300
committerJoshua Leung <aligorith@gmail.com>2010-03-16 09:18:49 +0300
commitea4a987fd424de77465f1a2cd95a655ccf42fd31 (patch)
treefe49fdb0e18ce012a3a366db7bed703635e0568c /source/blender/blenkernel/intern/anim_sys.c
parent604a2b1a1879c1e0ad1f637f5edc1ab12f61c31d (diff)
== Massive Keying Sets Recode ==
After a few days of wrong turns and learning the finer points of RNA-type-subclassing the hard way, this commit finally presents a refactored version of the Keying Sets system (now version 2) based on some requirements from Cessen. For a more thorough discussion of this commit, see http://sites.google.com/site/aligorith/keyingsets_2.pdf?attredirects=0&d=1 ------ The main highlight of this refactor is that relative Keying Sets have now been recoded so that Python callbacks are run to generate the Keying Set's list of paths everytime the Keying Set is used (to insert or delete keyframes), allowing complex heuristics to be used to determine whether a property gets keyframed based on the current context. These checks may include checking on selection status of related entities, or transform locks. Built-In KeyingSets have also been recoded, and moved from C and out into Python. These are now coded as Relative Keying Sets, and can to some extent serve as basis for adding new relative Keying Sets. However, these have mostly been coded in a slightly 'modular' way which may be confusing for those not so familiar with Python in general. A usable template will be added soon for more general usage. Keyframing settings (i.e. 'visual', 'needed') can now be specified on a per-path basis now, which is especially useful for Absolute Keying Sets, where control over this is often beneficial. Most of the places where Auto-Keyframing is performed have been tidied up for consistency. I'm sure quite a few issues still exist there, but these I'll clean up over the next few days.
Diffstat (limited to 'source/blender/blenkernel/intern/anim_sys.c')
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c67
1 files changed, 37 insertions, 30 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index a880417a111..8ec8f24d5fe 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -621,53 +621,48 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho
return ks;
}
-/* Add a destination to a KeyingSet. Nothing is returned for now...
+/* Add a path 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_path (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode)
+KS_Path *BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode)
{
KS_Path *ksp;
/* sanity checks */
if ELEM(NULL, ks, rna_path) {
- printf("ERROR: no Keying Set and/or RNA Path to add destination with \n");
- return;
+ printf("ERROR: no Keying Set and/or RNA Path to add path with \n");
+ return NULL;
}
- /* ID is optional for relative KeyingSets, but is necessary for absolute KeyingSets */
+ /* ID is required for all types of KeyingSets */
if (id == NULL) {
- if (ks->flag & KEYINGSET_ABSOLUTE) {
- printf("ERROR: No ID provided for absolute destination. \n");
- return;
- }
+ printf("ERROR: No ID provided for Keying Set Path. \n");
+ return NULL;
}
/* don't add if there is already a matching KS_Path in the KeyingSet */
if (BKE_keyingset_find_path(ks, id, group_name, rna_path, array_index, groupmode)) {
if (G.f & G_DEBUG)
printf("ERROR: destination already exists in Keying Set \n");
- return;
+ return NULL;
}
/* 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;
- if (group_name)
- BLI_snprintf(ksp->group, 64, group_name);
- else
- strcpy(ksp->group, "");
- }
+ ksp->id= id;
+ if (group_name)
+ BLI_snprintf(ksp->group, 64, group_name);
+ else
+ strcpy(ksp->group, "");
/* store additional info for relative paths (just in case user makes the set relative) */
if (id)
ksp->idtype= GS(id->name);
/* just copy path info */
- // XXX no checks are performed for templates yet
- // should array index be checked too?
+ // TODO: should array index be checked too?
ksp->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
ksp->array_index= array_index;
@@ -677,20 +672,37 @@ void BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[], con
/* add KeyingSet path to KeyingSet */
BLI_addtail(&ks->paths, ksp);
+
+ /* return this path */
+ return ksp;
}
+/* Free the given Keying Set path */
+void BKE_keyingset_free_path (KeyingSet *ks, KS_Path *ksp)
+{
+ /* sanity check */
+ if ELEM(NULL, ks, ksp)
+ return;
+
+ /* free RNA-path info */
+ MEM_freeN(ksp->rna_path);
+
+ /* free path itself */
+ BLI_freelinkN(&ks->paths, ksp);
+}
+
/* Copy all KeyingSets in the given list */
-void BKE_keyingsets_copy(ListBase *newlist, ListBase *list)
+void BKE_keyingsets_copy (ListBase *newlist, ListBase *list)
{
KeyingSet *ksn;
KS_Path *kspn;
-
+
BLI_duplicatelist(newlist, list);
- for(ksn=newlist->first; ksn; ksn=ksn->next) {
+ for (ksn=newlist->first; ksn; ksn=ksn->next) {
BLI_duplicatelist(&ksn->paths, &ksn->paths);
-
- for(kspn=ksn->paths.first; kspn; kspn=kspn->next)
+
+ for (kspn=ksn->paths.first; kspn; kspn=kspn->next)
kspn->rna_path= MEM_dupallocN(kspn->rna_path);
}
}
@@ -709,12 +721,7 @@ void BKE_keyingset_free (KeyingSet *ks)
/* 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, ksp);
+ BKE_keyingset_free_path(ks, ksp);
}
}