Animation: Allow NLA strips to be horizontally shuffled #105532

Merged
Nate Rupsis merged 22 commits from nrupsis/blender:NLA-horizontal-shuffle into main 2023-04-03 17:10:50 +02:00
3 changed files with 34 additions and 6 deletions
Showing only changes of commit bc81f5fe56 - Show all commits

View File

@ -812,7 +812,7 @@ void BKE_nlastrips_sort_strips(ListBase *strips)
for (sstrip = tmp.last; sstrip; sstrip = sstrip->prev) {
/* check if add after */
if (sstrip->end <= strip->start) {
if (sstrip->start <= strip->start) {
BLI_insertlinkafter(&tmp, sstrip, strip);
not_added = 0;
break;
@ -841,7 +841,7 @@ void BKE_nlastrips_add_strip_unsafe(ListBase *strips, NlaStrip *strip)
/* find the right place to add the strip to the nominated track */
for (ns = strips->first; ns; ns = ns->next) {
/* if current strip occurs after the new strip, add it before */
if (ns->start >= strip->end) {
if (ns->start >= strip->start) {
BLI_insertlinkbefore(strips, ns, strip);
not_added = 0;
break;
@ -1962,6 +1962,24 @@ void BKE_nla_validate_state(AnimData *adt)
return;
}
/* Ensure every transition's start/end properly set. */
LISTBASE_FOREACH_MUTABLE (NlaTrack *, track, &adt->nla_tracks) {
LISTBASE_FOREACH_MUTABLE (NlaStrip *, strip, &track->strips) {
if (!(strip->type & NLASTRIP_TYPE_TRANSITION)) {
continue;
}
if (strip->prev) {
strip->start = strip->prev->end;
}
if (strip->next) {
strip->end = strip->next->start;
}
if (strip->start >= strip->end || strip->prev == NULL || strip->next == NULL) {
BKE_nlastrip_free(strip, true);
}
}
}
/* Adjust blending values for auto-blending,
* and also do an initial pass to find the earliest strip. */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {

View File

@ -485,7 +485,8 @@ static void nla_draw_strip(SpaceNla *snla,
}
/* draw 'inside' of strip itself */
if (non_solo == 0 && is_nlastrip_enabled(adt, nlt, strip)) {
if (non_solo == 0 && is_nlastrip_enabled(adt, nlt, strip) &&
nrupsis marked this conversation as resolved Outdated

<rant about existing code>
I really don't like negated booleans. if (non_solo == 0 ...) just makes my head spin. As a followup patch, if you want to change that to if (solo ...), by all means!
</rant>

`<rant about existing code>` I really don't like negated booleans. `if (non_solo == 0 ...)` just makes my head spin. As a followup patch, if you want to change that to `if (solo ...)`, by all means! `</rant>`
!(strip->flag & NLASTRIP_FLAG_INVALID_LOCATION)) {
immUnbindProgram();
/* strip is in normal track */
@ -532,13 +533,17 @@ static void nla_draw_strip(SpaceNla *snla,
/* draw strip outline
* - color used here is to indicate active vs non-active
*/
if (strip->flag & (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT)) {
if (strip->flag & NLASTRIP_FLAG_INVALID_LOCATION) {
color[0] = 1.0f;
color[1] = color[2] = 0.15f;
}
else if (strip->flag & NLASTRIP_FLAG_ACTIVE) {
/* strip should appear 'sunken', so draw a light border around it */
color[0] = color[1] = color[2] = 1.0f; /* FIXME: hardcoded temp-hack colors */
color[0] = color[1] = color[2] = 0.0f; /* FIXME: hardcoded temp-hack colors */
}
else {
/* strip should appear to stand out, so draw a dark border around it */
color[0] = color[1] = color[2] = 0.0f; /* FIXME: or 1.0f ?? */
color[0] = color[1] = color[2] = 1.0f; /* FIXME: or 1.0f ?? */
}
/* draw outline

View File

@ -832,6 +832,11 @@ typedef enum eNlaStrip_Flag {
/* NLASTRIP_FLAG_MIRROR = (1 << 13), */ /* UNUSED */
/* temporary editing flags */
/** When transforming strips, this flag is set when the strip is placed in an invalid location
* such as overlapping another strip or moved to a locked track. In such cases, the strip's
* location must be fixed. */
nrupsis marked this conversation as resolved Outdated

"fixed" can mean 'corrected' as well as 'prevented from moving' (as in 'to fix a shelf to the wall'). Probably better to replace it with "corrected after the transform operator is done" or something along those lines.

"fixed" can mean 'corrected' as well as 'prevented from moving' (as in 'to fix a shelf to the wall'). Probably better to replace it with "corrected after the transform operator is done" or something along those lines.
NLASTRIP_FLAG_INVALID_LOCATION = (1 << 28),
/** NLA strip should ignore frame range and hold settings, and evaluate at global time. */
NLASTRIP_FLAG_NO_TIME_MAP = (1 << 29),
/** NLA-Strip is really just a temporary meta used to facilitate easier transform code */