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 | |
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.
-rw-r--r-- | source/blender/editors/include/ED_transform.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 10 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 26 |
5 files changed, 36 insertions, 5 deletions
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 3ab634afeff..d4d7f971b74 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -77,6 +77,7 @@ enum { TFM_TIME_SLIDE, TFM_TIME_SCALE, TFM_TIME_EXTEND, + TFM_TIME_DUPLICATE, TFM_BAKE_TIME, TFM_BEVEL, TFM_BWEIGHT, diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 10c4ebcd9ca..473e2ac3b96 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -663,7 +663,7 @@ static int actkeys_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED { actkeys_duplicate_exec(C, op); - RNA_int_set(op->ptr, "mode", TFM_TIME_TRANSLATE); + RNA_int_set(op->ptr, "mode", TFM_TIME_DUPLICATE); WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 62ce9b28484..c3a6ac7ce12 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -782,7 +782,7 @@ static int graphkeys_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUS { graphkeys_duplicate_exec(C, op); - RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); + RNA_int_set(op->ptr, "mode", TFM_TIME_DUPLICATE); WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); return OPERATOR_FINISHED; 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)) ) { |