Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/nla.c
| Show First 20 Lines • Show All 1,812 Lines • ▼ Show 20 Lines | bool BKE_nla_action_stash(AnimData *adt, const bool is_liboverride) | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* Core Tools ------------------------------------------- */ | /* Core Tools ------------------------------------------- */ | ||||
| void BKE_nla_action_pushdown(AnimData *adt, const bool is_liboverride) | void BKE_nla_action_pushdown(AnimData *adt, const bool is_liboverride) | ||||
| { | { | ||||
| NlaStrip *strip; | NlaStrip *strip; | ||||
| const bool is_first = (adt) && (adt->nla_tracks.first == NULL); | |||||
| /* sanity checks */ | /* sanity checks */ | ||||
| /* TODO: need to report the error for this */ | /* TODO: need to report the error for this */ | ||||
| if (ELEM(NULL, adt, adt->action)) { | if (ELEM(NULL, adt, adt->action)) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* if the action is empty, we also shouldn't try to add to stack, | /* if the action is empty, we also shouldn't try to add to stack, | ||||
| Show All 13 Lines | void BKE_nla_action_pushdown(AnimData *adt, const bool is_liboverride) | ||||
| /* clear reference to action now that we've pushed it onto the stack */ | /* clear reference to action now that we've pushed it onto the stack */ | ||||
| id_us_min(&adt->action->id); | id_us_min(&adt->action->id); | ||||
| adt->action = NULL; | adt->action = NULL; | ||||
| /* copy current "action blending" settings from adt to the strip, | /* copy current "action blending" settings from adt to the strip, | ||||
| * as it was keyframed with these settings, so omitting them will | * as it was keyframed with these settings, so omitting them will | ||||
| * change the effect [T54233] | * change the effect [T54233] | ||||
| * | |||||
| * NOTE: We only do this when there are no tracks | |||||
| */ | */ | ||||
| if (is_first == false) { | |||||
| strip->blendmode = adt->act_blendmode; | strip->blendmode = adt->act_blendmode; | ||||
| strip->influence = adt->act_influence; | strip->influence = adt->act_influence; | ||||
| strip->extendmode = adt->act_extendmode; | strip->extendmode = adt->act_extendmode; | ||||
| if (adt->act_influence < 1.0f) { | if (adt->act_influence < 1.0f) { | ||||
| /* enable "user-controlled" influence (which will insert a default keyframe) | /* enable "user-controlled" influence (which will insert a default keyframe) | ||||
| * so that the influence doesn't get lost on the new update | * so that the influence doesn't get lost on the new update | ||||
| * | * | ||||
| * NOTE: An alternative way would have been to instead hack the influence | * NOTE: An alternative way would have been to instead hack the influence | ||||
| * to not get always get reset to full strength if NLASTRIP_FLAG_USR_INFLUENCE | * to not get always get reset to full strength if NLASTRIP_FLAG_USR_INFLUENCE | ||||
| * is disabled but auto-blending isn't being used. However, that approach | * is disabled but auto-blending isn't being used. However, that approach | ||||
| * is a bit hacky/hard to discover, and may cause backwards compatibility issues, | * is a bit hacky/hard to discover, and may cause backwards compatibility issues, | ||||
| * so it's better to just do it this way. | * so it's better to just do it this way. | ||||
| */ | */ | ||||
| strip->flag |= NLASTRIP_FLAG_USR_INFLUENCE; | strip->flag |= NLASTRIP_FLAG_USR_INFLUENCE; | ||||
| BKE_nlastrip_validate_fcurves(strip); | BKE_nlastrip_validate_fcurves(strip); | ||||
| } | } | ||||
| } | |||||
| /* make strip the active one... */ | /* make strip the active one... */ | ||||
| BKE_nlastrip_set_active(adt, strip); | BKE_nlastrip_set_active(adt, strip); | ||||
| } | } | ||||
| static void nla_tweakmode_find_active(const ListBase /* NlaTrack */ *nla_tracks, | static void nla_tweakmode_find_active(const ListBase /* NlaTrack */ *nla_tracks, | ||||
| NlaTrack **r_track_of_active_strip, | NlaTrack **r_track_of_active_strip, | ||||
| NlaStrip **r_active_strip) | NlaStrip **r_active_strip) | ||||
| { | { | ||||
| NlaTrack *nlt, *activeTrack = NULL; | NlaTrack *nlt, *activeTrack = NULL; | ||||
| NlaStrip *strip, *activeStrip = NULL; | NlaStrip *strip, *activeStrip = NULL; | ||||
| /* go over the tracks, finding the active one, and its active strip | /* go over the tracks, finding the active one, and its active strip | ||||
| * - if we cannot find both, then there's nothing to do | * - if we cannot find both, then there's nothing to do | ||||
| */ | */ | ||||
| for (nlt = nla_tracks->first; nlt; nlt = nlt->next) { | for (nlt = nla_tracks->first; nlt; nlt = nlt->next) { | ||||
| /* check if active */ | /* check if active */ | ||||
| if (nlt->flag & NLATRACK_ACTIVE) { | if (nlt->flag & NLATRACK_ACTIVE) { | ||||
sybren: `is_first` is now no longer used, so the variable can be removed. | |||||
| /* store reference to this active track */ | /* store reference to this active track */ | ||||
| activeTrack = nlt; | activeTrack = nlt; | ||||
| /* now try to find active strip */ | /* now try to find active strip */ | ||||
| activeStrip = BKE_nlastrip_find_active(nlt); | activeStrip = BKE_nlastrip_find_active(nlt); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| Show All 14 Lines | for (nlt = nla_tracks->last; nlt; nlt = nlt->prev) { | ||||
| activeStrip = BKE_nlastrip_find_active(nlt); | activeStrip = BKE_nlastrip_find_active(nlt); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if ((activeTrack) && (activeStrip == NULL)) { | if ((activeTrack) && (activeStrip == NULL)) { | ||||
| /* No active strip in active or last selected track; | /* No active strip in active or last selected track; | ||||
| * compromise for first selected (assuming only single). */ | * compromise for first selected (assuming only single). */ | ||||
| for (strip = activeTrack->strips.first; strip; strip = strip->next) { | for (strip = activeTrack->strips.first; strip; strip = strip->next) { | ||||
Not Done Inline ActionsThis note is a bit hard to follow, because "consistency" can mean so many things. I'd suggest something like this:
Personally I feel that the NOTE: can be removed; such markers should be used (IMO) only for things that are more obscure / hard to realise at first glance. sybren: This note is a bit hard to follow, because "consistency" can mean so many things. I'd suggest… | |||||
| if (strip->flag & (NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE)) { | if (strip->flag & (NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE)) { | ||||
| activeStrip = strip; | activeStrip = strip; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| *r_track_of_active_strip = activeTrack; | *r_track_of_active_strip = activeTrack; | ||||
| ▲ Show 20 Lines • Show All 243 Lines • Show Last 20 Lines | |||||
is_first is now no longer used, so the variable can be removed.