diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-09-24 15:00:20 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-09-24 16:17:30 +0300 |
commit | 424084eeb5c2a523ccfac58882b796b017c01eb3 (patch) | |
tree | beb5ee2ed125a00af69b72a5a67553411917cc96 /source/blender/blenkernel/intern/nla.c | |
parent | 7ba30d35d15a5f6c88167c559ce3acc12c63e4a4 (diff) |
Cleanup: NLA, refactor condition, use early return
Simplify code by replacing `if (strip) { everything; }` with
`if (strip == NULL) { return; }`.
No functional changes.
Diffstat (limited to 'source/blender/blenkernel/intern/nla.c')
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 828a6c99838..c58acf3a74d 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1953,56 +1953,56 @@ void BKE_nla_action_pushdown(AnimData *adt) /* add a new NLA strip to the track, which references the active action */ strip = BKE_nlastack_add_strip(adt, adt->action); + if (strip == NULL) { + return; + } - /* do other necessary work on strip */ - if (strip) { - /* clear reference to action now that we've pushed it onto the stack */ - id_us_min(&adt->action->id); - adt->action = NULL; + /* clear reference to action now that we've pushed it onto the stack */ + id_us_min(&adt->action->id); + adt->action = NULL; - /* copy current "action blending" settings from adt to the strip, - * as it was keyframed with these settings, so omitting them will - * change the effect [T54233] - * - * NOTE: We only do this when there are no tracks - */ - if (is_first == false) { - strip->blendmode = adt->act_blendmode; - strip->influence = adt->act_influence; - strip->extendmode = adt->act_extendmode; - - if (adt->act_influence < 1.0f) { - /* enable "user-controlled" influence (which will insert a default keyframe) - * so that the influence doesn't get lost on the new update - * - * 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 - * 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, - * so it's better to just do it this way. - */ - strip->flag |= NLASTRIP_FLAG_USR_INFLUENCE; - BKE_nlastrip_validate_fcurves(strip); - } + /* copy current "action blending" settings from adt to the strip, + * as it was keyframed with these settings, so omitting them will + * change the effect [T54233] + * + * NOTE: We only do this when there are no tracks + */ + if (is_first == false) { + strip->blendmode = adt->act_blendmode; + strip->influence = adt->act_influence; + strip->extendmode = adt->act_extendmode; + + if (adt->act_influence < 1.0f) { + /* enable "user-controlled" influence (which will insert a default keyframe) + * so that the influence doesn't get lost on the new update + * + * 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 + * 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, + * so it's better to just do it this way. + */ + strip->flag |= NLASTRIP_FLAG_USR_INFLUENCE; + BKE_nlastrip_validate_fcurves(strip); } + } - /* if the strip is the first one in the track it lives in, check if there - * are strips in any other tracks that may be before this, and set the extend - * mode accordingly - */ - if (nlastrip_is_first(adt, strip) == 0) { - /* Not first, so extend mode can only be: - * NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD, - * so that it doesn't override strips in previous tracks. */ - /* FIXME: this needs to be more automated, since user can rearrange strips */ - if (strip->extendmode == NLASTRIP_EXTEND_HOLD) { - strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD; - } + /* if the strip is the first one in the track it lives in, check if there + * are strips in any other tracks that may be before this, and set the extend + * mode accordingly + */ + if (nlastrip_is_first(adt, strip) == 0) { + /* Not first, so extend mode can only be: + * NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD, + * so that it doesn't override strips in previous tracks. */ + /* FIXME: this needs to be more automated, since user can rearrange strips */ + if (strip->extendmode == NLASTRIP_EXTEND_HOLD) { + strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD; } - - /* make strip the active one... */ - BKE_nlastrip_set_active(adt, strip); } + + /* make strip the active one... */ + BKE_nlastrip_set_active(adt, strip); } /* Find the active strip + track combo, and set them up as the tweaking track, |