Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/anim_filter.c
| Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_sequencer.h" | #include "BKE_sequencer.h" | ||||
| #include "ED_anim_api.h" | #include "ED_anim_api.h" | ||||
| #include "ED_markers.h" | #include "ED_markers.h" | ||||
| #include "UI_resources.h" /* for TH_KEYFRAME_SCALE lookup */ | #include "UI_resources.h" /* for TH_KEYFRAME_SCALE lookup */ | ||||
| /* Forward declaration */ | |||||
| static void animlistelem_init( | |||||
| bAnimListElem *ale, void *data, eAnim_ChannelType datatype, ID *owner_id, ID *fcurve_owner_id); | |||||
| /* ************************************************************ */ | /* ************************************************************ */ | ||||
| /* Blender Context <-> Animation Context mapping */ | /* Blender Context <-> Animation Context mapping */ | ||||
| /* ----------- Private Stuff - General -------------------- */ | /* ----------- Private Stuff - General -------------------- */ | ||||
| /* Get vertical scaling factor (i.e. typically used for keyframe size) */ | /* Get vertical scaling factor (i.e. typically used for keyframe size) */ | ||||
| static void animedit_get_yscale_factor(bAnimContext *ac) | static void animedit_get_yscale_factor(bAnimContext *ac) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 453 Lines • ▼ Show 20 Lines | |||||
| * ! This causes the calling function to return early if we're only "peeking" for channels | * ! This causes the calling function to return early if we're only "peeking" for channels | ||||
| */ | */ | ||||
| // XXX: ale_statement stuff is really a hack for one special case. It shouldn't really be needed... | // XXX: ale_statement stuff is really a hack for one special case. It shouldn't really be needed... | ||||
| #define ANIMCHANNEL_NEW_CHANNEL_FULL( \ | #define ANIMCHANNEL_NEW_CHANNEL_FULL( \ | ||||
| channel_data, channel_type, owner_id, fcurve_owner_id, ale_statement) \ | channel_data, channel_type, owner_id, fcurve_owner_id, ale_statement) \ | ||||
| if (filter_mode & ANIMFILTER_TMP_PEEK) \ | if (filter_mode & ANIMFILTER_TMP_PEEK) \ | ||||
| return 1; \ | return 1; \ | ||||
| else { \ | else { \ | ||||
| bAnimListElem *ale = make_new_animlistelem( \ | animlistelem_init(animdata_filter_iter_data_get_ale(iter_data), \ | ||||
| channel_data, channel_type, (ID *)owner_id, fcurve_owner_id); \ | channel_data, \ | ||||
| if (ale) { \ | channel_type, \ | ||||
| BLI_addtail(anim_data, ale); \ | (ID *)owner_id, \ | ||||
| items++; \ | fcurve_owner_id); \ | ||||
| items += animdata_filter_iter_add(iter_data); \ | |||||
| ale_statement \ | ale_statement \ | ||||
| } \ | } \ | ||||
| } \ | |||||
| (void)0 | (void)0 | ||||
| #define ANIMCHANNEL_NEW_CHANNEL(channel_data, channel_type, owner_id, fcurve_owner_id) \ | #define ANIMCHANNEL_NEW_CHANNEL(channel_data, channel_type, owner_id, fcurve_owner_id) \ | ||||
| ANIMCHANNEL_NEW_CHANNEL_FULL(channel_data, channel_type, owner_id, fcurve_owner_id, {}) | ANIMCHANNEL_NEW_CHANNEL_FULL(channel_data, channel_type, owner_id, fcurve_owner_id, {}) | ||||
| /* ............................... */ | /* ............................... */ | ||||
| /* quick macro to test if an anim-channel representing an AnimData block is suitably active */ | /* quick macro to test if an anim-channel representing an AnimData block is suitably active */ | ||||
| Show All 14 Lines | |||||
| * 1) seledit off - don't need to consider the implications of this option | * 1) seledit off - don't need to consider the implications of this option | ||||
| * 2) foredit off - we're not considering editing, so channel is ok still | * 2) foredit off - we're not considering editing, so channel is ok still | ||||
| * 3) test_func (i.e. selection test) - only if selected, this test will pass | * 3) test_func (i.e. selection test) - only if selected, this test will pass | ||||
| */ | */ | ||||
| #define ANIMCHANNEL_SELEDITOK(test_func) \ | #define ANIMCHANNEL_SELEDITOK(test_func) \ | ||||
| (!(filter_mode & ANIMFILTER_SELEDIT) || !(filter_mode & ANIMFILTER_FOREDIT) || (test_func)) | (!(filter_mode & ANIMFILTER_SELEDIT) || !(filter_mode & ANIMFILTER_FOREDIT) || (test_func)) | ||||
| /* ----------- 'Private' Stuff --------------- */ | /* ----------- 'Private' Stuff --------------- */ | ||||
| /* ---------- Iterator --------------- */ | |||||
| #define MAX_LEVEL 10 | |||||
| typedef struct AnimFilterIterDataLevel { | |||||
| /* A template `ale` elem that can be reused when iterating */ | |||||
| bAnimListElem ale; | |||||
| bool already_added; | |||||
| } AnimFilterIterDataLevel; | |||||
| typedef struct AnimFilterIterData { | |||||
| animdata_filter_cb_t user_cb; | |||||
| void *user_data_cb; | |||||
| int level; | |||||
| AnimFilterIterDataLevel level_data[MAX_LEVEL]; | |||||
| GSet *already_added_items; | |||||
| eAnimFilter_Flags filter_mode; | |||||
| bool halt; | |||||
| } AnimFilterIterData; | |||||
| /* this function allocates memory for a new bAnimListElem struct for the | static void animdata_filter_iter_data_init(AnimFilterIterData *iter_data, | ||||
| * provided animation channel-data. | eAnimFilter_Flags filter_mode, | ||||
| */ | animdata_filter_cb_t animdata_filter_cb, | ||||
| static bAnimListElem *make_new_animlistelem(void *data, | void *user_data_cb) | ||||
| short datatype, | { | ||||
| memset(iter_data, 0, sizeof(AnimFilterIterData)); | |||||
| iter_data->user_data_cb = user_data_cb; | |||||
| iter_data->user_cb = animdata_filter_cb; | |||||
| iter_data->filter_mode = filter_mode; | |||||
| iter_data->halt = false; | |||||
| iter_data->already_added_items = NULL; | |||||
| if (iter_data->filter_mode & ANIMFILTER_NODUPLIS) { | |||||
| iter_data->already_added_items = BLI_gset_ptr_new(__func__); | |||||
| } | |||||
| } | |||||
| static void animdata_filter_iter_data_deinit(AnimFilterIterData *iter_data) | |||||
| { | |||||
| BLI_assert(iter_data->level == 0); | |||||
| if (iter_data->already_added_items) { | |||||
| BLI_gset_free(iter_data->already_added_items, NULL); | |||||
| iter_data->already_added_items = NULL; | |||||
| } | |||||
| } | |||||
| static AnimFilterIterDataLevel *animdata_filter_iter_data_get_level(AnimFilterIterData *iter_data) | |||||
| { | |||||
| return &iter_data->level_data[iter_data->level]; | |||||
| } | |||||
| static AnimFilterIterDataLevel *animdata_filter_iter_data_get_parent_level( | |||||
| AnimFilterIterData *iter_data) | |||||
| { | |||||
| return &iter_data->level_data[iter_data->level - 1]; | |||||
| } | |||||
| static bAnimListElem *animdata_filter_iter_data_get_ale(AnimFilterIterData *iter_data) | |||||
| { | |||||
| return &animdata_filter_iter_data_get_level(iter_data)->ale; | |||||
| } | |||||
| static void animdata_filter_iter_data_copy(AnimFilterIterData *dst, | |||||
| AnimFilterIterData *src, | |||||
| animdata_filter_cb_t animdata_filter_cb, | |||||
| void *user_data_cb) | |||||
| { | |||||
| memset(dst, 0, sizeof(AnimFilterIterData)); | |||||
| dst->user_data_cb = user_data_cb; | |||||
| dst->user_cb = animdata_filter_cb; | |||||
| dst->filter_mode = src->filter_mode; | |||||
| dst->halt = src->halt; | |||||
| dst->already_added_items = src->already_added_items; | |||||
| } | |||||
| static void animdata_filter_iter_data_increase_level(AnimFilterIterData *iter_data) | |||||
| { | |||||
| animdata_filter_iter_data_get_level(iter_data)->already_added = true; | |||||
| iter_data->level++; | |||||
| } | |||||
| static void animdata_filter_iter_data_decrease_level(AnimFilterIterData *iter_data) | |||||
| { | |||||
| iter_data->level--; | |||||
| } | |||||
| static void animdata_filter_iter_data_set_parent(AnimFilterIterData *iter_data, | |||||
| void *channel_data, | |||||
| eAnim_ChannelType channel_type, | |||||
| ID *owner_id, | ID *owner_id, | ||||
| ID *fcurve_owner_id) | ID *fcurve_owner_id) | ||||
| { | { | ||||
| bAnimListElem *ale = NULL; | AnimFilterIterDataLevel *parent = animdata_filter_iter_data_get_parent_level(iter_data); | ||||
| animlistelem_init(&parent->ale, channel_data, channel_type, owner_id, fcurve_owner_id); | |||||
| parent->already_added = false; | |||||
| } | |||||
| static size_t animdata_filter_listbase_cb(bAnimListElem *ale, | |||||
| void *user_data, | |||||
| bool *UNUSED(r_halt)) | |||||
| { | |||||
| ListBase *list_base = user_data; | |||||
| /* Make a shallow copy of `ale this way we can reuse a single instance which can be allocated on | |||||
| * the stack. This saves allocations when iterating */ | |||||
| bAnimListElem *ale_copy = MEM_mallocN(sizeof(bAnimListElem), __func__); | |||||
| memcpy(ale_copy, ale, sizeof(bAnimListElem)); | |||||
| BLI_addtail(list_base, ale_copy); | |||||
| return 1; | |||||
| } | |||||
| static size_t animdata_filter_iter_add(AnimFilterIterData *iter_data) | |||||
| { | |||||
| /* Caller has wants to stop iterating. */ | |||||
| if (iter_data->halt) { | |||||
| return 0; | |||||
| } | |||||
| bAnimListElem *ale = animdata_filter_iter_data_get_ale(iter_data); | |||||
| /* Do not add invalid types */ | |||||
| if (ale->type == ANIMTYPE_NONE) { | |||||
| memset(ale, 0, sizeof(bAnimListElem)); | |||||
| return 0; | |||||
| } | |||||
| /* Check for duplicates */ | |||||
| if (iter_data->filter_mode & ANIMFILTER_NODUPLIS) { | |||||
| BLI_assert(iter_data->already_added_items); | |||||
| if (!BLI_gset_add(iter_data->already_added_items, ale->data)) { | |||||
| memset(ale, 0, sizeof(bAnimListElem)); | |||||
| return 0; | |||||
| } | |||||
| } | |||||
| /* Add the parent that aren't yet added */ | |||||
| size_t result = 0; | |||||
| for (int level = 0; level < iter_data->level; level++) { | |||||
| AnimFilterIterDataLevel *level_data = &iter_data->level_data[level]; | |||||
| if (!level_data->already_added) { | |||||
| result += iter_data->user_cb(&level_data->ale, iter_data->user_data_cb, &iter_data->halt); | |||||
| memset(&level_data->ale, 0, sizeof(bAnimListElem)); | |||||
| level_data->already_added = true; | |||||
| } | |||||
| } | |||||
| result += iter_data->user_cb(ale, iter_data->user_data_cb, &iter_data->halt); | |||||
| memset(ale, 0, sizeof(bAnimListElem)); | |||||
| return result; | |||||
| } | |||||
| static size_t animdata_filter_iter_move_list(AnimFilterIterData *iter_data, ListBase *src) | |||||
| { | |||||
| size_t items = 0; | |||||
| // TODO(jbakker): do an actual move | |||||
| LISTBASE_FOREACH (bAnimListElem *, ale, src) { | |||||
| items += animdata_filter_iter_add(iter_data); | |||||
| } | |||||
| BLI_freelistN(src); | |||||
| return items; | |||||
| } | |||||
| /* this function allocates memory for a new bAnimListElem struct for the | |||||
| * provided animation channel-data. | |||||
| */ | |||||
| static void animlistelem_init( | |||||
| bAnimListElem *ale, void *data, eAnim_ChannelType datatype, ID *owner_id, ID *fcurve_owner_id) | |||||
| { | |||||
| /* only allocate memory if there is data to convert */ | /* only allocate memory if there is data to convert */ | ||||
| if (data) { | if (!data) { | ||||
| /* allocate and set generic data */ | *ale = (const bAnimListElem){NULL}; | ||||
| ale = MEM_callocN(sizeof(bAnimListElem), "bAnimListElem"); | return; | ||||
| } | |||||
| /* set generic data */ | |||||
| ale->data = data; | ale->data = data; | ||||
| ale->type = datatype; | ale->type = datatype; | ||||
| ale->id = owner_id; | ale->id = owner_id; | ||||
| ale->adt = BKE_animdata_from_id(owner_id); | ale->adt = BKE_animdata_from_id(owner_id); | ||||
| ale->fcurve_owner_id = fcurve_owner_id; | ale->fcurve_owner_id = fcurve_owner_id; | ||||
| /* do specifics */ | /* do specifics */ | ||||
| switch (datatype) { | switch (datatype) { | ||||
| case ANIMTYPE_SUMMARY: { | case ANIMTYPE_SUMMARY: { | ||||
| /* Nothing to include for now... this is just a dummy wrapper around | /* Nothing to include for now... this is just a dummy wrapper around | ||||
| * all the other channels in the DopeSheet, and gets included at the start of the list. */ | * all the other channels in the DopeSheet, and gets included at the start of the list. */ | ||||
| ale->key_data = NULL; | ale->key_data = NULL; | ||||
| ale->datatype = ALE_ALL; | ale->datatype = ALE_ALL; | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_SCENE: { | case ANIMTYPE_SCENE: { | ||||
| Scene *sce = (Scene *)data; | Scene *sce = (Scene *)data; | ||||
| ale->flag = sce->flag; | ale->flag = sce->flag; | ||||
| ale->key_data = sce; | ale->key_data = sce; | ||||
| ale->datatype = ALE_SCE; | ale->datatype = ALE_SCE; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_OBJECT: { | case ANIMTYPE_OBJECT: { | ||||
| Base *base = (Base *)data; | Base *base = (Base *)data; | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| ale->flag = ob->flag; | ale->flag = ob->flag; | ||||
| ale->key_data = ob; | ale->key_data = ob; | ||||
| ale->datatype = ALE_OB; | ale->datatype = ALE_OB; | ||||
| ale->adt = BKE_animdata_from_id(&ob->id); | ale->adt = BKE_animdata_from_id(&ob->id); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_FILLACTD: { | case ANIMTYPE_FILLACTD: { | ||||
| bAction *act = (bAction *)data; | bAction *act = (bAction *)data; | ||||
| ale->flag = act->flag; | ale->flag = act->flag; | ||||
| ale->key_data = act; | ale->key_data = act; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_FILLDRIVERS: { | case ANIMTYPE_FILLDRIVERS: { | ||||
| AnimData *adt = (AnimData *)data; | AnimData *adt = (AnimData *)data; | ||||
| ale->flag = adt->flag; | ale->flag = adt->flag; | ||||
| // XXX... drivers don't show summary for now | // XXX... drivers don't show summary for now | ||||
| ale->key_data = NULL; | ale->key_data = NULL; | ||||
| ale->datatype = ALE_NONE; | ale->datatype = ALE_NONE; | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSMAT: { | case ANIMTYPE_DSMAT: { | ||||
| Material *ma = (Material *)data; | Material *ma = (Material *)data; | ||||
| AnimData *adt = ma->adt; | AnimData *adt = ma->adt; | ||||
| ale->flag = FILTER_MAT_OBJD(ma); | ale->flag = FILTER_MAT_OBJD(ma); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSLAM: { | case ANIMTYPE_DSLAM: { | ||||
| Light *la = (Light *)data; | Light *la = (Light *)data; | ||||
| AnimData *adt = la->adt; | AnimData *adt = la->adt; | ||||
| ale->flag = FILTER_LAM_OBJD(la); | ale->flag = FILTER_LAM_OBJD(la); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSCAM: { | case ANIMTYPE_DSCAM: { | ||||
| Camera *ca = (Camera *)data; | Camera *ca = (Camera *)data; | ||||
| AnimData *adt = ca->adt; | AnimData *adt = ca->adt; | ||||
| ale->flag = FILTER_CAM_OBJD(ca); | ale->flag = FILTER_CAM_OBJD(ca); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSCACHEFILE: { | case ANIMTYPE_DSCACHEFILE: { | ||||
| CacheFile *cache_file = (CacheFile *)data; | CacheFile *cache_file = (CacheFile *)data; | ||||
| AnimData *adt = cache_file->adt; | AnimData *adt = cache_file->adt; | ||||
| ale->flag = FILTER_CACHEFILE_OBJD(cache_file); | ale->flag = FILTER_CACHEFILE_OBJD(cache_file); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSCUR: { | case ANIMTYPE_DSCUR: { | ||||
| Curve *cu = (Curve *)data; | Curve *cu = (Curve *)data; | ||||
| AnimData *adt = cu->adt; | AnimData *adt = cu->adt; | ||||
| ale->flag = FILTER_CUR_OBJD(cu); | ale->flag = FILTER_CUR_OBJD(cu); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSARM: { | case ANIMTYPE_DSARM: { | ||||
| bArmature *arm = (bArmature *)data; | bArmature *arm = (bArmature *)data; | ||||
| AnimData *adt = arm->adt; | AnimData *adt = arm->adt; | ||||
| ale->flag = FILTER_ARM_OBJD(arm); | ale->flag = FILTER_ARM_OBJD(arm); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSMESH: { | case ANIMTYPE_DSMESH: { | ||||
| Mesh *me = (Mesh *)data; | Mesh *me = (Mesh *)data; | ||||
| AnimData *adt = me->adt; | AnimData *adt = me->adt; | ||||
| ale->flag = FILTER_MESH_OBJD(me); | ale->flag = FILTER_MESH_OBJD(me); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSLAT: { | case ANIMTYPE_DSLAT: { | ||||
| Lattice *lt = (Lattice *)data; | Lattice *lt = (Lattice *)data; | ||||
| AnimData *adt = lt->adt; | AnimData *adt = lt->adt; | ||||
| ale->flag = FILTER_LATTICE_OBJD(lt); | ale->flag = FILTER_LATTICE_OBJD(lt); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSSPK: { | case ANIMTYPE_DSSPK: { | ||||
| Speaker *spk = (Speaker *)data; | Speaker *spk = (Speaker *)data; | ||||
| AnimData *adt = spk->adt; | AnimData *adt = spk->adt; | ||||
| ale->flag = FILTER_SPK_OBJD(spk); | ale->flag = FILTER_SPK_OBJD(spk); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSHAIR: { | case ANIMTYPE_DSHAIR: { | ||||
| Hair *hair = (Hair *)data; | Hair *hair = (Hair *)data; | ||||
| AnimData *adt = hair->adt; | AnimData *adt = hair->adt; | ||||
| ale->flag = FILTER_HAIR_OBJD(hair); | ale->flag = FILTER_HAIR_OBJD(hair); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSPOINTCLOUD: { | case ANIMTYPE_DSPOINTCLOUD: { | ||||
| PointCloud *pointcloud = (PointCloud *)data; | PointCloud *pointcloud = (PointCloud *)data; | ||||
| AnimData *adt = pointcloud->adt; | AnimData *adt = pointcloud->adt; | ||||
| ale->flag = FILTER_POINTS_OBJD(pointcloud); | ale->flag = FILTER_POINTS_OBJD(pointcloud); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSVOLUME: { | case ANIMTYPE_DSVOLUME: { | ||||
| Volume *volume = (Volume *)data; | Volume *volume = (Volume *)data; | ||||
| AnimData *adt = volume->adt; | AnimData *adt = volume->adt; | ||||
| ale->flag = FILTER_VOLUME_OBJD(volume); | ale->flag = FILTER_VOLUME_OBJD(volume); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSSKEY: { | case ANIMTYPE_DSSKEY: { | ||||
| Key *key = (Key *)data; | Key *key = (Key *)data; | ||||
| AnimData *adt = key->adt; | AnimData *adt = key->adt; | ||||
| ale->flag = FILTER_SKE_OBJD(key); | ale->flag = FILTER_SKE_OBJD(key); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSWOR: { | case ANIMTYPE_DSWOR: { | ||||
| World *wo = (World *)data; | World *wo = (World *)data; | ||||
| AnimData *adt = wo->adt; | AnimData *adt = wo->adt; | ||||
| ale->flag = FILTER_WOR_SCED(wo); | ale->flag = FILTER_WOR_SCED(wo); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSNTREE: { | case ANIMTYPE_DSNTREE: { | ||||
| bNodeTree *ntree = (bNodeTree *)data; | bNodeTree *ntree = (bNodeTree *)data; | ||||
| AnimData *adt = ntree->adt; | AnimData *adt = ntree->adt; | ||||
| ale->flag = FILTER_NTREE_DATA(ntree); | ale->flag = FILTER_NTREE_DATA(ntree); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSLINESTYLE: { | case ANIMTYPE_DSLINESTYLE: { | ||||
| FreestyleLineStyle *linestyle = (FreestyleLineStyle *)data; | FreestyleLineStyle *linestyle = (FreestyleLineStyle *)data; | ||||
| AnimData *adt = linestyle->adt; | AnimData *adt = linestyle->adt; | ||||
| ale->flag = FILTER_LS_SCED(linestyle); | ale->flag = FILTER_LS_SCED(linestyle); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSPART: { | case ANIMTYPE_DSPART: { | ||||
| ParticleSettings *part = (ParticleSettings *)ale->data; | ParticleSettings *part = (ParticleSettings *)ale->data; | ||||
| AnimData *adt = part->adt; | AnimData *adt = part->adt; | ||||
| ale->flag = FILTER_PART_OBJD(part); | ale->flag = FILTER_PART_OBJD(part); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSTEX: { | case ANIMTYPE_DSTEX: { | ||||
| Tex *tex = (Tex *)data; | Tex *tex = (Tex *)data; | ||||
| AnimData *adt = tex->adt; | AnimData *adt = tex->adt; | ||||
| ale->flag = FILTER_TEX_DATA(tex); | ale->flag = FILTER_TEX_DATA(tex); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSGPENCIL: { | case ANIMTYPE_DSGPENCIL: { | ||||
| bGPdata *gpd = (bGPdata *)data; | bGPdata *gpd = (bGPdata *)data; | ||||
| AnimData *adt = gpd->adt; | AnimData *adt = gpd->adt; | ||||
| /* NOTE: we just reuse the same expand filter for this case */ | /* NOTE: we just reuse the same expand filter for this case */ | ||||
| ale->flag = EXPANDED_GPD(gpd); | ale->flag = EXPANDED_GPD(gpd); | ||||
| // XXX: currently, this is only used for access to its animation data | // XXX: currently, this is only used for access to its animation data | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_DSMCLIP: { | case ANIMTYPE_DSMCLIP: { | ||||
| MovieClip *clip = (MovieClip *)data; | MovieClip *clip = (MovieClip *)data; | ||||
| AnimData *adt = clip->adt; | AnimData *adt = clip->adt; | ||||
| ale->flag = EXPANDED_MCLIP(clip); | ale->flag = EXPANDED_MCLIP(clip); | ||||
| ale->key_data = (adt) ? adt->action : NULL; | ale->key_data = (adt) ? adt->action : NULL; | ||||
| ale->datatype = ALE_ACT; | ale->datatype = ALE_ACT; | ||||
| ale->adt = BKE_animdata_from_id(data); | ale->adt = BKE_animdata_from_id(data); | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_NLACONTROLS: { | case ANIMTYPE_NLACONTROLS: { | ||||
| AnimData *adt = (AnimData *)data; | AnimData *adt = (AnimData *)data; | ||||
| ale->flag = adt->flag; | ale->flag = adt->flag; | ||||
| ale->key_data = NULL; | ale->key_data = NULL; | ||||
| ale->datatype = ALE_NONE; | ale->datatype = ALE_NONE; | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_GROUP: { | case ANIMTYPE_GROUP: { | ||||
| bActionGroup *agrp = (bActionGroup *)data; | bActionGroup *agrp = (bActionGroup *)data; | ||||
| ale->flag = agrp->flag; | ale->flag = agrp->flag; | ||||
| ale->key_data = NULL; | ale->key_data = NULL; | ||||
| ale->datatype = ALE_GROUP; | ale->datatype = ALE_GROUP; | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_FCURVE: | case ANIMTYPE_FCURVE: | ||||
| case ANIMTYPE_NLACURVE: /* practically the same as ANIMTYPE_FCURVE. | case ANIMTYPE_NLACURVE: /* practically the same as ANIMTYPE_FCURVE. | ||||
| * Differences are applied post-creation */ | * Differences are applied post-creation */ | ||||
| { | { | ||||
| FCurve *fcu = (FCurve *)data; | FCurve *fcu = (FCurve *)data; | ||||
| ale->flag = fcu->flag; | ale->flag = fcu->flag; | ||||
| ale->key_data = fcu; | ale->key_data = fcu; | ||||
| ale->datatype = ALE_FCURVE; | ale->datatype = ALE_FCURVE; | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_SHAPEKEY: { | case ANIMTYPE_SHAPEKEY: { | ||||
| KeyBlock *kb = (KeyBlock *)data; | KeyBlock *kb = (KeyBlock *)data; | ||||
| Key *key = (Key *)ale->id; | Key *key = (Key *)ale->id; | ||||
| ale->flag = kb->flag; | ale->flag = kb->flag; | ||||
| /* whether we have keyframes depends on whether there is a Key block to find it from */ | /* whether we have keyframes depends on whether there is a Key block to find it from */ | ||||
| if (key) { | if (key) { | ||||
| /* index of shapekey is defined by place in key's list */ | /* index of shapekey is defined by place in key's list */ | ||||
| ale->index = BLI_findindex(&key->block, kb); | ale->index = BLI_findindex(&key->block, kb); | ||||
| /* the corresponding keyframes are from the animdata */ | /* the corresponding keyframes are from the animdata */ | ||||
| if (ale->adt && ale->adt->action) { | if (ale->adt && ale->adt->action) { | ||||
| bAction *act = ale->adt->action; | bAction *act = ale->adt->action; | ||||
| char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); | char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); | ||||
| /* try to find the F-Curve which corresponds to this exactly, | /* try to find the F-Curve which corresponds to this exactly, | ||||
| * then free the MEM_alloc'd string | * then free the MEM_alloc'd string | ||||
| */ | */ | ||||
| if (rna_path) { | if (rna_path) { | ||||
| ale->key_data = (void *)list_find_fcurve(&act->curves, rna_path, 0); | ale->key_data = (void *)list_find_fcurve(&act->curves, rna_path, 0); | ||||
| MEM_freeN(rna_path); | MEM_freeN(rna_path); | ||||
| } | } | ||||
| } | } | ||||
| ale->datatype = (ale->key_data) ? ALE_FCURVE : ALE_NONE; | ale->datatype = (ale->key_data) ? ALE_FCURVE : ALE_NONE; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_GPLAYER: { | case ANIMTYPE_GPLAYER: { | ||||
| bGPDlayer *gpl = (bGPDlayer *)data; | bGPDlayer *gpl = (bGPDlayer *)data; | ||||
| ale->flag = gpl->flag; | ale->flag = gpl->flag; | ||||
| ale->key_data = NULL; | ale->key_data = NULL; | ||||
| ale->datatype = ALE_GPFRAME; | ale->datatype = ALE_GPFRAME; | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_MASKLAYER: { | case ANIMTYPE_MASKLAYER: { | ||||
| MaskLayer *masklay = (MaskLayer *)data; | MaskLayer *masklay = (MaskLayer *)data; | ||||
| ale->flag = masklay->flag; | ale->flag = masklay->flag; | ||||
| ale->key_data = NULL; | ale->key_data = NULL; | ||||
| ale->datatype = ALE_MASKLAY; | ale->datatype = ALE_MASKLAY; | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_NLATRACK: { | case ANIMTYPE_NLATRACK: { | ||||
| NlaTrack *nlt = (NlaTrack *)data; | NlaTrack *nlt = (NlaTrack *)data; | ||||
| ale->flag = nlt->flag; | ale->flag = nlt->flag; | ||||
| ale->key_data = &nlt->strips; | ale->key_data = &nlt->strips; | ||||
| ale->datatype = ALE_NLASTRIP; | ale->datatype = ALE_NLASTRIP; | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMTYPE_NLAACTION: { | case ANIMTYPE_NLAACTION: { | ||||
| /* nothing to include for now... nothing editable from NLA-perspective here */ | /* nothing to include for now... nothing editable from NLA-perspective here */ | ||||
| ale->key_data = NULL; | ale->key_data = NULL; | ||||
| ale->datatype = ALE_NONE; | ale->datatype = ALE_NONE; | ||||
| break; | break; | ||||
| } | } | ||||
| /* All animation types that can not (yet) be converted to an element */ | |||||
| case ANIMTYPE_NONE: | |||||
| case ANIMTYPE_ANIMDATA: | |||||
| case ANIMTYPE_SPECIALDATA__UNUSED: | |||||
| case ANIMTYPE_DSMBALL: | |||||
| case ANIMTYPE_GPDATABLOCK: | |||||
| case ANIMTYPE_MASKDATABLOCK: | |||||
| case ANIMTYPE_PALETTE: | |||||
| case ANIMTYPE_NUM_TYPES: { | |||||
| *ale = (const bAnimListElem){NULL}; | |||||
| } | } | ||||
| } | } | ||||
| /* return created datatype */ | |||||
| return ale; | |||||
| } | } | ||||
| /* ----------------------------------------- */ | /* ----------------------------------------- */ | ||||
| /* 'Only Selected' selected data and/or 'Include Hidden' filtering | /* 'Only Selected' selected data and/or 'Include Hidden' filtering | ||||
| * NOTE: when this function returns true, the F-Curve is to be skipped | * NOTE: when this function returns true, the F-Curve is to be skipped | ||||
| */ | */ | ||||
| static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode) | static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode) | ||||
| ▲ Show 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || (fcu->flag & FCURVE_VISIBLE)) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* no (more) F-Curves from the list are suitable... */ | /* no (more) F-Curves from the list are suitable... */ | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| static size_t animfilter_fcurves(ListBase *anim_data, | static size_t animfilter_fcurves(AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| FCurve *first, | FCurve *first, | ||||
| eAnim_ChannelType fcurve_type, | eAnim_ChannelType fcurve_type, | ||||
| int filter_mode, | int filter_mode, | ||||
| void *owner, | void *owner, | ||||
| ID *owner_id, | ID *owner_id, | ||||
| ID *fcurve_owner_id) | ID *fcurve_owner_id) | ||||
| { | { | ||||
| Show All 14 Lines | static size_t animfilter_fcurves(AnimFilterIterData *iter_data, | ||||
| */ | */ | ||||
| for (fcu = first; | for (fcu = first; | ||||
| ((fcu = animfilter_fcurve_next(ads, fcu, fcurve_type, filter_mode, owner, owner_id))); | ((fcu = animfilter_fcurve_next(ads, fcu, fcurve_type, filter_mode, owner, owner_id))); | ||||
| fcu = fcu->next) { | fcu = fcu->next) { | ||||
| if (UNLIKELY(fcurve_type == ANIMTYPE_NLACURVE)) { | if (UNLIKELY(fcurve_type == ANIMTYPE_NLACURVE)) { | ||||
| /* NLA Control Curve - Basically the same as normal F-Curves, | /* NLA Control Curve - Basically the same as normal F-Curves, | ||||
| * except we need to set some stuff differently */ | * except we need to set some stuff differently */ | ||||
| ANIMCHANNEL_NEW_CHANNEL_FULL(fcu, ANIMTYPE_NLACURVE, owner_id, fcurve_owner_id, { | ANIMCHANNEL_NEW_CHANNEL_FULL(fcu, ANIMTYPE_NLACURVE, owner_id, fcurve_owner_id, { | ||||
| bAnimListElem *ale = animdata_filter_iter_data_get_ale(iter_data); | |||||
| ale->owner = owner; /* strip */ | ale->owner = owner; /* strip */ | ||||
| ale->adt = NULL; /* to prevent time mapping from causing problems */ | ale->adt = NULL; /* to prevent time mapping from causing problems */ | ||||
| }); | }); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Normal FCurve */ | /* Normal FCurve */ | ||||
| ANIMCHANNEL_NEW_CHANNEL(fcu, ANIMTYPE_FCURVE, owner_id, fcurve_owner_id); | ANIMCHANNEL_NEW_CHANNEL(fcu, ANIMTYPE_FCURVE, owner_id, fcurve_owner_id); | ||||
| } | } | ||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animfilter_act_group(bAnimContext *ac, | static size_t animfilter_act_group(bAnimContext *ac, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| bAction *act, | bAction *act, | ||||
| bActionGroup *agrp, | bActionGroup *agrp, | ||||
| int filter_mode, | int filter_mode, | ||||
| ID *owner_id) | ID *owner_id) | ||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| // int ofilter = filter_mode; | // int ofilter = filter_mode; | ||||
| /* if we care about the selection status of the channels, | /* if we care about the selection status of the channels, | ||||
| * but the group isn't expanded (1)... | * but the group isn't expanded (1)... | ||||
| * (1) this only matters if we actually care about the hierarchy though. | * (1) this only matters if we actually care about the hierarchy though. | ||||
| * - Hierarchy matters: this hack should be applied | * - Hierarchy matters: this hack should be applied | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* filter selection of channel specially here again, | /* filter selection of channel specially here again, | ||||
| * since may be open and not subject to previous test */ | * since may be open and not subject to previous test */ | ||||
| if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp))) { | if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp))) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(agrp, ANIMTYPE_GROUP, owner_id, &act->id); | ANIMCHANNEL_NEW_CHANNEL(agrp, ANIMTYPE_GROUP, owner_id, &act->id); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animfilter_action(bAnimContext *ac, | static size_t animfilter_action(bAnimContext *ac, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| bAction *act, | bAction *act, | ||||
| int filter_mode, | int filter_mode, | ||||
| ID *owner_id) | ID *owner_id) | ||||
| { | { | ||||
| bActionGroup *agrp; | bActionGroup *agrp; | ||||
| FCurve *lastchan = NULL; | FCurve *lastchan = NULL; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| Show All 9 Lines | static size_t animfilter_action(bAnimContext *ac, | ||||
| // TODO: do nested groups? | // TODO: do nested groups? | ||||
| for (agrp = act->groups.first; agrp; agrp = agrp->next) { | for (agrp = act->groups.first; agrp; agrp = agrp->next) { | ||||
| /* store reference to last channel of group */ | /* store reference to last channel of group */ | ||||
| if (agrp->channels.last) { | if (agrp->channels.last) { | ||||
| lastchan = agrp->channels.last; | lastchan = agrp->channels.last; | ||||
| } | } | ||||
| /* action group's channels */ | /* action group's channels */ | ||||
| items += animfilter_act_group(ac, anim_data, ads, act, agrp, filter_mode, owner_id); | items += animfilter_act_group(ac, iter_data, ads, act, agrp, filter_mode, owner_id); | ||||
| } | } | ||||
| /* un-grouped F-Curves (only if we're not only considering those channels in the active group) */ | /* un-grouped F-Curves (only if we're not only considering those channels in the active group) | ||||
| */ | |||||
| if (!(filter_mode & ANIMFILTER_ACTGROUPED)) { | if (!(filter_mode & ANIMFILTER_ACTGROUPED)) { | ||||
| FCurve *firstfcu = (lastchan) ? (lastchan->next) : (act->curves.first); | FCurve *firstfcu = (lastchan) ? (lastchan->next) : (act->curves.first); | ||||
| items += animfilter_fcurves( | items += animfilter_fcurves( | ||||
| anim_data, ads, firstfcu, ANIMTYPE_FCURVE, filter_mode, NULL, owner_id, &act->id); | iter_data, ads, firstfcu, ANIMTYPE_FCURVE, filter_mode, NULL, owner_id, &act->id); | ||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Include NLA-Data for NLA-Editor: | /* Include NLA-Data for NLA-Editor: | ||||
| * - When ANIMFILTER_LIST_CHANNELS is used, that means we should be filtering the list for display | * - When ANIMFILTER_LIST_CHANNELS is used, that means we should be filtering the list for | ||||
| * Although the evaluation order is from the first track to the last and then apply the | * display Although the evaluation order is from the first track to the last and then apply the | ||||
| * Action on top, we present this in the UI as the Active Action followed by the last track | * Action on top, we present this in the UI as the Active Action followed by the last track | ||||
| * to the first so that we get the evaluation order presented as per a stack. | * to the first so that we get the evaluation order presented as per a stack. | ||||
| * - For normal filtering (i.e. for editing), | * - For normal filtering (i.e. for editing), | ||||
| * we only need the NLA-tracks but they can be in 'normal' evaluation order, i.e. first to last. | * we only need the NLA-tracks but they can be in 'normal' evaluation order, i.e. first to | ||||
| * Otherwise, some tools may get screwed up. | * last. Otherwise, some tools may get screwed up. | ||||
| */ | */ | ||||
| static size_t animfilter_nla(bAnimContext *UNUSED(ac), | static size_t animfilter_nla(bAnimContext *UNUSED(ac), | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| AnimData *adt, | AnimData *adt, | ||||
| int filter_mode, | int filter_mode, | ||||
| ID *owner_id) | ID *owner_id) | ||||
| { | { | ||||
| NlaTrack *nlt; | NlaTrack *nlt; | ||||
| NlaTrack *first = NULL, *next = NULL; | NlaTrack *first = NULL, *next = NULL; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* if showing channels, include active action */ | /* if showing channels, include active action */ | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* if NLA action-line filtering is off, don't show unless there are keyframes, | /* if NLA action-line filtering is off, don't show unless there are keyframes, | ||||
| * in order to keep things more compact for doing transforms | * in order to keep things more compact for doing transforms | ||||
| */ | */ | ||||
| if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) || (adt->action)) { | if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) || (adt->action)) { | ||||
| /* there isn't really anything editable here, so skip if need editable */ | /* there isn't really anything editable here, so skip if need editable */ | ||||
| if ((filter_mode & ANIMFILTER_FOREDIT) == 0) { | if ((filter_mode & ANIMFILTER_FOREDIT) == 0) { | ||||
| /* Just add the action track now (this MUST appear for drawing): | /* Just add the action track now (this MUST appear for drawing): | ||||
| * - As AnimData may not have an action, | * - As AnimData may not have an action, | ||||
| * we pass a dummy pointer just to get the list elem created, | * we pass a dummy pointer just to get the list elem created, | ||||
| * then overwrite this with the real value - REVIEW THIS. | * then overwrite this with the real value - REVIEW THIS. | ||||
| */ | */ | ||||
| ANIMCHANNEL_NEW_CHANNEL_FULL((void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id, NULL, { | ANIMCHANNEL_NEW_CHANNEL_FULL((void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id, NULL, { | ||||
| ale->data = adt->action ? adt->action : NULL; | animdata_filter_iter_data_get_ale(iter_data)->data = adt->action; | ||||
| }); | }); | ||||
| } | } | ||||
| } | } | ||||
| /* first track to include will be the last one if we're filtering by channels */ | /* first track to include will be the last one if we're filtering by channels */ | ||||
| first = adt->nla_tracks.last; | first = adt->nla_tracks.last; | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 20 Lines | for (nlt = first; nlt; nlt = next) { | ||||
| // and after an active-action channel. | // and after an active-action channel. | ||||
| if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED) && | if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED) && | ||||
| (adt->act_track != nlt)) { | (adt->act_track != nlt)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* only work with this channel and its subchannels if it is editable */ | /* only work with this channel and its subchannels if it is editable */ | ||||
| if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) { | if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) { | ||||
| /* only include this track if selected in a way consistent with the filtering requirements */ | /* only include this track if selected in a way consistent with the filtering requirements | ||||
| */ | |||||
| if (ANIMCHANNEL_SELOK(SEL_NLT(nlt))) { | if (ANIMCHANNEL_SELOK(SEL_NLT(nlt))) { | ||||
| /* only include if this track is active */ | /* only include if this track is active */ | ||||
| if (!(filter_mode & ANIMFILTER_ACTIVE) || (nlt->flag & NLATRACK_ACTIVE)) { | if (!(filter_mode & ANIMFILTER_ACTIVE) || (nlt->flag & NLATRACK_ACTIVE)) { | ||||
| /* name based filtering... */ | /* name based filtering... */ | ||||
| if (((ads) && (ads->searchstr[0] != '\0')) && (owner_id)) { | if (((ads) && (ads->searchstr[0] != '\0')) && (owner_id)) { | ||||
| bool track_ok = false, strip_ok = false; | bool track_ok = false, strip_ok = false; | ||||
| /* check if the name of the track, or the strips it has are ok... */ | /* check if the name of the track, or the strips it has are ok... */ | ||||
| Show All 25 Lines | static size_t animfilter_nla(bAnimContext *UNUSED(ac), | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Include the control FCurves per NLA Strip in the channel list | /* Include the control FCurves per NLA Strip in the channel list | ||||
| * NOTE: This is includes the expander too... | * NOTE: This is includes the expander too... | ||||
| */ | */ | ||||
| static size_t animfilter_nla_controls( | static size_t animfilter_nla_controls( | ||||
| ListBase *anim_data, bDopeSheet *ads, AnimData *adt, int filter_mode, ID *owner_id) | AnimFilterIterData *iter_data, bDopeSheet *ads, AnimData *adt, int filter_mode, ID *owner_id) | ||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* add control curves from each NLA strip... */ | /* add control curves from each NLA strip... */ | ||||
| /* NOTE: ANIMTYPE_FCURVES are created here, to avoid duplicating the code needed */ | /* NOTE: ANIMTYPE_FCURVES are created here, to avoid duplicating the code needed */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (((adt->flag & ADT_NLA_SKEYS_COLLAPSED) == 0)) { | BEGIN_ANIMFILTER_SUBCHANNELS (((adt->flag & ADT_NLA_SKEYS_COLLAPSED) == 0)) { | ||||
| NlaTrack *nlt; | NlaTrack *nlt; | ||||
| NlaStrip *strip; | NlaStrip *strip; | ||||
| Show All 24 Lines | if (tmp_items) { | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* currently these channels cannot be selected, so they should be skipped */ | /* currently these channels cannot be selected, so they should be skipped */ | ||||
| if ((filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) == 0) { | if ((filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) == 0) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_NLACONTROLS, owner_id, NULL); | ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_NLACONTROLS, owner_id, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* determine what animation data from AnimData block should get displayed */ | /* determine what animation data from AnimData block should get displayed */ | ||||
| static size_t animfilter_block_data( | static size_t animfilter_block_data( | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *id, int filter_mode) | bAnimContext *ac, AnimFilterIterData *iter_data, bDopeSheet *ads, ID *id, int filter_mode) | ||||
| { | { | ||||
| AnimData *adt = BKE_animdata_from_id(id); | AnimData *adt = BKE_animdata_from_id(id); | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* image object data-blocks have no anim-data so check for NULL */ | /* image object data-blocks have no anim-data so check for NULL */ | ||||
| if (adt) { | if (adt) { | ||||
| IdAdtTemplate *iat = (IdAdtTemplate *)id; | IdAdtTemplate *iat = (IdAdtTemplate *)id; | ||||
| /* NOTE: this macro is used instead of inlining the logic here, | /* NOTE: this macro is used instead of inlining the logic here, | ||||
| * since this sort of filtering is still needed in a few places in the rest of the code still - | * since this sort of filtering is still needed in a few places in the rest of the code still | ||||
| * notably for the few cases where special mode-based | * - notably for the few cases where special mode-based different types of data expanders are | ||||
| * different types of data expanders are required. | * required. | ||||
| */ | */ | ||||
| ANIMDATA_FILTER_CASES( | ANIMDATA_FILTER_CASES( | ||||
| iat, | iat, | ||||
| { /* AnimData */ | { /* AnimData */ | ||||
| /* specifically filter animdata block */ | /* specifically filter animdata block */ | ||||
| if (ANIMCHANNEL_SELOK(SEL_ANIMDATA(adt))) { | if (ANIMCHANNEL_SELOK(SEL_ANIMDATA(adt))) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_ANIMDATA, id, NULL); | ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_ANIMDATA, id, NULL); | ||||
| } | } | ||||
| }, | }, | ||||
| { /* NLA */ | { /* NLA */ | ||||
| items += animfilter_nla(ac, anim_data, ads, adt, filter_mode, id); | items += animfilter_nla(ac, iter_data, ads, adt, filter_mode, id); | ||||
| }, | }, | ||||
| { /* Drivers */ | { /* Drivers */ | ||||
| items += animfilter_fcurves( | items += animfilter_fcurves( | ||||
| anim_data, ads, adt->drivers.first, ANIMTYPE_FCURVE, filter_mode, NULL, id, id); | iter_data, ads, adt->drivers.first, ANIMTYPE_FCURVE, filter_mode, NULL, id, id); | ||||
| }, | }, | ||||
| { /* NLA Control Keyframes */ | { /* NLA Control Keyframes */ | ||||
| items += animfilter_nla_controls(anim_data, ads, adt, filter_mode, id); | items += animfilter_nla_controls(iter_data, ads, adt, filter_mode, id); | ||||
| }, | }, | ||||
| { /* Keyframes */ | { /* Keyframes */ | ||||
| items += animfilter_action(ac, anim_data, ads, adt->action, filter_mode, id); | items += animfilter_action(ac, iter_data, ads, adt->action, filter_mode, id); | ||||
| }); | }); | ||||
| } | } | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Include ShapeKey Data for ShapeKey Editor */ | /* Include ShapeKey Data for ShapeKey Editor */ | ||||
| static size_t animdata_filter_shapekey(bAnimContext *ac, | static size_t animdata_filter_shapekey(bAnimContext *ac, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| Key *key, | Key *key, | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* check if channels or only F-Curves */ | /* check if channels or only F-Curves */ | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| KeyBlock *kb; | KeyBlock *kb; | ||||
| Show All 23 Lines | else { | ||||
| // TODO: somehow manage to pass dopesheet info down here too? | // TODO: somehow manage to pass dopesheet info down here too? | ||||
| if (key->adt) { | if (key->adt) { | ||||
| if (filter_mode & ANIMFILTER_ANIMDATA) { | if (filter_mode & ANIMFILTER_ANIMDATA) { | ||||
| if (ANIMCHANNEL_SELOK(SEL_ANIMDATA(key->adt))) { | if (ANIMCHANNEL_SELOK(SEL_ANIMDATA(key->adt))) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(key->adt, ANIMTYPE_ANIMDATA, key, NULL); | ANIMCHANNEL_NEW_CHANNEL(key->adt, ANIMTYPE_ANIMDATA, key, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else if (key->adt->action) { | else if (key->adt->action) { | ||||
| items = animfilter_action(ac, anim_data, NULL, key->adt->action, filter_mode, (ID *)key); | items = animfilter_action(ac, iter_data, NULL, key->adt->action, filter_mode, (ID *)key); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Helper for Grease Pencil - layers within a data-block. */ | /* Helper for Grease Pencil - layers within a data-block. */ | ||||
| static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, | static size_t animdata_filter_gpencil_layers_data(AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| bGPdata *gpd, | bGPdata *gpd, | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| bGPDlayer *gpl; | bGPDlayer *gpl; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* loop over layers as the conditions are acceptable (top-Down order) */ | /* loop over layers as the conditions are acceptable (top-Down order) */ | ||||
| Show All 27 Lines | for (gpl = gpd->layers.last; gpl; gpl = gpl->prev) { | ||||
| /* add to list */ | /* add to list */ | ||||
| ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd, NULL); | ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd, NULL); | ||||
| } | } | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Helper for Grease Pencil - Grease Pencil data-block - GP Frames. */ | /* Helper for Grease Pencil - Grease Pencil data-block - GP Frames. */ | ||||
| static size_t animdata_filter_gpencil_data(ListBase *anim_data, | static size_t animdata_filter_gpencil_data(AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| bGPdata *gpd, | bGPdata *gpd, | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* When asked from "AnimData" blocks (i.e. the top-level containers for normal animation), | /* When asked from "AnimData" blocks (i.e. the top-level containers for normal animation), | ||||
| * for convenience, this will return GP Data-blocks instead. | * for convenience, this will return GP Data-blocks instead. | ||||
| * This may cause issues down the track, but for now, this will do. | * This may cause issues down the track, but for now, this will do. | ||||
| */ | */ | ||||
| if (filter_mode & ANIMFILTER_ANIMDATA) { | if (filter_mode & ANIMFILTER_ANIMDATA) { | ||||
| /* just add GPD as a channel - this will add everything needed */ | /* just add GPD as a channel - this will add everything needed */ | ||||
| ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, gpd, NULL); | ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, gpd, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| /* add gpencil animation channels */ | /* add gpencil animation channels */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_GPD(gpd)) { | BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_GPD(gpd)) { | ||||
| tmp_items += animdata_filter_gpencil_layers_data(&tmp_data, ads, gpd, filter_mode); | tmp_items += animdata_filter_gpencil_layers_data(&tmp_data, ads, gpd, filter_mode); | ||||
| } | } | ||||
| END_ANIMFILTER_SUBCHANNELS; | END_ANIMFILTER_SUBCHANNELS; | ||||
| /* did we find anything? */ | /* did we find anything? */ | ||||
| if (tmp_items) { | if (tmp_items) { | ||||
| /* include data-expand widget first */ | /* include data-expand widget first */ | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* add gpd as channel too (if for drawing, and it has layers) */ | /* add gpd as channel too (if for drawing, and it has layers) */ | ||||
| ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, NULL, NULL); | ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, NULL, NULL); | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| } | } | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Grab all Grease Pencil data-blocks in file. */ | /* Grab all Grease Pencil data-blocks in file. */ | ||||
| // TODO: should this be amalgamated with the dopesheet filtering code? | // TODO: should this be amalgamated with the dopesheet filtering code? | ||||
| static size_t animdata_filter_gpencil(bAnimContext *ac, | static size_t animdata_filter_gpencil(bAnimContext *ac, | ||||
| ListBase *anim_data, | |||||
| AnimFilterIterData *iter_data, | |||||
| void *UNUSED(data), | void *UNUSED(data), | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| bDopeSheet *ads = ac->ads; | bDopeSheet *ads = ac->ads; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| Scene *scene = (Scene *)ads->source; | Scene *scene = (Scene *)ads->source; | ||||
| ViewLayer *view_layer = (ViewLayer *)ac->view_layer; | ViewLayer *view_layer = (ViewLayer *)ac->view_layer; | ||||
| Base *base; | Base *base; | ||||
| /* Active scene's GPencil block first - No parent item needed... */ | /* Active scene's GPencil block first - No parent item needed... */ | ||||
| if (scene->gpd) { | if (scene->gpd) { | ||||
| items += animdata_filter_gpencil_data(anim_data, ads, scene->gpd, filter_mode); | items += animdata_filter_gpencil_data(iter_data, ads, scene->gpd, filter_mode); | ||||
| } | } | ||||
| /* Objects in the scene */ | /* Objects in the scene */ | ||||
| for (base = view_layer->object_bases.first; base; base = base->next) { | for (base = view_layer->object_bases.first; base; base = base->next) { | ||||
| /* Only consider this object if it has got some GP data (saving on all the other tests) */ | /* Only consider this object if it has got some GP data (saving on all the other tests) */ | ||||
| if (base->object && (base->object->type == OB_GPENCIL)) { | if (base->object && (base->object->type == OB_GPENCIL)) { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| Show All 33 Lines | if (base->object && (base->object->type == OB_GPENCIL)) { | ||||
| if (ads->filter_grp != NULL) { | if (ads->filter_grp != NULL) { | ||||
| if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) { | if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| /* finally, include this object's grease pencil data-block. */ | /* finally, include this object's grease pencil data-block. */ | ||||
| /* XXX: Should we store these under expanders per item? */ | /* XXX: Should we store these under expanders per item? */ | ||||
| items += animdata_filter_gpencil_data(anim_data, ads, ob->data, filter_mode); | items += animdata_filter_gpencil_data(iter_data, ads, ob->data, filter_mode); | ||||
| } | } | ||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Helper for Grease Pencil data integrated with main DopeSheet */ | /* Helper for Grease Pencil data integrated with main DopeSheet */ | ||||
| static size_t animdata_filter_ds_gpencil( | static size_t animdata_filter_ds_gpencil(bAnimContext *ac, | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bGPdata *gpd, int filter_mode) | |||||
| AnimFilterIterData *iter_data, | |||||
| bDopeSheet *ads, | |||||
| bGPdata *gpd, | |||||
| int filter_mode) | |||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* add relevant animation channels for Grease Pencil */ | /* add relevant animation channels for Grease Pencil */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_GPD(gpd)) { | BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_GPD(gpd)) { | ||||
| /* add animation channels */ | /* add animation channels */ | ||||
| tmp_items += animfilter_block_data(ac, &tmp_data, ads, &gpd->id, filter_mode); | tmp_items += animfilter_block_data(ac, &tmp_data, ads, &gpd->id, filter_mode); | ||||
| Show All 10 Lines | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by active status */ | /* check if filtering by active status */ | ||||
| // XXX: active check here needs checking | // XXX: active check here needs checking | ||||
| if (ANIMCHANNEL_ACTIVEOK(gpd)) { | if (ANIMCHANNEL_ACTIVEOK(gpd)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_DSGPENCIL, gpd, NULL); | ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_DSGPENCIL, gpd, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Helper for Cache File data integrated with main DopeSheet */ | /* Helper for Cache File data integrated with main DopeSheet */ | ||||
| static size_t animdata_filter_ds_cachefile( | static size_t animdata_filter_ds_cachefile(bAnimContext *ac, | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, CacheFile *cache_file, int filter_mode) | |||||
| AnimFilterIterData *iter_data, | |||||
| bDopeSheet *ads, | |||||
| CacheFile *cache_file, | |||||
| int filter_mode) | |||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* add relevant animation channels for Cache File */ | /* add relevant animation channels for Cache File */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_CACHEFILE_OBJD(cache_file)) { | BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_CACHEFILE_OBJD(cache_file)) { | ||||
| /* add animation channels */ | /* add animation channels */ | ||||
| tmp_items += animfilter_block_data(ac, &tmp_data, ads, &cache_file->id, filter_mode); | tmp_items += animfilter_block_data(ac, &tmp_data, ads, &cache_file->id, filter_mode); | ||||
| } | } | ||||
| END_ANIMFILTER_SUBCHANNELS; | END_ANIMFILTER_SUBCHANNELS; | ||||
| /* did we find anything? */ | /* did we find anything? */ | ||||
| if (tmp_items) { | if (tmp_items) { | ||||
| /* include data-expand widget first */ | /* include data-expand widget first */ | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by active status */ | /* check if filtering by active status */ | ||||
| // XXX: active check here needs checking | // XXX: active check here needs checking | ||||
| if (ANIMCHANNEL_ACTIVEOK(cache_file)) { | if (ANIMCHANNEL_ACTIVEOK(cache_file)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(cache_file, ANIMTYPE_DSCACHEFILE, cache_file, NULL); | ANIMCHANNEL_NEW_CHANNEL(cache_file, ANIMTYPE_DSCACHEFILE, cache_file, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Helper for Mask Editing - mask layers */ | /* Helper for Mask Editing - mask layers */ | ||||
| static size_t animdata_filter_mask_data(ListBase *anim_data, Mask *mask, const int filter_mode) | static size_t animdata_filter_mask_data(AnimFilterIterData *iter_data, | ||||
| Mask *mask, | |||||
| const int filter_mode) | |||||
| { | { | ||||
| MaskLayer *masklay_act = BKE_mask_layer_active(mask); | MaskLayer *masklay_act = BKE_mask_layer_active(mask); | ||||
| MaskLayer *masklay; | MaskLayer *masklay; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* loop over layers as the conditions are acceptable */ | /* loop over layers as the conditions are acceptable */ | ||||
| for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { | for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { | ||||
| /* only if selected */ | /* only if selected */ | ||||
| Show All 9 Lines | for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { | ||||
| } | } | ||||
| } | } | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Grab all mask data */ | /* Grab all mask data */ | ||||
| static size_t animdata_filter_mask(Main *bmain, | static size_t animdata_filter_mask(Main *bmain, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| void *UNUSED(data), | void *UNUSED(data), | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| Mask *mask; | Mask *mask; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| AnimFilterIterData tmp_data; | |||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| /* For now, grab mask data-blocks directly from main. */ | /* For now, grab mask data-blocks directly from main. */ | ||||
| // XXX: this is not good... | // XXX: this is not good... | ||||
| for (mask = bmain->masks.first; mask; mask = mask->id.next) { | for (mask = bmain->masks.first; mask; mask = mask->id.next) { | ||||
| ListBase tmp_data = {NULL, NULL}; | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| /* only show if mask is used by something... */ | /* only show if mask is used by something... */ | ||||
| if (ID_REAL_USERS(mask) < 1) { | if (ID_REAL_USERS(mask) < 1) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* add mask animation channels */ | /* add mask animation channels */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_MASK(mask)) { | BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_MASK(mask)) { | ||||
| tmp_items += animdata_filter_mask_data(&tmp_data, mask, filter_mode); | tmp_items += animdata_filter_mask_data(&tmp_data, mask, filter_mode); | ||||
| } | } | ||||
| END_ANIMFILTER_SUBCHANNELS; | END_ANIMFILTER_SUBCHANNELS; | ||||
| /* did we find anything? */ | /* did we find anything? */ | ||||
| if (tmp_items) { | if (tmp_items) { | ||||
| /* include data-expand widget first */ | /* include data-expand widget first */ | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* add mask data-block as channel too (if for drawing, and it has layers) */ | /* add mask data-block as channel too (if for drawing, and it has layers) */ | ||||
| ANIMCHANNEL_NEW_CHANNEL(mask, ANIMTYPE_MASKDATABLOCK, NULL, NULL); | ANIMCHANNEL_NEW_CHANNEL(mask, ANIMTYPE_MASKDATABLOCK, NULL, NULL); | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* NOTE: owner_id is scene, material, or texture block, | /* NOTE: owner_id is scene, material, or texture block, | ||||
| * which is the direct owner of the node tree in question. */ | * which is the direct owner of the node tree in question. */ | ||||
| static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, | static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| ID *owner_id, | ID *owner_id, | ||||
| bNodeTree *ntree, | bNodeTree *ntree, | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* add nodetree animation channels */ | /* add nodetree animation channels */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_NTREE_DATA(ntree)) { | BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_NTREE_DATA(ntree)) { | ||||
| /* animation data filtering */ | /* animation data filtering */ | ||||
| tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ntree, filter_mode); | tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ntree, filter_mode); | ||||
| } | } | ||||
| END_ANIMFILTER_SUBCHANNELS; | END_ANIMFILTER_SUBCHANNELS; | ||||
| /* did we find anything? */ | /* did we find anything? */ | ||||
| if (tmp_items) { | if (tmp_items) { | ||||
| /* include data-expand widget first */ | /* include data-expand widget first */ | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by active status */ | /* check if filtering by active status */ | ||||
| if (ANIMCHANNEL_ACTIVEOK(ntree)) { | if (ANIMCHANNEL_ACTIVEOK(ntree)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(ntree, ANIMTYPE_DSNTREE, owner_id, NULL); | ANIMCHANNEL_NEW_CHANNEL(ntree, ANIMTYPE_DSNTREE, owner_id, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_ds_nodetree(bAnimContext *ac, | static size_t animdata_filter_ds_nodetree(bAnimContext *ac, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| ID *owner_id, | ID *owner_id, | ||||
| bNodeTree *ntree, | bNodeTree *ntree, | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| bNode *node; | bNode *node; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, owner_id, ntree, filter_mode); | items += animdata_filter_ds_nodetree_group(ac, iter_data, ads, owner_id, ntree, filter_mode); | ||||
| for (node = ntree->nodes.first; node; node = node->next) { | for (node = ntree->nodes.first; node; node = node->next) { | ||||
| if (node->type == NODE_GROUP) { | if (node->type == NODE_GROUP) { | ||||
| if (node->id) { | if (node->id) { | ||||
| if ((ads->filterflag & ADS_FILTER_ONLYSEL) && (node->flag & NODE_SELECT) == 0) { | if ((ads->filterflag & ADS_FILTER_ONLYSEL) && (node->flag & NODE_SELECT) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Recurse into the node group */ | /* Recurse into the node group */ | ||||
| items += animdata_filter_ds_nodetree(ac, | items += animdata_filter_ds_nodetree(ac, | ||||
| anim_data, | iter_data, | ||||
| ads, | ads, | ||||
| owner_id, | owner_id, | ||||
| (bNodeTree *)node->id, | (bNodeTree *)node->id, | ||||
| filter_mode | ANIMFILTER_TMP_IGNORE_ONLYSEL); | filter_mode | ANIMFILTER_TMP_IGNORE_ONLYSEL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_ds_linestyle( | static size_t animdata_filter_ds_linestyle( | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) | bAnimContext *ac, AnimFilterIterData *iter_data, bDopeSheet *ads, Scene *sce, int filter_mode) | ||||
| { | { | ||||
| ViewLayer *view_layer; | ViewLayer *view_layer; | ||||
| FreestyleLineSet *lineset; | FreestyleLineSet *lineset; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| AnimFilterIterData tmp_data; | |||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { | for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { | ||||
| for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) { | for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) { | ||||
| if (lineset->linestyle) { | if (lineset->linestyle) { | ||||
| lineset->linestyle->id.tag |= LIB_TAG_DOIT; | lineset->linestyle->id.tag |= LIB_TAG_DOIT; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { | for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { | ||||
| /* skip render layers without Freestyle enabled */ | /* skip render layers without Freestyle enabled */ | ||||
| if ((view_layer->flag & VIEW_LAYER_FREESTYLE) == 0) { | if ((view_layer->flag & VIEW_LAYER_FREESTYLE) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* loop over linesets defined in the render layer */ | /* loop over linesets defined in the render layer */ | ||||
| for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) { | for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) { | ||||
| FreestyleLineStyle *linestyle = lineset->linestyle; | FreestyleLineStyle *linestyle = lineset->linestyle; | ||||
| ListBase tmp_data = {NULL, NULL}; | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| if ((linestyle == NULL) || !(linestyle->id.tag & LIB_TAG_DOIT)) { | if ((linestyle == NULL) || !(linestyle->id.tag & LIB_TAG_DOIT)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| linestyle->id.tag &= ~LIB_TAG_DOIT; | linestyle->id.tag &= ~LIB_TAG_DOIT; | ||||
| /* add scene-level animation channels */ | /* add scene-level animation channels */ | ||||
| Show All 9 Lines | for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) { | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by active status */ | /* check if filtering by active status */ | ||||
| if (ANIMCHANNEL_ACTIVEOK(linestyle)) { | if (ANIMCHANNEL_ACTIVEOK(linestyle)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(linestyle, ANIMTYPE_DSLINESTYLE, sce, NULL); | ANIMCHANNEL_NEW_CHANNEL(linestyle, ANIMTYPE_DSLINESTYLE, sce, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_ds_texture(bAnimContext *ac, | static size_t animdata_filter_ds_texture(bAnimContext *ac, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| Tex *tex, | Tex *tex, | ||||
| ID *owner_id, | ID *owner_id, | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* add texture's animation data to temp collection */ | /* add texture's animation data to temp collection */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_TEX_DATA(tex)) { | BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_TEX_DATA(tex)) { | ||||
| /* texture animdata */ | /* texture animdata */ | ||||
| tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)tex, filter_mode); | tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)tex, filter_mode); | ||||
| Show All 15 Lines | if (tmp_items) { | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by active status */ | /* check if filtering by active status */ | ||||
| if (ANIMCHANNEL_ACTIVEOK(tex)) { | if (ANIMCHANNEL_ACTIVEOK(tex)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(tex, ANIMTYPE_DSTEX, owner_id, NULL); | ANIMCHANNEL_NEW_CHANNEL(tex, ANIMTYPE_DSTEX, owner_id, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* NOTE: owner_id is the direct owner of the texture stack in question | /* NOTE: owner_id is the direct owner of the texture stack in question | ||||
| * It used to be Material/Light/World before the Blender Internal removal for 2.8 | * It used to be Material/Light/World before the Blender Internal removal for 2.8 | ||||
| */ | */ | ||||
| static size_t animdata_filter_ds_textures( | static size_t animdata_filter_ds_textures(bAnimContext *ac, | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode) | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | |||||
| ID *owner_id, | |||||
| int filter_mode) | |||||
| { | { | ||||
| MTex **mtex = NULL; | MTex **mtex = NULL; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| int a = 0; | int a = 0; | ||||
| /* get datatype specific data first */ | /* get datatype specific data first */ | ||||
| if (owner_id == NULL) { | if (owner_id == NULL) { | ||||
| return 0; | return 0; | ||||
| Show All 21 Lines | for (a = 0; a < MAX_MTEX; a++) { | ||||
| Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL; | Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL; | ||||
| /* for now, if no texture returned, skip (this shouldn't confuse the user I hope) */ | /* for now, if no texture returned, skip (this shouldn't confuse the user I hope) */ | ||||
| if (tex == NULL) { | if (tex == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* add texture's anim channels */ | /* add texture's anim channels */ | ||||
| items += animdata_filter_ds_texture(ac, anim_data, ads, tex, owner_id, filter_mode); | items += animdata_filter_ds_texture(ac, iter_data, ads, tex, owner_id, filter_mode); | ||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_ds_material( | static size_t animdata_filter_ds_material(bAnimContext *ac, | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Material *ma, int filter_mode) | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | |||||
| Material *ma, | |||||
| int filter_mode) | |||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* add material's animation data to temp collection */ | /* add material's animation data to temp collection */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_MAT_OBJD(ma)) { | BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_MAT_OBJD(ma)) { | ||||
| /* material's animation data */ | /* material's animation data */ | ||||
| tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode); | tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode); | ||||
| Show All 11 Lines | if (tmp_items) { | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by active status */ | /* check if filtering by active status */ | ||||
| if (ANIMCHANNEL_ACTIVEOK(ma)) { | if (ANIMCHANNEL_ACTIVEOK(ma)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma, NULL); | ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_ds_materials( | static size_t animdata_filter_ds_materials( | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) | bAnimContext *ac, AnimFilterIterData *iter_data, bDopeSheet *ads, Object *ob, int filter_mode) | ||||
| { | { | ||||
| size_t items = 0; | size_t items = 0; | ||||
| int a = 0; | int a = 0; | ||||
| /* First pass: take the materials referenced via the Material slots of the object. */ | /* First pass: take the materials referenced via the Material slots of the object. */ | ||||
| for (a = 1; a <= ob->totcol; a++) { | for (a = 1; a <= ob->totcol; a++) { | ||||
| Material *ma = BKE_object_material_get(ob, a); | Material *ma = BKE_object_material_get(ob, a); | ||||
| /* if material is valid, try to add relevant contents from here */ | /* if material is valid, try to add relevant contents from here */ | ||||
| if (ma) { | if (ma) { | ||||
| /* add channels */ | /* add channels */ | ||||
| items += animdata_filter_ds_material(ac, anim_data, ads, ma, filter_mode); | items += animdata_filter_ds_material(ac, iter_data, ads, ma, filter_mode); | ||||
| } | } | ||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* ............ */ | /* ............ */ | ||||
| /* Temporary context for modifier linked-data channel extraction */ | /* Temporary context for modifier linked-data channel extraction */ | ||||
| typedef struct tAnimFilterModifiersContext { | typedef struct tAnimFilterModifiersContext { | ||||
| bAnimContext *ac; /* anim editor context */ | bAnimContext *ac; /* anim editor context */ | ||||
| bDopeSheet *ads; /* dopesheet filtering settings */ | bDopeSheet *ads; /* dopesheet filtering settings */ | ||||
| ListBase tmp_data; /* list of channels created (but not yet added to the main list) */ | AnimFilterIterData *iter_data; | ||||
| size_t items; /* number of channels created */ | size_t items; /* number of channels created */ | ||||
| int filter_mode; /* flags for stuff we want to filter */ | int filter_mode; /* flags for stuff we want to filter */ | ||||
| } tAnimFilterModifiersContext; | } tAnimFilterModifiersContext; | ||||
| /* dependency walker callback for modifier dependencies */ | /* dependency walker callback for modifier dependencies */ | ||||
| static void animfilter_modifier_idpoin_cb(void *afm_ptr, | static void animfilter_modifier_idpoin_cb(void *afm_ptr, | ||||
| Object *ob, | Object *ob, | ||||
| ID **idpoin, | ID **idpoin, | ||||
| Show All 12 Lines | static void animfilter_modifier_idpoin_cb(void *afm_ptr, | ||||
| /* check if this is something we're interested in... */ | /* check if this is something we're interested in... */ | ||||
| switch (GS(id->name)) { | switch (GS(id->name)) { | ||||
| case ID_TE: /* Textures */ | case ID_TE: /* Textures */ | ||||
| { | { | ||||
| Tex *tex = (Tex *)id; | Tex *tex = (Tex *)id; | ||||
| if (!(afm->ads->filterflag & ADS_FILTER_NOTEX)) { | if (!(afm->ads->filterflag & ADS_FILTER_NOTEX)) { | ||||
| afm->items += animdata_filter_ds_texture( | afm->items += animdata_filter_ds_texture( | ||||
| afm->ac, &afm->tmp_data, afm->ads, tex, owner_id, afm->filter_mode); | afm->ac, afm->iter_data, afm->ads, tex, owner_id, afm->filter_mode); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| /* TODO: images? */ | /* TODO: images? */ | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* animation linked to data used by modifiers | /* animation linked to data used by modifiers | ||||
| * NOTE: strictly speaking, modifier animation is already included under Object level | * NOTE: strictly speaking, modifier animation is already included under Object level | ||||
| * but for some modifiers (e.g. Displace), there can be linked data that has settings | * but for some modifiers (e.g. Displace), there can be linked data that has settings | ||||
| * which would be nice to animate (i.e. texture parameters) but which are not actually | * which would be nice to animate (i.e. texture parameters) but which are not actually | ||||
| * attached to any other objects/materials/etc. in the scene | * attached to any other objects/materials/etc. in the scene | ||||
| */ | */ | ||||
| // TODO: do we want an expander for this? | // TODO: do we want an expander for this? | ||||
| static size_t animdata_filter_ds_modifiers( | static size_t animdata_filter_ds_modifiers( | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) | bAnimContext *ac, AnimFilterIterData *iter_data, bDopeSheet *ads, Object *ob, int filter_mode) | ||||
| { | { | ||||
| tAnimFilterModifiersContext afm = {NULL}; | tAnimFilterModifiersContext afm = {NULL}; | ||||
| size_t items = 0; | |||||
| /* 1) create a temporary "context" containing all the info we have here to pass to the callback | /* 1) create a temporary "context" containing all the info we have here to pass to the callback | ||||
| * use to walk through the dependencies of the modifiers | * use to walk through the dependencies of the modifiers | ||||
| * | * | ||||
| * Assumes that all other unspecified values (i.e. accumulation buffers) | * Assumes that all other unspecified values (i.e. accumulation buffers) | ||||
| * are zero'd out properly! | * are zero'd out properly! | ||||
| */ | */ | ||||
| afm.ac = ac; | afm.ac = ac; | ||||
| afm.ads = ads; | afm.ads = ads; | ||||
| afm.filter_mode = filter_mode; | afm.filter_mode = filter_mode; | ||||
| afm.iter_data = iter_data; | |||||
| /* 2) walk over dependencies */ | /* 2) walk over dependencies */ | ||||
| modifiers_foreachIDLink(ob, animfilter_modifier_idpoin_cb, &afm); | modifiers_foreachIDLink(ob, animfilter_modifier_idpoin_cb, &afm); | ||||
| /* 3) extract data from the context, merging it back into the standard list */ | return afm.items; | ||||
| if (afm.items) { | |||||
| /* now add the list of collected channels */ | |||||
| BLI_movelisttolist(anim_data, &afm.tmp_data); | |||||
| BLI_assert(BLI_listbase_is_empty(&afm.tmp_data)); | |||||
| items += afm.items; | |||||
| } | |||||
| return items; | |||||
| } | } | ||||
| /* ............ */ | /* ............ */ | ||||
| static size_t animdata_filter_ds_particles( | static size_t animdata_filter_ds_particles( | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) | bAnimContext *ac, AnimFilterIterData *iter_data, bDopeSheet *ads, Object *ob, int filter_mode) | ||||
| { | { | ||||
| ParticleSystem *psys; | ParticleSystem *psys; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| for (psys = ob->particlesystem.first; psys; psys = psys->next) { | for (psys = ob->particlesystem.first; psys; psys = psys->next) { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| /* Note that when psys->part->adt is NULL the textures can still be | /* Note that when psys->part->adt is NULL the textures can still be | ||||
| * animated. */ | * animated. */ | ||||
| if (psys->part == NULL) { | if (psys->part == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Show All 16 Lines | if (tmp_items) { | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by active status */ | /* check if filtering by active status */ | ||||
| if (ANIMCHANNEL_ACTIVEOK(psys->part)) { | if (ANIMCHANNEL_ACTIVEOK(psys->part)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(psys->part, ANIMTYPE_DSPART, psys->part, NULL); | ANIMCHANNEL_NEW_CHANNEL(psys->part, ANIMTYPE_DSPART, psys->part, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_ds_obdata( | static size_t animdata_filter_ds_obdata( | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) | bAnimContext *ac, AnimFilterIterData *iter_data, bDopeSheet *ads, Object *ob, int filter_mode) | ||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| IdAdtTemplate *iat = ob->data; | IdAdtTemplate *iat = ob->data; | ||||
| short type = 0, expanded = 0; | short type = 0, expanded = 0; | ||||
| /* get settings based on data type */ | /* get settings based on data type */ | ||||
| switch (ob->type) { | switch (ob->type) { | ||||
| ▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | if (tmp_items) { | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by active status */ | /* check if filtering by active status */ | ||||
| if (ANIMCHANNEL_ACTIVEOK(iat)) { | if (ANIMCHANNEL_ACTIVEOK(iat)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(iat, type, iat, NULL); | ANIMCHANNEL_NEW_CHANNEL(iat, type, iat, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* shapekey-level animation */ | /* shapekey-level animation */ | ||||
| static size_t animdata_filter_ds_keyanim( | static size_t animdata_filter_ds_keyanim(bAnimContext *ac, | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, Key *key, int filter_mode) | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | |||||
| Object *ob, | |||||
| Key *key, | |||||
| int filter_mode) | |||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* add shapekey-level animation channels */ | /* add shapekey-level animation channels */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_SKE_OBJD(key)) { | BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_SKE_OBJD(key)) { | ||||
| /* animation data filtering */ | /* animation data filtering */ | ||||
| tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)key, filter_mode); | tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)key, filter_mode); | ||||
| } | } | ||||
| END_ANIMFILTER_SUBCHANNELS; | END_ANIMFILTER_SUBCHANNELS; | ||||
| /* did we find anything? */ | /* did we find anything? */ | ||||
| if (tmp_items) { | if (tmp_items) { | ||||
| /* include key-expand widget first */ | /* include key-expand widget first */ | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| if (ANIMCHANNEL_ACTIVEOK(key)) { | if (ANIMCHANNEL_ACTIVEOK(key)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(key, ANIMTYPE_DSSKEY, ob, NULL); | ANIMCHANNEL_NEW_CHANNEL(key, ANIMTYPE_DSSKEY, ob, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* object-level animation */ | /* object-level animation */ | ||||
| static size_t animdata_filter_ds_obanim( | static size_t animdata_filter_ds_obanim( | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) | bAnimContext *ac, AnimFilterIterData *iter_data, bDopeSheet *ads, Object *ob, int filter_mode) | ||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| AnimData *adt = ob->adt; | AnimData *adt = ob->adt; | ||||
| short type = 0, expanded = 1; | short type = 0, expanded = 1; | ||||
| void *cdata = NULL; | void *cdata = NULL; | ||||
| animdata_filter_iter_data_increase_level(iter_data); | |||||
| /* include anim-expand widget first */ | |||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | |||||
| if (type != ANIMTYPE_NONE) { | |||||
| /* NOTE: active-status (and the associated checks) don't apply here... */ | |||||
| animdata_filter_iter_data_set_parent(iter_data, cdata, type, (ID *)ob, NULL); | |||||
| } | |||||
| } | |||||
| /* determine the type of expander channels to use */ | /* determine the type of expander channels to use */ | ||||
| /* this is the best way to do this for now... */ | /* this is the best way to do this for now... */ | ||||
| ANIMDATA_FILTER_CASES( | ANIMDATA_FILTER_CASES( | ||||
| ob, /* Some useless long comment to prevent wrapping by old clang-format versions... */ | ob, /* Some useless long comment to prevent wrapping by old clang-format versions... */ | ||||
| {/* AnimData - no channel, but consider data */}, | {/* AnimData - no channel, but consider data */}, | ||||
| {/* NLA - no channel, but consider data */}, | {/* NLA - no channel, but consider data */}, | ||||
| { /* Drivers */ | { /* Drivers */ | ||||
| type = ANIMTYPE_FILLDRIVERS; | type = ANIMTYPE_FILLDRIVERS; | ||||
| cdata = adt; | cdata = adt; | ||||
| expanded = EXPANDED_DRVD(adt); | expanded = EXPANDED_DRVD(adt); | ||||
| }, | }, | ||||
| {/* NLA Strip Controls - no dedicated channel for now (XXX) */}, | {/* NLA Strip Controls - no dedicated channel for now (XXX) */}, | ||||
| { /* Keyframes */ | { /* Keyframes */ | ||||
| type = ANIMTYPE_FILLACTD; | type = ANIMTYPE_FILLACTD; | ||||
| cdata = adt->action; | cdata = adt->action; | ||||
| expanded = EXPANDED_ACTC(adt->action); | expanded = EXPANDED_ACTC(adt->action); | ||||
| }); | }); | ||||
| /* add object-level animation channels */ | /* add object-level animation channels */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (expanded) { | BEGIN_ANIMFILTER_SUBCHANNELS (expanded) { | ||||
| /* animation data filtering */ | /* animation data filtering */ | ||||
| tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ob, filter_mode); | tmp_items += animfilter_block_data(ac, iter_data, ads, (ID *)ob, filter_mode); | ||||
| } | } | ||||
| END_ANIMFILTER_SUBCHANNELS; | END_ANIMFILTER_SUBCHANNELS; | ||||
| /* did we find anything? */ | animdata_filter_iter_data_decrease_level(iter_data); | ||||
| if (tmp_items) { | |||||
| /* include anim-expand widget first */ | |||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | |||||
| if (type != ANIMTYPE_NONE) { | |||||
| /* NOTE: active-status (and the associated checks) don't apply here... */ | |||||
| ANIMCHANNEL_NEW_CHANNEL(cdata, type, ob, NULL); | |||||
| } | |||||
| } | |||||
| /* now add the list of collected channels */ | |||||
| BLI_movelisttolist(anim_data, &tmp_data); | |||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | |||||
| items += tmp_items; | |||||
| } | |||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* get animation channels from object2 */ | /* get animation channels from object2 */ | ||||
| static size_t animdata_filter_dopesheet_ob( | static size_t animdata_filter_dopesheet_ob( | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode) | bAnimContext *ac, AnimFilterIterData *iter_data, bDopeSheet *ads, Base *base, int filter_mode) | ||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | |||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| size_t tmp_items = 0; | |||||
| size_t items = 0; | size_t items = 0; | ||||
| animdata_filter_iter_data_increase_level(iter_data); | |||||
| /* firstly add object expander if required */ | |||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | |||||
| /* check if filtering by selection */ | |||||
| /* XXX: double-check on this - | |||||
| * most of the time, a lot of tools need to filter out these channels! */ | |||||
| if (ANIMCHANNEL_SELOK((base->flag & BASE_SELECTED))) { | |||||
| /* check if filtering by active status */ | |||||
| if (ANIMCHANNEL_ACTIVEOK(ob)) { | |||||
| animdata_filter_iter_data_set_parent(iter_data, base, ANIMTYPE_OBJECT, (ID *)ob, NULL); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* filter data contained under object first */ | /* filter data contained under object first */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_OBJC(ob)) { | BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_OBJC(ob)) { | ||||
| Key *key = BKE_key_from_object(ob); | Key *key = BKE_key_from_object(ob); | ||||
| /* object-level animation */ | /* object-level animation */ | ||||
| if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) { | if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) { | ||||
| tmp_items += animdata_filter_ds_obanim(ac, &tmp_data, ads, ob, filter_mode); | items += animdata_filter_ds_obanim(ac, iter_data, ads, ob, filter_mode); | ||||
| } | } | ||||
| /* particle deflector textures */ | /* particle deflector textures */ | ||||
| if (ob->pd != NULL && ob->pd->tex != NULL && !(ads->filterflag & ADS_FILTER_NOTEX)) { | if (ob->pd != NULL && ob->pd->tex != NULL && !(ads->filterflag & ADS_FILTER_NOTEX)) { | ||||
| tmp_items += animdata_filter_ds_texture( | items += animdata_filter_ds_texture(ac, iter_data, ads, ob->pd->tex, &ob->id, filter_mode); | ||||
| ac, &tmp_data, ads, ob->pd->tex, &ob->id, filter_mode); | |||||
| } | } | ||||
| /* shape-key */ | /* shape-key */ | ||||
| if ((key && key->adt) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) { | if ((key && key->adt) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) { | ||||
| tmp_items += animdata_filter_ds_keyanim(ac, &tmp_data, ads, ob, key, filter_mode); | items += animdata_filter_ds_keyanim(ac, iter_data, ads, ob, key, filter_mode); | ||||
| } | } | ||||
| /* modifiers */ | /* modifiers */ | ||||
| if ((ob->modifiers.first) && !(ads->filterflag & ADS_FILTER_NOMODIFIERS)) { | if ((ob->modifiers.first) && !(ads->filterflag & ADS_FILTER_NOMODIFIERS)) { | ||||
| tmp_items += animdata_filter_ds_modifiers(ac, &tmp_data, ads, ob, filter_mode); | items += animdata_filter_ds_modifiers(ac, iter_data, ads, ob, filter_mode); | ||||
| } | } | ||||
| /* materials */ | /* materials */ | ||||
| if ((ob->totcol) && !(ads->filterflag & ADS_FILTER_NOMAT)) { | if ((ob->totcol) && !(ads->filterflag & ADS_FILTER_NOMAT)) { | ||||
| tmp_items += animdata_filter_ds_materials(ac, &tmp_data, ads, ob, filter_mode); | items += animdata_filter_ds_materials(ac, iter_data, ads, ob, filter_mode); | ||||
| } | } | ||||
| /* object data */ | /* object data */ | ||||
| if (ob->data) { | if (ob->data) { | ||||
| tmp_items += animdata_filter_ds_obdata(ac, &tmp_data, ads, ob, filter_mode); | items += animdata_filter_ds_obdata(ac, iter_data, ads, ob, filter_mode); | ||||
| } | } | ||||
| /* particles */ | /* particles */ | ||||
| if ((ob->particlesystem.first) && !(ads->filterflag & ADS_FILTER_NOPART)) { | if ((ob->particlesystem.first) && !(ads->filterflag & ADS_FILTER_NOPART)) { | ||||
| tmp_items += animdata_filter_ds_particles(ac, &tmp_data, ads, ob, filter_mode); | items += animdata_filter_ds_particles(ac, iter_data, ads, ob, filter_mode); | ||||
| } | } | ||||
| /* grease pencil */ | /* grease pencil */ | ||||
| if ((ob->type == OB_GPENCIL) && (ob->data) && !(ads->filterflag & ADS_FILTER_NOGPENCIL)) { | if ((ob->type == OB_GPENCIL) && (ob->data) && !(ads->filterflag & ADS_FILTER_NOGPENCIL)) { | ||||
| tmp_items += animdata_filter_ds_gpencil(ac, &tmp_data, ads, ob->data, filter_mode); | items += animdata_filter_ds_gpencil(ac, iter_data, ads, ob->data, filter_mode); | ||||
| } | } | ||||
| } | } | ||||
| END_ANIMFILTER_SUBCHANNELS; | END_ANIMFILTER_SUBCHANNELS; | ||||
| /* if we collected some channels, add these to the new list... */ | animdata_filter_iter_data_decrease_level(iter_data); | ||||
| if (tmp_items) { | |||||
| /* firstly add object expander if required */ | |||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | |||||
| /* check if filtering by selection */ | |||||
| /* XXX: double-check on this - | |||||
| * most of the time, a lot of tools need to filter out these channels! */ | |||||
| if (ANIMCHANNEL_SELOK((base->flag & BASE_SELECTED))) { | |||||
| /* check if filtering by active status */ | |||||
| if (ANIMCHANNEL_ACTIVEOK(ob)) { | |||||
| ANIMCHANNEL_NEW_CHANNEL(base, ANIMTYPE_OBJECT, ob, NULL); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* now add the list of collected channels */ | |||||
| BLI_movelisttolist(anim_data, &tmp_data); | |||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | |||||
| items += tmp_items; | |||||
| } | |||||
| /* return the number of items added */ | /* return the number of items added */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_ds_world( | static size_t animdata_filter_ds_world(bAnimContext *ac, | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, World *wo, int filter_mode) | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | |||||
| Scene *sce, | |||||
| World *wo, | |||||
| int filter_mode) | |||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* add world animation channels */ | /* add world animation channels */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_WOR_SCED(wo)) { | BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_WOR_SCED(wo)) { | ||||
| /* animation data filtering */ | /* animation data filtering */ | ||||
| tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)wo, filter_mode); | tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)wo, filter_mode); | ||||
| Show All 11 Lines | if (tmp_items) { | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by active status */ | /* check if filtering by active status */ | ||||
| if (ANIMCHANNEL_ACTIVEOK(wo)) { | if (ANIMCHANNEL_ACTIVEOK(wo)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(wo, ANIMTYPE_DSWOR, sce, NULL); | ANIMCHANNEL_NEW_CHANNEL(wo, ANIMTYPE_DSWOR, sce, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_ds_scene( | static size_t animdata_filter_ds_scene( | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) | bAnimContext *ac, AnimFilterIterData *iter_data, bDopeSheet *ads, Scene *sce, int filter_mode) | ||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| AnimData *adt = sce->adt; | AnimData *adt = sce->adt; | ||||
| short type = 0, expanded = 1; | short type = 0, expanded = 1; | ||||
| void *cdata = NULL; | void *cdata = NULL; | ||||
| /* determine the type of expander channels to use */ | /* determine the type of expander channels to use */ | ||||
| Show All 27 Lines | if (tmp_items) { | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| if (type != ANIMTYPE_NONE) { | if (type != ANIMTYPE_NONE) { | ||||
| /* NOTE: active-status (and the associated checks) don't apply here... */ | /* NOTE: active-status (and the associated checks) don't apply here... */ | ||||
| ANIMCHANNEL_NEW_CHANNEL(cdata, type, sce, NULL); | ANIMCHANNEL_NEW_CHANNEL(cdata, type, sce, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_dopesheet_scene( | static size_t animdata_filter_dopesheet_scene( | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) | bAnimContext *ac, AnimFilterIterData *iter_data, bDopeSheet *ads, Scene *sce, int filter_mode) | ||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* filter data contained under object first */ | /* filter data contained under object first */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_SCEC(sce)) { | BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_SCEC(sce)) { | ||||
| bNodeTree *ntree = sce->nodetree; | bNodeTree *ntree = sce->nodetree; | ||||
| bGPdata *gpd = sce->gpd; | bGPdata *gpd = sce->gpd; | ||||
| World *wo = sce->world; | World *wo = sce->world; | ||||
| Show All 35 Lines | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by selection */ | /* check if filtering by selection */ | ||||
| if (ANIMCHANNEL_SELOK((sce->flag & SCE_DS_SELECTED))) { | if (ANIMCHANNEL_SELOK((sce->flag & SCE_DS_SELECTED))) { | ||||
| /* NOTE: active-status doesn't matter for this! */ | /* NOTE: active-status doesn't matter for this! */ | ||||
| ANIMCHANNEL_NEW_CHANNEL(sce, ANIMTYPE_SCENE, sce, NULL); | ANIMCHANNEL_NEW_CHANNEL(sce, ANIMTYPE_SCENE, sce, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added */ | /* return the number of items added */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_ds_movieclip( | static size_t animdata_filter_ds_movieclip(bAnimContext *ac, | ||||
| bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, MovieClip *clip, int filter_mode) | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | |||||
| MovieClip *clip, | |||||
| int filter_mode) | |||||
| { | { | ||||
| ListBase tmp_data = {NULL, NULL}; | AnimFilterIterData tmp_data; | ||||
| ListBase tmp_list = {NULL, NULL}; | |||||
| animdata_filter_iter_data_copy(&tmp_data, iter_data, animdata_filter_listbase_cb, &tmp_list); | |||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* add world animation channels */ | /* add world animation channels */ | ||||
| BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_MCLIP(clip)) { | BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_MCLIP(clip)) { | ||||
| /* animation data filtering */ | /* animation data filtering */ | ||||
| tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)clip, filter_mode); | tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)clip, filter_mode); | ||||
| } | } | ||||
| END_ANIMFILTER_SUBCHANNELS; | END_ANIMFILTER_SUBCHANNELS; | ||||
| /* did we find anything? */ | /* did we find anything? */ | ||||
| if (tmp_items) { | if (tmp_items) { | ||||
| /* include data-expand widget first */ | /* include data-expand widget first */ | ||||
| if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | if (filter_mode & ANIMFILTER_LIST_CHANNELS) { | ||||
| /* check if filtering by active status */ | /* check if filtering by active status */ | ||||
| if (ANIMCHANNEL_ACTIVEOK(clip)) { | if (ANIMCHANNEL_ACTIVEOK(clip)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(clip, ANIMTYPE_DSMCLIP, clip, NULL); | ANIMCHANNEL_NEW_CHANNEL(clip, ANIMTYPE_DSMCLIP, clip, NULL); | ||||
| } | } | ||||
| } | } | ||||
| /* now add the list of collected channels */ | /* now add the list of collected channels */ | ||||
| BLI_movelisttolist(anim_data, &tmp_data); | items += animdata_filter_iter_move_list(iter_data, &tmp_list); | ||||
| BLI_assert(BLI_listbase_is_empty(&tmp_data)); | BLI_assert(BLI_listbase_is_empty(&tmp_list)); | ||||
| items += tmp_items; | |||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_dopesheet_movieclips(bAnimContext *ac, | static size_t animdata_filter_dopesheet_movieclips(bAnimContext *ac, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| size_t items = 0; | size_t items = 0; | ||||
| MovieClip *clip; | MovieClip *clip; | ||||
| for (clip = ac->bmain->movieclips.first; clip != NULL; clip = clip->id.next) { | for (clip = ac->bmain->movieclips.first; clip != NULL; clip = clip->id.next) { | ||||
| /* only show if gpd is used by something... */ | /* only show if gpd is used by something... */ | ||||
| if (ID_REAL_USERS(clip) < 1) { | if (ID_REAL_USERS(clip) < 1) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| items += animdata_filter_ds_movieclip(ac, anim_data, ads, clip, filter_mode); | items += animdata_filter_ds_movieclip(ac, iter_data, ads, clip, filter_mode); | ||||
| } | } | ||||
| /* return the number of items added to the list */ | /* return the number of items added to the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Helper for animdata_filter_dopesheet() - For checking if an object should be included or not */ | /* Helper for animdata_filter_dopesheet() - For checking if an object should be included or not | ||||
| */ | |||||
| static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_mode) | static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_mode) | ||||
| { | { | ||||
| Object *ob = base->object; | Object *ob = base->object; | ||||
| if (base->object == NULL) { | if (base->object == NULL) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads, | ||||
| *r_usable_bases = num_bases; | *r_usable_bases = num_bases; | ||||
| return sorted_bases; | return sorted_bases; | ||||
| } | } | ||||
| // TODO: implement pinning... | // TODO: implement pinning... | ||||
| // (if and when pinning is done, what we need to do is to provide freeing mechanisms - | // (if and when pinning is done, what we need to do is to provide freeing mechanisms - | ||||
| // to protect against data that was deleted). | // to protect against data that was deleted). | ||||
| static size_t animdata_filter_dopesheet(bAnimContext *ac, | static size_t animdata_filter_dopesheet(bAnimContext *ac, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| Scene *scene = (Scene *)ads->source; | Scene *scene = (Scene *)ads->source; | ||||
| ViewLayer *view_layer = (ViewLayer *)ac->view_layer; | ViewLayer *view_layer = (ViewLayer *)ac->view_layer; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* check that we do indeed have a scene */ | /* check that we do indeed have a scene */ | ||||
| Show All 14 Lines | if (ads->filterflag & ADS_FILTER_SELEDIT) { | ||||
| /* only selected F-Curves should get their keyframes considered for editability */ | /* only selected F-Curves should get their keyframes considered for editability */ | ||||
| filter_mode |= ANIMFILTER_SELEDIT; | filter_mode |= ANIMFILTER_SELEDIT; | ||||
| } | } | ||||
| /* Cache files level animations (frame duration and such). */ | /* Cache files level animations (frame duration and such). */ | ||||
| if (!(ads->filterflag2 & ADS_FILTER_NOCACHEFILES) && !(ads->filterflag & ADS_FILTER_ONLYSEL)) { | if (!(ads->filterflag2 & ADS_FILTER_NOCACHEFILES) && !(ads->filterflag & ADS_FILTER_ONLYSEL)) { | ||||
| CacheFile *cache_file = ac->bmain->cachefiles.first; | CacheFile *cache_file = ac->bmain->cachefiles.first; | ||||
| for (; cache_file; cache_file = cache_file->id.next) { | for (; cache_file; cache_file = cache_file->id.next) { | ||||
| items += animdata_filter_ds_cachefile(ac, anim_data, ads, cache_file, filter_mode); | items += animdata_filter_ds_cachefile(ac, iter_data, ads, cache_file, filter_mode); | ||||
| } | } | ||||
| } | } | ||||
| /* movie clip's animation */ | /* movie clip's animation */ | ||||
| if (!(ads->filterflag2 & ADS_FILTER_NOMOVIECLIPS) && !(ads->filterflag & ADS_FILTER_ONLYSEL)) { | if (!(ads->filterflag2 & ADS_FILTER_NOMOVIECLIPS) && !(ads->filterflag & ADS_FILTER_ONLYSEL)) { | ||||
| items += animdata_filter_dopesheet_movieclips(ac, anim_data, ads, filter_mode); | items += animdata_filter_dopesheet_movieclips(ac, iter_data, ads, filter_mode); | ||||
| } | } | ||||
| /* Scene-linked animation - e.g. world, compositing nodes, scene anim | /* Scene-linked animation - e.g. world, compositing nodes, scene anim | ||||
| * (including sequencer currently). */ | * (including sequencer currently). */ | ||||
| items += animdata_filter_dopesheet_scene(ac, anim_data, ads, scene, filter_mode); | items += animdata_filter_dopesheet_scene(ac, iter_data, ads, scene, filter_mode); | ||||
| /* If filtering for channel drawing, we want the objects in alphabetical order, | /* If filtering for channel drawing, we want the objects in alphabetical order, | ||||
| * to make it easier to predict where items are in the hierarchy | * to make it easier to predict where items are in the hierarchy | ||||
| * - This order only really matters | * - This order only really matters | ||||
| * if we need to show all channels in the list (e.g. for drawing). | * if we need to show all channels in the list (e.g. for drawing). | ||||
| * (XXX: What about lingering "active" flags? The order may now become unpredictable) | * (XXX: What about lingering "active" flags? The order may now become unpredictable) | ||||
| * - Don't do this if this behavior has been turned off (i.e. due to it being too slow) | * - Don't do this if this behavior has been turned off (i.e. due to it being too slow) | ||||
| * - Don't do this if there's just a single object | * - Don't do this if there's just a single object | ||||
| */ | */ | ||||
| if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && !(ads->flag & ADS_FLAG_NO_DB_SORT) && | if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && !(ads->flag & ADS_FLAG_NO_DB_SORT) && | ||||
| (view_layer->object_bases.first != view_layer->object_bases.last)) { | (view_layer->object_bases.first != view_layer->object_bases.last)) { | ||||
| /* Filter list of bases (i.e. objects), sort them, then add their contents normally... */ | /* Filter list of bases (i.e. objects), sort them, then add their contents normally... */ | ||||
| // TODO: Cache the old sorted order - if the set of bases hasn't changed, don't re-sort... | // TODO: Cache the old sorted order - if the set of bases hasn't changed, don't re-sort... | ||||
| Base **sorted_bases; | Base **sorted_bases; | ||||
| size_t num_bases; | size_t num_bases; | ||||
| sorted_bases = animdata_filter_ds_sorted_bases(ads, view_layer, filter_mode, &num_bases); | sorted_bases = animdata_filter_ds_sorted_bases(ads, view_layer, filter_mode, &num_bases); | ||||
| if (sorted_bases) { | if (sorted_bases) { | ||||
| /* Add the necessary channels for these bases... */ | /* Add the necessary channels for these bases... */ | ||||
| for (size_t i = 0; i < num_bases; i++) { | for (size_t i = 0; i < num_bases; i++) { | ||||
| items += animdata_filter_dopesheet_ob(ac, anim_data, ads, sorted_bases[i], filter_mode); | items += animdata_filter_dopesheet_ob(ac, iter_data, ads, sorted_bases[i], filter_mode); | ||||
| } | } | ||||
| // TODO: store something to validate whether any changes are needed? | // TODO: store something to validate whether any changes are needed? | ||||
| /* free temporary data */ | /* free temporary data */ | ||||
| MEM_freeN(sorted_bases); | MEM_freeN(sorted_bases); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Filter and add contents of each base (i.e. object) without them sorting first | /* Filter and add contents of each base (i.e. object) without them sorting first | ||||
| * NOTE: This saves performance in cases where order doesn't matter | * NOTE: This saves performance in cases where order doesn't matter | ||||
| */ | */ | ||||
| for (Base *base = view_layer->object_bases.first; base; base = base->next) { | for (Base *base = view_layer->object_bases.first; base; base = base->next) { | ||||
| if (animdata_filter_base_is_ok(ads, base, filter_mode)) { | if (animdata_filter_base_is_ok(ads, base, filter_mode)) { | ||||
| /* since we're still here, this object should be usable */ | /* since we're still here, this object should be usable */ | ||||
| items += animdata_filter_dopesheet_ob(ac, anim_data, ads, base, filter_mode); | items += animdata_filter_dopesheet_ob(ac, iter_data, ads, base, filter_mode); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* return the number of items in the list */ | /* return the number of items in the list */ | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* Summary track for DopeSheet/Action Editor | /* Summary track for DopeSheet/Action Editor | ||||
| * - return code is whether the summary lets the other channels get drawn | * - return code is whether the summary lets the other channels get drawn | ||||
| */ | */ | ||||
| static short animdata_filter_dopesheet_summary(bAnimContext *ac, | static short animdata_filter_dopesheet_summary(bAnimContext *ac, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| int filter_mode, | int filter_mode, | ||||
| size_t *items) | size_t *items) | ||||
| { | { | ||||
| bDopeSheet *ads = NULL; | bDopeSheet *ads = NULL; | ||||
| /* get the DopeSheet information to use | /* get the DopeSheet information to use | ||||
| * - we should only need to deal with the DopeSheet/Action Editor, | * - we should only need to deal with the DopeSheet/Action Editor, | ||||
| * since all the other Animation Editors won't have this concept | * since all the other Animation Editors won't have this concept | ||||
| * being applicable. | * being applicable. | ||||
| */ | */ | ||||
| if ((ac && ac->sl) && (ac->spacetype == SPACE_ACTION)) { | if ((ac && ac->sl) && (ac->spacetype == SPACE_ACTION)) { | ||||
| SpaceAction *saction = (SpaceAction *)ac->sl; | SpaceAction *saction = (SpaceAction *)ac->sl; | ||||
| ads = &saction->ads; | ads = &saction->ads; | ||||
| } | } | ||||
| else { | else { | ||||
| /* invalid space type - skip this summary channels */ | /* invalid space type - skip this summary channels */ | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| /* dopesheet summary | /* dopesheet summary | ||||
| * - only for drawing and/or selecting keyframes in channels, but not for real editing | * - only for drawing and/or selecting keyframes in channels, but not for real editing | ||||
| * - only useful for DopeSheet/Action/etc. editors where it is actually useful | * - only useful for DopeSheet/Action/etc. editors where it is actually useful | ||||
| */ | */ | ||||
| if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && (ads->filterflag & ADS_FILTER_SUMMARY)) { | if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && (ads->filterflag & ADS_FILTER_SUMMARY)) { | ||||
| bAnimListElem *ale = make_new_animlistelem(ac, ANIMTYPE_SUMMARY, NULL, NULL); | animlistelem_init( | ||||
| if (ale) { | animdata_filter_iter_data_get_ale(iter_data), ac, ANIMTYPE_SUMMARY, NULL, NULL); | ||||
| BLI_addtail(anim_data, ale); | *items += animdata_filter_iter_add(iter_data); | ||||
| (*items)++; | |||||
| } | |||||
| /* If summary is collapsed, don't show other channels beneath this - this check is put inside | /* If summary is collapsed, don't show other channels beneath this - this check is put inside | ||||
| * the summary check so that it doesn't interfere with normal operation. | * the summary check so that it doesn't interfere with normal operation. | ||||
| */ | */ | ||||
| if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED) { | if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| /* the other channels beneath this can be shown */ | /* the other channels beneath this can be shown */ | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| /* ......................... */ | /* ......................... */ | ||||
| /* filter data associated with a channel - usually for handling summary-channels in DopeSheet */ | /* filter data associated with a channel - usually for handling summary-channels in DopeSheet */ | ||||
| static size_t animdata_filter_animchan(bAnimContext *ac, | static size_t animdata_filter_animchan(bAnimContext *ac, | ||||
| ListBase *anim_data, | AnimFilterIterData *iter_data, | ||||
| bDopeSheet *ads, | bDopeSheet *ads, | ||||
| bAnimListElem *channel, | bAnimListElem *channel, | ||||
| int filter_mode) | int filter_mode) | ||||
| { | { | ||||
| size_t items = 0; | size_t items = 0; | ||||
| /* data to filter depends on channel type */ | /* data to filter depends on channel type */ | ||||
| /* NOTE: only common channel-types have been handled for now. More can be added as necessary */ | /* NOTE: only common channel-types have been handled for now. More can be added as necessary */ | ||||
| switch (channel->type) { | switch (channel->type) { | ||||
| case ANIMTYPE_SUMMARY: | case ANIMTYPE_SUMMARY: | ||||
| items += animdata_filter_dopesheet(ac, anim_data, ads, filter_mode); | items += animdata_filter_dopesheet(ac, iter_data, ads, filter_mode); | ||||
| break; | break; | ||||
| case ANIMTYPE_SCENE: | case ANIMTYPE_SCENE: | ||||
| items += animdata_filter_dopesheet_scene(ac, anim_data, ads, channel->data, filter_mode); | items += animdata_filter_dopesheet_scene(ac, iter_data, ads, channel->data, filter_mode); | ||||
| break; | break; | ||||
| case ANIMTYPE_OBJECT: | case ANIMTYPE_OBJECT: | ||||
| items += animdata_filter_dopesheet_ob(ac, anim_data, ads, channel->data, filter_mode); | items += animdata_filter_dopesheet_ob(ac, iter_data, ads, channel->data, filter_mode); | ||||
| break; | break; | ||||
| case ANIMTYPE_DSCACHEFILE: | case ANIMTYPE_DSCACHEFILE: | ||||
| items += animdata_filter_ds_cachefile(ac, anim_data, ads, channel->data, filter_mode); | items += animdata_filter_ds_cachefile(ac, iter_data, ads, channel->data, filter_mode); | ||||
| break; | break; | ||||
| case ANIMTYPE_ANIMDATA: | case ANIMTYPE_ANIMDATA: | ||||
| items += animfilter_block_data(ac, anim_data, ads, channel->id, filter_mode); | items += animfilter_block_data(ac, iter_data, ads, channel->id, filter_mode); | ||||
| break; | break; | ||||
| default: | default: | ||||
| printf("ERROR: Unsupported channel type (%d) in animdata_filter_animchan()\n", | printf("ERROR: Unsupported channel type (%d) in animdata_filter_animchan()\n", | ||||
| channel->type); | channel->type); | ||||
| break; | break; | ||||
| } | } | ||||
| return items; | return items; | ||||
| } | } | ||||
| /* ----------- Cleanup API --------------- */ | |||||
| /* Remove entries with invalid types in animation channel list */ | |||||
| static size_t animdata_filter_remove_invalid(ListBase *anim_data) | |||||
| { | |||||
| bAnimListElem *ale, *next; | |||||
| size_t items = 0; | |||||
| /* only keep entries with valid types */ | |||||
| for (ale = anim_data->first; ale; ale = next) { | |||||
| next = ale->next; | |||||
| if (ale->type == ANIMTYPE_NONE) { | |||||
| BLI_freelinkN(anim_data, ale); | |||||
| } | |||||
| else { | |||||
| items++; | |||||
| } | |||||
| } | |||||
| return items; | |||||
| } | |||||
| /* Remove duplicate entries in animation channel list */ | |||||
| static size_t animdata_filter_remove_duplis(ListBase *anim_data) | |||||
| { | |||||
| bAnimListElem *ale, *next; | |||||
| GSet *gs; | |||||
| size_t items = 0; | |||||
| /* build new hashtable to efficiently store and retrieve which entries have been | |||||
| * encountered already while searching | |||||
| */ | |||||
| gs = BLI_gset_ptr_new(__func__); | |||||
| /* loop through items, removing them from the list if a similar item occurs already */ | |||||
| for (ale = anim_data->first; ale; ale = next) { | |||||
| next = ale->next; | |||||
| /* check if hash has any record of an entry like this | |||||
| * - just use ale->data for now, though it would be nicer to involve | |||||
| * ale->type in combination too to capture corner cases | |||||
| * (where same data performs differently) | |||||
| */ | |||||
| if (BLI_gset_add(gs, ale->data)) { | |||||
| /* this entry is 'unique' and can be kept */ | |||||
| items++; | |||||
| } | |||||
| else { | |||||
| /* this entry isn't needed anymore */ | |||||
| BLI_freelinkN(anim_data, ale); | |||||
| } | |||||
| } | |||||
| /* free the hash... */ | |||||
| BLI_gset_free(gs, NULL); | |||||
| /* return the number of items still in the list */ | |||||
| return items; | |||||
| } | |||||
| /* ----------- Public API --------------- */ | /* ----------- Public API --------------- */ | ||||
| /* This function filters the active data source to leave only animation channels suitable for | /* This function filters the active data source to leave only animation channels suitable for | ||||
| * usage by the caller. It will return the length of the list | * usage by the caller. It will return the length of the list | ||||
| * | * | ||||
| * *anim_data: is a pointer to a ListBase, to which the filtered animation channels | * *anim_data: is a pointer to a ListBase, to which the filtered animation channels | ||||
| * will be placed for use. | * will be placed for use. | ||||
| * filter_mode: how should the data be filtered - bitmapping accessed flags | * filter_mode: how should the data be filtered - bitmapping accessed flags | ||||
| */ | */ | ||||
| size_t ANIM_animdata_filter(bAnimContext *ac, | size_t ANIM_animdata_filter(bAnimContext *ac, | ||||
| ListBase *anim_data, | ListBase *anim_data, | ||||
| eAnimFilter_Flags filter_mode, | eAnimFilter_Flags filter_mode, | ||||
| void *data, | void *data, | ||||
| eAnimCont_Types datatype) | eAnimCont_Types datatype) | ||||
| { | { | ||||
| size_t items = 0; | if (!anim_data) { | ||||
| return 0; | |||||
| } | |||||
| BLI_assert(BLI_listbase_is_empty(anim_data)); | |||||
| return ANIM_animdata_filter_iter( | |||||
| ac, filter_mode, data, datatype, animdata_filter_listbase_cb, anim_data); | |||||
| } | |||||
| size_t ANIM_animdata_filter_iter(bAnimContext *ac, | |||||
| eAnimFilter_Flags filter_mode, | |||||
| void *data, | |||||
| eAnimCont_Types datatype, | |||||
| animdata_filter_cb_t animdata_filter_cb, | |||||
| void *user_data_cb) | |||||
| { | |||||
| // TODO(jbakker) phase out items, isn't a bool enough? | |||||
| size_t items; | |||||
| /* only filter data if there's somewhere to put it */ | /* only filter data if there's somewhere to put it */ | ||||
| if (data && anim_data) { | if (data) { | ||||
| AnimFilterIterData user_data_template; | |||||
| AnimFilterIterData *iter_data = &user_data_template; | |||||
| animdata_filter_iter_data_init(iter_data, filter_mode, animdata_filter_cb, user_data_cb); | |||||
| /* firstly filter the data */ | /* firstly filter the data */ | ||||
| switch (datatype) { | switch (datatype) { | ||||
| /* Action-Editing Modes */ | /* Action-Editing Modes */ | ||||
| case ANIMCONT_ACTION: /* 'Action Editor' */ | case ANIMCONT_ACTION: /* 'Action Editor' */ | ||||
| { | { | ||||
| Object *obact = ac->obact; | Object *obact = ac->obact; | ||||
| SpaceAction *saction = (SpaceAction *)ac->sl; | SpaceAction *saction = (SpaceAction *)ac->sl; | ||||
| bDopeSheet *ads = (saction) ? &saction->ads : NULL; | bDopeSheet *ads = (saction) ? &saction->ads : NULL; | ||||
| /* specially check for AnimData filter... [#36687] */ | /* specially check for AnimData filter... [#36687] */ | ||||
| if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) { | if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) { | ||||
| /* all channels here are within the same AnimData block, hence this special case */ | /* all channels here are within the same AnimData block, hence this special case */ | ||||
| if (LIKELY(obact->adt)) { | if (LIKELY(obact->adt)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(obact->adt, ANIMTYPE_ANIMDATA, (ID *)obact, NULL); | ANIMCHANNEL_NEW_CHANNEL(obact->adt, ANIMTYPE_ANIMDATA, (ID *)obact, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* The check for the DopeSheet summary is included here | /* The check for the DopeSheet summary is included here | ||||
| * since the summary works here too. */ | * since the summary works here too. */ | ||||
| if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) { | if (animdata_filter_dopesheet_summary(ac, iter_data, filter_mode, &items)) { | ||||
| items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact); | items += animfilter_action(ac, iter_data, ads, data, filter_mode, (ID *)obact); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMCONT_SHAPEKEY: /* 'ShapeKey Editor' */ | case ANIMCONT_SHAPEKEY: /* 'ShapeKey Editor' */ | ||||
| { | { | ||||
| Key *key = (Key *)data; | Key *key = (Key *)data; | ||||
| /* specially check for AnimData filter... [#36687] */ | /* specially check for AnimData filter... [#36687] */ | ||||
| if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) { | if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) { | ||||
| /* all channels here are within the same AnimData block, hence this special case */ | /* all channels here are within the same AnimData block, hence this special case */ | ||||
| if (LIKELY(key->adt)) { | if (LIKELY(key->adt)) { | ||||
| ANIMCHANNEL_NEW_CHANNEL(key->adt, ANIMTYPE_ANIMDATA, (ID *)key, NULL); | ANIMCHANNEL_NEW_CHANNEL(key->adt, ANIMTYPE_ANIMDATA, (ID *)key, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* The check for the DopeSheet summary is included here | /* The check for the DopeSheet summary is included here | ||||
| * since the summary works here too. */ | * since the summary works here too. */ | ||||
| if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) { | if (animdata_filter_dopesheet_summary(ac, iter_data, filter_mode, &items)) { | ||||
| items = animdata_filter_shapekey(ac, anim_data, key, filter_mode); | items = animdata_filter_shapekey(ac, iter_data, key, filter_mode); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| /* Modes for Specialty Data Types (i.e. not keyframes) */ | /* Modes for Specialty Data Types (i.e. not keyframes) */ | ||||
| case ANIMCONT_GPENCIL: { | case ANIMCONT_GPENCIL: { | ||||
| if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) { | if (animdata_filter_dopesheet_summary(ac, iter_data, filter_mode, &items)) { | ||||
| items = animdata_filter_gpencil(ac, anim_data, data, filter_mode); | items = animdata_filter_gpencil(ac, iter_data, data, filter_mode); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMCONT_MASK: { | case ANIMCONT_MASK: { | ||||
| if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) { | if (animdata_filter_dopesheet_summary(ac, iter_data, filter_mode, &items)) { | ||||
| items = animdata_filter_mask(ac->bmain, anim_data, data, filter_mode); | items = animdata_filter_mask(ac->bmain, iter_data, data, filter_mode); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| /* DopeSheet Based Modes */ | /* DopeSheet Based Modes */ | ||||
| case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */ | case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */ | ||||
| { | { | ||||
| /* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */ | /* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */ | ||||
| if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) { | if (animdata_filter_dopesheet_summary(ac, iter_data, filter_mode, &items)) { | ||||
| items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode); | items += animdata_filter_dopesheet(ac, iter_data, data, filter_mode); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case ANIMCONT_FCURVES: /* Graph Editor -> F-Curves/Animation Editing */ | case ANIMCONT_FCURVES: /* Graph Editor -> F-Curves/Animation Editing */ | ||||
| case ANIMCONT_DRIVERS: /* Graph Editor -> Drivers Editing */ | case ANIMCONT_DRIVERS: /* Graph Editor -> Drivers Editing */ | ||||
| case ANIMCONT_NLA: /* NLA Editor */ | case ANIMCONT_NLA: /* NLA Editor */ | ||||
| { | { | ||||
| /* all of these editors use the basic DopeSheet data for filtering options, | /* all of these editors use the basic DopeSheet data for filtering options, | ||||
| * but don't have all the same features */ | * but don't have all the same features */ | ||||
| items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode); | items = animdata_filter_dopesheet(ac, iter_data, data, filter_mode); | ||||
| break; | break; | ||||
| } | } | ||||
| /* Timeline Mode - Basically the same as dopesheet, | /* Timeline Mode - Basically the same as dopesheet, | ||||
| * except we only have the summary for now */ | * except we only have the summary for now */ | ||||
| case ANIMCONT_TIMELINE: { | case ANIMCONT_TIMELINE: { | ||||
| /* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */ | /* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */ | ||||
| if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) { | if (animdata_filter_dopesheet_summary(ac, iter_data, filter_mode, &items)) { | ||||
| items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode); | items += animdata_filter_dopesheet(ac, iter_data, data, filter_mode); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| /* Special/Internal Use */ | /* Special/Internal Use */ | ||||
| case ANIMCONT_CHANNEL: /* animation channel */ | case ANIMCONT_CHANNEL: /* animation channel */ | ||||
| { | { | ||||
| bDopeSheet *ads = ac->ads; | bDopeSheet *ads = ac->ads; | ||||
| /* based on the channel type, filter relevant data for this */ | /* based on the channel type, filter relevant data for this */ | ||||
| items = animdata_filter_animchan(ac, anim_data, ads, data, filter_mode); | items = animdata_filter_animchan(ac, iter_data, ads, data, filter_mode); | ||||
| break; | break; | ||||
| } | } | ||||
| /* unhandled */ | /* unhandled */ | ||||
| default: { | default: { | ||||
| printf("ANIM_animdata_filter() - Invalid datatype argument %u\n", datatype); | printf("ANIM_animdata_filter() - Invalid datatype argument %u\n", datatype); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* remove any 'weedy' entries */ | animdata_filter_iter_data_deinit(iter_data); | ||||
| items = animdata_filter_remove_invalid(anim_data); | |||||
| /* remove duplicates (if required) */ | |||||
| if (filter_mode & ANIMFILTER_NODUPLIS) { | |||||
| items = animdata_filter_remove_duplis(anim_data); | |||||
| } | } | ||||
| } | |||||
| /* return the number of items in the list */ | |||||
| return items; | return items; | ||||
| } | } | ||||
| /* ************************************************************ */ | /* ************************************************************ */ | ||||