diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-10-08 09:53:26 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-10-08 09:53:26 +0400 |
commit | 6e43a69a8d3dc88594df6f0d15686cad8e7e6646 (patch) | |
tree | 5cf4565bb35e7e3165fcfbfddaa798324a3b4435 /source/blender/editors/transform/transform_conversions.c | |
parent | b4b031eae7569d5e08f034368417417d10da3a60 (diff) |
Bugfix #19576: Auto keyframing does not record rotations on object level animation
The hardcoded paths for rotation keyframes on objects got broken by my commits to rename the rotation properties. I've taken this opportunity to recode the auto-keyframing code here to use the builtin keyingsets instead of going through and manually calling insert_keyframe(), thus preventing this problem in future.
Diffstat (limited to 'source/blender/editors/transform/transform_conversions.c')
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 118 |
1 files changed, 44 insertions, 74 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 1b11d43c200..d2c1c9f55f0 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4242,10 +4242,15 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode) // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { - AnimData *adt= ob->adt; + bCommonKeySrc cks; + ListBase dsources = {&cks, &cks}; float cfra= (float)CFRA; // xxx this will do for now short flag = 0; + /* init common-key-source for use by KeyingSets */ + memset(&cks, 0, sizeof(bCommonKeySrc)); + cks.id= &ob->id; + if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED; if (IS_AUTOKEY_FLAG(AUTOMATKEY)) @@ -4254,6 +4259,8 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode) flag |= INSERTKEY_REPLACE; if (IS_AUTOKEY_FLAG(INSERTAVAIL)) { + AnimData *adt= ob->adt; + /* only key on available channels */ if (adt && adt->action) { for (fcu= adt->action->curves.first; fcu; fcu= fcu->next) { @@ -4292,41 +4299,25 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode) doScale = 1; } - // TODO: the group names here are temporary... - // TODO: should this be made to use the builtin KeyingSets instead? + /* insert keyframes for the affected sets of channels using the builtin KeyingSets found */ if (doLoc) { - insert_keyframe(id, NULL, "Object Transform", "location", 0, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "location", 1, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "location", 2, cfra, flag); + KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Location"); + modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } if (doRot) { - insert_keyframe(id, NULL, "Object Transform", "rotation", 0, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "rotation", 1, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "rotation", 2, cfra, flag); + KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Rotation"); + modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } if (doScale) { - insert_keyframe(id, NULL, "Object Transform", "scale", 0, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "scale", 1, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "scale", 2, cfra, flag); + KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Scale"); + modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } } + /* insert keyframe in all (transform) channels */ else { - // TODO: the group names here are temporary... - // TODO: should this be made to use the builtin KeyingSets instead? - insert_keyframe(id, NULL, "Object Transform", "location", 0, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "location", 1, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "location", 2, cfra, flag); - - insert_keyframe(id, NULL, "Object Transform", "rotation", 0, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "rotation", 1, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "rotation", 2, cfra, flag); - - insert_keyframe(id, NULL, "Object Transform", "scale", 0, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "scale", 1, cfra, flag); - insert_keyframe(id, NULL, "Object Transform", "scale", 2, cfra, flag); + KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale"); + modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } - - // XXX todo... find a way to send notifiers from here... } } @@ -4346,9 +4337,14 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode, // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { + bCommonKeySrc cks; + ListBase dsources = {&cks, &cks}; float cfra= (float)CFRA; short flag= 0; - char buf[512]; + + /* init common-key-source for use by KeyingSets */ + memset(&cks, 0, sizeof(bCommonKeySrc)); + cks.id= &ob->id; /* flag is initialised from UserPref keyframing settings * - special exception for targetless IK - INSERTKEY_MATRIX keyframes should get @@ -4401,60 +4397,34 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode, } if (doLoc) { - sprintf(buf, "pose.pose_channels[\"%s\"].location", pchan->name); - insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag); + KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Location"); + + /* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */ + cks.pchan= pchan; + modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } if (doRot) { - // FIXME: better to just use the keyingsets for this instead... - if (pchan->rotmode == ROT_MODE_QUAT) { - sprintf(buf, "pose.pose_channels[\"%s\"].rotation_quaternion", pchan->name); - insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 3, cfra, flag); - } - else { - sprintf(buf, "pose.pose_channels[\"%s\"].rotation_euler", pchan->name); - insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag); - } + KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Rotation"); + + /* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */ + cks.pchan= pchan; + modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } if (doScale) { - sprintf(buf, "pose.pose_channels[\"%s\"].scale", pchan->name); - insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag); + KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Scale"); + + /* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */ + cks.pchan= pchan; + modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } } - /* insert keyframe in any channel that's appropriate */ + /* insert keyframe in all (transform) channels */ else { - sprintf(buf, "pose.pose_channels[\"%s\"].location", pchan->name); - insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag); - - // FIXME: better to just use the keyingsets for this instead... - if (pchan->rotmode == ROT_MODE_QUAT) { - sprintf(buf, "pose.pose_channels[\"%s\"].rotation", pchan->name); - insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 3, cfra, flag); - } - else { - sprintf(buf, "pose.pose_channels[\"%s\"].rotation_euler", pchan->name); - insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag); - } + KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale"); - sprintf(buf, "pose.pose_channels[\"%s\"].scale", pchan->name); - insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag); - insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag); + /* init cks for this PoseChannel, then use the relative KeyingSets to keyframe it */ + cks.pchan= pchan; + modify_keyframes(scene, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); } } } |