Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/anim_channels_edit.c
| Show First 20 Lines • Show All 1,438 Lines • ▼ Show 20 Lines | static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode mode) | ||||
| /* get rearranging function */ | /* get rearranging function */ | ||||
| AnimChanRearrangeFp rearrange_func = rearrange_gpencil_get_mode_func(mode); | AnimChanRearrangeFp rearrange_func = rearrange_gpencil_get_mode_func(mode); | ||||
| if (rearrange_func == NULL) { | if (rearrange_func == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* get Grease Pencil datablocks */ | /* get Grease Pencil datablocks */ | ||||
| filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); | filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | | ||||
| ANIMFILTER_LIST_CHANNELS); | |||||
| ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); | ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); | ||||
| for (ale = anim_data.first; ale; ale = ale->next) { | for (ale = anim_data.first; ale; ale = ale->next) { | ||||
| /* only consider grease pencil container channels */ | |||||
| if (!ELEM(ale->type, ANIMTYPE_GPDATABLOCK, ANIMTYPE_DSGPENCIL)) { | |||||
| continue; | |||||
| } | |||||
| ListBase anim_data_visible = {NULL, NULL}; | ListBase anim_data_visible = {NULL, NULL}; | ||||
| bGPdata *gpd = ale->data; | bGPdata *gpd = ale->data; | ||||
| /* only consider layers if this datablock is open */ | /* only consider layers if this datablock is open */ | ||||
| BLI_assert(ale->type == ANIMTYPE_GPDATABLOCK); | |||||
| if ((gpd->flag & GP_DATA_EXPAND) == 0) { | if ((gpd->flag & GP_DATA_EXPAND) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Filter visible data. */ | /* Filter visible data. */ | ||||
| rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GPLAYER); | rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GPLAYER); | ||||
| /* rearrange datablock's layers */ | /* rearrange datablock's layers */ | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | else if (ac.datatype == ANIMCONT_ACTION) { | ||||
| /* Directly rearrange action's channels */ | /* Directly rearrange action's channels */ | ||||
| rearrange_action_channels(&ac, ac.data, mode); | rearrange_action_channels(&ac, ac.data, mode); | ||||
| } | } | ||||
| else { | else { | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| bAnimListElem *ale; | bAnimListElem *ale; | ||||
| int filter; | int filter; | ||||
| if (ELEM(ac.datatype, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) { | |||||
| rearrange_gpencil_channels(&ac, mode); | |||||
| } | |||||
sybren: It's not entirely clear to me why this has to do yet another check on `ac.datatype`. The above… | |||||
Done Inline ActionsThe issue is that in current state, the loop in rearrange_gpencil_channels needs to have ANIMFILTER_LIST_CHANNELS, in order to deal with ANIMTYPE_DSGPENCIL(grease pencil containers in the dopesheet) and rearrange among them BUT adding this filter to the main dopesheet loop also embeds other channel types (including summary), which are not treated well by the call to rearrange_action_channels and lead to a crash. That being said, I agree that this the current solution not ideal, I am going to think of a cleaner way to deal with this. afonde: The issue is that in current state, the loop in `rearrange_gpencil_channels` needs to have… | |||||
| /* get animdata blocks */ | /* get animdata blocks */ | ||||
| filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | | filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | | ||||
| ANIMFILTER_FCURVESONLY); | ANIMFILTER_FCURVESONLY); | ||||
| ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); | ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); | ||||
| for (ale = anim_data.first; ale; ale = ale->next) { | for (ale = anim_data.first; ale; ale = ale->next) { | ||||
| AnimData *adt = ale->data; | AnimData *adt = ale->data; | ||||
| ▲ Show 20 Lines • Show All 2,151 Lines • Show Last 20 Lines | |||||
It's not entirely clear to me why this has to do yet another check on ac.datatype. The above already has a chain-of-if-else that checks on those, and below there is also a check on ac.datatype inside the for-loop. The code now seems to do two loops over the animation data, with one loop handling a subset of the items, and the other loop the other subset.
Would it be possible to extract the inner part of the for-loop of rearrange_gpencil_channels() into its own function, then call that from both loops? That way animchannels_rearrange_exec() wouldn't have to call rearrange_gpencil_channels(), which cut the number of loops in half.