From 424084eeb5c2a523ccfac58882b796b017c01eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 24 Sep 2020 14:00:20 +0200 Subject: Cleanup: NLA, refactor condition, use early return Simplify code by replacing `if (strip) { everything; }` with `if (strip == NULL) { return; }`. No functional changes. --- source/blender/blenkernel/intern/nla.c | 88 +++++++++++++++++----------------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'source/blender/blenkernel/intern/nla.c') 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, -- cgit v1.2.3