NLA: Fix strip Sync Length moving animation data
Change the way Sync Length works so that it keeps keyframes at the same key as before the sync. Now when the user exits tweak mode, the overall NLA result is unchanged. Reviewed By: sybren Differential Revision: https://developer.blender.org/D7602
This commit is contained in:
parent
12dd08ef52
commit
50919413fe
|
@ -102,6 +102,7 @@ void BKE_nlastrip_set_active(struct AnimData *adt, struct NlaStrip *strip);
|
|||
|
||||
bool BKE_nlastrip_within_bounds(struct NlaStrip *strip, float min, float max);
|
||||
void BKE_nlastrip_recalculate_bounds(struct NlaStrip *strip);
|
||||
void BKE_nlastrip_recalculate_bounds_sync_action(struct NlaStrip *strip);
|
||||
|
||||
void BKE_nlastrip_validate_name(struct AnimData *adt, struct NlaStrip *strip);
|
||||
|
||||
|
|
|
@ -1361,6 +1361,25 @@ static void nlastrip_fix_resize_overlaps(NlaStrip *strip)
|
|||
}
|
||||
}
|
||||
|
||||
/** Recalculate the start and end frames for the strip to match the bounds of its action such that
|
||||
* the overall NLA animation result is unchanged. */
|
||||
void BKE_nlastrip_recalculate_bounds_sync_action(NlaStrip *strip)
|
||||
{
|
||||
float prev_actstart;
|
||||
|
||||
if (strip == NULL || strip->type != NLASTRIP_TYPE_CLIP) {
|
||||
return;
|
||||
}
|
||||
|
||||
prev_actstart = strip->actstart;
|
||||
|
||||
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
|
||||
|
||||
/* Set start such that key's do not visually move, to preserve the overall animation result. */
|
||||
strip->start += (strip->actstart - prev_actstart) * strip->scale;
|
||||
|
||||
BKE_nlastrip_recalculate_bounds(strip);
|
||||
}
|
||||
/* Recalculate the start and end frames for the current strip, after changing
|
||||
* the extents of the action or the mapping (repeats or scale factor) info
|
||||
*/
|
||||
|
@ -2133,11 +2152,7 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
|
|||
|
||||
/* must be action-clip only (transitions don't have scale) */
|
||||
if ((strip->type == NLASTRIP_TYPE_CLIP) && (strip->act)) {
|
||||
/* recalculate the length of the action */
|
||||
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
|
||||
|
||||
/* adjust the strip extents in response to this */
|
||||
BKE_nlastrip_recalculate_bounds(strip);
|
||||
BKE_nlastrip_recalculate_bounds_sync_action(strip);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2151,11 +2166,7 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
|
|||
/* sync strip extents if this strip uses the same action */
|
||||
if ((adt->actstrip) && (adt->actstrip->act == strip->act) &&
|
||||
(strip->flag & NLASTRIP_FLAG_SYNC_LENGTH)) {
|
||||
/* recalculate the length of the action */
|
||||
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
|
||||
|
||||
/* adjust the strip extents in response to this */
|
||||
BKE_nlastrip_recalculate_bounds(strip);
|
||||
BKE_nlastrip_recalculate_bounds_sync_action(strip);
|
||||
}
|
||||
|
||||
/* clear tweakuser flag */
|
||||
|
|
|
@ -1847,11 +1847,7 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
|
|||
continue;
|
||||
}
|
||||
|
||||
/* recalculate the length of the action */
|
||||
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
|
||||
|
||||
/* adjust the strip extents in response to this */
|
||||
BKE_nlastrip_recalculate_bounds(strip);
|
||||
BKE_nlastrip_recalculate_bounds_sync_action(strip);
|
||||
|
||||
ale->update |= ANIM_UPDATE_DEPS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue