Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/animation/anim_filter.c
| Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* ----------- Private Stuff - Action Editor ------------- */ | /* ----------- Private Stuff - Action Editor ------------- */ | ||||
| /* Get shapekey data being edited (for Action Editor -> ShapeKey mode) */ | /* Get shapekey data being edited (for Action Editor -> ShapeKey mode) */ | ||||
| /* Note: there's a similar function in key.c (BKE_key_from_object) */ | /* Note: there's a similar function in key.c (BKE_key_from_object) */ | ||||
| static Key *actedit_get_shapekeys(bAnimContext *ac) | static Key *actedit_get_shapekeys(bAnimContext *ac) | ||||
| { | { | ||||
| SceneLayer *sl = ac->scene_layer; | ViewLayer *sl = ac->view_layer; | ||||
| Object *ob; | Object *ob; | ||||
| Key *key; | Key *key; | ||||
| ob = OBACT(sl); | ob = OBACT(sl); | ||||
| if (ob == NULL) | if (ob == NULL) | ||||
| return NULL; | return NULL; | ||||
| /* XXX pinning is not available in 'ShapeKey' mode... */ | /* XXX pinning is not available in 'ShapeKey' mode... */ | ||||
| ▲ Show 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) | ||||
| if (ac == NULL) return false; | if (ac == NULL) return false; | ||||
| memset(ac, 0, sizeof(bAnimContext)); | memset(ac, 0, sizeof(bAnimContext)); | ||||
| /* get useful default context settings from context */ | /* get useful default context settings from context */ | ||||
| ac->scene = scene; | ac->scene = scene; | ||||
| if (scene) { | if (scene) { | ||||
| ac->markers = ED_context_get_markers(C); | ac->markers = ED_context_get_markers(C); | ||||
| } | } | ||||
| ac->scene_layer = CTX_data_scene_layer(C); | ac->view_layer = CTX_data_view_layer(C); | ||||
| ac->obact = (ac->scene_layer->basact) ? ac->scene_layer->basact->object : NULL; | ac->obact = (ac->view_layer->basact) ? ac->view_layer->basact->object : NULL; | ||||
| ac->sa = sa; | ac->sa = sa; | ||||
| ac->ar = ar; | ac->ar = ar; | ||||
| ac->sl = sl; | ac->sl = sl; | ||||
| ac->spacetype = (sa) ? sa->spacetype : 0; | ac->spacetype = (sa) ? sa->spacetype : 0; | ||||
| ac->regiontype = (ar) ? ar->regiontype : 0; | ac->regiontype = (ar) ? ar->regiontype : 0; | ||||
| /* initialise default y-scale factor */ | /* initialise default y-scale factor */ | ||||
| animedit_get_yscale_factor(ac); | animedit_get_yscale_factor(ac); | ||||
| ▲ Show 20 Lines • Show All 1,287 Lines • ▼ Show 20 Lines | |||||
| // 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, ListBase *anim_data, void *UNUSED(data), int filter_mode) | static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, void *UNUSED(data), int filter_mode) | ||||
| { | { | ||||
| bDopeSheet *ads = ac->ads; | bDopeSheet *ads = ac->ads; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| if (ads->filterflag & ADS_FILTER_GP_3DONLY) { | if (ads->filterflag & ADS_FILTER_GP_3DONLY) { | ||||
| Scene *scene = (Scene *)ads->source; | Scene *scene = (Scene *)ads->source; | ||||
| SceneLayer *sl = (SceneLayer *)ac->scene_layer; | ViewLayer *sl = (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(anim_data, ads, scene->gpd, filter_mode); | ||||
| } | } | ||||
| /* Objects in the scene */ | /* Objects in the scene */ | ||||
| ▲ Show 20 Lines • Show All 255 Lines • ▼ Show 20 Lines | for (node = ntree->nodes.first; node; node = node->next) { | ||||
| } | } | ||||
| } | } | ||||
| return items; | return items; | ||||
| } | } | ||||
| static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) | static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) | ||||
| { | { | ||||
| SceneLayer *scene_layer; | ViewLayer *view_layer; | ||||
| FreestyleLineSet *lineset; | FreestyleLineSet *lineset; | ||||
| size_t items = 0; | size_t items = 0; | ||||
| for (scene_layer = sce->render_layers.first; scene_layer; scene_layer = scene_layer->next) { | for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { | ||||
| for (lineset = scene_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 (scene_layer = sce->render_layers.first; scene_layer; scene_layer = scene_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 ((scene_layer->flag & SCENE_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 = scene_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}; | ListBase tmp_data = {NULL, NULL}; | ||||
| size_t tmp_items = 0; | size_t tmp_items = 0; | ||||
| if ((linestyle == NULL) || | if ((linestyle == NULL) || | ||||
| !(linestyle->id.tag & LIB_TAG_DOIT)) | !(linestyle->id.tag & LIB_TAG_DOIT)) | ||||
| { | { | ||||
| continue; | continue; | ||||
| ▲ Show 20 Lines • Show All 947 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| const Base *b1 = *((const Base **)base1_ptr); | const Base *b1 = *((const Base **)base1_ptr); | ||||
| const Base *b2 = *((const Base **)base2_ptr); | const Base *b2 = *((const Base **)base2_ptr); | ||||
| return strcmp(b1->object->id.name + 2, b2->object->id.name + 2); | return strcmp(b1->object->id.name + 2, b2->object->id.name + 2); | ||||
| } | } | ||||
| /* Get a sorted list of all the bases - for inclusion in dopesheet (when drawing channels) */ | /* Get a sorted list of all the bases - for inclusion in dopesheet (when drawing channels) */ | ||||
| static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads, SceneLayer *sl, int filter_mode, size_t *r_usable_bases) | static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads, ViewLayer *sl, int filter_mode, size_t *r_usable_bases) | ||||
| { | { | ||||
| /* Create an array with space for all the bases, but only containing the usable ones */ | /* Create an array with space for all the bases, but only containing the usable ones */ | ||||
| size_t tot_bases = BLI_listbase_count(&sl->object_bases); | size_t tot_bases = BLI_listbase_count(&sl->object_bases); | ||||
| size_t num_bases = 0; | size_t num_bases = 0; | ||||
| Base **sorted_bases = MEM_mallocN(sizeof(Base *) * tot_bases, "Dopesheet Usable Sorted Bases"); | Base **sorted_bases = MEM_mallocN(sizeof(Base *) * tot_bases, "Dopesheet Usable Sorted Bases"); | ||||
| for (Base *base = sl->object_bases.first; base; base = base->next) { | for (Base *base = sl->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)) { | ||||
| Show All 9 Lines | static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads, ViewLayer *sl, int filter_mode, size_t *r_usable_bases) | ||||
| return sorted_bases; | return sorted_bases; | ||||
| } | } | ||||
| // TODO: implement pinning... (if and when pinning is done, what we need to do is to provide freeing mechanisms - to protect against data that was deleted) | // TODO: implement pinning... (if and when pinning is done, what we need to do is to provide freeing mechanisms - to protect against data that was deleted) | ||||
| static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, int filter_mode) | static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, int filter_mode) | ||||
| { | { | ||||
| Scene *scene = (Scene *)ads->source; | Scene *scene = (Scene *)ads->source; | ||||
| SceneLayer *sl = (SceneLayer *)ac->scene_layer; | ViewLayer *sl = (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 */ | ||||
| if ((ads->source == NULL) || (GS(ads->source->name) != ID_SCE)) { | if ((ads->source == NULL) || (GS(ads->source->name) != ID_SCE)) { | ||||
| printf("Dope Sheet Error: No scene!\n"); | printf("Dope Sheet Error: No scene!\n"); | ||||
| if (G.debug & G_DEBUG) | if (G.debug & G_DEBUG) | ||||
| printf("\tPointer = %p, Name = '%s'\n", (void *)ads->source, (ads->source) ? ads->source->name : NULL); | printf("\tPointer = %p, Name = '%s'\n", (void *)ads->source, (ads->source) ? ads->source->name : NULL); | ||||
| return 0; | return 0; | ||||
| ▲ Show 20 Lines • Show All 329 Lines • Show Last 20 Lines | |||||