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/makesrna/intern/rna_animation_api.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/makesrna/intern/rna_animation_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_animation_api.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c
index b07f147ac96..46ecc8679e7 100644
--- a/source/blender/makesrna/intern/rna_animation_api.c
+++ b/source/blender/makesrna/intern/rna_animation_api.c
@@ -41,10 +41,11 @@
#include "BKE_animsys.h"
-static void rna_KeyingSet_add_path(KeyingSet *keyingset, ReportList *reports,
+static KS_Path *rna_KeyingSet_add_path(KeyingSet *keyingset, ReportList *reports,
ID *id, char rna_path[], int array_index, int entire_array,
int grouping_method, char group_name[])
{
+ KS_Path *ksp = NULL;
short flag = 0;
/* validate flags */
@@ -53,12 +54,31 @@ static void rna_KeyingSet_add_path(KeyingSet *keyingset, ReportList *reports,
/* if data is valid, call the API function for this */
if (keyingset) {
- BKE_keyingset_add_path(keyingset, id, group_name, rna_path, array_index, flag, grouping_method);
+ ksp= BKE_keyingset_add_path(keyingset, id, group_name, rna_path, array_index, flag, grouping_method);
keyingset->active_path= BLI_countlist(&keyingset->paths);
}
else {
BKE_report(reports, RPT_ERROR, "Keying Set Path could not be added.");
}
+
+ /* return added path */
+ return ksp;
+}
+
+static void rna_KeyingSet_remove_path(KeyingSet *keyingset, ReportList *reports, KS_Path *ksp)
+{
+ /* if data is valid, call the API function for this */
+ if (keyingset && ksp) {
+ /* remove the active path from the KeyingSet */
+ BKE_keyingset_free_path(keyingset, ksp);
+
+ /* the active path number will most likely have changed */
+ // TODO: we should get more fancy and actually check if it was removed, but this will do for now
+ keyingset->active_path = 0;
+ }
+ else {
+ BKE_report(reports, RPT_ERROR, "Keying Set Path could not be removed.");
+ }
}
#else
@@ -68,10 +88,13 @@ void RNA_api_keyingset(StructRNA *srna)
FunctionRNA *func;
PropertyRNA *parm;
- /* Add Destination */
+ /* Add Path */
func= RNA_def_function(srna, "add_path", "rna_KeyingSet_add_path");
- RNA_def_function_ui_description(func, "Add a new destination for the Keying Set.");
+ RNA_def_function_ui_description(func, "Add a new path for the Keying Set.");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ /* return arg */
+ parm= RNA_def_pointer(func, "ksp", "KeyingSetPath", "New Path", "Path created and added to the Keying Set");
+ RNA_def_function_return(func, parm);
/* ID-block for target */
parm= RNA_def_pointer(func, "target_id", "ID", "Target ID", "ID-Datablock for the destination.");
RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -84,6 +107,14 @@ void RNA_api_keyingset(StructRNA *srna)
/* grouping */
parm=RNA_def_enum(func, "grouping_method", keyingset_path_grouping_items, KSP_GROUP_KSNAME, "Grouping Method", "Method used to define which Group-name to use.");
parm=RNA_def_string(func, "group_name", "", 64, "Group Name", "Name of Action Group to assign destination to (only if grouping mode is to use this name).");
+
+ /* Remove Path */
+ func= RNA_def_function(srna, "remove_path", "rna_KeyingSet_remove_path");
+ RNA_def_function_ui_description(func, "Remove the given path from the Keying Set.");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ /* path to remove */
+ parm= RNA_def_pointer(func, "path", "KeyingSetPath", "Path", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED);
}
#endif