Blender V5.3
anim_filter.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors, Joshua Leung. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9/* This file contains a system used to provide a layer of abstraction between sources
10 * of animation data and tools in Animation Editors. The method used here involves
11 * generating a list of edit structures which enable tools to naively perform the actions
12 * they require without all the boiler-plate associated with loops within loops and checking
13 * for cases to ignore.
14 *
15 * While this is primarily used for the Action/Dopesheet Editor (and its accessory modes),
16 * the Graph Editor also uses this for its channel list and for determining which curves
17 * are being edited. Likewise, the NLA Editor also uses this for its channel list and in
18 * its operators.
19 *
20 * NOTE: much of the original system this was based on was built before the creation of the RNA
21 * system. In future, it would be interesting to replace some parts of this code with RNA queries,
22 * however, RNA does not eliminate some of the boiler-plate reduction benefits presented by this
23 * system, so if any such work does occur, it should only be used for the internals used here...
24 *
25 * -- Joshua Leung, Dec 2008 (Last revision July 2009)
26 */
27
28#include <cstring>
29
30#include "DNA_anim_types.h"
31#include "DNA_armature_types.h"
32#include "DNA_cachefile_types.h"
33#include "DNA_camera_types.h"
34#include "DNA_curves_types.h"
37#include "DNA_key_types.h"
38#include "DNA_lattice_types.h"
39#include "DNA_layer_types.h"
40#include "DNA_light_types.h"
42#include "DNA_linestyle_types.h"
43#include "DNA_mask_types.h"
44#include "DNA_material_types.h"
45#include "DNA_mesh_types.h"
46#include "DNA_meta_types.h"
47#include "DNA_movieclip_types.h"
48#include "DNA_node_types.h"
50#include "DNA_object_types.h"
51#include "DNA_particle_types.h"
53#include "DNA_scene_types.h"
54#include "DNA_screen_types.h"
55#include "DNA_sequence_types.h"
56#include "DNA_space_types.h"
57#include "DNA_speaker_types.h"
58#include "DNA_userdef_types.h"
59#include "DNA_volume_types.h"
60#include "DNA_world_types.h"
61
62#include "MEM_guardedalloc.h"
63
64#include "BLI_alloca.hh"
65#include "BLI_listbase.hh"
66#include "BLI_string.hh"
67#include "BLI_utildefines.hh"
68
69#include "BKE_action.hh"
70#include "BKE_anim_data.hh"
71#include "BKE_collection.hh"
72#include "BKE_context.hh"
73#include "BKE_fcurve.hh"
74#include "BKE_fcurve_driver.h"
75#include "BKE_global.hh"
76#include "BKE_grease_pencil.hh"
77#include "BKE_key.hh"
78#include "BKE_layer.hh"
79#include "BKE_library.hh"
80#include "BKE_main.hh"
81#include "BKE_mask.hh"
82#include "BKE_material.hh"
83#include "BKE_modifier.hh"
84#include "BKE_node.hh"
85#include "BKE_node_runtime.hh"
86
87#include "ED_anim_api.hh"
88
89#include "SEQ_iterator.hh"
90#include "SEQ_modifier.hh"
91#include "SEQ_sequencer.hh"
92#include "SEQ_utils.hh"
93
94#include "ANIM_action.hh"
95#include "ANIM_armature.hh"
96
97#include "anim_intern.hh"
98
99namespace blender {
100
101/* ************************************************************ */
102/* Blender Context <-> Animation Context mapping */
103
105 Scene *scene,
106 ViewLayer *view_layer,
107 const ScrArea *area,
108 ID **r_action_user)
109{
110 if (!area || area->spacetype != SPACE_ACTION) {
111 return nullptr;
112 }
113
114 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
116 if (!ob) {
117 return nullptr;
118 }
119
120 const SpaceAction *saction = area->spacedata.first_as<SpaceAction>();
121 switch (eAnimEdit_Context(saction->mode)) {
122 case SACTCONT_ACTION: {
123 bAction *active_action = ob->adt ? ob->adt->action : nullptr;
124 if (r_action_user) {
125 *r_action_user = &ob->id;
126 }
127 return active_action;
128 }
129
130 case SACTCONT_SHAPEKEY: {
131 Key *active_key = BKE_key_from_object(ob);
132 bAction *active_action = (active_key && active_key->adt) ? active_key->adt->action : nullptr;
133 if (r_action_user) {
134 *r_action_user = &active_key->id;
135 }
136 return active_action;
137 }
138
139 case SACTCONT_GPENCIL:
141 case SACTCONT_MASK:
144 if (r_action_user) {
145 *r_action_user = nullptr;
146 }
147 return nullptr;
148 }
149
151 return nullptr;
152}
153
154/* ----------- Private Stuff - Action Editor ------------- */
155
156/* Get shapekey data being edited (for Action Editor -> ShapeKey mode) */
157/* NOTE: there's a similar function in `key.cc` #BKE_key_from_object. */
159{
160 Scene *scene = ac->scene;
161 ViewLayer *view_layer = ac->view_layer;
162 Object *ob;
163
164 BKE_view_layer_synced_ensure(*ac->bmain, scene, view_layer);
165 ob = BKE_view_layer_active_object_get(view_layer);
166 if (ob == nullptr) {
167 return nullptr;
168 }
169
170 /* XXX pinning is not available in 'ShapeKey' mode... */
171 // if (saction->pin) { return nullptr; }
172
173 /* shapekey data is stored with geometry data */
174 return BKE_key_from_object(ob);
175}
176
177/* Get data being edited in Action Editor (depending on current 'mode') */
179{
180 /* get dopesheet */
181 ac->ads = &saction->ads;
182 ac->dopesheet_mode = eAnimEdit_Context(saction->mode);
183
184 /* Set the default filters. These can be overridden later. */
187
189 *ac->bmain, ac->scene, ac->view_layer, ac->area, &ac->active_action_user);
190
191 /* sync settings with current view status, then return appropriate data */
192 switch (saction->mode) {
193 case SACTCONT_ACTION: /* 'Action Editor' */
195 ac->data = ac->active_action;
196
197 if (ac->active_action && (saction->flag & SACTION_POSEMARKERS_SHOW)) {
198 ac->markers = &ac->active_action->markers;
199 }
200
201 return true;
202
203 case SACTCONT_SHAPEKEY: /* 'ShapeKey Editor' */
205 ac->data = actedit_get_shapekeys(ac);
206
207 if (ac->active_action && (saction->flag & SACTION_POSEMARKERS_SHOW)) {
208 ac->markers = &ac->active_action->markers;
209 }
210
211 return true;
212
213 case SACTCONT_GPENCIL: /* Grease Pencil */ /* XXX review how this mode is handled... */
214 /* update scene-pointer (no need to check for pinning yet, as not implemented) */
215 saction->ads.source = reinterpret_cast<ID *>(ac->scene);
216
218 ac->data = &saction->ads;
219 return true;
220
221 case SACTCONT_CACHEFILE: /* Cache File */
222 /* update scene-pointer (no need to check for pinning yet, as not implemented) */
223 saction->ads.source = reinterpret_cast<ID *>(ac->scene);
224
226 ac->data = &saction->ads;
227 return true;
228
229 case SACTCONT_MASK: /* Mask */ /* XXX: review how this mode is handled. */
230 {
231 /* TODO: other methods to get the mask. */
232#if 0
233 Strip *strip = SEQ_select_active_get(ac->scene);
234 MovieClip *clip = ac->scene->clip;
235 struct Mask *mask = strip ? strip->mask : nullptr;
236#endif
237
238 /* update scene-pointer (no need to check for pinning yet, as not implemented) */
239 saction->ads.source = reinterpret_cast<ID *>(ac->scene);
240
242 ac->data = &saction->ads;
243 return true;
244 }
245
246 case SACTCONT_DOPESHEET: /* DopeSheet */
247 /* update scene-pointer (no need to check for pinning yet, as not implemented) */
248 saction->ads.source = reinterpret_cast<ID *>(ac->scene);
249
251 ac->data = &saction->ads;
252 return true;
253
254 case SACTCONT_TIMELINE: {
255 saction->ads.source = reinterpret_cast<ID *>(ac->scene);
256
258 ac->data = &saction->ads;
259
260 /* The 'only show selected' filter has to come from the scene flag, not the dopesheet filter.
261 * Most filter flags are hard-coded for the timeline. */
262 const eDopeSheet_FilterFlag flag_only_selected = (ac->scene->flag & SCE_KEYS_NO_SELONLY) ?
265 const eDopeSheet_FilterFlag flag_only_errors = eDopeSheet_FilterFlag(ac->ads->filterflag &
267 ac->filters.flag = flag_only_selected | flag_only_errors;
268 ac->filters.flag2 = eDopeSheet_FilterFlag2(0);
269 return true;
270 }
271 default: /* unhandled yet */
273 ac->data = nullptr;
274 return false;
275 }
276}
277
278/* ----------- Private Stuff - Graph Editor ------------- */
279
280/* Get data being edited in Graph Editor (depending on current 'mode') */
282{
283 /* init dopesheet data if non-existent (i.e. for old files) */
284 if (sipo->ads == nullptr) {
285 sipo->ads = MEM_new<bDopeSheet>("GraphEdit DopeSheet");
286 sipo->ads->source = reinterpret_cast<ID *>(ac->scene);
287 }
288 ac->ads = sipo->ads;
290
291 /* set settings for Graph Editor - "Selected = Editable" */
292 if (U.animation_flag & USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS) {
294 }
295 else {
297 }
298
299 bool ok;
300
301 /* sync settings with current view status, then return appropriate data */
302 switch (sipo->mode) {
303 case SIPO_MODE_ANIMATION: /* Animation F-Curve Editor */
304 /* update scene-pointer (no need to check for pinning yet, as not implemented) */
305 sipo->ads->source = reinterpret_cast<ID *>(ac->scene);
307
309 ac->data = sipo->ads;
310 ok = true;
311 break;
312
313 case SIPO_MODE_DRIVERS: /* Driver F-Curve Editor */
314 /* update scene-pointer (no need to check for pinning yet, as not implemented) */
315 sipo->ads->source = reinterpret_cast<ID *>(ac->scene);
317
319 ac->data = sipo->ads;
320 ok = true;
321 break;
322
323 default: /* unhandled yet */
325 ac->data = nullptr;
326 ok = false;
327 break;
328 }
329
330 ac->filters.flag = eDopeSheet_FilterFlag(sipo->ads->filterflag);
331 ac->filters.flag2 = eDopeSheet_FilterFlag2(sipo->ads->filterflag2);
332
333 return ok;
334}
335
336/* ----------- Private Stuff - NLA Editor ------------- */
337
338/* Get data being edited in Graph Editor (depending on current 'mode') */
340{
341 /* init dopesheet data if non-existent (i.e. for old files) */
342 if (snla->ads == nullptr) {
343 snla->ads = MEM_new<bDopeSheet>("NlaEdit DopeSheet");
344 }
345 ac->ads = snla->ads;
346
347 /* sync settings with current view status, then return appropriate data */
348 /* update scene-pointer (no need to check for pinning yet, as not implemented) */
349 snla->ads->source = reinterpret_cast<ID *>(ac->scene);
351 ac->filters.flag2 = eDopeSheet_FilterFlag2(snla->ads->filterflag2);
352
354 ac->data = snla->ads;
355
356 return true;
357}
358
359/* ----------- Public API --------------- */
360
362{
363 SpaceLink *sl = ac->sl;
364 bool ok = false;
365
366 /* context depends on editor we are currently in */
367 if (sl) {
368 switch (ac->spacetype) {
369 case SPACE_ACTION: {
370 SpaceAction *saction = reinterpret_cast<SpaceAction *>(sl);
371 ok = actedit_get_context(ac, saction);
372 break;
373 }
374 case SPACE_GRAPH: {
375 SpaceGraph *sipo = reinterpret_cast<SpaceGraph *>(sl);
376 ok = graphedit_get_context(ac, sipo);
377 break;
378 }
379 case SPACE_NLA: {
380 SpaceNla *snla = reinterpret_cast<SpaceNla *>(sl);
381 ok = nlaedit_get_context(ac, snla);
382 break;
383 }
384 case SPACE_EMPTY:
385 case SPACE_VIEW3D:
386 case SPACE_OUTLINER:
387 case SPACE_PROPERTIES:
388 case SPACE_FILE:
389 case SPACE_IMAGE:
390 case SPACE_INFO:
391 case SPACE_SEQ:
392 case SPACE_TEXT:
393 case SPACE_SCRIPT:
394 case SPACE_NODE:
395 case SPACE_CONSOLE:
396 case SPACE_USERPREF:
397 case SPACE_CLIP:
398 case SPACE_TOPBAR:
399 case SPACE_STATUSBAR:
401 case SPACE_PROJECT:
402 break;
403 }
404 }
405
406 /* check if there's any valid data */
407 return (ok && ac->data);
408}
409
411{
412 Main *bmain = CTX_data_main(C);
413 ScrArea *area = CTX_wm_area(C);
414 ARegion *region = CTX_wm_region(C);
416 Scene *scene = CTX_data_scene(C);
417
418 /* clear old context info */
419 if (ac == nullptr) {
420 return false;
421 }
422 memset(ac, 0, sizeof(bAnimContext));
423
424 /* get useful default context settings from context */
425 ac->bmain = bmain;
426 ac->scene = scene;
428 if (scene) {
429 /* This may be overwritten by actedit_get_context() when pose markers should be shown. */
430 ac->markers = &scene->markers;
431 }
432 if (scene && ac->view_layer) {
433 BKE_view_layer_synced_ensure(*bmain, scene, ac->view_layer);
435 }
437 ac->area = area;
438 ac->region = region;
439 ac->sl = sl;
440 ac->spacetype = eSpace_Type((area) ? area->spacetype : 0);
441 ac->regiontype = eRegion_Type((region) ? region->regiontype : 0);
442
443 /* get data context info */
444 /* XXX: if the below fails, try to grab this info from context instead...
445 * (to allow for scripting). */
447}
448
453
454/* ************************************************************ */
455/* Blender Data <-- Filter --> Channels to be operated on */
456
457/* macros to use before/after getting the sub-channels of some channel,
458 * to abstract away some of the tricky logic involved
459 *
460 * cases:
461 * 1) Graph Edit main area (just data) OR channels visible in Channel List
462 * 2) If not showing channels, we're only interested in the data (Action Editor's editing)
463 * 3) We don't care what data, we just care there is some (so that a collapsed
464 * channel can be kept around). No need to clear channels-flag in order to
465 * keep expander channels with no sub-data out, as those cases should get
466 * dealt with by the recursive detection idiom in place.
467 *
468 * Implementation NOTE:
469 * YES the _doSubChannels variable is NOT read anywhere. BUT, this is NOT an excuse
470 * to go steamrolling the logic into a single-line expression as from experience,
471 * those are notoriously difficult to read + debug when extending later on. The code
472 * below is purposefully laid out so that each case noted above corresponds clearly to
473 * one case below.
474 */
475#define BEGIN_ANIMFILTER_SUBCHANNELS(expanded_check) \
476 { \
477 const eAnimFilter_Flags _filter = filter_mode; \
478 short _doSubChannels = 0; \
479 if (!(filter_mode & ANIMFILTER_LIST_VISIBLE) || (expanded_check)) { \
480 _doSubChannels = 1; \
481 } \
482 else if (!(filter_mode & ANIMFILTER_LIST_CHANNELS)) { \
483 _doSubChannels = 2; \
484 } \
485 else { \
486 filter_mode |= ANIMFILTER_TMP_PEEK; \
487 } \
488\
489 { \
490 (void)_doSubChannels; \
491 }
492/* ... standard sub-channel filtering can go on here now ... */
493#define END_ANIMFILTER_SUBCHANNELS \
494 filter_mode = _filter; \
495 } \
496 (void)0
497
498/* ............................... */
499
500/* Test whether AnimData has a usable Action. */
501
502#define ANIMDATA_HAS_ACTION(id) ((id)->adt && (id)->adt->action)
503
504/* quick macro to test if AnimData is usable for drivers */
505#define ANIMDATA_HAS_DRIVERS(id) ((id)->adt && (id)->adt->drivers.first_)
506
507/* quick macro to test if AnimData is usable for NLA */
508#define ANIMDATA_HAS_NLA(id) ((id)->adt && (id)->adt->nla_tracks.first_)
509
547#define ANIMDATA_FILTER_CASES( \
548 id, adtOk, nlaOk, driversOk, nlaKeysOk, legacyActionOk, layeredActionOk) \
549 { \
550 if ((id)->adt) { \
551 if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || \
552 !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) \
553 { \
554 if (filter_mode & ANIMFILTER_ANIMDATA) { \
555 adtOk \
556 } \
557 else if (ac->filters.flag & ADS_FILTER_ONLYNLA) { \
558 if (ANIMDATA_HAS_NLA(id)) { \
559 nlaOk \
560 } \
561 else if (!(ac->filters.flag & ADS_FILTER_NLA_NOACT) || ANIMDATA_HAS_ACTION(id)) { \
562 nlaOk \
563 } \
564 } \
565 else if (ac->filters.flag & ADS_FILTER_ONLYDRIVERS) { \
566 if (ANIMDATA_HAS_DRIVERS(id)) { \
567 driversOk \
568 } \
569 } \
570 else { \
571 if (ANIMDATA_HAS_NLA(id)) { \
572 nlaKeysOk \
573 } \
574 if (ANIMDATA_HAS_ACTION(id)) { \
575 layeredActionOk \
576 } \
577 } \
578 } \
579 } \
580 } \
581 (void)0
582
583/* ............................... */
584
591#define ANIMCHANNEL_NEW_CHANNEL_FULL( \
592 bmain, channel_data, channel_type, owner_id, fcurve_owner_id, ale_statement) \
593 if (filter_mode & ANIMFILTER_TMP_PEEK) { \
594 return 1; \
595 } \
596 { \
597 bAnimListElem *ale = make_new_animlistelem( \
598 bmain, channel_data, channel_type, (ID *)owner_id, fcurve_owner_id); \
599 if (ale) { \
600 BLI_addtail(anim_data, ale); \
601 items++; \
602 ale_statement \
603 } \
604 } \
605 (void)0
606
607#define ANIMCHANNEL_NEW_CHANNEL(bmain, channel_data, channel_type, owner_id, fcurve_owner_id) \
608 ANIMCHANNEL_NEW_CHANNEL_FULL(bmain, channel_data, channel_type, owner_id, fcurve_owner_id, {})
609
610/* ............................... */
611
612/* quick macro to test if an anim-channel representing an AnimData block is suitably active */
613#define ANIMCHANNEL_ACTIVEOK(ale) \
614 (!(filter_mode & ANIMFILTER_ACTIVE) || !(ale->adt) || (ale->adt->flag & ADT_UI_ACTIVE))
615
616/* Quick macro to test if an anim-channel (F-Curve, Group, etc.)
617 * is selected in an acceptable way. */
618#define ANIMCHANNEL_SELOK(test_func) \
619 (!(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) || \
620 ((filter_mode & ANIMFILTER_SEL) && test_func) || \
621 ((filter_mode & ANIMFILTER_UNSEL) && test_func == 0))
622
632#define ANIMCHANNEL_SELEDITOK(test_func) \
633 (!(filter_mode & ANIMFILTER_SELEDIT) || !(filter_mode & ANIMFILTER_FOREDIT) || (test_func))
634
635/* ----------- 'Private' Stuff --------------- */
636
642{
643 ale.adt = adt;
644
645 if (!adt || !adt->action) {
646 ale.key_data = nullptr;
647 ale.datatype = ALE_NONE;
648 return;
649 }
650
651 animrig::Action &action = adt->action->wrap();
652 ale.key_data = &action;
654}
655
656/* this function allocates memory for a new bAnimListElem struct for the
657 * provided animation channel-data.
658 */
660 Main *bmain, void *data, const eAnim_ChannelType datatype, ID *owner_id, ID *fcurve_owner_id)
661{
662 /* Only allocate memory if there is data to convert. */
663 if (!data) {
664 return nullptr;
665 }
666
667 /* Allocate and set generic data. */
668 bAnimListElem *ale = MEM_new_zeroed<bAnimListElem>("bAnimListElem");
669
670 ale->data = data;
671 ale->type = datatype;
672
673 ale->bmain = bmain;
674 ale->id = owner_id;
675 ale->adt = BKE_animdata_from_id(owner_id);
676 ale->fcurve_owner_id = fcurve_owner_id;
677
678 /* do specifics */
679 switch (datatype) {
680 case ANIMTYPE_SUMMARY: {
681 /* Nothing to include for now... this is just a dummy wrapper around
682 * all the other channels in the DopeSheet, and gets included at the start of the list. */
683 ale->key_data = nullptr;
684 ale->datatype = ALE_ALL;
685 break;
686 }
687 case ANIMTYPE_SCENE: {
688 Scene *sce = static_cast<Scene *>(data);
689
690 ale->flag = sce->flag;
691
692 ale->key_data = sce;
693 ale->datatype = ALE_SCE;
694
695 ale->adt = BKE_animdata_from_id(static_cast<ID *>(data));
696 break;
697 }
698 case ANIMTYPE_OBJECT: {
699 Base *base = static_cast<Base *>(data);
700 Object *ob = base->object;
701
702 ale->flag = ob->flag;
703
704 ale->key_data = ob;
705 ale->datatype = ALE_OB;
706
707 ale->adt = BKE_animdata_from_id(&ob->id);
708 break;
709 }
711 bAction *action = static_cast<bAction *>(data);
712
713 ale->flag = action->flag;
714
715 ale->key_data = action;
717 break;
718 }
720 animrig::Slot *slot = static_cast<animrig::Slot *>(data);
721 ale->flag = slot->slot_flags;
722
723 BLI_assert_msg(GS(fcurve_owner_id->name) == ID_AC, "fcurve_owner_id should be an Action");
724 /* ale->data = the slot itself, key_data = the Action. */
725 ale->key_data = fcurve_owner_id;
727 break;
728 }
729 case ANIMTYPE_FILLACTD: {
730 bAction *act = static_cast<bAction *>(data);
731
732 ale->flag = act->flag;
733
734 ale->key_data = act;
735 ale->datatype = ALE_ACT;
736 break;
737 }
739 AnimData *adt = static_cast<AnimData *>(data);
740
741 ale->flag = adt->flag;
742
743 /* XXX drivers don't show summary for now. */
744 ale->key_data = nullptr;
745 ale->datatype = ALE_NONE;
746 break;
747 }
748 case ANIMTYPE_DSMAT: {
749 Material *ma = static_cast<Material *>(data);
750 ale->flag = FILTER_MAT_OBJD(ma);
751 key_data_from_adt(*ale, ma->adt);
752 break;
753 }
754 case ANIMTYPE_DSLAM: {
755 Light *la = static_cast<Light *>(data);
756 ale->flag = FILTER_LAM_OBJD(la);
757 key_data_from_adt(*ale, la->adt);
758 break;
759 }
760 case ANIMTYPE_DSCAM: {
761 Camera *ca = static_cast<Camera *>(data);
762 ale->flag = FILTER_CAM_OBJD(ca);
763 key_data_from_adt(*ale, ca->adt);
764 break;
765 }
767 CacheFile *cache_file = static_cast<CacheFile *>(data);
768 ale->flag = FILTER_CACHEFILE_OBJD(cache_file);
769 key_data_from_adt(*ale, cache_file->adt);
770 break;
771 }
772 case ANIMTYPE_DSCUR: {
773 Curve *cu = static_cast<Curve *>(data);
774 ale->flag = FILTER_CUR_OBJD(cu);
775 key_data_from_adt(*ale, cu->adt);
776 break;
777 }
778 case ANIMTYPE_DSARM: {
779 bArmature *arm = static_cast<bArmature *>(data);
780 ale->flag = FILTER_ARM_OBJD(arm);
781 key_data_from_adt(*ale, arm->adt);
782 break;
783 }
784 case ANIMTYPE_DSMESH: {
785 Mesh *mesh = static_cast<Mesh *>(data);
786 ale->flag = FILTER_MESH_OBJD(mesh);
787 key_data_from_adt(*ale, mesh->adt);
788 break;
789 }
790 case ANIMTYPE_DSLAT: {
791 Lattice *lt = static_cast<Lattice *>(data);
792 ale->flag = FILTER_LATTICE_OBJD(lt);
793 key_data_from_adt(*ale, lt->adt);
794 break;
795 }
796 case ANIMTYPE_DSSPK: {
797 Speaker *spk = static_cast<Speaker *>(data);
798 ale->flag = FILTER_SPK_OBJD(spk);
799 key_data_from_adt(*ale, spk->adt);
800 break;
801 }
802 case ANIMTYPE_DSHAIR: {
803 Curves *curves = static_cast<Curves *>(data);
805 key_data_from_adt(*ale, curves->adt);
806 break;
807 }
809 PointCloud *pointcloud = static_cast<PointCloud *>(data);
810 ale->flag = FILTER_POINTS_OBJD(pointcloud);
811 key_data_from_adt(*ale, pointcloud->adt);
812 break;
813 }
814 case ANIMTYPE_DSVOLUME: {
815 Volume *volume = static_cast<Volume *>(data);
816 ale->flag = FILTER_VOLUME_OBJD(volume);
817 key_data_from_adt(*ale, volume->adt);
818 break;
819 }
821 LightProbe *probe = static_cast<LightProbe *>(data);
822 ale->flag = FILTER_LIGHTPROBE_OBJD(probe);
823 key_data_from_adt(*ale, probe->adt);
824 break;
825 }
826 case ANIMTYPE_DSSKEY: {
827 Key *key = static_cast<Key *>(data);
828 ale->flag = FILTER_SKE_OBJD(key);
829 key_data_from_adt(*ale, key->adt);
830 break;
831 }
832 case ANIMTYPE_DSWOR: {
833 World *wo = static_cast<World *>(data);
834 ale->flag = FILTER_WOR_SCED(wo);
835 key_data_from_adt(*ale, wo->adt);
836 break;
837 }
838 case ANIMTYPE_DSNTREE: {
839 bNodeTree *ntree = static_cast<bNodeTree *>(data);
840 ale->flag = FILTER_NTREE_DATA(ntree);
841 key_data_from_adt(*ale, ntree->adt);
842 break;
843 }
845 FreestyleLineStyle *linestyle = static_cast<FreestyleLineStyle *>(data);
846 ale->flag = FILTER_LS_SCED(linestyle);
847 key_data_from_adt(*ale, linestyle->adt);
848 break;
849 }
850 case ANIMTYPE_DSPART: {
851 ParticleSettings *part = static_cast<ParticleSettings *>(ale->data);
852 ale->flag = FILTER_PART_OBJD(part);
853 key_data_from_adt(*ale, part->adt);
854 break;
855 }
856 case ANIMTYPE_DSTEX: {
857 Tex *tex = static_cast<Tex *>(data);
858 ale->flag = FILTER_TEX_DATA(tex);
859 key_data_from_adt(*ale, tex->adt);
860 break;
861 }
862 case ANIMTYPE_DSGPENCIL: {
863 bGPdata *gpd = static_cast<bGPdata *>(data);
864 /* NOTE: we just reuse the same expand filter for this case */
865 ale->flag = EXPANDED_GPD(gpd);
866
867 /* XXX: currently, this is only used for access to its animation data */
868 key_data_from_adt(*ale, gpd->adt);
869 break;
870 }
871 case ANIMTYPE_DSMCLIP: {
872 MovieClip *clip = static_cast<MovieClip *>(data);
873 ale->flag = EXPANDED_MCLIP(clip);
874 key_data_from_adt(*ale, clip->adt);
875 break;
876 }
878 AnimData *adt = static_cast<AnimData *>(data);
879
880 ale->flag = adt->flag;
881
882 ale->key_data = nullptr;
883 ale->datatype = ALE_NONE;
884 break;
885 }
886 case ANIMTYPE_GROUP: {
887 BLI_assert_msg(GS(fcurve_owner_id->name) == ID_AC, "fcurve_owner_id should be an Action");
888
889 bActionGroup *agrp = static_cast<bActionGroup *>(data);
890
891 ale->flag = agrp->flag;
892
893 ale->key_data = nullptr;
894 ale->datatype = ALE_GROUP;
895 break;
896 }
897 case ANIMTYPE_FCURVE:
898 case ANIMTYPE_NLACURVE: /* practically the same as ANIMTYPE_FCURVE.
899 * Differences are applied post-creation */
900 {
901 FCurve *fcu = static_cast<FCurve *>(data);
902
903 ale->flag = fcu->flag;
904
905 ale->key_data = fcu;
906 ale->datatype = ALE_FCURVE;
907 break;
908 }
909 case ANIMTYPE_SHAPEKEY: {
910 KeyBlock *kb = static_cast<KeyBlock *>(data);
911 Key *key = reinterpret_cast<Key *>(ale->id);
912
913 ale->flag = kb->flag;
914
915 /* whether we have keyframes depends on whether there is a Key block to find it from */
916 if (key) {
917 /* index of shapekey is defined by place in key's list */
918 ale->index = BLI_findindex(&key->block, kb);
919
920 /* the corresponding keyframes are from the animdata */
921 if (ale->adt && ale->adt->action) {
922 /* Try to find the F-Curve which corresponds to this exactly. */
923 if (std::optional<std::string> rna_path = BKE_keyblock_curval_rnapath_get(key, kb)) {
924 ale->key_data = static_cast<void *>(
925 animrig::fcurve_find_in_assigned_slot(*ale->adt, {*rna_path, 0}));
926 }
927 }
928 ale->datatype = (ale->key_data) ? ALE_FCURVE : ALE_NONE;
929 }
930 break;
931 }
932 case ANIMTYPE_GPLAYER: {
933 bGPDlayer *gpl = static_cast<bGPDlayer *>(data);
934
935 ale->flag = gpl->flag;
936
937 ale->key_data = nullptr;
938 ale->datatype = ALE_GPFRAME;
939 break;
940 }
943
944 ale->flag = layer->base.flag;
945
946 ale->key_data = nullptr;
948 break;
949 }
951 GreasePencilLayerTreeGroup *layer_group = static_cast<GreasePencilLayerTreeGroup *>(data);
952
953 ale->flag = layer_group->base.flag;
954
955 ale->key_data = nullptr;
957 break;
958 }
960 GreasePencil *grease_pencil = static_cast<GreasePencil *>(data);
961
962 ale->flag = grease_pencil->flag;
963
964 ale->key_data = nullptr;
966 break;
967 }
968 case ANIMTYPE_MASKLAYER: {
969 MaskLayer *masklay = static_cast<MaskLayer *>(data);
970
971 ale->flag = masklay->flag;
972
973 ale->key_data = nullptr;
974 ale->datatype = ALE_MASKLAY;
975 break;
976 }
977 case ANIMTYPE_NLATRACK: {
978 NlaTrack *nlt = static_cast<NlaTrack *>(data);
979
980 ale->flag = nlt->flag;
981
982 ale->key_data = &nlt->strips;
983 ale->datatype = ALE_NLASTRIP;
984 break;
985 }
986 case ANIMTYPE_NLAACTION: {
987 /* nothing to include for now... nothing editable from NLA-perspective here */
988 ale->key_data = nullptr;
989 ale->datatype = ALE_NONE;
990 break;
991 }
992
993 case ANIMTYPE_NONE:
996 case ANIMTYPE_DSMBALL:
998 case ANIMTYPE_PALETTE:
1000 break;
1001 }
1002
1003 return ale;
1004}
1005
1006/* ----------------------------------------- */
1007
1008/* 'Only Selected' selected data and/or 'Include Hidden' filtering
1009 * NOTE: when this function returns true, the F-Curve is to be skipped
1010 */
1012 FCurve *fcu,
1013 ID *owner_id,
1014 const eAnimFilter_Flags filter_mode)
1015{
1016 if (fcu->grp != nullptr && fcu->grp->flag & AGRP_CURVES_ALWAYS_VISIBLE) {
1017 return false;
1018 }
1019 /* hidden items should be skipped if we only care about visible data,
1020 * but we aren't interested in hidden stuff */
1021 const bool skip_hidden = (filter_mode & ANIMFILTER_DATA_VISIBLE) &&
1022 !(ac->filters.flag & ADS_FILTER_INCL_HIDDEN);
1023
1024 if (GS(owner_id->name) == ID_OB) {
1025 Object *ob = reinterpret_cast<Object *>(owner_id);
1026 bPoseChannel *pchan = nullptr;
1027 char bone_name[sizeof(pchan->name)];
1028
1029 /* Only consider if F-Curve involves `pose.bones`. */
1031 fcu->rna_path().c_str(), "pose.bones[", bone_name, sizeof(bone_name)))
1032 {
1033 /* Get bone-name, and check if this bone is selected. */
1034 pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
1035
1036 /* check whether to continue or skip */
1037 if (pchan && pchan->bone_get(*ob)) {
1038 /* If only visible channels,
1039 * skip if bone not visible unless user wants channels from hidden data too. */
1040 if (skip_hidden) {
1041 bArmature *arm = id_cast<bArmature *>(ob->data);
1042
1043 /* Skipping - is currently hidden. */
1044 if (!animrig::bone_is_visible(arm, {pchan, pchan->bone_get(*ob)})) {
1045 return true;
1046 }
1047 }
1048
1049 /* can only add this F-Curve if it is selected */
1050 if (ac->filters.flag & ADS_FILTER_ONLYSEL) {
1051 if ((pchan->flag & POSE_SELECTED) == 0) {
1052 return true;
1053 }
1054 }
1055 }
1056 }
1057 }
1058 else if (GS(owner_id->name) == ID_SCE) {
1059 Scene *scene = reinterpret_cast<Scene *>(owner_id);
1060 Strip *strip = nullptr;
1061 char strip_name[sizeof(strip->name)];
1062
1063 /* Only consider if F-Curve involves `sequence_editor.strips`. */
1065 fcu->rna_path().c_str(), "strips_all[", strip_name, sizeof(strip_name)))
1066 {
1067 /* Get strip name, and check if this strip is selected. */
1068 Editing *ed = seq::editing_get(scene);
1069 if (ed) {
1070 strip = seq::get_strip_by_name(ed->current_strips(), strip_name, false);
1071 }
1072
1073 /* Can only add this F-Curve if it is selected. */
1074 if (ac->filters.flag & ADS_FILTER_ONLYSEL) {
1075
1076 /* NOTE(@ideasman42): The `strip == nullptr` check doesn't look right
1077 * (compared to other checks in this function which skip data that can't be found).
1078 *
1079 * This is done since the search for sequence strips doesn't use a global lookup:
1080 * - Nested meta-strips are excluded.
1081 * - When inside a meta-strip - strips outside the meta-strip excluded.
1082 *
1083 * Instead, only the strips directly visible to the user are considered for selection.
1084 * The nullptr check here means everything else is considered unselected and is not shown.
1085 *
1086 * There is a subtle difference between nodes, pose-bones ... etc
1087 * since data-paths that point to missing strips are not shown.
1088 * If this is an important difference, the nullptr case could perform a global lookup,
1089 * only returning `true` if the sequence strip exists elsewhere
1090 * (ignoring its selection state). */
1091 if (strip == nullptr) {
1092 return true;
1093 }
1094
1095 if ((strip->flag & SEQ_SELECT) == 0) {
1096 return true;
1097 }
1098 }
1099 }
1100 }
1101 else if (GS(owner_id->name) == ID_NT) {
1102 bNodeTree *ntree = reinterpret_cast<bNodeTree *>(owner_id);
1103 bNode *node = nullptr;
1104 char node_name[sizeof(node->name)];
1105
1106 /* Check for selected nodes. */
1107 if (BLI_str_quoted_substr(fcu->rna_path().c_str(), "nodes[", node_name, sizeof(node_name))) {
1108 /* Get strip name, and check if this strip is selected. */
1109 node = bke::node_find_node_by_name(*ntree, node_name);
1110
1111 /* Can only add this F-Curve if it is selected. */
1112 if (node) {
1113 if (ac->filters.flag & ADS_FILTER_ONLYSEL) {
1114 if (!node->is_selected()) {
1115 return true;
1116 }
1117 }
1118 }
1119 }
1120 }
1121
1122 return false;
1123}
1124
1125/* Helper for name-based filtering - Perform "partial/fuzzy matches" (as in 80a7efd) */
1126static bool name_matches_dopesheet_filter(const bDopeSheet *ads, const char *name)
1127{
1128 if (ads->flag & ADS_FLAG_FUZZY_NAMES) {
1129 /* full fuzzy, multi-word, case insensitive matches */
1130 const size_t str_len = strlen(ads->searchstr);
1131 const int words_max = BLI_string_max_possible_word_count(str_len);
1132
1133 int (*words)[2] = static_cast<int (*)[2]>(BLI_array_alloca(words, words_max));
1134 const int words_len = BLI_string_find_split_words(
1135 ads->searchstr, str_len, ' ', words, words_max);
1136 bool found = false;
1137
1138 /* match name against all search words */
1139 for (int index = 0; index < words_len; index++) {
1140 if (BLI_strncasestr(name, ads->searchstr + words[index][0], words[index][1])) {
1141 found = true;
1142 break;
1143 }
1144 }
1145
1146 /* if we have a match somewhere, this returns true */
1147 return ((ads->flag & ADS_FLAG_INVERT_FILTER) == 0) ? found : !found;
1148 }
1149 /* fallback/default - just case insensitive, but starts from start of word */
1150 bool found = BLI_strcasestr(name, ads->searchstr) != nullptr;
1151 return ((ads->flag & ADS_FLAG_INVERT_FILTER) == 0) ? found : !found;
1152}
1153
1154/* (Display-)Name-based F-Curve filtering
1155 * NOTE: when this function returns true, the F-Curve is to be skipped
1156 */
1158 bAnimContext *ac, FCurve *fcu, eAnim_ChannelType channel_type, void *owner, ID *owner_id)
1159{
1160 bAnimListElem ale_dummy = {nullptr};
1161 const bAnimChannelType *acf;
1162
1163 /* create a dummy wrapper for the F-Curve, so we can get typeinfo for it */
1164 ale_dummy.type = channel_type;
1165 ale_dummy.owner = owner;
1166 ale_dummy.id = owner_id;
1167 ale_dummy.data = fcu;
1168
1169 /* get type info for channel */
1170 acf = ANIM_channel_get_typeinfo(&ale_dummy);
1171 if (acf && acf->name) {
1172 char name[ANIM_CHAN_NAME_SIZE];
1173
1174 /* get name */
1175 acf->name(&ale_dummy, name);
1176
1177 /* check for partial match with the match string, assuming case insensitive filtering
1178 * if match, this channel shouldn't be ignored!
1179 */
1180 return !name_matches_dopesheet_filter(ac->ads, name);
1181 }
1182
1183 /* just let this go... */
1184 return true;
1185}
1186
1188{
1190 if (!acf) {
1192 /* Do not filter out stuff unless we know it can be filtered out. */
1193 return true;
1194 }
1195
1196 char name[ANIM_CHAN_NAME_SIZE];
1197 acf->name(&ale, name);
1198 return name_matches_dopesheet_filter(&ads, name);
1199}
1200
1206static bool fcurve_has_errors(bAnimContext *ac, const FCurve *fcu)
1207{
1208 /* F-Curve disabled (path evaluation error). */
1209 if (fcu->flag & FCURVE_DISABLED) {
1210 return true;
1211 }
1212
1213 /* driver? */
1214 if (fcu->driver) {
1215 const ChannelDriver *driver = fcu->driver;
1216
1217 /* error flag on driver usually means that there is an error
1218 * BUT this may not hold with PyDrivers as this flag gets cleared
1219 * if no critical errors prevent the driver from working...
1220 */
1221 if (driver->flag & DRIVER_FLAG_INVALID) {
1222 return true;
1223 }
1224
1225 /* check variables for other things that need linting... */
1226 /* TODO: maybe it would be more efficient just to have a quick flag for this? */
1227 for (DriverVar &dvar : driver->variables) {
1229 if (dtar->flag & DTAR_FLAG_INVALID) {
1230 return true;
1231 }
1232
1233 if ((dtar->flag & DTAR_FLAG_FALLBACK_USED) &&
1235 {
1236 return true;
1237 }
1238 }
1240 }
1241 }
1242
1243 /* no errors found */
1244 return false;
1245}
1246
1247/* find the next F-Curve that is usable for inclusion */
1249 FCurve *first,
1250 eAnim_ChannelType channel_type,
1251 const eAnimFilter_Flags filter_mode,
1252 void *owner,
1253 ID *owner_id)
1254{
1255 bActionGroup *grp = (channel_type == ANIMTYPE_FCURVE) ? static_cast<bActionGroup *>(owner) :
1256 nullptr;
1257 FCurve *fcu = nullptr;
1258
1259 /* Loop over F-Curves - assume that the caller of this has already checked
1260 * that these should be included.
1261 * NOTE: we need to check if the F-Curves belong to the same group,
1262 * as this gets called for groups too...
1263 */
1264 for (fcu = first; ((fcu) && (fcu->grp == grp)); fcu = fcu->next) {
1265 /* special exception for Pose-Channel/Sequence-Strip/Node Based F-Curves:
1266 * - The 'Only Selected' and 'Include Hidden' data filters should be applied to sub-ID data
1267 * which can be independently selected/hidden, such as Pose-Channels, Sequence Strips,
1268 * and Nodes. Since these checks were traditionally done as first check for objects,
1269 * we do the same here.
1270 * - We currently use an 'approximate' method for getting these F-Curves that doesn't require
1271 * carefully checking the entire path.
1272 * - This will also affect things like Drivers, and also works for Bone Constraints.
1273 */
1274 if (ac->ads && owner_id) {
1275 if ((filter_mode & ANIMFILTER_TMP_IGNORE_ONLYSEL) == 0) {
1276 if ((ac->filters.flag & ADS_FILTER_ONLYSEL) ||
1277 (ac->filters.flag & ADS_FILTER_INCL_HIDDEN) == 0)
1278 {
1279 if (skip_fcurve_selected_data(ac, fcu, owner_id, filter_mode)) {
1280 continue;
1281 }
1282 }
1283 }
1284 }
1285
1286 /* only include if visible (Graph Editor check, not channels check) */
1287 if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || (fcu->flag & FCURVE_VISIBLE)) {
1288 /* only work with this channel and its subchannels if it is editable */
1289 if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_FCU(fcu)) {
1290 /* Only include this curve if selected in a way consistent
1291 * with the filtering requirements. */
1293 /* only include if this curve is active */
1294 if (!(filter_mode & ANIMFILTER_ACTIVE) || (fcu->flag & FCURVE_ACTIVE)) {
1295 /* name based filtering... */
1296 if (((ac->ads) && (ac->ads->searchstr[0] != '\0')) && (owner_id)) {
1297 if (skip_fcurve_with_name(ac, fcu, channel_type, owner, owner_id)) {
1298 continue;
1299 }
1300 }
1301
1302 /* error-based filtering... */
1303 if ((ac->ads) && (ac->filters.flag & ADS_FILTER_ONLY_ERRORS)) {
1304 /* skip if no errors... */
1305 if (!fcurve_has_errors(ac, fcu)) {
1306 continue;
1307 }
1308 }
1309
1310 /* this F-Curve can be used, so return it */
1311 return fcu;
1312 }
1313 }
1314 }
1315 }
1316 }
1317
1318 /* no (more) F-Curves from the list are suitable... */
1319 return nullptr;
1320}
1321
1323 ListBaseT<bAnimListElem> *anim_data,
1324 FCurve *first,
1325 eAnim_ChannelType fcurve_type,
1326 const eAnimFilter_Flags filter_mode,
1327 void *owner,
1328 ID *owner_id,
1329 ID *fcurve_owner_id)
1330{
1331 FCurve *fcu;
1332 size_t items = 0;
1333
1334 /* Loop over every F-Curve able to be included.
1335 *
1336 * This for-loop works like this:
1337 * 1) The starting F-Curve is assigned to the fcu pointer
1338 * so that we have a starting point to search from.
1339 * 2) The first valid F-Curve to start from (which may include the one given as 'first')
1340 * in the remaining list of F-Curves is found, and verified to be non-null.
1341 * 3) The F-Curve referenced by fcu pointer is added to the list
1342 * 4) The fcu pointer is set to the F-Curve after the one we just added,
1343 * so that we can keep going through the rest of the F-Curve list without an eternal loop.
1344 * Back to step 2 :)
1345 */
1346 for (fcu = first;
1347 (fcu = animfilter_fcurve_next(ac, fcu, fcurve_type, filter_mode, owner, owner_id));
1348 fcu = fcu->next)
1349 {
1350 if (fcurve_type == ANIMTYPE_NLACURVE) [[unlikely]] {
1351 /* NLA Control Curve - Basically the same as normal F-Curves,
1352 * except we need to set some stuff differently */
1353 ANIMCHANNEL_NEW_CHANNEL_FULL(ac->bmain, fcu, ANIMTYPE_NLACURVE, owner_id, fcurve_owner_id, {
1354 ale->owner = owner; /* strip */
1355 /* Since #130440 landed, this should now in theory be something like
1356 * `ale->adt = BKE_animdata_from_id(owner_id)`, rather than a nullptr.
1357 * However, at the moment the nullptr doesn't hurt, and it helps us
1358 * catch bugs like #147803 via the assert in `fcurve_to_keylist()`. If
1359 * the nullptr does start to hurt at some point, please change it! */
1360 ale->adt = nullptr;
1361 });
1362 }
1363 else {
1364 /* Normal FCurve */
1365 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, fcu, ANIMTYPE_FCURVE, owner_id, fcurve_owner_id);
1366 }
1367 }
1368
1369 /* return the number of items added to the list */
1370 return items;
1371}
1372
1373static inline bool fcurve_span_selection_matters(const eAnimFilter_Flags filter_mode)
1374{
1375 /* This means that ANIMFILTER_SELEDIT only works if ANIMFILTER_FOREDIT is also set. Given the
1376 * description on ANIMFILTER_SELEDIT this seems reasonable. */
1377 if ((filter_mode & ANIMFILTER_FOREDIT) && (filter_mode & ANIMFILTER_SELEDIT)) {
1378 return true;
1379 }
1380 return filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL);
1381}
1382
1383static inline bool fcurve_span_must_be_selected(const eAnimFilter_Flags filter_mode)
1384{
1385 if ((filter_mode & ANIMFILTER_FOREDIT) && (filter_mode & ANIMFILTER_SELEDIT)) {
1386 return true;
1387 }
1388 return filter_mode & ANIMFILTER_SEL;
1389}
1390
1407 ListBaseT<bAnimListElem> *anim_data,
1408 Span<FCurve *> fcurves,
1409 const animrig::slot_handle_t slot_handle,
1410 const eAnimFilter_Flags filter_mode,
1411 ID *animated_id,
1412 ID *fcurve_owner_id)
1413{
1414 size_t num_items = 0;
1415 BLI_assert(animated_id);
1416
1417 const bool active_matters = filter_mode & ANIMFILTER_ACTIVE;
1418 const bool selection_matters = fcurve_span_selection_matters(filter_mode);
1419 const bool must_be_selected = fcurve_span_must_be_selected(filter_mode);
1420 const bool visibility_matters = filter_mode & ANIMFILTER_CURVE_VISIBLE;
1421 const bool editability_matters = filter_mode & ANIMFILTER_FOREDIT;
1422 const bool show_only_errors = ac->ads && (ac->filters.flag & ADS_FILTER_ONLY_ERRORS);
1423 const bool filter_by_name = ac->ads && (ac->ads->searchstr[0] != '\0');
1424
1425 for (FCurve *fcu : fcurves) {
1426 /* make_new_animlistelem will return nullptr when fcu == nullptr, and that's
1427 * going to cause problems. */
1428 BLI_assert(fcu);
1429
1430 if (editability_matters && (fcu->flag & FCURVE_PROTECTED)) {
1431 continue;
1432 }
1433
1434 if (selection_matters && bool(fcu->flag & FCURVE_SELECTED) != must_be_selected) {
1435 continue;
1436 }
1437 if (active_matters && !(fcu->flag & FCURVE_ACTIVE)) {
1438 continue;
1439 }
1440 if (visibility_matters && !(fcu->flag & FCURVE_VISIBLE)) {
1441 continue;
1442 }
1443 if (show_only_errors && !fcurve_has_errors(ac, fcu)) {
1444 continue;
1445 }
1446 if (skip_fcurve_selected_data(ac, fcu, animated_id, filter_mode)) {
1447 continue;
1448 }
1449 if (ac->spacetype == SPACE_GRAPH) {
1450 const SpaceGraph *sipo = reinterpret_cast<SpaceGraph *>(ac->sl);
1451 if ((sipo->local_view_bit) && (fcu->local_view_bits & sipo->local_view_bit) == 0) {
1452 continue;
1453 }
1454 }
1455
1457 ac->bmain, fcu, ANIMTYPE_FCURVE, animated_id, fcurve_owner_id);
1458
1459 /* Filtering by name needs a way to look up the name, which is easiest if
1460 * there is already an #bAnimListElem. */
1461 if (filter_by_name && !ale_name_matches_dopesheet_filter(*ac->ads, *ale)) {
1462 MEM_delete(ale);
1463 continue;
1464 }
1465
1466 if (filter_mode & ANIMFILTER_TMP_PEEK) {
1467 /* Found an animation channel, which is good enough for the 'TMP_PEEK' mode. */
1468 MEM_delete(ale);
1469 return 1;
1470 }
1471
1472 /* bAnimListElem::slot_handle is exposed as int32_t and not as slot_handle_t, so better
1473 * ensure that these are still equivalent.
1474 * TODO: move to another part of the code. */
1475 static_assert(
1476 std::is_same_v<decltype(ActionSlot::handle), decltype(bAnimListElem::slot_handle)>);
1477
1478 /* Note that this might not be the same as ale->adt->slot_handle. The reason this F-Curve is
1479 * shown could be because it's in the Action editor, showing ale->adt->action with _all_
1480 * slots, and this F-Curve could be from a different slot than what's used by the owner
1481 * of `ale->adt`. */
1482 ale->slot_handle = slot_handle;
1483
1484 BLI_addtail(anim_data, ale);
1485 num_items++;
1486 }
1487
1488 return num_items;
1489}
1490
1500 ListBaseT<bAnimListElem> *anim_data,
1501 bAction *act,
1502 animrig::slot_handle_t slot_handle,
1503 bActionGroup *agrp,
1504 eAnimFilter_Flags filter_mode,
1505 ID *owner_id)
1506{
1507 BLI_assert(act != nullptr);
1508 BLI_assert(agrp != nullptr);
1509
1510 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
1511 size_t tmp_items = 0;
1512 size_t items = 0;
1513
1514 /* if we care about the selection status of the channels,
1515 * but the group isn't expanded (1)...
1516 * (1) this only matters if we actually care about the hierarchy though.
1517 * - Hierarchy matters: this hack should be applied
1518 * - Hierarchy ignored: cases like #21276 won't work properly, unless we skip this hack
1519 */
1520 if (
1521 /* Care about hierarchy but group isn't expanded. */
1522 ((filter_mode & ANIMFILTER_LIST_VISIBLE) && EXPANDED_AGRP(ac, agrp) == 0) &&
1523 /* Care about selection status. */
1524 (filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)))
1525 {
1526 /* If the group itself isn't selected appropriately,
1527 * we shouldn't consider its children either. */
1528 if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0) {
1529 return 0;
1530 }
1531
1532 /* if we're still here,
1533 * then the selection status of the curves within this group should not matter,
1534 * since this creates too much overhead for animators (i.e. making a slow workflow).
1535 *
1536 * Tools affected by this at time of coding (2010 Feb 09):
1537 * - Inserting keyframes on selected channels only.
1538 * - Pasting keyframes.
1539 * - Creating ghost curves in Graph Editor.
1540 */
1542 }
1543
1544 /* add grouped F-Curves */
1546 /* special filter so that we can get just the F-Curves within the active group */
1547 if (!(filter_mode & ANIMFILTER_ACTGROUPED) || (agrp->flag & AGRP_ACTIVE)) {
1548 /* for the Graph Editor, curves may be set to not be visible in the view to lessen
1549 * clutter, but to do this, we need to check that the group doesn't have its
1550 * not-visible flag set preventing all its sub-curves to be shown
1551 */
1552 if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !(agrp->flag & AGRP_NOTVISIBLE)) {
1553 /* group must be editable for its children to be editable (if we care about this) */
1554 if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_AGRP(agrp)) {
1555 /* Filter the fcurves in this group, adding them to the temporary
1556 * filter list. */
1557 BLI_assert(agrp->channelbag != nullptr);
1558 Span<FCurve *> fcurves = agrp->wrap().fcurves();
1559 tmp_items += animfilter_fcurves_span(
1560 ac, &tmp_data, fcurves, slot_handle, filter_mode, owner_id, &act->id);
1561 }
1562 }
1563 }
1564 }
1566
1567 /* did we find anything? */
1568 if (tmp_items) {
1569 /* add this group as a channel first */
1570 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
1571 /* filter selection of channel specially here again,
1572 * since may be open and not subject to previous test */
1573 if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp))) {
1574 ANIMCHANNEL_NEW_CHANNEL_FULL(ac->bmain, agrp, ANIMTYPE_GROUP, owner_id, &act->id, {
1575 ale->slot_handle = slot_handle;
1576 });
1577 }
1578 }
1579
1580 /* now add the list of collected channels */
1581 BLI_movelisttolist(anim_data, &tmp_data);
1582 BLI_assert(tmp_data.is_empty());
1583 items += tmp_items;
1584 }
1585
1586 /* return the number of items added to the list */
1587 return items;
1588}
1589
1591 ListBaseT<bAnimListElem> *anim_data,
1592 animrig::Action &action,
1593 animrig::Slot &slot,
1594 const eAnimFilter_Flags filter_mode,
1595 ID *animated_id)
1596{
1597 BLI_assert(ac);
1598
1599 /* In some cases (see `ob_to_keylist()` and friends) fake bDopeSheet and fake bAnimContext are
1600 * created. These are mostly null-initialized, and so do not have a bmain. This means that
1601 * lookup of the animated ID is not possible, which can result in failure to look up the proper
1602 * F-Curve display name. For the `..._to_keylist` functions that doesn't matter, as those are
1603 * only interested in the key data anyway. So rather than trying to get a reliable `bmain`
1604 * through the maze, this code just treats it as optional (even though ideally it should always
1605 * be known). */
1606 ID *slot_user_id = nullptr;
1607 if (ac->bmain) {
1608 slot_user_id = animrig::action_slot_get_id_best_guess(*ac->bmain, slot, animated_id);
1609 }
1610 if (!slot_user_id) {
1611 BLI_assert(animated_id);
1612 /* At the time of writing this (PR #134922), downstream code (see e.g.
1613 * `animfilter_fcurves_span()`) assumes this is non-null, so we need to set
1614 * it to *something*. If it's not an actual user of the slot then channels
1615 * might not resolve to an actual property and thus be displayed oddly in
1616 * the channel list, but that's not technically a problem, it's just a
1617 * little strange for the end user. */
1618 slot_user_id = animated_id;
1619 }
1620
1621 /* Don't include anything from this animation if it is linked in from another
1622 * file, and we're getting stuff for editing... */
1623 if ((filter_mode & ANIMFILTER_FOREDIT) &&
1624 (ID_IS_LINKED(&action) || ID_IS_OVERRIDE_LIBRARY(&action)))
1625 {
1626 return 0;
1627 }
1628
1629 const bool selection_matters = filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL);
1630 const bool must_be_selected = filter_mode & ANIMFILTER_SEL;
1631 const bool selection_ok_for_slot = !selection_matters || slot.is_selected() == must_be_selected;
1632
1633 int items = 0;
1634
1635 /* Add a list element for the Slot itself, but only if in Action mode. The Dopesheet mode
1636 * shouldn't display Slots, as F-Curves are always shown in the context of the animated ID
1637 * anyway. */
1638 const bool is_action_mode = (ac->spacetype == SPACE_ACTION &&
1640 const bool show_active_group_only = filter_mode & ANIMFILTER_ACTGROUPED;
1641 const bool include_summary_channels = (filter_mode & ANIMFILTER_LIST_CHANNELS);
1642 const bool show_slot_channel = (is_action_mode && selection_ok_for_slot &&
1643 include_summary_channels);
1644 if (show_slot_channel) {
1645 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, &slot, ANIMTYPE_ACTION_SLOT, slot_user_id, &action.id);
1646 items++;
1647 }
1648
1649 /* If the 'list visible' flag is used, the expansion state of the Slot
1650 * matters. Otherwise the sub-channels can always be listed. */
1651 const bool visible_only = (filter_mode & ANIMFILTER_LIST_VISIBLE);
1652 const bool expansion_is_ok = !visible_only || !show_slot_channel || slot.is_expanded();
1653
1655 if (channelbag == nullptr) {
1656 return items;
1657 }
1658
1659 if (!expansion_is_ok) {
1660 return items;
1661 }
1662
1663 /* Add channel groups and their member channels. */
1664 for (bActionGroup *group : channelbag->channel_groups()) {
1665 items += animfilter_act_group(
1666 ac, anim_data, &action, slot.handle, group, filter_mode, slot_user_id);
1667 }
1668
1669 /* Add ungrouped channels. */
1670 if (!show_active_group_only) {
1671 int first_ungrouped_fcurve_index = 0;
1672 if (!channelbag->channel_groups().is_empty()) {
1673 const bActionGroup *last_group = channelbag->channel_groups().last();
1674 first_ungrouped_fcurve_index = last_group->fcurve_range_start +
1675 last_group->fcurve_range_length;
1676 }
1677
1678 Span<FCurve *> fcurves = channelbag->fcurves().drop_front(first_ungrouped_fcurve_index);
1679 items += animfilter_fcurves_span(
1680 ac, anim_data, fcurves, slot.handle, filter_mode, slot_user_id, &action.id);
1681 }
1682
1683 return items;
1684}
1685
1687 ListBaseT<bAnimListElem> *anim_data,
1688 animrig::Action &action,
1689 const eAnimFilter_Flags filter_mode,
1690 ID *owner_id)
1691{
1692 /* Don't include anything from this animation if it is linked in from another
1693 * file, and we're getting stuff for editing... */
1694 if ((filter_mode & ANIMFILTER_FOREDIT) &&
1695 (ID_IS_LINKED(&action) || ID_IS_OVERRIDE_LIBRARY(&action)))
1696 {
1697 return 0;
1698 }
1699
1700 int num_items = 0;
1701 for (animrig::Slot *slot : action.slots()) {
1702 BLI_assert(slot);
1703
1704 num_items += ANIM_animfilter_action_slot(ac, anim_data, action, *slot, filter_mode, owner_id);
1705 }
1706
1707 return num_items;
1708}
1709
1711 ListBaseT<bAnimListElem> *anim_data,
1712 animrig::Action &action,
1713 const animrig::slot_handle_t slot_handle,
1714 const eAnimFilter_Flags filter_mode,
1715 ID *owner_id)
1716{
1717 if (action.is_empty()) {
1718 return 0;
1719 }
1720
1721 /* don't include anything from this action if it is linked in from another file,
1722 * and we're getting stuff for editing...
1723 */
1724 if ((filter_mode & ANIMFILTER_FOREDIT) &&
1725 (!ID_IS_EDITABLE(&action) || ID_IS_OVERRIDE_LIBRARY(&action)))
1726 {
1727 return 0;
1728 }
1729
1730 /* For now we don't show layers anywhere, just the contained F-Curves. */
1731
1732 /* Only show all Slots in Action editor mode. Otherwise the F-Curves ought to be displayed
1733 * underneath their animated ID anyway. */
1734 const bool is_action_mode = (ac->spacetype == SPACE_ACTION &&
1736 const bool show_active_only = (ac->filters.flag & ADS_FILTER_ONLY_SLOTS_OF_ACTIVE);
1737 if (is_action_mode && !show_active_only) {
1738 return animfilter_action_slots(ac, anim_data, action, filter_mode, owner_id);
1739 }
1740
1741 animrig::Slot *slot = action.slot_for_handle(slot_handle);
1742 if (!slot) {
1743 /* Can happen when an Action is assigned, but not a Slot. */
1744 return 0;
1745 }
1746 return ANIM_animfilter_action_slot(ac, anim_data, action, *slot, filter_mode, owner_id);
1747}
1748
1749/* Include NLA-Data for NLA-Editor:
1750 * - When ANIMFILTER_LIST_CHANNELS is used, that means we should be filtering the list for display
1751 * Although the evaluation order is from the first track to the last and then apply the
1752 * Action on top, we present this in the UI as the Active Action followed by the last track
1753 * to the first so that we get the evaluation order presented as per a stack.
1754 * - For normal filtering (i.e. for editing),
1755 * we only need the NLA-tracks but they can be in 'normal' evaluation order, i.e. first to last.
1756 * Otherwise, some tools may get screwed up.
1757 */
1759 ListBaseT<bAnimListElem> *anim_data,
1760 AnimData *adt,
1761 const eAnimFilter_Flags filter_mode,
1762 ID *owner_id)
1763{
1764 NlaTrack *nlt;
1765 NlaTrack *first = nullptr, *next = nullptr;
1766 size_t items = 0;
1767
1768 /* if showing channels, include active action */
1769 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
1770 /* if NLA action-line filtering is off, don't show unless there are keyframes,
1771 * in order to keep things more compact for doing transforms
1772 */
1773 if (!(ac->filters.flag & ADS_FILTER_NLA_NOACT) || (adt->action)) {
1774 /* there isn't really anything editable here, so skip if need editable */
1775 if ((filter_mode & ANIMFILTER_FOREDIT) == 0) {
1776 /* Just add the action track now (this MUST appear for drawing):
1777 * - As AnimData may not have an action,
1778 * we pass a dummy pointer just to get the list elem created,
1779 * then overwrite this with the real value - REVIEW THIS.
1780 */
1782 ac->bmain, (void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id, nullptr, {
1783 ale->data = adt->action ? adt->action : nullptr;
1784 });
1785 }
1786 }
1787
1788 /* first track to include will be the last one if we're filtering by channels */
1789 first = adt->nla_tracks.last();
1790 }
1791 else {
1792 /* first track to include will the first one (as per normal) */
1793 first = adt->nla_tracks.first();
1794 }
1795
1796 /* loop over NLA Tracks -
1797 * assume that the caller of this has already checked that these should be included */
1798 for (nlt = first; nlt; nlt = next) {
1799 /* 'next' NLA-Track to use depends on whether we're filtering for drawing or not */
1800 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
1801 next = nlt->prev;
1802 }
1803 else {
1804 next = nlt->next;
1805 }
1806
1807 /* only work with this channel and its subchannels if it is editable */
1808 if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) {
1809 /* only include this track if selected in a way consistent with the filtering requirements */
1810 if (ANIMCHANNEL_SELOK(SEL_NLT(nlt))) {
1811 /* only include if this track is active */
1812 if (!(filter_mode & ANIMFILTER_ACTIVE) || (nlt->flag & NLATRACK_ACTIVE)) {
1813 /* name based filtering... */
1814 if (((ac->ads) && (ac->ads->searchstr[0] != '\0')) && (owner_id)) {
1815 bool track_ok = false, strip_ok = false;
1816
1817 /* check if the name of the track, or the strips it has are ok... */
1818 track_ok = name_matches_dopesheet_filter(ac->ads, nlt->name);
1819
1820 if (track_ok == false) {
1821 for (NlaStrip &strip : nlt->strips) {
1822 if (name_matches_dopesheet_filter(ac->ads, strip.name) ||
1823 (strip.flag & NLASTRIP_FLAG_TEMP_META))
1824 {
1825 strip_ok = true;
1826 break;
1827 }
1828 }
1829 }
1830
1831 /* skip if both fail this test... */
1832 if (!track_ok && !strip_ok) {
1833 continue;
1834 }
1835 }
1836
1837 /* add the track now that it has passed all our tests */
1838 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, nlt, ANIMTYPE_NLATRACK, owner_id, nullptr);
1839 }
1840 }
1841 }
1842 }
1843
1844 /* return the number of items added to the list */
1845 return items;
1846}
1847
1848/* Include the control FCurves per NLA Strip in the channel list
1849 * NOTE: This is includes the expander too...
1850 */
1852 ListBaseT<bAnimListElem> *anim_data,
1853 AnimData *adt,
1854 eAnimFilter_Flags filter_mode,
1855 ID *owner_id)
1856{
1857 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
1858 size_t tmp_items = 0;
1859 size_t items = 0;
1860
1861 /* add control curves from each NLA strip... */
1862 /* NOTE: ANIMTYPE_FCURVES are created here, to avoid duplicating the code needed */
1864 /* for now, we only go one level deep - so controls on grouped FCurves are not handled */
1865 for (NlaTrack &nlt : adt->nla_tracks) {
1866 for (NlaStrip &strip : nlt.strips) {
1867 /* pass strip as the "owner",
1868 * so that the name lookups (used while filtering) will resolve */
1869 /* NLA tracks are coming from AnimData, so owner of f-curves
1870 * is the same as owner of animation data. */
1871 tmp_items += animfilter_fcurves(ac,
1872 &tmp_data,
1873 strip.fcurves.first(),
1875 filter_mode,
1876 &strip,
1877 owner_id,
1878 owner_id);
1879 }
1880 }
1881 }
1883
1884 /* did we find anything? */
1885 if (tmp_items) {
1886 /* add the expander as a channel first */
1887 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
1888 /* currently these channels cannot be selected, so they should be skipped */
1889 if ((filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) == 0) {
1890 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, adt, ANIMTYPE_NLACONTROLS, owner_id, nullptr);
1891 }
1892 }
1893
1894 /* now add the list of collected channels */
1895 BLI_movelisttolist(anim_data, &tmp_data);
1896 BLI_assert(tmp_data.is_empty());
1897 items += tmp_items;
1898 }
1899
1900 /* return the number of items added to the list */
1901 return items;
1902}
1903
1904/* determine what animation data from AnimData block should get displayed */
1906 ListBaseT<bAnimListElem> *anim_data,
1907 ID *id,
1908 const eAnimFilter_Flags filter_mode)
1909{
1910 AnimData *adt = BKE_animdata_from_id(id);
1911 size_t items = 0;
1912
1913 /* image object data-blocks have no anim-data so check for nullptr */
1914 if (adt) {
1915 IdAdtTemplate *iat = reinterpret_cast<IdAdtTemplate *>(id);
1916
1917 /* NOTE: this macro is used instead of inlining the logic here,
1918 * since this sort of filtering is still needed in a few places in the rest of the code still -
1919 * notably for the few cases where special mode-based
1920 * different types of data expanders are required.
1921 */
1923 iat,
1924 { /* AnimData */
1925 /* specifically filter animdata block */
1926 if (ANIMCHANNEL_SELOK(SEL_ANIMDATA(adt))) {
1927 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, adt, ANIMTYPE_ANIMDATA, id, nullptr);
1928 }
1929 },
1930 { /* NLA */
1931 items += animfilter_nla(ac, anim_data, adt, filter_mode, id);
1932 },
1933 { /* Drivers */
1934 items += animfilter_fcurves(
1935 ac, anim_data, adt->drivers.first(), ANIMTYPE_FCURVE, filter_mode, nullptr, id, id);
1936 },
1937 { /* NLA Control Keyframes */
1938 items += animfilter_nla_controls(ac, anim_data, adt, filter_mode, id);
1939 },
1940 { /* Keyframes from legacy Action. */
1941 items += animfilter_action(ac,
1942 anim_data,
1943 adt->action->wrap(),
1944 adt->slot_handle,
1945 eAnimFilter_Flags(filter_mode),
1946 id);
1947 },
1948 { /* Keyframes from layered Action. */
1949 items += animfilter_action(ac,
1950 anim_data,
1951 adt->action->wrap(),
1952 adt->slot_handle,
1953 eAnimFilter_Flags(filter_mode),
1954 id);
1955 });
1956 }
1957
1958 return items;
1959}
1960
1961/* Include ShapeKey Data for ShapeKey Editor */
1963 ListBaseT<bAnimListElem> *anim_data,
1964 Key *key,
1965 const eAnimFilter_Flags filter_mode)
1966{
1967 using namespace blender::animrig;
1968
1969 size_t items = 0;
1970
1971 /* check if channels or only F-Curves */
1972 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
1973 bDopeSheet *ads = ac->ads;
1974
1975 if (key->type == KEY_RELATIVE) {
1976 /* TODO: This currently doesn't take into account the animatable "Range Min/Max" keys on the
1977 * key-blocks. */
1978
1979 /* loop through the channels adding ShapeKeys as appropriate */
1980 for (KeyBlock &kb : key->block) {
1981 /* skip the first one, since that's the non-animatable basis */
1982 if (&kb == key->block.first_) {
1983 continue;
1984 }
1985
1986 /* Skip shapekey if the name doesn't match the filter string. */
1987 if (ads != nullptr && ads->searchstr[0] != '\0' &&
1988 name_matches_dopesheet_filter(ads, kb.name) == false)
1989 {
1990 continue;
1991 }
1992
1993 /* only work with this channel and its subchannels if it is editable */
1994 if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_SHAPEKEY(&kb)) {
1995 /* Only include this track if selected in a way consistent
1996 * with the filtering requirements. */
1997 if (ANIMCHANNEL_SELOK(SEL_SHAPEKEY(&kb))) {
1998 /* TODO: consider 'active' too? */
1999
2000 /* owner-id here must be key so that the F-Curve can be resolved... */
2001 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, &kb, ANIMTYPE_SHAPEKEY, key, nullptr);
2002 }
2003 }
2004 }
2005 }
2006 else {
2007 /* key->type == KEY_NORMAL */
2008 if (!key->adt || !key->adt->action) {
2009 return 0;
2010 }
2011 Action &action = key->adt->action->wrap();
2012
2013 Vector<FCurve *> key_fcurves;
2014 for (FCurve *fcurve : fcurves_for_action_slot(action, key->adt->slot_handle)) {
2015 if (fcurve->rna_path() == "eval_time" ||
2016 BLI_str_endswith(fcurve->rna_path().c_str(), ".interpolation"))
2017 {
2018 key_fcurves.append(fcurve);
2019 }
2020 }
2021
2022 items += animfilter_fcurves_span(
2023 ac, anim_data, key_fcurves, key->adt->slot_handle, filter_mode, &key->id, &action.id);
2024 }
2025 }
2026 else {
2027 /* just use the action associated with the shapekey */
2028 /* TODO: somehow manage to pass dopesheet info down here too? */
2029 if (key->adt) {
2030 if (filter_mode & ANIMFILTER_ANIMDATA) {
2031 if (ANIMCHANNEL_SELOK(SEL_ANIMDATA(key->adt))) {
2032 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, key->adt, ANIMTYPE_ANIMDATA, key, nullptr);
2033 }
2034 }
2035 else if (key->adt->action) {
2036 items = animfilter_action(ac,
2037 anim_data,
2038 key->adt->action->wrap(),
2039 key->adt->slot_handle,
2040 eAnimFilter_Flags(filter_mode),
2041 reinterpret_cast<ID *>(key));
2042 }
2043 }
2044 }
2045
2046 /* return the number of items added to the list */
2047 return items;
2048}
2049
2050/* Helper for Grease Pencil - layers within a data-block. */
2051
2053 ListBaseT<bAnimListElem> *anim_data,
2056 const eAnimFilter_Flags filter_mode)
2057{
2058
2059 size_t items = 0;
2060
2061 /* Only if the layer is selected. */
2062 if (!ANIMCHANNEL_SELOK(layer.is_selected())) {
2063 return items;
2064 }
2065
2066 /* Only if the layer is editable. */
2067 if ((filter_mode & ANIMFILTER_FOREDIT) && layer.is_locked()) {
2068 return items;
2069 }
2070
2071 /* Only if the layer is active. */
2072 if ((filter_mode & ANIMFILTER_ACTIVE) && grease_pencil->is_layer_active(&layer)) {
2073 return items;
2074 }
2075
2076 /* Skip empty layers. */
2077 if (layer.is_empty()) {
2078 return items;
2079 }
2080
2081 /* Add layer channel. */
2083 static_cast<void *>(&layer),
2086 nullptr);
2087
2088 return items;
2089}
2090
2092 bAnimContext *ac,
2093 ListBaseT<bAnimListElem> *anim_data,
2096 eAnimFilter_Flags filter_mode)
2097{
2098 using namespace blender::bke::greasepencil;
2099 size_t items = 0;
2100
2101 /* Skip node if the name doesn't match the filter string. */
2102 const bool name_search = (ac->ads->searchstr[0] != '\0');
2103 const bool skip_node = name_search &&
2104 !name_matches_dopesheet_filter(ac->ads, node.name().c_str());
2105
2106 if (node.is_layer() && !skip_node) {
2108 ac, anim_data, grease_pencil, node.as_layer(), filter_mode);
2109 }
2110 else if (node.is_group()) {
2111 LayerGroup &layer_group = node.as_group();
2112
2113 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2114 size_t tmp_items = 0;
2115
2116 /* Add grease pencil layer channels. */
2118 for (GreasePencilLayerTreeNode &node_ : layer_group.children.items_reversed()) {
2120 ac, &tmp_data, grease_pencil, node_.wrap(), filter_mode);
2121 }
2122 }
2124
2125 if ((tmp_items == 0) && !name_search) {
2126 /* If no sub-channels, return early.
2127 * Except if the search by name is on, because we might want to display the layer group alone
2128 * in that case. */
2129 return items;
2130 }
2131
2132 if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && !skip_node) {
2133 /* Add data block container (if for drawing, and it contains sub-channels). */
2135 static_cast<void *>(&node),
2138 nullptr);
2139 }
2140
2141 /* Add the list of collected channels. */
2142 BLI_movelisttolist(anim_data, &tmp_data);
2143 BLI_assert(tmp_data.is_empty());
2144 items += tmp_items;
2145 }
2146 return items;
2147}
2148
2150 ListBaseT<bAnimListElem> *anim_data,
2152 const eAnimFilter_Flags filter_mode)
2153{
2154 size_t items = 0;
2155
2156 for (GreasePencilLayerTreeNode &node : grease_pencil->root_group_ptr->children.items_reversed())
2157 {
2159 ac, anim_data, grease_pencil, node.wrap(), filter_mode);
2160 }
2161
2162 return items;
2163}
2164
2165/* Helper for Grease Pencil - layers within a data-block. */
2167 ListBaseT<bAnimListElem> *anim_data,
2168 bGPdata *gpd,
2169 const eAnimFilter_Flags filter_mode)
2170{
2171 size_t items = 0;
2172
2173 /* loop over layers as the conditions are acceptable (top-Down order) */
2174 for (bGPDlayer &gpl : gpd->layers.items_reversed()) {
2175 /* only if selected */
2176 if (!ANIMCHANNEL_SELOK(SEL_GPL(&gpl))) {
2177 continue;
2178 }
2179
2180 /* only if editable */
2181 if ((filter_mode & ANIMFILTER_FOREDIT) && !EDITABLE_GPL(&gpl)) {
2182 continue;
2183 }
2184
2185 /* active... */
2186 if ((filter_mode & ANIMFILTER_ACTIVE) && (gpl.flag & GP_LAYER_ACTIVE) == 0) {
2187 continue;
2188 }
2189
2190 /* skip layer if the name doesn't match the filter string */
2191 if (ac->ads != nullptr && ac->ads->searchstr[0] != '\0' &&
2192 name_matches_dopesheet_filter(ac->ads, gpl.info) == false)
2193 {
2194 continue;
2195 }
2196
2197 /* Skip empty layers. */
2198 if (gpl.frames.is_empty()) {
2199 continue;
2200 }
2201
2202 /* add to list */
2203 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, &gpl, ANIMTYPE_GPLAYER, gpd, nullptr);
2204 }
2205
2206 return items;
2207}
2208
2210 ListBaseT<bAnimListElem> *anim_data,
2212 eAnimFilter_Flags filter_mode)
2213{
2214 size_t items = 0;
2215
2216 /* The Grease Pencil mode is not supposed to show channels for regular F-Curves from regular
2217 * Actions. At some point this might be desirable, but it would also require changing the
2218 * filtering flags for pretty much all operators running there. */
2219 const bool show_animdata = grease_pencil->adt && (ac->datatype != ANIMCONT_GPENCIL);
2220
2221 /* When asked from "AnimData" blocks (i.e. the top-level containers for normal animation),
2222 * for convenience, this will return grease pencil data-blocks instead.
2223 * This may cause issues down the track, but for now, this will do.
2224 */
2225 if (filter_mode & ANIMFILTER_ANIMDATA) {
2226 if (show_animdata) {
2227 items += animfilter_block_data(
2228 ac, anim_data, reinterpret_cast<ID *>(grease_pencil), filter_mode);
2229 }
2230 }
2231 else {
2232 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2233 size_t tmp_items = 0;
2234
2235 /* Add grease pencil layer channels. */
2237 if (show_animdata) {
2238 tmp_items += animfilter_block_data(
2239 ac, &tmp_data, reinterpret_cast<ID *>(grease_pencil), filter_mode);
2240 }
2241
2242 if (!(filter_mode & ANIMFILTER_FCURVESONLY)) {
2244 ac, &tmp_data, grease_pencil, filter_mode);
2245 }
2246 }
2248
2249 if (tmp_items == 0) {
2250 /* If no sub-channels, return early. */
2251 return items;
2252 }
2253
2254 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
2255 /* Add data block container (if for drawing, and it contains sub-channels). */
2258 }
2259
2260 /* Add the list of collected channels. */
2261 BLI_movelisttolist(anim_data, &tmp_data);
2262 BLI_assert(tmp_data.is_empty());
2263 items += tmp_items;
2264 }
2265
2266 return items;
2267}
2268
2270 ListBaseT<bAnimListElem> *anim_data,
2271 const eAnimFilter_Flags filter_mode)
2272{
2273 size_t items = 0;
2274 Scene *scene = ac->scene;
2275 ViewLayer *view_layer = ac->view_layer;
2276 bDopeSheet *ads = ac->ads;
2277
2278 BKE_view_layer_synced_ensure(*ac->bmain, scene, view_layer);
2279 for (Base &base : *BKE_view_layer_object_bases_get(view_layer)) {
2280 if (!base.object || (base.object->type != OB_GREASE_PENCIL)) {
2281 continue;
2282 }
2283 Object *ob = base.object;
2284
2285 if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ac->filters.flag & ADS_FILTER_INCL_HIDDEN)) {
2286 /* Layer visibility - we check both object and base,
2287 * since these may not be in sync yet. */
2288 if ((base.flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT) == 0 ||
2290 {
2291 continue;
2292 }
2293
2294 /* Outliner restrict-flag */
2296 continue;
2297 }
2298 }
2299
2300 /* Check selection and object type filters */
2301 if ((ac->filters.flag & ADS_FILTER_ONLYSEL) && !(base.flag & BASE_SELECTED)) {
2302 /* Only selected should be shown */
2303 continue;
2304 }
2305
2306 if (ads->filter_grp != nullptr) {
2308 continue;
2309 }
2310 }
2311
2313 ac, anim_data, id_cast<GreasePencil *>(ob->data), filter_mode);
2314 }
2315
2316 /* Return the number of items added to the list */
2317 return items;
2318}
2319
2320/* Helper for Grease Pencil data integrated with main DopeSheet */
2322 ListBaseT<bAnimListElem> *anim_data,
2323 bGPdata *gpd,
2324 eAnimFilter_Flags filter_mode)
2325{
2326 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2327 size_t tmp_items = 0;
2328 size_t items = 0;
2329
2330 /* add relevant animation channels for Grease Pencil */
2332 /* add animation channels */
2333 tmp_items += animfilter_block_data(ac, &tmp_data, &gpd->id, filter_mode);
2334
2335 /* add Grease Pencil layers */
2336 if (!(filter_mode & ANIMFILTER_FCURVESONLY)) {
2337 tmp_items += animdata_filter_gpencil_layers_data_legacy(ac, &tmp_data, gpd, filter_mode);
2338 }
2339
2340 /* TODO: do these need a separate expander?
2341 * XXX: what order should these go in? */
2342 }
2344
2345 /* did we find anything? */
2346 if (tmp_items) {
2347 /* include data-expand widget first */
2348 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
2349 /* check if filtering by active status */
2350 /* XXX: active check here needs checking */
2351 if (ANIMCHANNEL_ACTIVEOK(gpd)) {
2352 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, gpd, ANIMTYPE_DSGPENCIL, gpd, nullptr);
2353 }
2354 }
2355
2356 /* now add the list of collected channels */
2357 BLI_movelisttolist(anim_data, &tmp_data);
2358 BLI_assert(tmp_data.is_empty());
2359 items += tmp_items;
2360 }
2361
2362 /* return the number of items added to the list */
2363 return items;
2364}
2365
2366/* Helper for Cache File data integrated with main DopeSheet */
2368 ListBaseT<bAnimListElem> *anim_data,
2369 CacheFile *cache_file,
2370 eAnimFilter_Flags filter_mode)
2371{
2372 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2373 size_t tmp_items = 0;
2374 size_t items = 0;
2375
2376 /* add relevant animation channels for Cache File */
2378 /* add animation channels */
2379 tmp_items += animfilter_block_data(ac, &tmp_data, &cache_file->id, filter_mode);
2380 }
2382
2383 /* did we find anything? */
2384 if (tmp_items) {
2385 /* include data-expand widget first */
2386 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
2387 /* check if filtering by active status */
2388 /* XXX: active check here needs checking */
2389 if (ANIMCHANNEL_ACTIVEOK(cache_file)) {
2390 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, cache_file, ANIMTYPE_DSCACHEFILE, cache_file, nullptr);
2391 }
2392 }
2393
2394 /* now add the list of collected channels */
2395 BLI_movelisttolist(anim_data, &tmp_data);
2396 BLI_assert(tmp_data.is_empty());
2397 items += tmp_items;
2398 }
2399
2400 /* return the number of items added to the list */
2401 return items;
2402}
2403
2404/* Helper for Mask Editing - mask layers */
2406 ListBaseT<bAnimListElem> *anim_data,
2407 Mask *mask,
2408 const eAnimFilter_Flags filter_mode)
2409{
2410 const MaskLayer *masklay_act = BKE_mask_layer_active(mask);
2411 size_t items = 0;
2412
2413 for (MaskLayer &masklay : mask->masklayers) {
2414 if (!ANIMCHANNEL_SELOK(SEL_MASKLAY(&masklay))) {
2415 continue;
2416 }
2417
2418 if ((filter_mode & ANIMFILTER_FOREDIT) && !EDITABLE_MASK(&masklay)) {
2419 continue;
2420 }
2421
2422 if ((filter_mode & ANIMFILTER_ACTIVE) & (masklay_act != &masklay)) {
2423 continue;
2424 }
2425
2426 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, &masklay, ANIMTYPE_MASKLAYER, mask, nullptr);
2427 }
2428
2429 return items;
2430}
2431
2432/* Grab all mask data */
2434 ListBaseT<bAnimListElem> *anim_data,
2435 void * /*data*/,
2436 eAnimFilter_Flags filter_mode)
2437{
2438 size_t items = 0;
2439
2440 /* For now, grab mask data-blocks directly from main. */
2441 /* XXX: this is not good... */
2442 for (Mask &mask : ac->bmain->masks) {
2443 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2444 size_t tmp_items = 0;
2445
2446 /* only show if mask is used by something... */
2447 if (ID_REAL_USERS(&mask) < 1) {
2448 continue;
2449 }
2450
2451 /* add mask animation channels */
2452 if (!(filter_mode & ANIMFILTER_FCURVESONLY)) {
2454 tmp_items += animdata_filter_mask_data(ac, &tmp_data, &mask, filter_mode);
2455 }
2457 }
2458
2459 /* did we find anything? */
2460 if (!tmp_items) {
2461 continue;
2462 }
2463
2464 /* include data-expand widget first */
2465 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
2466 /* add mask data-block as channel too (if for drawing, and it has layers) */
2467 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, &mask, ANIMTYPE_MASKDATABLOCK, nullptr, nullptr);
2468 }
2469
2470 /* now add the list of collected channels */
2471 BLI_movelisttolist(anim_data, &tmp_data);
2472 BLI_assert(tmp_data.is_empty());
2473 items += tmp_items;
2474 }
2475
2476 /* return the number of items added to the list */
2477 return items;
2478}
2479
2480/* NOTE: owner_id is scene, material, or texture block,
2481 * which is the direct owner of the node tree in question. */
2483 ListBaseT<bAnimListElem> *anim_data,
2484 ID *owner_id,
2485 bNodeTree *ntree,
2486 eAnimFilter_Flags filter_mode)
2487{
2488 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2489 size_t tmp_items = 0;
2490 size_t items = 0;
2491
2492 /* add nodetree animation channels */
2494 /* animation data filtering */
2495 tmp_items += animfilter_block_data(ac, &tmp_data, reinterpret_cast<ID *>(ntree), filter_mode);
2496 }
2498
2499 /* did we find anything? */
2500 if (tmp_items) {
2501 /* include data-expand widget first */
2502 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
2503 /* check if filtering by active status */
2504 if (ANIMCHANNEL_ACTIVEOK(ntree)) {
2505 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, ntree, ANIMTYPE_DSNTREE, owner_id, nullptr);
2506 }
2507 }
2508
2509 /* now add the list of collected channels */
2510 BLI_movelisttolist(anim_data, &tmp_data);
2511 BLI_assert(tmp_data.is_empty());
2512 items += tmp_items;
2513 }
2514
2515 /* return the number of items added to the list */
2516 return items;
2517}
2518
2520 ListBaseT<bAnimListElem> *anim_data,
2521 ID *owner_id,
2522 bNodeTree *ntree,
2523 const eAnimFilter_Flags filter_mode)
2524{
2525 size_t items = 0;
2526
2527 items += animdata_filter_ds_nodetree_group(ac, anim_data, owner_id, ntree, filter_mode);
2528
2529 for (bNode *node : ntree->all_nodes()) {
2530 if (node->is_group()) {
2531 if (node->id) {
2532 if ((ac->filters.flag & ADS_FILTER_ONLYSEL) && !node->is_selected()) {
2533 continue;
2534 }
2535 /* Recurse into the node group */
2536 items += animdata_filter_ds_nodetree(ac,
2537 anim_data,
2538 owner_id,
2539 reinterpret_cast<bNodeTree *>(node->id),
2540 filter_mode | ANIMFILTER_TMP_IGNORE_ONLYSEL);
2541 }
2542 }
2543 }
2544
2545 return items;
2546}
2547
2549 ListBaseT<bAnimListElem> *anim_data,
2550 Scene *sce,
2551 eAnimFilter_Flags filter_mode)
2552{
2553 size_t items = 0;
2554
2555 for (ViewLayer &view_layer : sce->view_layers) {
2556 for (FreestyleLineSet &lineset : view_layer.freestyle_config.linesets) {
2557 if (lineset.linestyle) {
2558 lineset.linestyle->id.tag |= ID_TAG_DOIT;
2559 }
2560 }
2561 }
2562
2563 for (ViewLayer &view_layer : sce->view_layers) {
2564 /* skip render layers without Freestyle enabled */
2565 if ((view_layer.flag & VIEW_LAYER_FREESTYLE) == 0) {
2566 continue;
2567 }
2568
2569 /* loop over linesets defined in the render layer */
2570 for (FreestyleLineSet &lineset : view_layer.freestyle_config.linesets) {
2571 FreestyleLineStyle *linestyle = lineset.linestyle;
2572 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2573 size_t tmp_items = 0;
2574
2575 if ((linestyle == nullptr) || !(linestyle->id.tag & ID_TAG_DOIT)) {
2576 continue;
2577 }
2578 linestyle->id.tag &= ~ID_TAG_DOIT;
2579
2580 /* add scene-level animation channels */
2582 /* animation data filtering */
2583 tmp_items += animfilter_block_data(
2584 ac, &tmp_data, reinterpret_cast<ID *>(linestyle), filter_mode);
2585 }
2587
2588 /* did we find anything? */
2589 if (tmp_items) {
2590 /* include anim-expand widget first */
2591 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
2592 /* check if filtering by active status */
2593 if (ANIMCHANNEL_ACTIVEOK(linestyle)) {
2594 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, linestyle, ANIMTYPE_DSLINESTYLE, sce, nullptr);
2595 }
2596 }
2597
2598 /* now add the list of collected channels */
2599 BLI_movelisttolist(anim_data, &tmp_data);
2600 BLI_assert(tmp_data.is_empty());
2601 items += tmp_items;
2602 }
2603 }
2604 }
2605
2606 /* return the number of items added to the list */
2607 return items;
2608}
2609
2611 ListBaseT<bAnimListElem> *anim_data,
2612 Tex *tex,
2613 ID *owner_id,
2614 eAnimFilter_Flags filter_mode)
2615{
2616 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2617 size_t tmp_items = 0;
2618 size_t items = 0;
2619
2620 /* add texture's animation data to temp collection */
2622 /* texture animdata */
2623 tmp_items += animfilter_block_data(ac, &tmp_data, reinterpret_cast<ID *>(tex), filter_mode);
2624
2625 /* nodes */
2626 if ((tex->nodetree) && !(ac->filters.flag & ADS_FILTER_NONTREE)) {
2627 /* owner_id as id instead of texture,
2628 * since it'll otherwise be impossible to track the depth. */
2629
2630 /* FIXME: perhaps as a result, textures should NOT be included under materials,
2631 * but under their own section instead so that free-floating textures can also be animated.
2632 */
2633 tmp_items += animdata_filter_ds_nodetree(
2634 ac, &tmp_data, reinterpret_cast<ID *>(tex), tex->nodetree, filter_mode);
2635 }
2636 }
2638
2639 /* did we find anything? */
2640 if (tmp_items) {
2641 /* include texture-expand widget? */
2642 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
2643 /* check if filtering by active status */
2644 if (ANIMCHANNEL_ACTIVEOK(tex)) {
2645 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, tex, ANIMTYPE_DSTEX, owner_id, nullptr);
2646 }
2647 }
2648
2649 /* now add the list of collected channels */
2650 BLI_movelisttolist(anim_data, &tmp_data);
2651 BLI_assert(tmp_data.is_empty());
2652 items += tmp_items;
2653 }
2654
2655 /* return the number of items added to the list */
2656 return items;
2657}
2658
2659/* NOTE: owner_id is the direct owner of the texture stack in question
2660 * It used to be Material/Light/World before the Blender Internal removal for 2.8
2661 */
2663 ListBaseT<bAnimListElem> *anim_data,
2664 ID *owner_id,
2665 const eAnimFilter_Flags filter_mode)
2666{
2667 MTex **mtex = nullptr;
2668 size_t items = 0;
2669 int a = 0;
2670
2671 /* get datatype specific data first */
2672 if (owner_id == nullptr) {
2673 return 0;
2674 }
2675
2676 switch (GS(owner_id->name)) {
2677 case ID_PA: {
2678 ParticleSettings *part = reinterpret_cast<ParticleSettings *>(owner_id);
2679 mtex = reinterpret_cast<MTex **>(&part->mtex);
2680 break;
2681 }
2682 default: {
2683 /* invalid/unsupported option */
2684 if (G.debug & G_DEBUG) {
2685 printf("ERROR: Unsupported owner_id (i.e. texture stack) for filter textures - %s\n",
2686 owner_id->name);
2687 }
2688 return 0;
2689 }
2690 }
2691
2692 /* Firstly check that we actually have some textures,
2693 * by gathering all textures in a temp list. */
2694 for (a = 0; a < MAX_MTEX; a++) {
2695 Tex *tex = (mtex[a]) ? mtex[a]->tex : nullptr;
2696
2697 /* for now, if no texture returned, skip (this shouldn't confuse the user I hope) */
2698 if (tex == nullptr) {
2699 continue;
2700 }
2701
2702 /* add texture's anim channels */
2703 items += animdata_filter_ds_texture(ac, anim_data, tex, owner_id, filter_mode);
2704 }
2705
2706 /* return the number of items added to the list */
2707 return items;
2708}
2709
2711 ListBaseT<bAnimListElem> *anim_data,
2712 Material *ma,
2713 eAnimFilter_Flags filter_mode)
2714{
2715 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2716 size_t tmp_items = 0;
2717 size_t items = 0;
2718
2719 /* add material's animation data to temp collection */
2721 /* material's animation data */
2722 tmp_items += animfilter_block_data(ac, &tmp_data, reinterpret_cast<ID *>(ma), filter_mode);
2723
2724 /* nodes */
2725 if ((ma->nodetree) && !(ac->filters.flag & ADS_FILTER_NONTREE)) {
2726 tmp_items += animdata_filter_ds_nodetree(
2727 ac, &tmp_data, reinterpret_cast<ID *>(ma), ma->nodetree, filter_mode);
2728 }
2729 }
2731
2732 /* did we find anything? */
2733 if (tmp_items) {
2734 /* include material-expand widget first */
2735 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
2736 /* check if filtering by active status */
2737 if (ANIMCHANNEL_ACTIVEOK(ma)) {
2738 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, ma, ANIMTYPE_DSMAT, ma, nullptr);
2739 }
2740 }
2741
2742 /* now add the list of collected channels */
2743 BLI_movelisttolist(anim_data, &tmp_data);
2744 BLI_assert(tmp_data.is_empty());
2745 items += tmp_items;
2746 }
2747
2748 return items;
2749}
2750
2752 ListBaseT<bAnimListElem> *anim_data,
2753 Object *ob,
2754 const eAnimFilter_Flags filter_mode)
2755{
2756 size_t items = 0;
2757 int a = 0;
2758
2759 /* First pass: take the materials referenced via the Material slots of the object. */
2760 for (a = 1; a <= ob->totcol; a++) {
2761 Material *ma = BKE_object_material_get(ob, a);
2762
2763 /* if material is valid, try to add relevant contents from here */
2764 if (ma) {
2765 /* add channels */
2766 items += animdata_filter_ds_material(ac, anim_data, ma, filter_mode);
2767 }
2768 }
2769
2770 /* return the number of items added to the list */
2771 return items;
2772}
2773
2774/* ............ */
2775
2776/* Temporary context for modifier linked-data channel extraction */
2778 bAnimContext *ac; /* anim editor context */
2779 bDopeSheet *ads; /* TODO: Remove this pointer from the struct and just use ac->ads. */
2780
2781 ListBaseT<bAnimListElem>
2782 tmp_data; /* list of channels created (but not yet added to the main list) */
2783 size_t items; /* number of channels created */
2784
2785 eAnimFilter_Flags filter_mode; /* flags for stuff we want to filter */
2786};
2787
2788/* dependency walker callback for modifier dependencies */
2789static void animfilter_modifier_idpoin_cb(void *afm_ptr,
2790 Object *ob,
2791 ID **idpoin,
2792 LibraryForeachIDCallbackFlag /*cb_flag*/)
2793{
2794 tAnimFilterModifiersContext *afm = static_cast<tAnimFilterModifiersContext *>(afm_ptr);
2795 ID *owner_id = &ob->id;
2796 ID *id = *idpoin;
2797
2798 /* NOTE: the walker only guarantees to give us all the ID-ptr *slots*,
2799 * not just the ones which are actually used, so be careful!
2800 */
2801 if (id == nullptr) {
2802 return;
2803 }
2804
2805 /* check if this is something we're interested in... */
2806 switch (GS(id->name)) {
2807 case ID_TE: /* Textures */
2808 {
2809 Tex *tex = reinterpret_cast<Tex *>(id);
2810 if (!(afm->ac->filters.flag & ADS_FILTER_NOTEX)) {
2811 BLI_assert(afm->ac->ads == afm->ads);
2813 afm->ac, &afm->tmp_data, tex, owner_id, afm->filter_mode);
2814 }
2815 break;
2816 }
2817 case ID_NT: {
2818 bNodeTree *node_tree = reinterpret_cast<bNodeTree *>(id);
2819 if (!(afm->ac->filters.flag & ADS_FILTER_NONTREE)) {
2820 BLI_assert(afm->ac->ads == afm->ads);
2822 afm->ac, &afm->tmp_data, owner_id, node_tree, afm->filter_mode);
2823 }
2824 break;
2825 }
2826 case ID_CF: {
2827 CacheFile *cache_file = id_cast<CacheFile *>(id);
2828 BLI_assert(afm->ac->ads == afm->ads);
2830 afm->ac, &afm->tmp_data, cache_file, afm->filter_mode);
2831 break;
2832 }
2833
2834 /* TODO: images? */
2835 default:
2836 break;
2837 }
2838}
2839
2840/* animation linked to data used by modifiers
2841 * NOTE: strictly speaking, modifier animation is already included under Object level
2842 * but for some modifiers (e.g. Displace), there can be linked data that has settings
2843 * which would be nice to animate (i.e. texture parameters) but which are not actually
2844 * attached to any other objects/materials/etc. in the scene
2845 */
2846/* TODO: do we want an expander for this? */
2848 ListBaseT<bAnimListElem> *anim_data,
2849 Object *ob,
2850 const eAnimFilter_Flags filter_mode)
2851{
2852 tAnimFilterModifiersContext afm = {nullptr};
2853 size_t items = 0;
2854
2855 /* 1) create a temporary "context" containing all the info we have here to pass to the callback
2856 * use to walk through the dependencies of the modifiers
2857 *
2858 * Assumes that all other unspecified values (i.e. accumulation buffers)
2859 * are zeroed out properly!
2860 */
2861 afm.ac = ac;
2862 afm.ads = ac->ads; /* TODO: Remove this pointer from the struct and just use afm.ac->ads. */
2863 afm.filter_mode = filter_mode;
2864
2865 /* 2) walk over dependencies */
2867
2868 /* 3) extract data from the context, merging it back into the standard list */
2869 if (afm.items) {
2870 /* now add the list of collected channels */
2871 BLI_movelisttolist(anim_data, &afm.tmp_data);
2872 BLI_assert(afm.tmp_data.is_empty());
2873 items += afm.items;
2874 }
2875
2876 return items;
2877}
2878
2879/* ............ */
2880
2882 ListBaseT<bAnimListElem> *anim_data,
2883 Object *ob,
2884 eAnimFilter_Flags filter_mode)
2885{
2886 size_t items = 0;
2887
2888 for (ParticleSystem &psys : ob->particlesystem) {
2889 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2890 size_t tmp_items = 0;
2891
2892 /* Note that when psys->part->adt is nullptr the textures can still be
2893 * animated. */
2894 if (psys.part == nullptr) {
2895 continue;
2896 }
2897
2898 /* add particle-system's animation data to temp collection */
2900 /* particle system's animation data */
2901 tmp_items += animfilter_block_data(
2902 ac, &tmp_data, reinterpret_cast<ID *>(psys.part), filter_mode);
2903
2904 /* textures */
2905 if (!(ac->filters.flag & ADS_FILTER_NOTEX)) {
2906 tmp_items += animdata_filter_ds_textures(
2907 ac, &tmp_data, reinterpret_cast<ID *>(psys.part), filter_mode);
2908 }
2909 }
2911
2912 /* did we find anything? */
2913 if (tmp_items) {
2914 /* include particle-expand widget first */
2915 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
2916 /* check if filtering by active status */
2917 if (ANIMCHANNEL_ACTIVEOK(psys.part)) {
2918 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, psys.part, ANIMTYPE_DSPART, psys.part, nullptr);
2919 }
2920 }
2921
2922 /* now add the list of collected channels */
2923 BLI_movelisttolist(anim_data, &tmp_data);
2924 BLI_assert(tmp_data.is_empty());
2925 items += tmp_items;
2926 }
2927 }
2928
2929 /* return the number of items added to the list */
2930 return items;
2931}
2932
2934 ListBaseT<bAnimListElem> *anim_data,
2935 Object *ob,
2936 eAnimFilter_Flags filter_mode)
2937{
2938 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
2939 size_t tmp_items = 0;
2940 size_t items = 0;
2941
2942 IdAdtTemplate *iat = reinterpret_cast<IdAdtTemplate *>(ob->data);
2944 short expanded = 0;
2945 const eDopeSheet_FilterFlag ads_filterflag = ac->filters.flag;
2946 const eDopeSheet_FilterFlag2 ads_filterflag2 = ac->filters.flag2;
2947
2948 /* get settings based on data type */
2949 switch (ob->type) {
2950 case OB_CAMERA: /* ------- Camera ------------ */
2951 {
2952 Camera *ca = id_cast<Camera *>(ob->data);
2953
2954 if (ads_filterflag & ADS_FILTER_NOCAM) {
2955 return 0;
2956 }
2957
2958 type = ANIMTYPE_DSCAM;
2959 expanded = FILTER_CAM_OBJD(ca);
2960 break;
2961 }
2962 case OB_LAMP: /* ---------- Light ----------- */
2963 {
2964 Light *la = id_cast<Light *>(ob->data);
2965
2966 if (ads_filterflag & ADS_FILTER_NOLAM) {
2967 return 0;
2968 }
2969
2970 type = ANIMTYPE_DSLAM;
2971 expanded = FILTER_LAM_OBJD(la);
2972 break;
2973 }
2974 case OB_CURVES_LEGACY: /* ------- Curve ---------- */
2975 case OB_SURF: /* ------- Nurbs Surface ---------- */
2976 case OB_FONT: /* ------- Text Curve ---------- */
2977 {
2978 Curve *cu = id_cast<Curve *>(ob->data);
2979
2980 if (ads_filterflag & ADS_FILTER_NOCUR) {
2981 return 0;
2982 }
2983
2984 type = ANIMTYPE_DSCUR;
2985 expanded = FILTER_CUR_OBJD(cu);
2986 break;
2987 }
2988 case OB_MBALL: /* ------- MetaBall ---------- */
2989 {
2990 MetaBall *mb = id_cast<MetaBall *>(ob->data);
2991
2992 if (ads_filterflag & ADS_FILTER_NOMBA) {
2993 return 0;
2994 }
2995
2996 type = ANIMTYPE_DSMBALL;
2997 expanded = FILTER_MBALL_OBJD(mb);
2998 break;
2999 }
3000 case OB_ARMATURE: /* ------- Armature ---------- */
3001 {
3002 bArmature *arm = id_cast<bArmature *>(ob->data);
3003
3004 if (ads_filterflag & ADS_FILTER_NOARM) {
3005 return 0;
3006 }
3007
3008 type = ANIMTYPE_DSARM;
3009 expanded = FILTER_ARM_OBJD(arm);
3010 break;
3011 }
3012 case OB_MESH: /* ------- Mesh ---------- */
3013 {
3014 Mesh *mesh = id_cast<Mesh *>(ob->data);
3015
3016 if (ads_filterflag & ADS_FILTER_NOMESH) {
3017 return 0;
3018 }
3019
3020 type = ANIMTYPE_DSMESH;
3021 expanded = FILTER_MESH_OBJD(mesh);
3022 break;
3023 }
3024 case OB_LATTICE: /* ---- Lattice ---- */
3025 {
3026 Lattice *lt = id_cast<Lattice *>(ob->data);
3027
3028 if (ads_filterflag & ADS_FILTER_NOLAT) {
3029 return 0;
3030 }
3031
3032 type = ANIMTYPE_DSLAT;
3033 expanded = FILTER_LATTICE_OBJD(lt);
3034 break;
3035 }
3036 case OB_SPEAKER: /* ---------- Speaker ----------- */
3037 {
3038 Speaker *spk = id_cast<Speaker *>(ob->data);
3039
3040 type = ANIMTYPE_DSSPK;
3041 expanded = FILTER_SPK_OBJD(spk);
3042 break;
3043 }
3044 case OB_CURVES: /* ---------- Curves ----------- */
3045 {
3046 Curves *curves = id_cast<Curves *>(ob->data);
3047
3048 if (ads_filterflag2 & ADS_FILTER_NOHAIR) {
3049 return 0;
3050 }
3051
3052 type = ANIMTYPE_DSHAIR;
3053 expanded = FILTER_CURVES_OBJD(curves);
3054 break;
3055 }
3056 case OB_POINTCLOUD: /* ---------- PointCloud ----------- */
3057 {
3058 PointCloud *pointcloud = id_cast<PointCloud *>(ob->data);
3059
3060 if (ads_filterflag2 & ADS_FILTER_NOPOINTCLOUD) {
3061 return 0;
3062 }
3063
3064 type = ANIMTYPE_DSPOINTCLOUD;
3065 expanded = FILTER_POINTS_OBJD(pointcloud);
3066 break;
3067 }
3068 case OB_VOLUME: /* ---------- Volume ----------- */
3069 {
3070 Volume *volume = id_cast<Volume *>(ob->data);
3071
3072 if (ads_filterflag2 & ADS_FILTER_NOVOLUME) {
3073 return 0;
3074 }
3075
3076 type = ANIMTYPE_DSVOLUME;
3077 expanded = FILTER_VOLUME_OBJD(volume);
3078 break;
3079 }
3080 case OB_LIGHTPROBE: /* ---------- LightProbe ----------- */
3081 {
3082 LightProbe *probe = id_cast<LightProbe *>(ob->data);
3083
3084 if (ads_filterflag2 & ADS_FILTER_NOLIGHTPROBE) {
3085 return 0;
3086 }
3087
3088 type = ANIMTYPE_DSLIGHTPROBE;
3089 expanded = FILTER_LIGHTPROBE_OBJD(probe);
3090 break;
3091 }
3092 default:
3093 break;
3094 }
3095
3096 /* add object data animation channels */
3097 BEGIN_ANIMFILTER_SUBCHANNELS (expanded) {
3098 /* animation data filtering */
3099 tmp_items += animfilter_block_data(ac, &tmp_data, reinterpret_cast<ID *>(iat), filter_mode);
3100
3101 /* sub-data filtering... */
3102 switch (ob->type) {
3103 case OB_LAMP: /* light - textures + nodetree */
3104 {
3105 Light *la = id_cast<Light *>(ob->data);
3106 bNodeTree *ntree = la->nodetree;
3107
3108 /* nodetree */
3109 if ((ntree) && !(ads_filterflag & ADS_FILTER_NONTREE)) {
3110 tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, &la->id, ntree, filter_mode);
3111 }
3112 break;
3113 }
3114 default:
3115 break;
3116 }
3117 }
3119
3120 /* did we find anything? */
3121 if (tmp_items) {
3122 /* include data-expand widget first */
3123 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
3124 /* check if filtering by active status */
3125 if (ANIMCHANNEL_ACTIVEOK(iat)) {
3126 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, iat, type, iat, nullptr);
3127 }
3128 }
3129
3130 /* now add the list of collected channels */
3131 BLI_movelisttolist(anim_data, &tmp_data);
3132 BLI_assert(tmp_data.is_empty());
3133 items += tmp_items;
3134 }
3135
3136 /* return the number of items added to the list */
3137 return items;
3138}
3139
3140/* shapekey-level animation */
3142 ListBaseT<bAnimListElem> *anim_data,
3143 Object *ob,
3144 Key *key,
3145 eAnimFilter_Flags filter_mode)
3146{
3147 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
3148 size_t tmp_items = 0;
3149 size_t items = 0;
3150
3151 /* add shapekey-level animation channels */
3153 /* animation data filtering */
3154 tmp_items += animfilter_block_data(ac, &tmp_data, reinterpret_cast<ID *>(key), filter_mode);
3155 }
3157
3158 /* did we find anything? */
3159 if (tmp_items) {
3160 /* include key-expand widget first */
3161 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
3162 if (ANIMCHANNEL_ACTIVEOK(key)) {
3163 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, key, ANIMTYPE_DSSKEY, ob, nullptr);
3164 }
3165 }
3166
3167 /* now add the list of collected channels */
3168 BLI_movelisttolist(anim_data, &tmp_data);
3169 BLI_assert(tmp_data.is_empty());
3170 items += tmp_items;
3171 }
3172
3173 /* return the number of items added to the list */
3174 return items;
3175}
3176
3177/* object-level animation */
3179 ListBaseT<bAnimListElem> *anim_data,
3180 Object *ob,
3181 eAnimFilter_Flags filter_mode)
3182{
3183 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
3184 size_t tmp_items = 0;
3185 size_t items = 0;
3186
3187 AnimData *adt = ob->adt;
3189 short expanded = 1;
3190 void *cdata = nullptr;
3191
3192 /* determine the type of expander channels to use */
3193 /* this is the best way to do this for now... */
3195 ob, /* Some useless long comment to prevent wrapping by old clang-format versions... */
3196 {/* AnimData - no channel, but consider data */},
3197 {/* NLA - no channel, but consider data */},
3198 { /* Drivers */
3199 type = ANIMTYPE_FILLDRIVERS;
3200 cdata = adt;
3201 expanded = EXPANDED_DRVD(adt);
3202 },
3203 {/* NLA Strip Controls - no dedicated channel for now (XXX) */},
3204 { /* Keyframes from legacy Action. */
3205 type = ANIMTYPE_FILLACTD;
3206 cdata = adt->action;
3207 expanded = EXPANDED_ACTC(adt->action);
3208 },
3209 { /* Keyframes from layered action. */
3211 cdata = adt->action;
3212 expanded = EXPANDED_ADT(adt);
3213 });
3214
3215 /* add object-level animation channels */
3216 BEGIN_ANIMFILTER_SUBCHANNELS (expanded) {
3217 /* animation data filtering */
3218 tmp_items += animfilter_block_data(ac, &tmp_data, reinterpret_cast<ID *>(ob), filter_mode);
3219 }
3221
3222 /* did we find anything? */
3223 if (tmp_items) {
3224 /* include anim-expand widget first */
3225 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
3226 if (type != ANIMTYPE_NONE) {
3227 /* NOTE: active-status (and the associated checks) don't apply here... */
3228 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, cdata, type, ob, nullptr);
3229 }
3230 }
3231
3232 /* now add the list of collected channels */
3233 BLI_movelisttolist(anim_data, &tmp_data);
3234 BLI_assert(tmp_data.is_empty());
3235 items += tmp_items;
3236 }
3237
3238 /* return the number of items added to the list */
3239 return items;
3240}
3241
3242/* get animation channels from object2 */
3244 ListBaseT<bAnimListElem> *anim_data,
3245 Base *base,
3246 eAnimFilter_Flags filter_mode)
3247{
3248 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
3249 Object *ob = base->object;
3250 size_t tmp_items = 0;
3251 size_t items = 0;
3252 const eDopeSheet_FilterFlag ads_filterflag = ac->filters.flag;
3253
3254 /* filter data contained under object first */
3256 Key *key = BKE_key_from_object(ob);
3257
3258 /* object-level animation */
3259 if ((ob->adt) && !(ads_filterflag & ADS_FILTER_NOOBJ)) {
3260 tmp_items += animdata_filter_ds_obanim(ac, &tmp_data, ob, filter_mode);
3261 }
3262
3263 /* particle deflector textures */
3264 if (ob->pd != nullptr && ob->pd->tex != nullptr && !(ads_filterflag & ADS_FILTER_NOTEX)) {
3265 tmp_items += animdata_filter_ds_texture(ac, &tmp_data, ob->pd->tex, &ob->id, filter_mode);
3266 }
3267
3268 /* shape-key */
3269 if ((key && key->adt) && !(ads_filterflag & ADS_FILTER_NOSHAPEKEYS)) {
3270 tmp_items += animdata_filter_ds_keyanim(ac, &tmp_data, ob, key, filter_mode);
3271 }
3272
3273 /* modifiers */
3274 if ((ob->modifiers.first_) && !(ads_filterflag & ADS_FILTER_NOMODIFIERS)) {
3275 tmp_items += animdata_filter_ds_modifiers(ac, &tmp_data, ob, filter_mode);
3276 }
3277
3278 /* materials */
3279 if ((ob->totcol) && !(ads_filterflag & ADS_FILTER_NOMAT)) {
3280 tmp_items += animdata_filter_ds_materials(ac, &tmp_data, ob, filter_mode);
3281 }
3282
3283 /* object data */
3284 if (ob->data) {
3285 tmp_items += animdata_filter_ds_obdata(ac, &tmp_data, ob, filter_mode);
3286 }
3287
3288 /* particles */
3289 if ((ob->particlesystem.first_) && !(ads_filterflag & ADS_FILTER_NOPART)) {
3290 tmp_items += animdata_filter_ds_particles(ac, &tmp_data, ob, filter_mode);
3291 }
3292
3293 /* grease pencil */
3294 if (ob->type == OB_GREASE_PENCIL && (ob->data) && !(ads_filterflag & ADS_FILTER_NOGPENCIL)) {
3296 ac, &tmp_data, id_cast<GreasePencil *>(ob->data), filter_mode);
3297 }
3298 }
3300
3301 /* if we collected some channels, add these to the new list... */
3302 if (tmp_items) {
3303 /* firstly add object expander if required */
3304 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
3305 /* check if filtering by selection */
3306 /* XXX: double-check on this -
3307 * most of the time, a lot of tools need to filter out these channels! */
3308 if (ANIMCHANNEL_SELOK((base->flag & BASE_SELECTED))) {
3309 /* check if filtering by active status */
3310 if (ANIMCHANNEL_ACTIVEOK(ob)) {
3311 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, base, ANIMTYPE_OBJECT, ob, nullptr);
3312 }
3313 }
3314 }
3315
3316 /* now add the list of collected channels */
3317 BLI_movelisttolist(anim_data, &tmp_data);
3318 BLI_assert(tmp_data.is_empty());
3319 items += tmp_items;
3320 }
3321
3322 /* return the number of items added */
3323 return items;
3324}
3325
3327 ListBaseT<bAnimListElem> *anim_data,
3328 Scene *sce,
3329 World *wo,
3330 eAnimFilter_Flags filter_mode)
3331{
3332 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
3333 size_t tmp_items = 0;
3334 size_t items = 0;
3335
3336 /* add world animation channels */
3338 /* animation data filtering */
3339 tmp_items += animfilter_block_data(ac, &tmp_data, reinterpret_cast<ID *>(wo), filter_mode);
3340
3341 /* nodes */
3342 if ((wo->nodetree) && !(ac->filters.flag & ADS_FILTER_NONTREE)) {
3343 tmp_items += animdata_filter_ds_nodetree(
3344 ac, &tmp_data, reinterpret_cast<ID *>(wo), wo->nodetree, filter_mode);
3345 }
3346 }
3348
3349 /* did we find anything? */
3350 if (tmp_items) {
3351 /* include data-expand widget first */
3352 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
3353 /* check if filtering by active status */
3354 if (ANIMCHANNEL_ACTIVEOK(wo)) {
3355 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, wo, ANIMTYPE_DSWOR, sce, nullptr);
3356 }
3357 }
3358
3359 /* now add the list of collected channels */
3360 BLI_movelisttolist(anim_data, &tmp_data);
3361 BLI_assert(tmp_data.is_empty());
3362 items += tmp_items;
3363 }
3364
3365 /* return the number of items added to the list */
3366 return items;
3367}
3368
3370 ListBaseT<bAnimListElem> *anim_data,
3371 Scene *sce,
3372 eAnimFilter_Flags filter_mode)
3373{
3374 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
3375 size_t tmp_items = 0;
3376 size_t items = 0;
3377
3378 AnimData *adt = sce->adt;
3380 short expanded = 1;
3381 void *cdata = nullptr;
3382
3383 /* determine the type of expander channels to use */
3384 /* this is the best way to do this for now... */
3386 sce, /* Some useless long comment to prevent wrapping by old clang-format versions... */
3387 {/* AnimData - no channel, but consider data */},
3388 {/* NLA - no channel, but consider data */},
3389 { /* Drivers */
3390 type = ANIMTYPE_FILLDRIVERS;
3391 cdata = adt;
3392 expanded = EXPANDED_DRVD(adt);
3393 },
3394 {/* NLA Strip Controls - no dedicated channel for now (XXX) */},
3395 { /* Keyframes from legacy Action. */
3396 type = ANIMTYPE_FILLACTD;
3397 cdata = adt->action;
3398 expanded = EXPANDED_ACTC(adt->action);
3399 },
3400 { /* Keyframes from layered Action. */
3402 cdata = adt->action;
3403 expanded = EXPANDED_ADT(adt);
3404 });
3405
3406 /* add scene-level animation channels */
3407 BEGIN_ANIMFILTER_SUBCHANNELS (expanded) {
3408 /* animation data filtering */
3409 tmp_items += animfilter_block_data(ac, &tmp_data, reinterpret_cast<ID *>(sce), filter_mode);
3410 }
3412
3413 /* did we find anything? */
3414 if (tmp_items) {
3415 /* include anim-expand widget first */
3416 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
3417 if (type != ANIMTYPE_NONE) {
3418 /* NOTE: active-status (and the associated checks) don't apply here... */
3419 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, cdata, type, sce, nullptr);
3420 }
3421 }
3422
3423 /* now add the list of collected channels */
3424 BLI_movelisttolist(anim_data, &tmp_data);
3425 BLI_assert(tmp_data.is_empty());
3426 items += tmp_items;
3427 }
3428
3429 /* return the number of items added to the list */
3430 return items;
3431}
3432
3434 ListBaseT<bAnimListElem> *anim_data,
3435 Scene *sce,
3436 eAnimFilter_Flags filter_mode)
3437{
3438 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
3439 size_t tmp_items = 0;
3440 size_t items = 0;
3441
3442 /* filter data contained under object first */
3444 World *wo = sce->world;
3445 Editing *ed = sce->ed;
3446
3447 /* Action, Drivers, or NLA for Scene */
3448 if ((ac->filters.flag & ADS_FILTER_NOSCE) == 0) {
3449 tmp_items += animdata_filter_ds_scene(ac, &tmp_data, sce, filter_mode);
3450 }
3451
3452 /* world */
3453 if ((wo) && !(ac->filters.flag & ADS_FILTER_NOWOR)) {
3454 tmp_items += animdata_filter_ds_world(ac, &tmp_data, sce, wo, filter_mode);
3455 }
3456
3457 /* nodetree */
3458 if (!(ac->filters.flag & ADS_FILTER_NONTREE)) {
3459 VectorSet<bNodeTree *> node_trees;
3460 for (SceneCompositorEffect &effect : sce->compositor_effects) {
3461 if (!effect.node_group || ID_MISSING(effect.node_group)) {
3462 continue;
3463 }
3464 node_trees.add(effect.node_group);
3465 }
3466 for (bNodeTree *node_tree : node_trees) {
3467 tmp_items += animdata_filter_ds_nodetree(
3468 ac, &tmp_data, reinterpret_cast<ID *>(sce), node_tree, filter_mode);
3469 }
3470 }
3471
3472 /* VSE strip node trees. */
3473 if (ed && !(ac->filters.flag & ADS_FILTER_NONTREE)) {
3474 VectorSet<ID *> node_trees;
3475 seq::foreach_strip(&ed->seqbase, [&](Strip *strip) {
3476 if (strip->type == STRIP_TYPE_COMPOSITOR && strip->effectdata) {
3477 CompositorEffectVars *comp_data = static_cast<CompositorEffectVars *>(strip->effectdata);
3478 if (comp_data->node_group) {
3479 node_trees.add(reinterpret_cast<ID *>(comp_data->node_group));
3480 }
3481 }
3482 seq::foreach_strip_modifier_id(strip, [&](ID *id) {
3483 if (GS(id->name) == ID_NT) {
3484 node_trees.add(id);
3485 }
3486 });
3487 return true;
3488 });
3489 for (ID *node_tree : node_trees) {
3490 tmp_items += animdata_filter_ds_nodetree(
3491 ac, &tmp_data, &sce->id, reinterpret_cast<bNodeTree *>(node_tree), filter_mode);
3492 }
3493 }
3494
3495 /* line styles */
3496 if ((ac->filters.flag & ADS_FILTER_NOLINESTYLE) == 0) {
3497 tmp_items += animdata_filter_ds_linestyle(ac, &tmp_data, sce, filter_mode);
3498 }
3499
3500 /* TODO: one day, when sequencer becomes its own datatype,
3501 * perhaps it should be included here. */
3502 }
3504
3505 /* if we collected some channels, add these to the new list... */
3506 if (tmp_items) {
3507 /* firstly add object expander if required */
3508 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
3509 /* check if filtering by selection */
3510 if (ANIMCHANNEL_SELOK((sce->flag & SCE_DS_SELECTED))) {
3511 /* NOTE: active-status doesn't matter for this! */
3512 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, sce, ANIMTYPE_SCENE, sce, nullptr);
3513 }
3514 }
3515
3516 /* now add the list of collected channels */
3517 BLI_movelisttolist(anim_data, &tmp_data);
3518 BLI_assert(tmp_data.is_empty());
3519 items += tmp_items;
3520 }
3521
3522 /* return the number of items added */
3523 return items;
3524}
3525
3527 ListBaseT<bAnimListElem> *anim_data,
3528 MovieClip *clip,
3529 eAnimFilter_Flags filter_mode)
3530{
3531 ListBaseT<bAnimListElem> tmp_data = {nullptr, nullptr};
3532 size_t tmp_items = 0;
3533 size_t items = 0;
3534 /* add world animation channels */
3536 /* animation data filtering */
3537 tmp_items += animfilter_block_data(ac, &tmp_data, reinterpret_cast<ID *>(clip), filter_mode);
3538 }
3540 /* did we find anything? */
3541 if (tmp_items) {
3542 /* include data-expand widget first */
3543 if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
3544 /* check if filtering by active status */
3545 if (ANIMCHANNEL_ACTIVEOK(clip)) {
3546 ANIMCHANNEL_NEW_CHANNEL(ac->bmain, clip, ANIMTYPE_DSMCLIP, clip, nullptr);
3547 }
3548 }
3549 /* now add the list of collected channels */
3550 BLI_movelisttolist(anim_data, &tmp_data);
3551 BLI_assert(tmp_data.is_empty());
3552 items += tmp_items;
3553 }
3554 /* return the number of items added to the list */
3555 return items;
3556}
3557
3559 ListBaseT<bAnimListElem> *anim_data,
3560 const eAnimFilter_Flags filter_mode)
3561{
3562 size_t items = 0;
3563 for (MovieClip &clip : ac->bmain->movieclips) {
3564 /* only show if gpd is used by something... */
3565 if (ID_REAL_USERS(&clip) < 1) {
3566 continue;
3567 }
3568 items += animdata_filter_ds_movieclip(ac, anim_data, &clip, filter_mode);
3569 }
3570 /* return the number of items added to the list */
3571 return items;
3572}
3573
3574/* Helper for animdata_filter_dopesheet() - For checking if an object should be included or not */
3576 Base *base,
3577 const eObjectMode object_mode,
3578 const eAnimFilter_Flags filter_mode)
3579{
3580 Object *ob = base->object;
3581
3582 if (base->object == nullptr) {
3583 return false;
3584 }
3585
3586 /* firstly, check if object can be included, by the following factors:
3587 * - if only visible, must check for layer and also viewport visibility
3588 * --> while tools may demand only visible, user setting takes priority
3589 * as user option controls whether sets of channels get included while
3590 * tool-flag takes into account collapsed/open channels too
3591 * - if only selected, must check if object is selected
3592 * - there must be animation data to edit (this is done recursively as we
3593 * try to add the channels)
3594 */
3595 if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ac->filters.flag & ADS_FILTER_INCL_HIDDEN)) {
3596 /* layer visibility - we check both object and base, since these may not be in sync yet */
3599 {
3600 return false;
3601 }
3602
3603 /* outliner restrict-flag */
3605 return false;
3606 }
3607 }
3608
3609 /* if only F-Curves with visible flags set can be shown, check that
3610 * data-block hasn't been set to invisible.
3611 */
3612 if (filter_mode & ANIMFILTER_CURVE_VISIBLE) {
3613 if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE)) {
3614 return false;
3615 }
3616 }
3617
3618 /* Pinned curves are visible regardless of selection flags. */
3619 if ((ob->adt) && (ob->adt->flag & ADT_CURVES_ALWAYS_VISIBLE)) {
3620 return true;
3621 }
3622
3623 /* Special case.
3624 * We don't do recursive checks for pin, but we need to deal with tricky
3625 * setup like animated camera lens without (pinned) animated camera location.
3626 * Without such special handle here we wouldn't be able to pin such
3627 * camera data animation to the editor.
3628 */
3629 if (ob->data != nullptr) {
3630 AnimData *data_adt = BKE_animdata_from_id(ob->data);
3631 if (data_adt != nullptr && (data_adt->flag & ADT_CURVES_ALWAYS_VISIBLE)) {
3632 return true;
3633 }
3634 }
3635
3636 /* check selection and object type filters */
3637 if (ac->filters.flag & ADS_FILTER_ONLYSEL) {
3638 if (object_mode & OB_MODE_POSE) {
3639 /* When in pose-mode handle all pose-mode objects.
3640 * This avoids problems with pose-mode where objects may be unselected,
3641 * where a selected bone of an unselected object would be hidden. see: #81922. */
3642 if (!(base->object->mode & object_mode)) {
3643 return false;
3644 }
3645 }
3646 else {
3647 /* only selected should be shown (ignore active) */
3648 if (!(base->flag & BASE_SELECTED)) {
3649 return false;
3650 }
3651 }
3652 }
3653
3654 /* check if object belongs to the filtering group if option to filter
3655 * objects by the grouped status is on
3656 * - used to ease the process of doing multiple-character choreographies
3657 */
3658 if (ac->ads->filter_grp != nullptr) {
3660 return false;
3661 }
3662 }
3663
3664 /* no reason to exclude this object... */
3665 return true;
3666}
3667
3668/* Helper for animdata_filter_ds_sorted_bases() - Comparison callback for two Base pointers... */
3669static int ds_base_sorting_cmp(const void *base1_ptr, const void *base2_ptr)
3670{
3671 const Base *b1 = *(static_cast<const Base **>(const_cast<void *>(base1_ptr)));
3672 const Base *b2 = *(static_cast<const Base **>(const_cast<void *>(base2_ptr)));
3673
3674 return BLI_strcasecmp_natural(b1->object->id.name + 2, b2->object->id.name + 2);
3675}
3676
3677/* Get a sorted list of all the bases - for inclusion in dopesheet (when drawing channels) */
3679 const Scene *scene,
3680 ViewLayer *view_layer,
3681 const eAnimFilter_Flags filter_mode,
3682 size_t *r_usable_bases)
3683{
3684 /* Create an array with space for all the bases, but only containing the usable ones */
3685 BKE_view_layer_synced_ensure(*ac->bmain, scene, view_layer);
3686 ListBaseT<Base> *object_bases = BKE_view_layer_object_bases_get(view_layer);
3687 size_t tot_bases = object_bases->count();
3688 size_t num_bases = 0;
3689
3690 Base **sorted_bases = MEM_new_array_zeroed<Base *>(tot_bases, "Dopesheet Usable Sorted Bases");
3691 for (Base &base : *object_bases) {
3692 const eObjectMode object_mode = base.object->mode;
3693 if (animdata_filter_base_is_ok(ac, &base, object_mode, filter_mode)) {
3694 sorted_bases[num_bases++] = &base;
3695 }
3696 }
3697
3698 /* Sort this list of pointers (based on the names) */
3699 qsort(sorted_bases, num_bases, sizeof(Base *), ds_base_sorting_cmp);
3700
3701 /* Return list of sorted bases */
3702 *r_usable_bases = num_bases;
3703 return sorted_bases;
3704}
3705
3706/* TODO: implement pinning...
3707 * (if and when pinning is done, what we need to do is to provide freeing mechanisms -
3708 * to protect against data that was deleted). */
3710 ListBaseT<bAnimListElem> *anim_data,
3711 eAnimFilter_Flags filter_mode)
3712{
3713 bDopeSheet *ads = ac->ads;
3714 Scene *scene = reinterpret_cast<Scene *>(ads->source);
3715 ViewLayer *view_layer = ac->view_layer;
3716 size_t items = 0;
3717
3718 /* check that we do indeed have a scene */
3719 if ((ads->source == nullptr) || (GS(ads->source->name) != ID_SCE)) {
3720 printf("Dope Sheet Error: No scene!\n");
3721 if (G.debug & G_DEBUG) {
3722 printf("\tPointer = %p, Name = '%s'\n",
3723 static_cast<void *>(ads->source),
3724 (ads->source) ? ads->source->name : nullptr);
3725 }
3726 return 0;
3727 }
3728
3729 /* augment the filter-flags with settings based on the dopesheet filterflags
3730 * so that some temp settings can get added automagically...
3731 */
3732 if (ac->filters.flag & ADS_FILTER_SELEDIT) {
3733 /* only selected F-Curves should get their keyframes considered for editability */
3734 filter_mode |= ANIMFILTER_SELEDIT;
3735 }
3736
3737 /* Cache files level animations (frame duration and such). */
3738 const bool use_only_selected = (ac->filters.flag & ADS_FILTER_ONLYSEL);
3739 if (!use_only_selected && !(ac->filters.flag2 & ADS_FILTER_NOCACHEFILES)) {
3740 for (CacheFile &cache_file : ac->bmain->cachefiles) {
3741 items += animdata_filter_ds_cachefile(ac, anim_data, &cache_file, filter_mode);
3742 }
3743 }
3744
3745 /* Annotations are always shown if "Only Show Selected" is disabled. */
3746 if (!use_only_selected && !(ac->filters.flag & ADS_FILTER_NOGPENCIL)) {
3747 for (bGPdata &gp_data : ac->bmain->gpencils) {
3748 items += animdata_filter_ds_gpencil(ac, anim_data, &gp_data, filter_mode);
3749 }
3750 }
3751
3752 /* movie clip's animation */
3753 if (!use_only_selected && !(ac->filters.flag2 & ADS_FILTER_NOMOVIECLIPS)) {
3754 items += animdata_filter_dopesheet_movieclips(ac, anim_data, filter_mode);
3755 }
3756
3757 /* Scene-linked animation - e.g. world, compositing nodes, scene anim
3758 * (including sequencer currently). */
3759 items += animdata_filter_dopesheet_scene(ac, anim_data, scene, filter_mode);
3760
3761 /* If filtering for channel drawing, we want the objects in alphabetical order,
3762 * to make it easier to predict where items are in the hierarchy
3763 * - This order only really matters
3764 * if we need to show all channels in the list (e.g. for drawing).
3765 * (XXX: What about lingering "active" flags? The order may now become unpredictable)
3766 * - Don't do this if this behavior has been turned off (i.e. due to it being too slow)
3767 * - Don't do this if there's just a single object
3768 */
3769 BKE_view_layer_synced_ensure(*ac->bmain, scene, view_layer);
3770 ListBaseT<Base> *object_bases = BKE_view_layer_object_bases_get(view_layer);
3771 if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && !(ads->flag & ADS_FLAG_NO_DB_SORT) &&
3772 (object_bases->first_ != object_bases->last()))
3773 {
3774 /* Filter list of bases (i.e. objects), sort them, then add their contents normally... */
3775 /* TODO: Cache the old sorted order - if the set of bases hasn't changed, don't re-sort... */
3776 Base **sorted_bases;
3777 size_t num_bases;
3778
3779 sorted_bases = animdata_filter_ds_sorted_bases(ac, scene, view_layer, filter_mode, &num_bases);
3780 if (sorted_bases) {
3781 /* Add the necessary channels for these bases... */
3782 for (size_t i = 0; i < num_bases; i++) {
3783 items += animdata_filter_dopesheet_ob(ac, anim_data, sorted_bases[i], filter_mode);
3784 }
3785
3786 /* TODO: store something to validate whether any changes are needed? */
3787
3788 /* free temporary data */
3789 MEM_delete(sorted_bases);
3790 }
3791 }
3792 else {
3793 /* Filter and add contents of each base (i.e. object) without them sorting first
3794 * NOTE: This saves performance in cases where order doesn't matter
3795 */
3796 Object *obact = BKE_view_layer_active_object_get(view_layer);
3797 const eObjectMode object_mode = (obact != nullptr) ? obact->mode : OB_MODE_OBJECT;
3798 for (Base &base : *object_bases) {
3799 if (animdata_filter_base_is_ok(ac, &base, object_mode, filter_mode)) {
3800 /* since we're still here, this object should be usable */
3801 items += animdata_filter_dopesheet_ob(ac, anim_data, &base, filter_mode);
3802 }
3803 }
3804 }
3805
3806 /* return the number of items in the list */
3807 return items;
3808}
3809
3810/* Summary track for DopeSheet/Action Editor
3811 * - return code is whether the summary lets the other channels get drawn
3812 */
3814 ListBaseT<bAnimListElem> *anim_data,
3815 const eAnimFilter_Flags filter_mode,
3816 size_t *items)
3817{
3818 bDopeSheet *ads = nullptr;
3819
3820 /* get the DopeSheet information to use
3821 * - we should only need to deal with the DopeSheet/Action Editor,
3822 * since all the other Animation Editors won't have this concept
3823 * being applicable.
3824 */
3825 if ((ac && ac->sl) && (ac->spacetype == SPACE_ACTION)) {
3826 SpaceAction *saction = reinterpret_cast<SpaceAction *>(ac->sl);
3827 ads = &saction->ads;
3828 }
3829 else {
3830 /* invalid space type - skip this summary channels */
3831 return 1;
3832 }
3833
3834 if ((filter_mode & ANIMFILTER_LIST_CHANNELS) == 0) {
3835 /* Without ANIMFILTER_LIST_CHANNELS flag, summary channels should not be created.
3836 * Sub-channels of this summary should still be visited. */
3837 return 1;
3838 }
3839
3840 /* dopesheet summary
3841 * - only for drawing and/or selecting keyframes in channels, but not for real editing
3842 * - only useful for DopeSheet/Action/etc. editors where it is actually useful
3843 */
3844 const bool is_timeline = ac->dopesheet_mode == SACTCONT_TIMELINE;
3845 if (is_timeline || (ac->filters.flag & ADS_FILTER_SUMMARY)) {
3846 bAnimListElem *ale = make_new_animlistelem(ac->bmain, ac, ANIMTYPE_SUMMARY, nullptr, nullptr);
3847 if (ale) {
3848 BLI_addtail(anim_data, ale);
3849 (*items)++;
3850 }
3851
3852 /* If summary is collapsed, don't show other channels beneath this - this check is put inside
3853 * the summary check so that it doesn't interfere with normal operation.
3854 */
3855 if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED) {
3856 return 0;
3857 }
3858 }
3859
3860 /* the other channels beneath this can be shown */
3861 return 1;
3862}
3863
3864/* ......................... */
3865
3866/* filter data associated with a channel - usually for handling summary-channels in DopeSheet */
3868 ListBaseT<bAnimListElem> *anim_data,
3869 bAnimListElem *channel,
3870 const eAnimFilter_Flags filter_mode)
3871{
3872 size_t items = 0;
3873
3874 /* data to filter depends on channel type */
3875 /* NOTE: only common channel-types have been handled for now. More can be added as necessary */
3876 switch (channel->type) {
3877 case ANIMTYPE_NONE:
3878 return 0;
3879
3880 case ANIMTYPE_SUMMARY:
3881 items += animdata_filter_dopesheet(ac, anim_data, filter_mode);
3882 break;
3883
3884 case ANIMTYPE_SCENE:
3886 ac, anim_data, static_cast<Scene *>(channel->data), filter_mode);
3887 break;
3888
3889 case ANIMTYPE_OBJECT:
3891 ac, anim_data, static_cast<Base *>(channel->data), filter_mode);
3892 break;
3893
3896 ac, anim_data, static_cast<CacheFile *>(channel->data), filter_mode);
3897 break;
3898
3899 case ANIMTYPE_ANIMDATA:
3900 items += animfilter_block_data(ac, anim_data, channel->id, filter_mode);
3901 break;
3902
3903 default:
3904 printf("ERROR: Unsupported channel type (%d) in animdata_filter_animchan()\n",
3905 channel->type);
3906 break;
3907 }
3908
3909 return items;
3910}
3911
3912/* ----------- Cleanup API --------------- */
3913
3914/* Remove entries with invalid types in animation channel list */
3915static size_t animdata_filter_remove_invalid(ListBaseT<bAnimListElem> *anim_data)
3916{
3917 size_t items = 0;
3918
3919 /* only keep entries with valid types */
3920 for (bAnimListElem &ale : anim_data->items_mutable()) {
3921 if (ale.type == ANIMTYPE_NONE) {
3922 BLI_freelinkN(anim_data, &ale);
3923 }
3924 else {
3925 items++;
3926 }
3927 }
3928
3929 return items;
3930}
3931
3932/* Remove duplicate entries in animation channel list */
3933static size_t animdata_filter_remove_duplis(ListBaseT<bAnimListElem> *anim_data)
3934{
3935 /* Build new hash-table to efficiently store and retrieve which entries have been
3936 * encountered already while searching. */
3938
3939 /* loop through items, removing them from the list if a similar item occurs already */
3940 for (bAnimListElem &ale : anim_data->items_mutable()) {
3941 /* check if hash has any record of an entry like this
3942 * - just use ale->data for now, though it would be nicer to involve
3943 * ale->type in combination too to capture corner cases
3944 * (where same data performs differently)
3945 */
3946 if (!gs.add(ale.data)) {
3947 /* this entry isn't needed anymore */
3948 BLI_freelinkN(anim_data, &ale);
3949 }
3950 }
3951
3952 /* return the number of items still in the list */
3953 return gs.size();
3954}
3955
3956/* ----------- Public API --------------- */
3957
3959 ListBaseT<bAnimListElem> *anim_data,
3960 const eAnimFilter_Flags filter_mode,
3961 void *data,
3962 const eAnimCont_Types datatype)
3963{
3964 if (!data || !anim_data) {
3965 return 0;
3966 }
3967
3968 size_t items = 0;
3969 switch (datatype) {
3970 /* Action-Editing Modes */
3971 case ANIMCONT_ACTION: /* 'Action Editor' */
3972 {
3973 Object *obact = ac->obact;
3974 SpaceAction *saction = reinterpret_cast<SpaceAction *>(ac->sl);
3975 bDopeSheet *ads = (saction) ? &saction->ads : nullptr;
3976 BLI_assert(ads == ac->ads);
3977 UNUSED_VARS_NDEBUG(ads);
3978
3979 /* specially check for AnimData filter, see #36687. */
3980 /* TODO: see how this interacts with the new layered Actions. */
3981 if (filter_mode & ANIMFILTER_ANIMDATA) [[unlikely]] {
3982 /* all channels here are within the same AnimData block, hence this special case */
3983 if (obact->adt) [[likely]] {
3985 ac->bmain, obact->adt, ANIMTYPE_ANIMDATA, reinterpret_cast<ID *>(obact), nullptr);
3986 }
3987 }
3988 else {
3989 /* The check for the DopeSheet summary is included here
3990 * since the summary works here too. */
3991 if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
3993 obact->adt && data == obact->adt->action,
3994 "This code assumes the Action editor shows the Action of the active object");
3995
3996 animrig::Action &action = static_cast<bAction *>(data)->wrap();
3997 const animrig::slot_handle_t slot_handle = obact->adt->slot_handle;
3998 items += animfilter_action(
3999 ac, anim_data, action, slot_handle, filter_mode, reinterpret_cast<ID *>(obact));
4000 }
4001 }
4002
4003 break;
4004 }
4005 case ANIMCONT_SHAPEKEY: /* 'ShapeKey Editor' */
4006 {
4007 Key *key = static_cast<Key *>(data);
4008
4009 /* specially check for AnimData filter, see #36687. */
4010 if (filter_mode & ANIMFILTER_ANIMDATA) [[unlikely]] {
4011 /* all channels here are within the same AnimData block, hence this special case */
4012 if (key->adt) [[likely]] {
4014 ac->bmain, key->adt, ANIMTYPE_ANIMDATA, reinterpret_cast<ID *>(key), nullptr);
4015 }
4016 }
4017 else {
4018 /* The check for the DopeSheet summary is included here
4019 * since the summary works here too. */
4020 if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
4021 items = animdata_filter_shapekey(ac, anim_data, key, filter_mode);
4022 }
4023 }
4024
4025 break;
4026 }
4027
4028 /* Modes for Specialty Data Types (i.e. not keyframes) */
4029 case ANIMCONT_GPENCIL: {
4030 if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
4031 items = animdata_filter_grease_pencil(ac, anim_data, filter_mode);
4032 }
4033 break;
4034 }
4035 case ANIMCONT_MASK: {
4036 if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
4037 items = animdata_filter_mask(ac, anim_data, data, filter_mode);
4038 }
4039 break;
4040 }
4041 case ANIMCONT_CACHEFILE: {
4042 if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
4043 for (CacheFile &cache_file : ac->bmain->cachefiles) {
4044 items += animdata_filter_ds_cachefile(ac, anim_data, &cache_file, filter_mode);
4045 }
4046 }
4047 break;
4048 }
4049
4050 /* DopeSheet Based Modes */
4051 case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */
4052 {
4053 /* Due to code in `actedit_get_context()`, the equation below holds. The `data` pointer is no
4054 * longer used here, in favor of always passing `ac` down the call chain. The called code
4055 * can access it via `ac->ads`. Because the anim filtering code is quite complex, I (Sybren)
4056 * want to keep this assertion in place. */
4057 BLI_assert_msg(ac->ads == data, "ANIMCONT_DOPESHEET");
4058
4059 /* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
4060 if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
4061 items += animdata_filter_dopesheet(ac, anim_data, filter_mode);
4062 }
4063 break;
4064 }
4065 case ANIMCONT_FCURVES: /* Graph Editor -> F-Curves/Animation Editing */
4066 case ANIMCONT_DRIVERS: /* Graph Editor -> Drivers Editing */
4067 case ANIMCONT_NLA: /* NLA Editor */
4068 {
4069 /* Due to code in `actedit_get_context()`, the equation below holds. The `data` pointer is no
4070 * longer used here, in favor of always passing `ac` down the call chain. The called code
4071 * can access it via `ac->ads`. Because the anim filtering code is quite complex, I (Sybren)
4072 * want to keep this assertion in place. */
4073 BLI_assert_msg(ac->ads == data, "ANIMCONT_FCURVES/DRIVERS/NLA");
4074
4075 /* all of these editors use the basic DopeSheet data for filtering options,
4076 * but don't have all the same features */
4077 items = animdata_filter_dopesheet(ac, anim_data, filter_mode);
4078 break;
4079 }
4080
4081 /* Timeline Mode - Basically the same as dopesheet,
4082 * except we only have the summary for now */
4083 case ANIMCONT_TIMELINE: {
4084 /* Due to code in `actedit_get_context()`, the equation below holds. The `data` pointer is no
4085 * longer used here, in favor of always passing `ac` down the call chain. The called code
4086 * can access it via `ac->ads`. Because the anim filtering code is quite complex, I (Sybren)
4087 * want to keep this assertion in place. */
4088 BLI_assert_msg(ac->ads == data, "ANIMCONT_TIMELINE");
4089 if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
4090 items += animdata_filter_dopesheet(ac, anim_data, filter_mode);
4091 }
4092 break;
4093 }
4094
4095 /* Special/Internal Use */
4096 case ANIMCONT_CHANNEL: /* animation channel */
4097 {
4098 /* based on the channel type, filter relevant data for this */
4100 ac, anim_data, static_cast<bAnimListElem *>(data), filter_mode);
4101 break;
4102 }
4103
4104 case ANIMCONT_NONE:
4105 printf("ANIM_animdata_filter() - Invalid datatype argument ANIMCONT_NONE\n");
4106 break;
4107 }
4108
4109 /* remove any 'weedy' entries */
4110 items = animdata_filter_remove_invalid(anim_data);
4111
4112 /* remove duplicates (if required) */
4113 if (filter_mode & ANIMFILTER_NODUPLIS) {
4114 items = animdata_filter_remove_duplis(anim_data);
4115 }
4116
4117 return items;
4118}
4119
4120/* ************************************************************ */
4121
4122} // namespace blender
Functions and classes to work with Actions.
Functions to deal with Armatures.
Blender kernel action and pose functionality.
#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
Low-level operations for grease pencil.
General operations, lookup, etc. for materials.
#define BLI_array_alloca(arr, realsize)
Definition BLI_alloca.hh:18
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_REAL_USERS(id)
Definition DNA_ID.h:679
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
#define ID_MISSING(_id)
Definition DNA_ID.h:695
Object is a sort of wrapper for general info.
#define EXPANDED_ADT(adt)
#define FILTER_SPK_OBJD(spk)
#define FILTER_CACHEFILE_OBJD(cf)
#define SEL_SHAPEKEY(kb)
#define FILTER_LIGHTPROBE_OBJD(probe)
#define EXPANDED_MCLIP(clip)
#define FILTER_NTREE_DATA(ntree)
#define FILTER_SKE_OBJD(key)
#define FILTER_MESH_OBJD(me)
#define EDITABLE_GPL(gpl)
#define SEL_AGRP(agrp)
#define EXPANDED_SCEC(sce)
#define SEL_MASKLAY(masklay)
#define SEL_GPL(gpl)
#define FILTER_ARM_OBJD(arm)
#define EDITABLE_AGRP(agrp)
#define EXPANDED_AGRP(ac, agrp)
#define FILTER_CAM_OBJD(ca)
#define FILTER_LATTICE_OBJD(lt)
#define FILTER_CURVES_OBJD(ha)
#define EXPANDED_ACTC(actc)
#define FILTER_LAM_OBJD(la)
#define EXPANDED_OBJC(ob)
#define SEL_FCU(fcu)
#define EDITABLE_SHAPEKEY(kb)
#define EDITABLE_FCU(fcu)
#define EDITABLE_MASK(masklay)
#define FILTER_CUR_OBJD(cu)
#define FILTER_MAT_OBJD(ma)
#define EDITABLE_NLT(nlt)
#define FILTER_WOR_SCED(wo)
#define FILTER_MBALL_OBJD(mb)
#define FILTER_LS_SCED(linestyle)
#define EXPANDED_DRVD(adt)
#define EXPANDED_MASK(mask)
#define SEL_ANIMDATA(adt)
#define FILTER_POINTS_OBJD(pt)
#define EXPANDED_GPD(gpd)
#define FILTER_TEX_DATA(tex)
#define FILTER_VOLUME_OBJD(vo)
#define SEL_NLT(nlt)
#define FILTER_PART_OBJD(part)
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define MAX_MTEX
Definition Stroke.h:31
#define ANIMCHANNEL_NEW_CHANNEL(bmain, channel_data, channel_type, owner_id, fcurve_owner_id)
#define ANIMCHANNEL_SELOK(test_func)
#define ANIMCHANNEL_ACTIVEOK(ale)
#define END_ANIMFILTER_SUBCHANNELS
#define BEGIN_ANIMFILTER_SUBCHANNELS(expanded_check)
#define ANIMDATA_FILTER_CASES(id, adtOk, nlaOk, driversOk, nlaKeysOk, legacyActionOk, layeredActionOk)
#define ANIMCHANNEL_NEW_CHANNEL_FULL(bmain, channel_data, channel_type, owner_id, fcurve_owner_id, ale_statement)
#define ANIMCHANNEL_SELEDITOK(test_func)
#define ANIM_CHAN_NAME_SIZE
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
#define BLI_assert(a)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
int64_t size() const
Definition BLI_set.hh:606
bool add(const Key &key)
Definition BLI_set.hh:248
bool add(const Key &key)
void append(const T &value)
Span< const Slot * > slots() const
Slot * slot_for_handle(slot_handle_t handle)
Span< const bActionGroup * > channel_groups() const
Span< const FCurve * > fcurves() const
#define layer
decltype(blender::ActionSlot::handle) slot_handle_t
const animrig::Channelbag * channelbag_for_action_slot(const Action &action, slot_handle_t slot_handle)
bool bone_is_visible(const bArmature *armature, const Bone *bone)
ID * action_slot_get_id_best_guess(Main &bmain, Slot &slot, ID *primary_id)
Span< FCurve * > fcurves_for_action_slot(Action &action, slot_handle_t slot_handle)
FCurve * fcurve_find_in_assigned_slot(AnimData &adt, const FCurveDescriptor &fcurve_descriptor)
bNode * node_find_node_by_name(bNodeTree &ntree, StringRefNull name)
Definition node.cc:4047
BLI_INLINE Texture * wrap(MTLTexture *texture)
void foreach_strip_modifier_id(Strip *strip, const FunctionRef< void(ID *)> fn)
void foreach_strip(ListBaseT< Strip > *seqbase, ForEachFunc callback, void *user_data)
Definition iterator.cc:60
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
Strip * get_strip_by_name(ListBaseT< Strip > *seqbase, const char *name, bool recursive)
BMesh Iterators.
static size_t animfilter_action(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, animrig::Action &action, const animrig::slot_handle_t slot_handle, const eAnimFilter_Flags filter_mode, ID *owner_id)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static size_t animdata_filter_grease_pencil_layer(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, GreasePencil *grease_pencil, bke::greasepencil::Layer &layer, const eAnimFilter_Flags filter_mode)
static bool ale_name_matches_dopesheet_filter(const bDopeSheet &ads, bAnimListElem &ale)
@ AGRP_CURVES_ALWAYS_VISIBLE
ScrArea * CTX_wm_area(const bContext *C)
static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Base *base, eAnimFilter_Flags filter_mode)
static Key * actedit_get_shapekeys(bAnimContext *ac)
static size_t animdata_filter_ds_material(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Material *ma, eAnimFilter_Flags filter_mode)
static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, eAnimFilter_Flags filter_mode)
@ DRIVER_FLAG_INVALID
static void animfilter_modifier_idpoin_cb(void *afm_ptr, Object *ob, ID **idpoin, LibraryForeachIDCallbackFlag)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
int char char int int int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
const bAnimChannelType * ANIM_channel_get_typeinfo(const bAnimListElem *ale)
static size_t animdata_filter_remove_invalid(ListBaseT< bAnimListElem > *anim_data)
static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Object *ob, const eAnimFilter_Flags filter_mode)
@ ADS_FLAG_SUMMARY_COLLAPSED
bool bool BLI_str_quoted_substr(const char *__restrict str, const char *__restrict prefix, char *result, size_t result_maxncpy)
@ ANIMCONT_CHANNEL
@ ANIMCONT_SHAPEKEY
@ ANIMCONT_DRIVERS
@ ANIMCONT_CACHEFILE
@ ANIMCONT_NONE
@ ANIMCONT_TIMELINE
@ ANIMCONT_ACTION
@ ANIMCONT_DOPESHEET
@ ANIMCONT_FCURVES
@ ANIMCONT_GPENCIL
static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Object *ob, Key *key, eAnimFilter_Flags filter_mode)
static bool graphedit_get_context(bAnimContext *ac, SpaceGraph *sipo)
static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, ID *owner_id, bNodeTree *ntree, const eAnimFilter_Flags filter_mode)
static size_t animdata_filter_animchan(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, bAnimListElem *channel, const eAnimFilter_Flags filter_mode)
int bool bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL(1
static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Tex *tex, ID *owner_id, eAnimFilter_Flags filter_mode)
@ NLASTRIP_FLAG_TEMP_META
static size_t animfilter_block_data(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, ID *id, const eAnimFilter_Flags filter_mode)
@ BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT
@ BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Object *ob, eAnimFilter_Flags filter_mode)
Material * BKE_object_material_get(Object *ob, short act)
static Base ** animdata_filter_ds_sorted_bases(bAnimContext *ac, const Scene *scene, ViewLayer *view_layer, const eAnimFilter_Flags filter_mode, size_t *r_usable_bases)
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
static size_t animdata_filter_grease_pencil_data(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, GreasePencil *grease_pencil, eAnimFilter_Flags filter_mode)
static size_t animdata_filter_ds_modifiers(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Object *ob, const eAnimFilter_Flags filter_mode)
@ ADT_CURVES_NOT_VISIBLE
@ ADT_CURVES_ALWAYS_VISIBLE
@ ADT_NLA_SKEYS_COLLAPSED
void void void BKE_modifiers_foreach_ID_link(Object *ob, IDWalkFunc walk, void *user_data)
static size_t animdata_filter_grease_pencil(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode)
void void void BLI_movelisttolist(ListBase *dst, ListBase *src) ATTR_NONNULL(1
Definition listbase.cc:32
@ ADS_FILTER_ONLY_SLOTS_OF_ACTIVE
static size_t animdata_filter_gpencil_layers_data_legacy(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, bGPdata *gpd, const eAnimFilter_Flags filter_mode)
static size_t animdata_filter_ds_particles(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Object *ob, eAnimFilter_Flags filter_mode)
static size_t animdata_filter_remove_duplis(ListBaseT< bAnimListElem > *anim_data)
static bool fcurve_span_must_be_selected(const eAnimFilter_Flags filter_mode)
@ USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS
@ ANIMTYPE_MASKDATABLOCK
@ ANIMTYPE_NLAACTION
@ ANIMTYPE_NLACURVE
@ ANIMTYPE_GREASE_PENCIL_LAYER_GROUP
@ ANIMTYPE_DSPOINTCLOUD
@ ANIMTYPE_DSMCLIP
@ ANIMTYPE_DSLIGHTPROBE
@ ANIMTYPE_DSNTREE
@ ANIMTYPE_GREASE_PENCIL_DATABLOCK
@ ANIMTYPE_FCURVE
@ ANIMTYPE_ANIMDATA
@ ANIMTYPE_DSVOLUME
@ ANIMTYPE_NLATRACK
@ ANIMTYPE_OBJECT
@ ANIMTYPE_GPLAYER
@ ANIMTYPE_GREASE_PENCIL_LAYER
@ ANIMTYPE_DSMBALL
@ ANIMTYPE_DSMESH
@ ANIMTYPE_NUM_TYPES
@ ANIMTYPE_NLACONTROLS
@ ANIMTYPE_DSHAIR
@ ANIMTYPE_FILLDRIVERS
@ ANIMTYPE_SUMMARY
@ ANIMTYPE_FILLACT_LAYERED
@ ANIMTYPE_SHAPEKEY
@ ANIMTYPE_SPECIALDATA__UNUSED
@ ANIMTYPE_ACTION_SLOT
@ ANIMTYPE_DSCACHEFILE
@ ANIMTYPE_MASKLAYER
@ ANIMTYPE_DSGPENCIL
@ ANIMTYPE_DSPART
@ ANIMTYPE_FILLACTD
@ ANIMTYPE_DSSKEY
@ ANIMTYPE_DSLINESTYLE
@ ANIMTYPE_PALETTE
bool ANIM_animdata_context_getdata(bAnimContext *ac)
static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Object *ob, eAnimFilter_Flags filter_mode)
static bool animdata_filter_base_is_ok(bAnimContext *ac, Base *base, const eObjectMode object_mode, const eAnimFilter_Flags filter_mode)
bAction * ANIM_active_action_from_area(const Main &bmain, Scene *scene, ViewLayer *view_layer, const ScrArea *area, ID **r_action_user)
int char * BLI_strcasestr(const char *s, const char *find) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
static size_t animfilter_fcurves_span(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Span< FCurve * > fcurves, const animrig::slot_handle_t slot_handle, const eAnimFilter_Flags filter_mode, ID *animated_id, ID *fcurve_owner_id)
bool bool int BLI_string_find_split_words(const char *str, size_t str_maxlen, char delim, int r_words[][2], int words_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
static size_t animdata_filter_mask_data(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Mask *mask, const eAnimFilter_Flags filter_mode)
bool ANIM_animdata_can_have_greasepencil(const eAnimCont_Types type)
static bool name_matches_dopesheet_filter(const bDopeSheet *ads, const char *name)
ViewLayer * CTX_data_view_layer(const bContext *C)
static size_t animdata_filter_ds_cachefile(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, CacheFile *cache_file, eAnimFilter_Flags filter_mode)
static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
static size_t animdata_filter_shapekey(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Key *key, const eAnimFilter_Flags filter_mode)
static bool fcurve_has_errors(bAnimContext *ac, const FCurve *fcu)
Global G
Definition blender.cc:57
static size_t animdata_filter_ds_movieclip(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, MovieClip *clip, eAnimFilter_Flags filter_mode)
static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, ID *owner_id, bNodeTree *ntree, eAnimFilter_Flags filter_mode)
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:93
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
@ ALE_GREASE_PENCIL_GROUP
@ ALE_ACTION_LAYERED
@ ALE_GREASE_PENCIL_DATA
@ ALE_ACTION_SLOT
@ ALE_GREASE_PENCIL_CEL
static void key_data_from_adt(bAnimListElem &ale, AnimData *adt)
static bool skip_fcurve_with_name(bAnimContext *ac, FCurve *fcu, eAnim_ChannelType channel_type, void *owner, ID *owner_id)
size_t ANIM_animdata_filter(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode, void *data, const eAnimCont_Types datatype)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, ID *owner_id, const eAnimFilter_Flags filter_mode)
static size_t animfilter_act_group(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, bAction *act, animrig::slot_handle_t slot_handle, bActionGroup *agrp, eAnimFilter_Flags filter_mode, ID *owner_id)
@ ANIMFILTER_FCURVESONLY
@ ANIMFILTER_TMP_IGNORE_ONLYSEL
@ ANIMFILTER_ANIMDATA
@ ANIMFILTER_FOREDIT
@ ANIMFILTER_LIST_VISIBLE
@ ANIMFILTER_DATA_VISIBLE
@ ANIMFILTER_CURVE_VISIBLE
@ ANIMFILTER_UNSEL
@ ANIMFILTER_ACTGROUPED
@ ANIMFILTER_ACTIVE
@ ANIMFILTER_TMP_PEEK
@ ANIMFILTER_NODUPLIS
@ ANIMFILTER_SELEDIT
@ ANIMFILTER_LIST_CHANNELS
static bool nlaedit_get_context(bAnimContext *ac, SpaceNla *snla)
static size_t animfilter_nla(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, AnimData *adt, const eAnimFilter_Flags filter_mode, ID *owner_id)
static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Scene *sce, eAnimFilter_Flags filter_mode)
size_t ANIM_animfilter_action_slot(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, animrig::Action &action, animrig::Slot &slot, const eAnimFilter_Flags filter_mode, ID *animated_id)
BMesh const char void * data
std::optional< std::string > BKE_keyblock_curval_rnapath_get(const Key *key, const KeyBlock *kb)
Definition key.cc:1460
int bool bool bool size_t size_t size_t int BLI_string_max_possible_word_count(int str_len) ATTR_WARN_UNUSED_RESULT
MaskLayer * BKE_mask_layer_active(Mask *mask)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:277
static FCurve * animfilter_fcurve_next(bAnimContext *ac, FCurve *first, eAnim_ChannelType channel_type, const eAnimFilter_Flags filter_mode, void *owner, ID *owner_id)
static size_t animfilter_fcurves(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, FCurve *first, eAnim_ChannelType fcurve_type, const eAnimFilter_Flags filter_mode, void *owner, ID *owner_id, ID *fcurve_owner_id)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
static size_t animdata_filter_mask(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, void *, eAnimFilter_Flags filter_mode)
static size_t animdata_filter_grease_pencil_layer_node_recursive(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, GreasePencil *grease_pencil, bke::greasepencil::TreeNode &node, eAnimFilter_Flags filter_mode)
@ ADS_FILTER_NOCACHEFILES
@ ADS_FILTER_NOLIGHTPROBE
@ ADS_FILTER_NOMOVIECLIPS
@ ADS_FILTER_NOPOINTCLOUD
@ ADS_FILTER_DRIVER_FALLBACK_AS_ERROR
SpaceLink * CTX_wm_space_data(const bContext *C)
static int ds_base_sorting_cmp(const void *base1_ptr, const void *base2_ptr)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
Main * CTX_data_main(const bContext *C)
static size_t animdata_filter_dopesheet_movieclips(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode)
static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode, size_t *items)
static size_t animdata_filter_ds_world(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Scene *sce, World *wo, eAnimFilter_Flags filter_mode)
static bAnimListElem * make_new_animlistelem(Main *bmain, void *data, const eAnim_ChannelType datatype, ID *owner_id, ID *fcurve_owner_id)
static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Scene *sce, eAnimFilter_Flags filter_mode)
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ ID_TAG_DOIT
Definition DNA_ID.h:1029
static size_t animfilter_nla_controls(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, AnimData *adt, eAnimFilter_Flags filter_mode, ID *owner_id)
Scene * CTX_data_scene(const bContext *C)
@ SACTION_POSEMARKERS_SHOW
bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
static bool fcurve_span_selection_matters(const eAnimFilter_Flags filter_mode)
LibraryForeachIDCallbackFlag
Key * BKE_key_from_object(Object *ob)
Definition key.cc:1311
@ DTAR_FLAG_FALLBACK_USED
int char char * BLI_strncasestr(const char *s, const char *find, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
static size_t animfilter_action_slots(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, animrig::Action &action, const eAnimFilter_Flags filter_mode, ID *owner_id)
ARegion * CTX_wm_region(const bContext *C)
ListBaseT< Base > * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
static bool skip_fcurve_selected_data(bAnimContext *ac, FCurve *fcu, ID *owner_id, const eAnimFilter_Flags filter_mode)
static size_t animdata_filter_grease_pencil_layers_data(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, GreasePencil *grease_pencil, const eAnimFilter_Flags filter_mode)
static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, Scene *sce, eAnimFilter_Flags filter_mode)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static size_t animdata_filter_ds_gpencil(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, bGPdata *gpd, eAnimFilter_Flags filter_mode)
eRegion_Type regiontype
eAnimData_Flag flag
ListBaseT< FCurve > drivers
ListBaseT< NlaTrack > nla_tracks
struct Object * object
struct AnimData * adt
ListBaseT< DriverVar > variables
struct AnimData * adt
bActionGroup * grp
eFCurve_Flags flag
struct FCurve * next
ChannelDriver * driver
ListBaseT< FreestyleLineSet > linesets
struct FreestyleLineStyle * linestyle
ListBaseT< GreasePencilLayerTreeNode > children
char name[258]
Definition DNA_ID.h:433
KeyBlockFlag flag
ListBaseT< KeyBlock > block
ShapekeyContainerType type
struct AnimData * adt
struct AnimData * adt
ListBaseT< bGPdata > gpencils
Definition BKE_main.hh:417
ListBaseT< MovieClip > movieclips
Definition BKE_main.hh:419
ListBaseT< CacheFile > cachefiles
Definition BKE_main.hh:422
ListBaseT< Mask > masks
Definition BKE_main.hh:420
struct AnimData * adt
ListBaseT< FCurve > fcurves
eNlaStrip_Flag flag
struct NlaTrack * prev
eNlaTrack_Flag flag
ListBaseT< NlaStrip > strips
struct NlaTrack * next
struct PartDeflect * pd
ListBaseT< ModifierData > modifiers
ListBaseT< struct ParticleSystem > particlesystem
eObject_VisibilityFlag visibility_flag
struct AnimData * adt
struct bPose * pose
ListBaseT< ViewLayer > view_layers
struct World * world
struct Editing * ed
struct AnimData * adt
ListBaseT< TimeMarker > markers
ListBaseT< SceneCompositorEffect > compositor_effects
struct MovieClip * clip
ListBaseT< SpaceLink > spacedata
eAnimEdit_Context mode
struct bDopeSheet * ads
eGraphEdit_Mode mode
struct bDopeSheet * ads
struct AnimData * adt
struct bNodeTree * nodetree
struct AnimData * adt
struct FreestyleConfig freestyle_config
eViewLayer_Flag flag
struct AnimData * adt
struct ActionChannelbag * channelbag
ListBaseT< struct TimeMarker > markers
void(*) name(bAnimListElem *ale, char *name)
ListBaseT< TimeMarker > * markers
eRegion_Type regiontype
eGraphEdit_Mode grapheditor_mode
struct blender::bAnimContext::@354357007254244122245111034311231000121111260015 filters
eAnimEdit_Context dopesheet_mode
eAnimCont_Types datatype
eAnim_ChannelType type
struct AnimData * adt
eDopeSheet_FilterFlag2 filterflag2
eDopeSheet_FilterFlag filterflag
struct Collection * filter_grp
ListBaseT< bGPDlayer > layers
struct AnimData * adt
ListBaseT< bAnimListElem > tmp_data