Fix T39880: Cancelling transforms in Graph Editor does not restore F-Curves to original state

Since autosnap was being applied during the flushing step for various practical reasons,
it wasn't possible to restore keyframes and handles to their original values, as these
would always get overwritten before getting a chance to be written back to the keyframes.
This commit is contained in:
Joshua Leung 2014-04-25 13:32:27 +12:00
parent b1932477a7
commit 3b75d6c4f9
2 changed files with 44 additions and 36 deletions

@ -4107,8 +4107,9 @@ void flushTransGraphData(TransInfo *t)
/* handle snapping for time values
* - we should still be in NLA-mapping timespace
* - only apply to keyframes (but never to handles)
* - don't do this when cancelling, or else these changes won't go away
*/
if ((td->flag & TD_NOTIMESNAP) == 0) {
if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0) {
switch (sipo->autosnap) {
case SACTSNAP_FRAME: /* snap to nearest frame */
td2d->loc[0] = floor((double)td2d->loc[0] + 0.5);
@ -4136,8 +4137,11 @@ void flushTransGraphData(TransInfo *t)
*
* NOTE: We also have to apply to td->loc, as that's what the handle-adjustment step below looks
* to, otherwise we get "swimming handles"
* NOTE: We don't do this when cancelling transforms, or else these changes don't go away
*/
if ((td->flag & TD_NOTIMESNAP) == 0 && ELEM(sipo->autosnap, SACTSNAP_STEP, SACTSNAP_TSTEP)) {
if ((t->state != TRANS_CANCEL) && (td->flag & TD_NOTIMESNAP) == 0 &&
ELEM(sipo->autosnap, SACTSNAP_STEP, SACTSNAP_TSTEP))
{
switch (sipo->autosnap) {
case SACTSNAP_STEP: /* frame step */
td2d->loc2d[0] = floor((double)td2d->loc[0] + 0.5);

@ -529,7 +529,10 @@ static void recalcData_nla(TransInfo *t)
break;
}
/* handle auto-snapping */
/* handle auto-snapping
* NOTE: only do this when transform is still running, or we can't restore
*/
if (t->state != TRANS_CANCEL) {
switch (snla->autosnap) {
case SACTSNAP_FRAME: /* snap to nearest frame */
case SACTSNAP_STEP: /* frame step - this is basically the same, since we don't have any remapping going on */
@ -566,6 +569,7 @@ static void recalcData_nla(TransInfo *t)
break;
}
}
}
/* Use RNA to write the values to ensure that constraints on these are obeyed
* (e.g. for transition strips, the values are taken from the neighbours)