Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-09-25 17:03:00 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-09-28 12:00:15 +0300
commit3fe97bced448d9f080057087b2b92cc8b9213dc4 (patch)
tree40b66eab1f6f03e809b17f6bba32963d506601b3 /source/blender/editors/animation
parent4c19dd523e27f3ef5d44ff2254fa2b8c53eb6ff0 (diff)
Cleanup: animation, split up ANIM_flush_setting_anim_channels()
Split up `ANIM_flush_setting_anim_channels()` into smaller functions. This makes it easier to understand how it works, and makes future improvements also easier. No functional changes.
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c186
1 files changed, 99 insertions, 87 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 560b14bfd9a..be4ee859f89 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -461,64 +461,14 @@ void ANIM_deselect_anim_channels(
/* ---------------------------- Graph Editor ------------------------------------- */
-/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting
- * - anim_data: list of the all the anim channels that can be chosen
- * -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too,
- * then the channels under closed expanders get ignored...
- * - ale_setting: the anim channel (not in the anim_data list directly, though occurring there)
- * with the new state of the setting that we want flushed up/down the hierarchy
- * - setting: type of setting to set
- * - on: whether the visibility setting has been enabled or disabled
- */
-void ANIM_flush_setting_anim_channels(bAnimContext *ac,
- ListBase *anim_data,
- bAnimListElem *ale_setting,
- eAnimChannel_Settings setting,
- eAnimChannels_SetFlag mode)
+/* Copy a certain channel setting to parents of the modified channel. */
+static void anim_flush_channel_setting_up(bAnimContext *ac,
+ const eAnimChannel_Settings setting,
+ const eAnimChannels_SetFlag mode,
+ bAnimListElem *const match,
+ const int matchLevel)
{
- bAnimListElem *ale, *match = NULL;
- int prevLevel = 0, matchLevel = 0;
-
- /* sanity check */
- if (ELEM(NULL, anim_data, anim_data->first)) {
- return;
- }
-
- if (setting == ACHANNEL_SETTING_ALWAYS_VISIBLE) {
- return;
- }
-
- /* find the channel that got changed */
- for (ale = anim_data->first; ale; ale = ale->next) {
- /* compare data, and type as main way of identifying the channel */
- if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) {
- /* We also have to check the ID, this is assigned to,
- * since a block may have multiple users. */
- /* TODO: is the owner-data more revealing? */
- if (ale->id == ale_setting->id) {
- match = ale;
- break;
- }
- }
- }
- if (match == NULL) {
- printf("ERROR: no channel matching the one changed was found\n");
- return;
- }
-
- {
- const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale_setting);
- if (acf == NULL) {
- printf("ERROR: no channel info for the changed channel\n");
- return;
- }
-
- /* get the level of the channel that was affected
- * - we define the level as simply being the offset for the start of the channel
- */
- matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0;
- prevLevel = matchLevel;
- }
+ int prevLevel = matchLevel;
/* flush up?
*
@@ -534,9 +484,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
((setting != ACHANNEL_SETTING_VISIBLE) && (mode == ACHANNEL_SETFLAG_CLEAR))) {
/* Go backwards in the list, until the highest-ranking element
* (by indention has been covered). */
- for (ale = match->prev; ale; ale = ale->prev) {
+ for (bAnimListElem *ale = match->prev; ale; ale = ale->prev) {
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
- int level;
/* if no channel info was found, skip, since this type might not have any useful info */
if (acf == NULL) {
@@ -546,7 +495,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
/* get the level of the current channel traversed
* - we define the level as simply being the offset for the start of the channel
*/
- level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
+ const int level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
/* 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,
@@ -575,43 +524,106 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
}
}
}
+}
- /* flush down (always) */
- {
- /* go forwards in the list, until the lowest-ranking element (by indention has been covered) */
- for (ale = match->next; ale; ale = ale->next) {
- const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
- int level;
+/* Copy a certain channel setting to children of the modified channel. */
+static void anim_flush_channel_setting_down(bAnimContext *ac,
+ const eAnimChannel_Settings setting,
+ const eAnimChannels_SetFlag mode,
+ bAnimListElem *const match,
+ const int matchLevel)
+{
+ /* go forwards in the list, until the lowest-ranking element (by indention has been covered) */
+ for (bAnimListElem *ale = match->next; ale; ale = ale->next) {
+ const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
- /* if no channel info was found, skip, since this type might not have any useful info */
- if (acf == NULL) {
- continue;
- }
+ /* if no channel info was found, skip, since this type might not have any useful info */
+ if (acf == NULL) {
+ continue;
+ }
- /* get the level of the current channel traversed
- * - we define the level as simply being the offset for the start of the channel
- */
- level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0;
+ /* 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 the level is 'greater than' (i.e. less important) the channel that was changed,
- * flush the new status...
+ /* if the level is 'greater than' (i.e. less important) the channel that was changed,
+ * flush the new status...
+ */
+ if (level > matchLevel) {
+ ANIM_channel_setting_set(ac, ale, setting, mode);
+ /* however, if the level is 'less than or equal to' the channel that was changed,
+ * (i.e. the current channel is as important if not more important than the changed
+ * channel) then we should stop, since we've found the last one of the children we should
+ * flush
*/
- if (level > matchLevel) {
- ANIM_channel_setting_set(ac, ale, setting, mode);
- /* however, if the level is 'less than or equal to' the channel that was changed,
- * (i.e. the current channel is as important if not more important than the changed
- * channel) then we should stop, since we've found the last one of the children we should
- * flush
- */
- }
- else {
+ }
+ else {
+ break;
+ }
+ }
+}
+
+/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting
+ * - anim_data: list of the all the anim channels that can be chosen
+ * -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too,
+ * then the channels under closed expanders get ignored...
+ * - ale_setting: the anim channel (not in the anim_data list directly, though occurring there)
+ * with the new state of the setting that we want flushed up/down the hierarchy
+ * - setting: type of setting to set
+ * - on: whether the visibility setting has been enabled or disabled
+ */
+void ANIM_flush_setting_anim_channels(bAnimContext *ac,
+ ListBase *anim_data,
+ bAnimListElem *ale_setting,
+ eAnimChannel_Settings setting,
+ eAnimChannels_SetFlag mode)
+{
+ bAnimListElem *ale, *match = NULL;
+ int matchLevel = 0;
+
+ /* sanity check */
+ if (ELEM(NULL, anim_data, anim_data->first)) {
+ return;
+ }
+
+ if (setting == ACHANNEL_SETTING_ALWAYS_VISIBLE) {
+ return;
+ }
+
+ /* find the channel that got changed */
+ for (ale = anim_data->first; ale; ale = ale->next) {
+ /* compare data, and type as main way of identifying the channel */
+ if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) {
+ /* We also have to check the ID, this is assigned to,
+ * since a block may have multiple users. */
+ /* TODO: is the owner-data more revealing? */
+ if (ale->id == ale_setting->id) {
+ match = ale;
break;
}
+ }
+ }
+ if (match == NULL) {
+ printf("ERROR: no channel matching the one changed was found\n");
+ return;
+ }
- /* store this level as the 'old' level now */
- // prevLevel = level; // XXX: prevLevel is unused
+ {
+ const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale_setting);
+ if (acf == NULL) {
+ printf("ERROR: no channel info for the changed channel\n");
+ return;
}
+
+ /* get the level of the channel that was affected
+ * - we define the level as simply being the offset for the start of the channel
+ */
+ matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0;
}
+
+ anim_flush_channel_setting_up(ac, setting, mode, match, matchLevel);
+ anim_flush_channel_setting_down(ac, setting, mode, match, matchLevel);
}
/* -------------------------- F-Curves ------------------------------------- */