[Bf-blender-cvs] [424084eeb5c] master: Cleanup: NLA, refactor condition, use early return

Sybren A. Stüvel noreply at git.blender.org
Thu Sep 24 15:19:11 CEST 2020


Commit: 424084eeb5c2a523ccfac58882b796b017c01eb3
Author: Sybren A. Stüvel
Date:   Thu Sep 24 14:00:20 2020 +0200
Branches: master
https://developer.blender.org/rB424084eeb5c2a523ccfac58882b796b017c01eb3

Cleanup: NLA, refactor condition, use early return

Simplify code by replacing `if (strip) { everything; }` with
`if (strip == NULL) { return; }`.

No functional changes.

===================================================================

M	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,



More information about the Bf-blender-cvs mailing list