diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-03-03 02:39:08 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-03-03 02:39:08 +0300 |
commit | a19e9177826312d8ab60d73dd61347042cb68a41 (patch) | |
tree | 1c05df5760374c749cf47025e7bff4967ac1465f /source/blender/editors/transform | |
parent | 9f397b3a3d4bda2e28feb99f4a10c775e8fbbff7 (diff) |
Bugfix [#26269] Initiating a duplication with shift D and cancelling
in dope sheet/ graph editor leads to duplicated keys
The old hack using the transform "undostring" didn't work anymore, as
this wasn't set. Instead, I've added a special mode transform mode for
this that the duplicate operators can set to get this functionality.
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform.c | 10 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 26 |
2 files changed, 33 insertions, 3 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index b713171a309..ede8af2afe8 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1677,6 +1677,16 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int case TFM_TIME_SCALE: initTimeScale(t); break; + case TFM_TIME_DUPLICATE: + /* same as TFM_TIME_EXTEND, but we need the mode info for later + * so that duplicate-culling will work properly + */ + if ELEM(t->spacetype, SPACE_IPO, SPACE_NLA) + initTranslation(t); + else + initTimeTranslate(t); + t->mode = mode; + break; case TFM_TIME_EXTEND: /* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation * Editors because they have only 1D transforms for time values) or TFM_TRANSLATION diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index d0ff7767178..11f82f4160d 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4681,7 +4681,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) Object *ob; // short redrawipo=0, resetslowpar=1; int cancelled= (t->state == TRANS_CANCEL); - short duplicate= (t->undostr && strstr(t->undostr, "Duplicate")) ? 1 : 0; /* see bugreport #21229 for reasons for this data */ + short duplicate= (t->mode == TFM_TIME_DUPLICATE); /* early out when nothing happened */ if (t->total == 0 || t->mode == TFM_DUMMY) @@ -4743,6 +4743,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) AnimData *adt= ANIM_nla_mapping_get(&ac, ale); FCurve *fcu= (FCurve *)ale->key_data; + /* 3 cases here for curve cleanups: + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed + * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these + */ if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 && ((cancelled == 0) || (duplicate)) ) { @@ -4769,7 +4774,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) DAG_id_tag_update(&ob->id, OB_RECALC_OB); } - /* Do curve cleanups? */ + /* 3 cases here for curve cleanups: + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed + * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these + */ if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 && ((cancelled == 0) || (duplicate)) ) { @@ -4796,7 +4805,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else if (ac.datatype == ANIMCONT_GPENCIL) { /* remove duplicate frames and also make sure points are in order! */ - if ((cancelled == 0) || (duplicate)) + /* 3 cases here for curve cleanups: + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed + * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these + */ + if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 && + ((cancelled == 0) || (duplicate)) ) { bGPdata *gpd; @@ -4836,6 +4851,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) AnimData *adt= ANIM_nla_mapping_get(&ac, ale); FCurve *fcu= (FCurve *)ale->key_data; + /* 3 cases here for curve cleanups: + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed + * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these + */ if ( (sipo->flag & SIPO_NOTRANSKEYCULL)==0 && ((cancelled == 0) || (duplicate)) ) { |