[Bf-blender-cvs] [e4e6288] temp_motionpaths: Remove inserted keyframes if transform was cancelled
Antony Riakiotakis
noreply at git.blender.org
Mon Mar 9 15:43:39 CET 2015
Commit: e4e62880d7c24b26b960e0dec9bea0dd74fe7752
Author: Antony Riakiotakis
Date: Mon Mar 9 15:43:27 2015 +0100
Branches: temp_motionpaths
https://developer.blender.org/rBe4e62880d7c24b26b960e0dec9bea0dd74fe7752
Remove inserted keyframes if transform was cancelled
===================================================================
M source/blender/editors/transform/transform.c
M source/blender/editors/transform/transform.h
M source/blender/editors/transform/transform_conversions.c
M source/blender/editors/transform/transform_generics.c
===================================================================
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index eeeb0d6..0beb39e 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2360,16 +2360,16 @@ void transformApply(bContext *C, TransInfo *t)
if ((t->flag & T_POSE) && (t->poseobj) && (t->mode != TFM_DUMMY) && t->scene->toolsettings->realtime_motion_path) {
if ((t->poseobj->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
//ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear
- int targetless_ik = (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
+ bool targetless_ik = (t->flag & T_AUTOIK) != 0; // XXX this currently doesn't work, since flags aren't set yet!
- autokeyframe_pose_cb_func(C, t->scene, (View3D *)t->view, t->poseobj, t->mode, targetless_ik);
+ autokeyframe_pose_cb_func(C, t->scene, (View3D *)t->view, t->poseobj, t->mode, targetless_ik, true);
}
}
else {
int i;
for (i = 0; i < t->total; i++) {
TransData *td = t->data + i;
- autokeyframe_ob_cb_func(C, t->scene, (View3D *)t->view, td->ob, t->mode);
+ autokeyframe_ob_cb_func(C, t->scene, (View3D *)t->view, td->ob, t->mode, true);
}
}
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index d65d1de..14c0947 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -590,8 +590,8 @@ bool transdata_check_local_islands(TransInfo *t, short around);
int count_set_pose_transflags(int *out_mode, short around, struct Object *ob);
/* auto-keying stuff used by special_aftertrans_update */
-void autokeyframe_ob_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode);
-void autokeyframe_pose_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, short targetless_ik);
+void autokeyframe_ob_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, bool insert);
+void autokeyframe_pose_cb_func(struct bContext *C, struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, bool targetless_ik, bool insert);
/*********************** Constraints *****************************/
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 535d367..c2395c9 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -5195,7 +5195,7 @@ static void clear_trans_object_base_flags(TransInfo *t)
* tmode: should be a transform mode
*/
// NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
-void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode)
+void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode, bool insert)
{
ID *id = &ob->id;
FCurve *fcu;
@@ -5218,7 +5218,10 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
/* only insert into active keyingset
* NOTE: we assume here that the active Keying Set does not need to have its iterator overridden spe
*/
- ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
+ if (insert)
+ ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
+ else
+ ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_DELETE, cfra);
}
else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) {
AnimData *adt = ob->adt;
@@ -5227,9 +5230,16 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
if (adt && adt->action) {
for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) {
fcu->flag &= ~FCURVE_SELECTED;
- insert_keyframe(reports, id, adt->action,
- (fcu->grp ? fcu->grp->name : NULL),
- fcu->rna_path, fcu->array_index, cfra, flag);
+ if (insert) {
+ insert_keyframe(reports, id, adt->action,
+ (fcu->grp ? fcu->grp->name : NULL),
+ fcu->rna_path, fcu->array_index, cfra, flag);
+ }
+ else {
+ delete_keyframe(reports, id, adt->action,
+ (fcu->grp ? fcu->grp->name : NULL),
+ fcu->rna_path, fcu->array_index, cfra, flag);
+ }
}
}
}
@@ -5266,21 +5276,33 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
/* insert keyframes for the affected sets of channels using the builtin KeyingSets found */
if (do_loc) {
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID);
- ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ if (insert)
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ else
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
}
if (do_rot) {
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_ROTATION_ID);
- ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ if (insert)
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ else
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
}
if (do_scale) {
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_SCALING_ID);
- ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ if (insert)
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ else
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
}
}
/* insert keyframe in all (transform) channels */
else {
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID);
- ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ if (insert)
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ else
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
}
/* only calculate paths if there are paths to be recalculated,
@@ -5309,7 +5331,7 @@ void autokeyframe_ob_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob,
* targetless_ik: has targetless ik been done on any channels?
*/
// NOTE: context may not always be available, so must check before using it as it's a luxury for a few cases
-void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode, short targetless_ik)
+void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *ob, int tmode, bool targetless_ik, bool insert)
{
ID *id = &ob->id;
AnimData *adt = ob->adt;
@@ -5348,7 +5370,10 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
/* only insert into active keyingset? */
if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (active_ks)) {
/* run the active Keying Set on the current datasource */
- ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
+ if (insert)
+ ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_INSERT, cfra);
+ else
+ ANIM_apply_keyingset(C, &dsources, NULL, active_ks, MODIFYKEY_MODE_DELETE, cfra);
}
/* only insert into available channels? */
else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) {
@@ -5361,9 +5386,12 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
/* only if bone name matches too...
* NOTE: this will do constraints too, but those are ok to do here too?
*/
- if (pchanName && STREQ(pchanName, pchan->name))
- insert_keyframe(reports, id, act, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
-
+ if (pchanName && STREQ(pchanName, pchan->name)) {
+ if (insert)
+ insert_keyframe(reports, id, act, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
+ else
+ delete_keyframe(reports, id, act, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
+ }
if (pchanName) MEM_freeN(pchanName);
}
}
@@ -5397,21 +5425,33 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o
if (do_loc) {
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID);
- ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ if (insert)
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ else
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
}
if (do_rot) {
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_ROTATION_ID);
- ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ if (insert)
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ else
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
}
if (do_scale) {
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_SCALING_ID);
- ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ if (insert)
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ else
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
}
}
/* insert keyframe in all (transform) channels */
else {
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID);
- ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ if (insert)
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
+ else
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MOD
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list