Keying Sets: BuiltIn vs Absolute Tweaks

This commit clarifies the somewhat "murky" separation between "builtin" and "absolute" KeyingSets as a result of discussions with Cessen.

* "Builtin" Keying Sets are now just the Keying Sets which in the past have been known as PyKeyingSets or Relative KeyingSets. These are registered from Py Scripts at startup, and will use the context info to determine what data they should be keyframing. These are stored per Blender session, independent of files, since usually these will be coded specific to sets of rigs used at a studio.

* "Absolute" Keying Sets are the ones that you can create from the Scene buttons and/or KKEY or RMB over any property. They specify the exact set of properties which should always get keyframed together. These are stored in the scene. 

In relation to this, I've made it possible to now set one of the builtin Keying Set types as the active Keying Set. 
* For now, this can only be done via the box beside the insert/delete key operator buttons on the TimeLine header (now complete with an recycled icon - HINT TO ICON DESIGNERS, to make this a bit more obvious). Later on I'll commit an operator to set this via a hotkey.
* The "IKEY" menu will only show up when there is no active Keying Set. When there is one, keying will happen silently (with info notice at the top of the screen). Later on, I'll hook this menu up to a hotkey, so that that active Keying Set can be changed without inserting keyframes or clearing active Keying Set...
* By default, there isn't any default Keying Set enabled. IMO, this is probably a good default, though some might like to have LocRotScale instead.
* I'm not terribly impressed with the search menu for the items being SORTED (and of all things, alphabetically!) currently, since this does break muscle-memory with the menu (and jumbles up order of closely related vs not closely related).
* The Scene buttons for KeyingSets still need some changes to fully cope with users setting builtin KeyingSets as active sometimes. Controls which are useless or shouldn't be used when a builtin set is shown are being shown.

Builtin set registrations have been tweaked a bit:
* Renamed "bl_idname" to "bl_label" for consistency with rest of API. Note that this is the identifier used by Blender internally when searching for the KeyingSet, and is also what the user sees.
This commit is contained in:
Joshua Leung 2010-03-23 11:59:34 +00:00
parent d2225edfce
commit 4ae515a4e5
8 changed files with 120 additions and 90 deletions

