Cleanup of Auto-Keyframing code:
Moved duplicated code out to a special new function so that this doesn't need to be copied all over for each transform op that needs this.
This commit is contained in:
parent
e8465555cb
commit
d6ee8a0e4d
@ -155,6 +155,7 @@ void ANIM_set_active_channel (bAnimContext *ac, void *data, short datatype, int
|
||||
case ANIMTYPE_DSMESH:
|
||||
{
|
||||
/* need to verify that this data is valid for now */
|
||||
// XXX: ale may be null!
|
||||
if (ale->adt)
|
||||
ale->adt->flag |= ADT_UI_ACTIVE;
|
||||
}
|
||||
@ -462,7 +463,7 @@ void ANIM_flush_setting_anim_channels (bAnimContext *ac, ListBase *anim_data, bA
|
||||
break;
|
||||
|
||||
/* store this level as the 'old' level now */
|
||||
prevLevel= level;
|
||||
prevLevel= level; // XXX: prevLevel is unused
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1899,7 +1900,6 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* get useful pointers from animation context data */
|
||||
scene= ac.scene;
|
||||
ar= ac.ar;
|
||||
v2d= &ar->v2d;
|
||||
|
||||
|
@ -676,6 +676,21 @@ int ANIM_scene_get_keyingset_index (Scene *scene, KeyingSet *ks)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get Keying Set to use for Auto-Keyframing some transforms */
|
||||
KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformKSName)
|
||||
{
|
||||
/* get KeyingSet to use
|
||||
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
|
||||
* or otherwise key transforms only
|
||||
*/
|
||||
if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
|
||||
return ANIM_scene_get_active_keyingset(scene);
|
||||
else if (IS_AUTOKEY_FLAG(INSERTAVAIL))
|
||||
return ANIM_builtin_keyingset_get_named(NULL, "Available");
|
||||
else
|
||||
return ANIM_builtin_keyingset_get_named(NULL, tranformKSName);
|
||||
}
|
||||
|
||||
/* Menu of All Keying Sets ----------------------------- */
|
||||
|
||||
/* Create (and show) a menu containing all the Keying Sets which can be used in the current context */
|
||||
|
@ -4948,18 +4948,8 @@ static int pose_clear_scale_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* perform autokeying on the bones if needed */
|
||||
if (autokey) {
|
||||
KeyingSet *ks;
|
||||
|
||||
/* get KeyingSet to use
|
||||
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
|
||||
* or otherwise key transforms only
|
||||
*/
|
||||
if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
|
||||
ks = ANIM_scene_get_active_keyingset(scene);
|
||||
else if (IS_AUTOKEY_FLAG(INSERTAVAIL))
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Available");
|
||||
else
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Scaling");
|
||||
/* get KeyingSet to use */
|
||||
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "Scaling");
|
||||
|
||||
/* insert keyframes */
|
||||
ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
|
||||
@ -5027,18 +5017,8 @@ static int pose_clear_loc_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* perform autokeying on the bones if needed */
|
||||
if (autokey) {
|
||||
KeyingSet *ks;
|
||||
|
||||
/* get KeyingSet to use
|
||||
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
|
||||
* or otherwise key transforms only
|
||||
*/
|
||||
if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
|
||||
ks = ANIM_scene_get_active_keyingset(scene);
|
||||
else if (IS_AUTOKEY_FLAG(INSERTAVAIL))
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Available");
|
||||
else
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Location");
|
||||
/* get KeyingSet to use */
|
||||
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "Location");
|
||||
|
||||
/* insert keyframes */
|
||||
ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
|
||||
@ -5190,18 +5170,8 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* perform autokeying on the bones if needed */
|
||||
if (autokey) {
|
||||
KeyingSet *ks;
|
||||
|
||||
/* get KeyingSet to use
|
||||
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
|
||||
* or otherwise key transforms only
|
||||
*/
|
||||
if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
|
||||
ks = ANIM_scene_get_active_keyingset(scene);
|
||||
else if (IS_AUTOKEY_FLAG(INSERTAVAIL))
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Available");
|
||||
else
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Rotation");
|
||||
/* get KeyingSet to use */
|
||||
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "Rotation");
|
||||
|
||||
/* insert keyframes */
|
||||
ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
|
||||
|
@ -773,21 +773,9 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData
|
||||
if (pchan) {
|
||||
if (autokeyframe_cfra_can_key(scene, &pld->ob->id)) {
|
||||
ListBase dsources = {NULL, NULL};
|
||||
KeyingSet *ks = NULL;
|
||||
|
||||
/* get KeyingSet to use
|
||||
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
|
||||
* or otherwise key transforms only
|
||||
*/
|
||||
if (poselib_ks_locrotscale == NULL)
|
||||
poselib_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
|
||||
|
||||
if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
|
||||
ks = ANIM_scene_get_active_keyingset(scene);
|
||||
else if (IS_AUTOKEY_FLAG(INSERTAVAIL))
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Available");
|
||||
else
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
|
||||
/* get KeyingSet to use */
|
||||
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "LocRotScale");
|
||||
|
||||
/* now insert the keyframe(s) using the Keying Set
|
||||
* 1) add datasource override for the PoseChannel
|
||||
|
@ -1012,18 +1012,9 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
|
||||
/* keyframing tagging */
|
||||
if (autokeyframe_cfra_can_key(scene, &ob->id)) {
|
||||
ListBase dsources = {NULL, NULL};
|
||||
KeyingSet *ks = NULL;
|
||||
|
||||
/* get KeyingSet to use
|
||||
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
|
||||
* or otherwise key transforms only
|
||||
*/
|
||||
if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
|
||||
ks = ANIM_scene_get_active_keyingset(scene);
|
||||
else if (IS_AUTOKEY_FLAG(INSERTAVAIL))
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Available");
|
||||
else
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
|
||||
/* get KeyingSet to use */
|
||||
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "LocRotScale");
|
||||
|
||||
/* now insert the keyframe(s) using the Keying Set
|
||||
* 1) add datasource override for the PoseChannel
|
||||
|
@ -193,6 +193,9 @@ 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);
|
||||
|
||||
/* Get Keying Set to use for Auto-Keyframing some transforms */
|
||||
struct KeyingSet *ANIM_get_keyingset_for_autokeying(struct Scene *scene, const char *tranformKSName);
|
||||
|
||||
/* Create (and show) a menu containing all the Keying Sets which can be used in the current context */
|
||||
void ANIM_keying_sets_menu_setup(struct bContext *C, char title[], char op_name[]);
|
||||
|
||||
|
@ -68,18 +68,9 @@ static int object_location_clear_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
KeyingSet *ks;
|
||||
|
||||
/* get KeyingSet to use
|
||||
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
|
||||
* or otherwise key transforms only
|
||||
*/
|
||||
if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
|
||||
ks = ANIM_scene_get_active_keyingset(scene);
|
||||
else if (IS_AUTOKEY_FLAG(INSERTAVAIL))
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Available");
|
||||
else
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Location");
|
||||
/* get KeyingSet to use */
|
||||
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "Location");
|
||||
|
||||
/* clear location of selected objects if not in weight-paint mode */
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
@ -138,18 +129,9 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
KeyingSet *ks;
|
||||
|
||||
/* get KeyingSet to use
|
||||
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
|
||||
* or otherwise key transforms only
|
||||
*/
|
||||
if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
|
||||
ks = ANIM_scene_get_active_keyingset(scene);
|
||||
else if (IS_AUTOKEY_FLAG(INSERTAVAIL))
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Available");
|
||||
else
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Rotation");
|
||||
/* get KeyingSet to use */
|
||||
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "Rotation");
|
||||
|
||||
/* clear rotation of selected objects if not in weight-paint mode */
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
@ -292,18 +274,9 @@ static int object_scale_clear_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
KeyingSet *ks;
|
||||
|
||||
/* get KeyingSet to use
|
||||
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
|
||||
* or otherwise key transforms only
|
||||
*/
|
||||
if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
|
||||
ks = ANIM_scene_get_active_keyingset(scene);
|
||||
else if (IS_AUTOKEY_FLAG(INSERTAVAIL))
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Available");
|
||||
else
|
||||
ks = ANIM_builtin_keyingset_get_named(NULL, "Scaling");
|
||||
/* get KeyingSet to use */
|
||||
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, "Scaling");
|
||||
|
||||
/* clear scales of selected objects if not in weight-paint mode */
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
|
Loading…
Reference in New Issue
Block a user