diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-09-25 17:30:01 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-09-28 12:00:15 +0300 |
commit | 1f5331ee87018cb51a029d786ef138653815e56e (patch) | |
tree | 218c9ffaa3caf1e4967e9e2944825aecf9d9e17c /source/blender/editors/animation/anim_channels_edit.c | |
parent | 3fe97bced448d9f080057087b2b92cc8b9213dc4 (diff) |
Cleanup: animation, simplify `anim_flush_channel_setting_up()`
Simplify `anim_flush_channel_setting_up()` by flipping conditions and
returning early. This makes it easier to understand what is actually
happening in the code.
No functional changes.
Diffstat (limited to 'source/blender/editors/animation/anim_channels_edit.c')
-rw-r--r-- | source/blender/editors/animation/anim_channels_edit.c | 84 |
1 files changed, 45 insertions, 39 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index be4ee859f89..80976d150c0 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -468,8 +468,6 @@ static void anim_flush_channel_setting_up(bAnimContext *ac, bAnimListElem *const match, const int matchLevel) { - int prevLevel = matchLevel; - /* flush up? * * For Visibility: @@ -480,49 +478,57 @@ static void anim_flush_channel_setting_up(bAnimContext *ac, * - only flush up if the current state is now disabled (negative 'off' state is default) * (otherwise, it's too much work to force the parents to be active too) */ - if (((setting == ACHANNEL_SETTING_VISIBLE) && (mode != ACHANNEL_SETFLAG_CLEAR)) || - ((setting != ACHANNEL_SETTING_VISIBLE) && (mode == ACHANNEL_SETFLAG_CLEAR))) { - /* Go backwards in the list, until the highest-ranking element - * (by indention has been covered). */ - for (bAnimListElem *ale = match->prev; ale; ale = ale->prev) { - const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + if (setting == ACHANNEL_SETTING_VISIBLE) { + if (mode == ACHANNEL_SETFLAG_CLEAR) { + return; + } + } + else { + if (mode != ACHANNEL_SETFLAG_CLEAR) { + return; + } + } - /* if no channel info was found, skip, since this type might not have any useful info */ - if (acf == NULL) { - continue; - } + /* Go backwards in the list, until the highest-ranking element + * (by indention has been covered). */ + int prevLevel = matchLevel; + for (bAnimListElem *ale = match->prev; ale; ale = ale->prev) { + const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); - /* get the level of the current channel traversed - * - we define the level as simply being the offset for the start of the channel - */ - const int level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + /* if no channel info was found, skip, since this type might not have any useful info */ + if (acf == NULL) { + continue; + } - /* if the level is 'less than' (i.e. more important) the level we're matching - * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves, - * when toggling visibility of F-Curves, gets flushed, which should happen if we don't let - * prevLevel get updated below once the first 1st group is found). - */ - if (level < prevLevel) { - /* flush the new status... */ - ANIM_channel_setting_set(ac, ale, setting, mode); + /* Get the level of the current channel traversed + * - we define the level as simply being the offset for the start of the channel + */ + const int level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; - /* store this level as the 'old' level now */ - prevLevel = level; - } - /* if the level is 'greater than' (i.e. less important) than the previous level... */ - else if (level > prevLevel) { - /* if previous level was a base-level (i.e. 0 offset / root of one hierarchy), - * stop here - */ - if (prevLevel == 0) { - break; - /* otherwise, this level weaves into another sibling hierarchy to the previous one just - * finished, so skip until we get to the parent of this level - */ - } - continue; + if (level == prevLevel) { + /* Don't influence siblings. */ + continue; + } + + if (level > prevLevel) { + /* If previous level was a base-level (i.e. 0 offset / root of one hierarchy), stop here. */ + if (prevLevel == 0) { + return; } + + /* Otherwise, this level weaves into another sibling hierarchy to the previous one just + * finished, so skip until we get to the parent of this level. */ + continue; } + + /* The level is 'less than' (i.e. more important) the level we're matching but also 'less + * than' the level just tried (i.e. only the 1st group above grouped F-Curves, when toggling + * visibility of F-Curves, gets flushed, which should happen if we don't let prevLevel get + * updated below once the first 1st group is found). */ + ANIM_channel_setting_set(ac, ale, setting, mode); + + /* store this level as the 'old' level now */ + prevLevel = level; } } |