@ -11,8 +11,7 @@ from keyingsets_utils import *
# Location
class BUILTIN_KSI_Location(bpy.types.KeyingSetInfo):
bl_idname = "Location"
bl_builtin = True
bl_label = "Location"
# poll - use predefined callback for selected bones/objects
poll = RKS_POLL_selected_items
@ -25,8 +24,7 @@ class BUILTIN_KSI_Location(bpy.types.KeyingSetInfo):
# Rotation
class BUILTIN_KSI_Rotation(bpy.types.KeyingSetInfo):
bl_idname = "Rotation"
bl_builtin = True
bl_label = "Rotation"
# poll - use predefined callback for selected bones/objects
poll = RKS_POLL_selected_items
@ -39,8 +37,7 @@ class BUILTIN_KSI_Rotation(bpy.types.KeyingSetInfo):
# Scale
class BUILTIN_KSI_Scaling(bpy.types.KeyingSetInfo):
bl_idname = "Scaling"
bl_builtin = True
bl_label = "Scaling"
# poll - use predefined callback for selected bones/objects
poll = RKS_POLL_selected_items
@ -55,8 +52,7 @@ class BUILTIN_KSI_Scaling(bpy.types.KeyingSetInfo):
# LocRot
class BUILTIN_KSI_LocRot(bpy.types.KeyingSetInfo):
bl_idname = "LocRot"
bl_builtin = True
bl_label = "LocRot"
# poll - use predefined callback for selected bones/objects
poll = RKS_POLL_selected_items
@ -73,8 +69,7 @@ class BUILTIN_KSI_LocRot(bpy.types.KeyingSetInfo):
# LocScale
class BUILTIN_KSI_LocScale(bpy.types.KeyingSetInfo):
bl_idname = "LocScale"
bl_builtin = True
bl_label = "LocScale"
# poll - use predefined callback for selected bones/objects
poll = RKS_POLL_selected_items
@ -91,8 +86,7 @@ class BUILTIN_KSI_LocScale(bpy.types.KeyingSetInfo):
# LocRotScale
class BUILTIN_KSI_LocRotScale(bpy.types.KeyingSetInfo):
bl_idname = "LocRotScale"
bl_builtin = True
bl_label = "LocRotScale"
# poll - use predefined callback for selected bones/objects
poll = RKS_POLL_selected_items
@ -111,8 +105,7 @@ class BUILTIN_KSI_LocRotScale(bpy.types.KeyingSetInfo):
# RotScale
class BUILTIN_KSI_RotScale(bpy.types.KeyingSetInfo):
bl_idname = "RotScale"
bl_builtin = True
bl_label = "RotScale"
# poll - use predefined callback for selected bones/objects
poll = RKS_POLL_selected_items
@ -131,8 +124,7 @@ class BUILTIN_KSI_RotScale(bpy.types.KeyingSetInfo):
# Location
class BUILTIN_KSI_VisualLoc(bpy.types.KeyingSetInfo):
bl_idname = "Visual Location"
bl_builtin = True
bl_label = "Visual Location"
insertkey_visual = True
@ -147,8 +139,7 @@ class BUILTIN_KSI_VisualLoc(bpy.types.KeyingSetInfo):
# Rotation
class BUILTIN_KSI_VisualRot(bpy.types.KeyingSetInfo):
bl_idname = "Visual Rotation"
bl_builtin = True
bl_label = "Visual Rotation"
insertkey_visual = True
@ -163,8 +154,7 @@ class BUILTIN_KSI_VisualRot(bpy.types.KeyingSetInfo):
# VisualLocRot
class BUILTIN_KSI_VisualLocRot(bpy.types.KeyingSetInfo):
bl_idname = "Visual LocRot"
bl_builtin = True
bl_label = "Visual LocRot"
insertkey_visual = True
@ -185,8 +175,7 @@ class BUILTIN_KSI_VisualLocRot(bpy.types.KeyingSetInfo):
# Available
class BUILTIN_KSI_Available(bpy.types.KeyingSetInfo):
bl_idname = "Available"
bl_builtin = True
bl_label = "Available"
# poll - use predefined callback for selected objects
# TODO: this should really check whether the selected object (or datablock)

@ -101,7 +101,6 @@ class SCENE_PT_keying_sets(SceneButtonsPanel):
col = row.column()
col.prop(ks, "name")
col.prop(ks, "absolute")
subcol = col.column()
subcol.operator_context = 'INVOKE_DEFAULT'

@ -77,7 +77,7 @@ class TIME_HT_header(bpy.types.Header):
layout.separator()
row = layout.row(align=True)
row.prop_object(scene, "active_keying_set", scene, "keying_sets", text="")
row.prop_object(scene, "active_keying_set", scene, "all_keying_sets", text="")
row.operator("anim.keyframe_insert", text="", icon='KEY_HLT')
row.operator("anim.keyframe_delete", text="", icon='KEY_DEHLT')

@ -769,11 +769,11 @@ static short animsys_remap_path (AnimMapper *remap, char *path, char **dst)
/* Write the given value to a setting using RNA, and return success */
static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value)
{
// printf("%p %s %i %f\n", ptr, path, array_index, value);
PropertyRNA *prop;
PointerRNA new_ptr;
//printf("%p %s %i %f\n", ptr, path, array_index, value);
/* get property to write to */
if (RNA_path_resolve(ptr, path, &new_ptr, &prop))
{
@ -781,7 +781,7 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
if (RNA_property_animateable(&new_ptr, prop))
{
int array_len= RNA_property_array_length(&new_ptr, prop);
if(array_len && array_index >= array_len)
{
if (G.f & G_DEBUG) {
@ -789,10 +789,10 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
(ptr && ptr->id.data) ? (((ID *)ptr->id.data)->name+2) : "<No ID>",
path, array_index, array_len-1);
}
return 0;
}
switch (RNA_property_type(prop))
{
case PROP_BOOLEAN:
@ -1003,7 +1003,12 @@ static void nlastrip_evaluate_controls (NlaStrip *strip, float ctime)
animsys_evaluate_fcurves(&strip_ptr, &strip->fcurves, NULL, ctime);
}
if (strip->flag & NLASTRIP_FLAG_USR_TIME && strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC)
/* if user can control the evaluation time (using F-Curves), consider the option which allows this time to be clamped
* to lie within extents of the action-clip, so that a steady changing rate of progress through several cycles of the clip
* can be achieved easily
*/
// NOTE: if we add any more of these special cases, we better group them up nicely...
if ((strip->flag & NLASTRIP_FLAG_USR_TIME) && (strip->flag & NLASTRIP_FLAG_USR_TIME_CYCLIC))
strip->strip_time= fmod(strip->strip_time - strip->actstart, strip->actend - strip->actstart);
}
@ -1740,7 +1745,7 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re
*/
// TODO: need to double check that this all works correctly
if ((recalc & ADT_RECALC_ANIM) || (adt->recalc & ADT_RECALC_ANIM))
{
{
/* evaluate NLA data */
if ((adt->nla_tracks.first) && !(adt->flag & ADT_NLA_EVAL_OFF))
{

@ -521,20 +521,12 @@ KeyingSet *ANIM_builtin_keyingset_get_named (KeyingSet *prevKS, const char name[
/* Add the given KeyingSetInfo to the list of type infos, and create an appropriate builtin set too */
void ANIM_keyingset_info_register (const bContext *C, KeyingSetInfo *ksi)
{
Scene *scene = CTX_data_scene(C);
ListBase *list = NULL;
KeyingSet *ks;
/* determine the KeyingSet list to include the new KeyingSet in */
if (ksi->builtin==0 && scene)
list = &scene->keyingsets;
else
list = &builtin_keyingsets;
/* create a new KeyingSet
* - inherit name and keyframing settings from the typeinfo
*/
ks = BKE_keyingset_add(list, ksi->name, ksi->builtin, ksi->keyingflag);
ks = BKE_keyingset_add(&builtin_keyingsets, ksi->name, 1, ksi->keyingflag);
/* link this KeyingSet with its typeinfo */
memcpy(&ks->typeinfo, ksi->name, sizeof(ks->typeinfo));
@ -549,8 +541,10 @@ void ANIM_keyingset_info_unregister (const bContext *C, KeyingSetInfo *ksi)
Scene *scene = CTX_data_scene(C);
KeyingSet *ks, *ksn;
/* find relevant scene KeyingSets which use this, and remove them */
for (ks= scene->keyingsets.first; ks; ks= ksn) {
/* find relevant builtin KeyingSets which use this, and remove them */
// TODO: this isn't done now, since unregister is really only used atm when we
// reload the scripts, which kindof defeats the purpose of "builtin"?
for (ks= builtin_keyingsets.first; ks; ks= ksn) {
ksn = ks->next;
/* remove if matching typeinfo name */
@ -560,11 +554,6 @@ void ANIM_keyingset_info_unregister (const bContext *C, KeyingSetInfo *ksi)
}
}
/* do the same with builtin sets? */
// TODO: this isn't done now, since unregister is really only used atm when we
// reload the scripts, which kindof defeats the purpose of "builtin"?
/* free the type info */
BLI_freelinkN(&keyingset_type_infos, ksi);
}
@ -595,18 +584,49 @@ void ANIM_keyingset_infos_exit ()
/* Get the active Keying Set for the Scene provided */
KeyingSet *ANIM_scene_get_active_keyingset (Scene *scene)
{
if (ELEM(NULL, scene, scene->keyingsets.first))
/* if no scene, we've got no hope of finding the Keying Set */
if (scene == NULL)
return NULL;
/* currently, there are several possibilities here:
* - 0: no active keying set
* - > 0: one of the user-defined Keying Sets, but indices start from 0 (hence the -1)
* - < 0: a builtin keying set (XXX this isn't enabled yet so that we don't get errors on reading back files)
* - < 0: a builtin keying set
*/
if (scene->active_keyingset > 0)
return BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
else // for now...
return NULL;
else
return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset)-1);
}
/* Get the index of the Keying Set provided, for the given Scene */
int ANIM_scene_get_keyingset_index (Scene *scene, KeyingSet *ks)
{
int index;
/* if no KeyingSet provided, have none */
if (ks == NULL)
return 0;
/* check if the KeyingSet exists in scene list */
if (scene) {
/* get index and if valid, return
* - (absolute) Scene KeyingSets are from (>= 1)
*/
index = BLI_findindex(&scene->keyingsets, ks);
if (index != -1)
return (index + 1);
}
/* still here, so try builtins list too
* - builtins are from (<= -1)
* - none/invalid is (= 0)
*/
index = BLI_findindex(&builtin_keyingsets, ks);
if (index != -1)
return -(index + 1);
else
return 0;
}
/* Check if KeyingSet can be used in the current context */

@ -127,8 +127,6 @@ typedef struct KeyingSetInfo {
char name[64];
/* keying settings */
short keyingflag;
/* builtin? */
short builtin;
/* polling callbacks */
/* callback for polling the context for whether the right data is available */
@ -190,6 +188,9 @@ void ANIM_keyingset_infos_exit(void);
/* Get the active KeyingSet for the given scene */
struct KeyingSet *ANIM_scene_get_active_keyingset(struct Scene *scene);
/* Get the index of the Keying Set provided, for the given Scene */
int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks);
/* Check if KeyingSet can be used in the current context */
short ANIM_keyingset_context_ok_poll(struct bContext *C, struct KeyingSet *ks);

@ -362,18 +362,13 @@ static void rna_def_keyingset_info(BlenderRNA *brna)
RNA_define_verify_sdna(0); // not in sdna
/* Name */
prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
/* Name */
prop= RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_name_property(srna, prop);
RNA_def_property_flag(prop, PROP_REGISTER);
prop= RNA_def_property(srna, "bl_builtin", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "builtin", 1);
RNA_def_property_ui_text(prop, "BuiltIn", "Keying Set type is required internally.");
RNA_def_property_flag(prop, PROP_REGISTER);
rna_def_common_keying_flags(srna, 1); /* '1' arg here is to indicate that we need these to be set on registering */
RNA_define_verify_sdna(1);
@ -471,6 +466,7 @@ static void rna_def_keyingset(BlenderRNA *brna)
/* Name */
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_struct_ui_icon(srna, ICON_KEY_HLT); // TODO: we need a dedicated icon
RNA_def_struct_name_property(srna, prop);
/* TypeInfo associated with Relative KeyingSet (only) */
@ -501,7 +497,7 @@ static void rna_def_keyingset(BlenderRNA *brna)
/* Flags */
prop= RNA_def_property(srna, "absolute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYINGSET_ABSOLUTE);
RNA_def_property_ui_text(prop, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)");
RNA_def_property_ui_text(prop, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)");
/* Keyframing Flags */
rna_def_common_keying_flags(srna, 0);

@ -167,6 +167,7 @@ EnumPropertyItem image_type_items[] = {
#include "ED_view3d.h"
#include "ED_object.h"
#include "ED_mesh.h"
#include "ED_keyframing.h"
#include "RE_pipeline.h"
@ -359,46 +360,60 @@ static void rna_Scene_frame_update(bContext *C, PointerRNA *ptr)
sound_seek_scene(C);
}
static int rna_Scene_active_keying_set_editable(PointerRNA *ptr)
{
Scene *scene= (Scene *)ptr->data;
/* only editable if there are some Keying Sets to change to */
return (scene->keyingsets.first != NULL);
}
static PointerRNA rna_Scene_active_keying_set_get(PointerRNA *ptr)
{
Scene *scene= (Scene *)ptr->data;
return rna_pointer_inherit_refine(ptr, &RNA_KeyingSet, BLI_findlink(&scene->keyingsets, scene->active_keyingset-1));
return rna_pointer_inherit_refine(ptr, &RNA_KeyingSet, ANIM_scene_get_active_keyingset(scene));
}
static void rna_Scene_active_keying_set_set(PointerRNA *ptr, PointerRNA value)
{
Scene *scene= (Scene *)ptr->data;
KeyingSet *ks= (KeyingSet*)value.data;
scene->active_keyingset= BLI_findindex(&scene->keyingsets, ks) + 1;
}
static int rna_Scene_active_keying_set_index_get(PointerRNA *ptr)
{
Scene *scene= (Scene *)ptr->data;
return MAX2(scene->active_keyingset-1, 0);
}
static void rna_Scene_active_keying_set_index_set(PointerRNA *ptr, int value)
{
Scene *scene= (Scene *)ptr->data;
scene->active_keyingset= value+1;
scene->active_keyingset= ANIM_scene_get_keyingset_index(scene, ks);
}
#if 0 // XXX: these need to be fixed up first...
static void rna_Scene_active_keying_set_index_range(PointerRNA *ptr, int *min, int *max)
{
Scene *scene= (Scene *)ptr->data;
// FIXME: would need access to builtin keyingsets list to count min...
*min= 0;
*max= BLI_countlist(&scene->keyingsets)-1;
*max= MAX2(0, *max);
*max= 0;
}
#endif
// XXX: evil... builtin_keyingsets is defined in keyingsets.c!
// TODO: make API function to retrieve this...
extern ListBase builtin_keyingsets;
static void rna_Scene_all_keyingsets_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Scene *scene= (Scene*)ptr->data;
/* start going over the scene KeyingSets first, while we still have pointer to it
* but only if we have any Keying Sets to use...
*/
if (scene->keyingsets.first)
rna_iterator_listbase_begin(iter, &scene->keyingsets, NULL);
else
rna_iterator_listbase_begin(iter, &builtin_keyingsets, NULL);
}
static void rna_Scene_all_keyingsets_next(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
KeyingSet *ks= (KeyingSet*)internal->link;
/* if we've run out of links in Scene list, jump over to the builtins list unless we're there already */
if ((ks->next == NULL) && (ks != builtin_keyingsets.last))
internal->link= (Link*)builtin_keyingsets.first;
else
internal->link= (Link*)ks->next;
iter->valid= (internal->link != NULL);
}
@ -2831,21 +2846,26 @@ void RNA_def_scene(BlenderRNA *brna)
prop= RNA_def_property(srna, "keying_sets", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "keyingsets", NULL);
RNA_def_property_struct_type(prop, "KeyingSet");
RNA_def_property_ui_text(prop, "Keying Sets", "Keying Sets for this Scene");
RNA_def_property_ui_text(prop, "Absolute Keying Sets", "Absolute Keying Sets for this Scene");
RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL);
prop= RNA_def_property(srna, "all_keying_sets", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop, "rna_Scene_all_keyingsets_begin", "rna_Scene_all_keyingsets_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0);
RNA_def_property_struct_type(prop, "KeyingSet");
RNA_def_property_ui_text(prop, "All Keying Sets", "All Keying Sets available for use (builtins and Absolute Keying Sets for this Scene)");
RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL);
prop= RNA_def_property(srna, "active_keying_set", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "KeyingSet");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_editable_func(prop, "rna_Scene_active_keying_set_editable");
RNA_def_property_pointer_funcs(prop, "rna_Scene_active_keying_set_get", "rna_Scene_active_keying_set_set", NULL);
RNA_def_property_ui_text(prop, "Active Keying Set", "Active Keying Set used to insert/delete keyframes");
RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL);
prop= RNA_def_property(srna, "active_keying_set_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "active_keyingset");
RNA_def_property_int_funcs(prop, "rna_Scene_active_keying_set_index_get", "rna_Scene_active_keying_set_index_set", "rna_Scene_active_keying_set_index_range");
RNA_def_property_ui_text(prop, "Active Keying Set Index", "Current Keying Set index");
//RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Scene_active_keying_set_index_range"); // XXX
RNA_def_property_ui_text(prop, "Active Keying Set Index", "Current Keying Set index (negative for 'builtin' and positive for 'absolute')");
RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL);
/* Tool Settings */