Blender V5.3
keyframes_keylist.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors, Joshua Leung. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9/* System includes ----------------------------------------------------- */
10
11#include <algorithm>
12#include <cfloat>
13#include <cstdlib>
14#include <cstring>
15#include <functional>
16#include <optional>
17
18#include "MEM_guardedalloc.h"
19
20#include "BLI_array.hh"
21#include "BLI_bounds_types.hh"
22#include "BLI_listbase.hh"
23#include "BLI_utildefines.hh"
24
25#include "DNA_anim_types.h"
26#include "DNA_cachefile_types.h"
28#include "DNA_layer_types.h"
29#include "DNA_mask_types.h"
30#include "DNA_object_types.h"
31#include "DNA_scene_types.h"
32#include "DNA_sequence_types.h"
33
34#include "BKE_fcurve.hh"
35#include "BKE_grease_pencil.hh"
36
37#include "ED_anim_api.hh"
39
40#include "SEQ_retiming.hh"
41
42#include "ANIM_action.hh"
43
44namespace blender {
45
46/* *************************** Keyframe Processing *************************** */
47
48/* ActKeyColumns (Keyframe Columns) ------------------------------------------ */
49
50BLI_INLINE bool is_cfra_eq(const float a, const float b)
51{
53}
54
55BLI_INLINE bool is_cfra_lt(const float a, const float b)
56{
57 return (b - a) > BEZT_BINARYSEARCH_THRESH;
58}
59
60/* --------------- */
61
70
72 /* Number of ActKeyColumn's in the keylist. */
73 size_t column_len = 0;
74
76
77 /* Before initializing the runtime, the key_columns list base is used to quickly add columns.
78 * Contains `ActKeyColumn`. Should not be used after runtime is initialized. */
79 ListBaseT<ActKeyColumn> key_columns;
80 /* Last accessed column in the key_columns list base. Inserting columns are typically done in
81 * order. The last accessed column is used as starting point to search for a location to add or
82 * update the next column. */
83 std::optional<ActKeyColumn *> last_accessed_column = std::nullopt;
84
85 struct {
86 /* When initializing the runtime the columns from the list base `AnimKeyList.key_columns` are
87 * transferred to an array to support binary searching and index based access. */
89 /* Wrapper around runtime.key_columns so it can still be accessed as a ListBase.
90 * Elements are owned by `runtime.key_columns`. */
91 ListBaseT<ActKeyColumn> list_wrapper;
93
95 {
96 this->key_columns.clear_no_delete();
97 this->runtime.list_wrapper.clear_no_delete();
98 }
99
101 {
102 this->key_columns.free_no_destruct();
103 this->runtime.list_wrapper.clear_no_delete();
104 }
105
106 MEM_CXX_CLASS_ALLOC_FUNCS("editors:AnimKeylist")
107};
108
110{
111 AnimKeylist *keylist = new AnimKeylist();
112 return keylist;
113}
114
116{
117 BLI_assert(keylist);
118 delete keylist;
119}
120
122{
123 for (auto [index, key] : keylist->key_columns.enumerate()) {
124 keylist->runtime.key_columns[index] = key;
125 }
126}
127
129{
130 for (size_t index = 0; index < keylist->column_len; index++) {
131 const bool is_first = (index == 0);
132 keylist->runtime.key_columns[index].prev = is_first ? nullptr :
133 &keylist->runtime.key_columns[index - 1];
134 const bool is_last = (index == keylist->column_len - 1);
135 keylist->runtime.key_columns[index].next = is_last ? nullptr :
136 &keylist->runtime.key_columns[index + 1];
137 }
138}
139
141{
142 if (ED_keylist_is_empty(keylist)) {
143 keylist->runtime.list_wrapper.clear_no_delete();
144 return;
145 }
146
147 keylist->runtime.list_wrapper.first_ = keylist->runtime.key_columns.data();
148 keylist->runtime.list_wrapper.last_ = &keylist->runtime.key_columns[keylist->column_len - 1];
149}
150
152{
154
156
157 /* Convert linked list to array to support fast searching. */
159 /* Ensure that the array can also be used as a listbase for external usages. */
162
163 keylist->is_runtime_initialized = true;
164}
165
167{
169 keylist->last_accessed_column.reset();
170}
171
173{
174 if (keylist->is_runtime_initialized) {
175 return;
176 }
177 keylist_runtime_init(keylist);
178}
179
180static const ActKeyColumn *keylist_find_lower_bound(const AnimKeylist *keylist, const float cfra)
181{
183 const ActKeyColumn *begin = std::begin(keylist->runtime.key_columns);
184 const ActKeyColumn *end = std::end(keylist->runtime.key_columns);
185 ActKeyColumn value;
186 value.cfra = cfra;
187
188 const ActKeyColumn *found_column = std::lower_bound(
189 begin, end, value, [](const ActKeyColumn &column, const ActKeyColumn &other) {
190 return is_cfra_lt(column.cfra, other.cfra);
191 });
192 return found_column;
193}
194
195static const ActKeyColumn *keylist_find_upper_bound(const AnimKeylist *keylist, const float cfra)
196{
198 const ActKeyColumn *begin = std::begin(keylist->runtime.key_columns);
199 const ActKeyColumn *end = std::end(keylist->runtime.key_columns);
200 ActKeyColumn value;
201 value.cfra = cfra;
202
203 const ActKeyColumn *found_column = std::upper_bound(
204 begin, end, value, [](const ActKeyColumn &column, const ActKeyColumn &other) {
205 return is_cfra_lt(column.cfra, other.cfra);
206 });
207 return found_column;
208}
209
210const ActKeyColumn *ED_keylist_find_exact(const AnimKeylist *keylist, const float cfra)
211{
213 "ED_keylist_prepare_for_direct_access needs to be called before searching.");
214
215 if (ED_keylist_is_empty(keylist)) {
216 return nullptr;
217 }
218
219 const ActKeyColumn *found_column = keylist_find_lower_bound(keylist, cfra);
220
221 const ActKeyColumn *end = std::end(keylist->runtime.key_columns);
222 if (found_column == end) {
223 return nullptr;
224 }
225 if (is_cfra_eq(found_column->cfra, cfra)) {
226 return found_column;
227 }
228 return nullptr;
229}
230
231const ActKeyColumn *ED_keylist_find_next(const AnimKeylist *keylist, const float cfra)
232{
234 "ED_keylist_prepare_for_direct_access needs to be called before searching.");
235
236 if (ED_keylist_is_empty(keylist)) {
237 return nullptr;
238 }
239
240 const ActKeyColumn *found_column = keylist_find_upper_bound(keylist, cfra);
241
242 const ActKeyColumn *end = std::end(keylist->runtime.key_columns);
243 if (found_column == end) {
244 return nullptr;
245 }
246 return found_column;
247}
248
249const ActKeyColumn *ED_keylist_find_prev(const AnimKeylist *keylist, const float cfra)
250{
252 "ED_keylist_prepare_for_direct_access needs to be called before searching.");
253
254 if (ED_keylist_is_empty(keylist)) {
255 return nullptr;
256 }
257
258 const ActKeyColumn *end = std::end(keylist->runtime.key_columns);
259 const ActKeyColumn *found_column = keylist_find_lower_bound(keylist, cfra);
260
261 if (found_column == end) {
262 /* Nothing found, return the last item. */
263 return end - 1;
264 }
265
266 const ActKeyColumn *prev_column = found_column->prev;
267 return prev_column;
268}
269
270const ActKeyColumn *ED_keylist_find_closest(const AnimKeylist *keylist, const float cfra)
271{
273 "ED_keylist_prepare_for_direct_access needs to be called before searching.");
274 if (ED_keylist_is_empty(keylist)) {
275 return nullptr;
276 }
277 /* Need to check against #BEZT_BINARYSEARCH_THRESH because #ED_keylist_find_prev does so as well.
278 * Not doing that here could cause that function to return a nullptr. */
279 if (cfra - keylist->runtime.key_columns.first().cfra < BEZT_BINARYSEARCH_THRESH) {
280 return &keylist->runtime.key_columns.first();
281 }
282 if (cfra - keylist->runtime.key_columns.last().cfra > BEZT_BINARYSEARCH_THRESH) {
283 keylist->runtime.key_columns.last();
284 }
285 const ActKeyColumn *prev = ED_keylist_find_prev(keylist, cfra);
286 BLI_assert_msg(prev != nullptr,
287 "This should exist since we checked for cfra bounds just before");
288 /* This could be a nullptr though. */
289 const ActKeyColumn *next = prev->next;
290
291 if (!next) {
292 return prev;
293 }
294
295 const float prev_delta = cfra - prev->cfra;
296 const float next_delta = next->cfra - cfra;
297 /* `prev_delta` and `next_delta` can both be 0 if the given `cfra` is exactly at a key column. */
298
299 if (prev_delta <= next_delta) {
300 return prev;
301 }
302 return next;
303}
304
306 const Bounds<float> frame_range)
307{
309 "ED_keylist_prepare_for_direct_access needs to be called before searching.");
310
311 if (ED_keylist_is_empty(keylist)) {
312 return nullptr;
313 }
314
315 const ActKeyColumn *column = keylist_find_lower_bound(keylist, frame_range.min);
316 const ActKeyColumn *end = std::end(keylist->runtime.key_columns);
317 if (column == end) {
318 return nullptr;
319 }
320 if (column->cfra >= frame_range.max) {
321 return nullptr;
322 }
323 return column;
324}
325
327{
329 keylist->is_runtime_initialized,
330 "ED_keylist_prepare_for_direct_access needs to be called before accessing array.");
331 return keylist->runtime.key_columns.data();
332}
333
335{
336 return keylist->column_len;
337}
338
340{
341 return keylist->column_len == 0;
342}
343
344const ListBaseT<ActKeyColumn> *ED_keylist_listbase(const AnimKeylist *keylist)
345{
346 if (keylist->is_runtime_initialized) {
347 return &keylist->runtime.list_wrapper;
348 }
349 return &keylist->key_columns;
350}
351
352static void keylist_first_last(const AnimKeylist *keylist,
353 const ActKeyColumn **first_column,
354 const ActKeyColumn **last_column)
355{
356 if (keylist->is_runtime_initialized) {
357 *first_column = keylist->runtime.key_columns.data();
358 *last_column = &keylist->runtime.key_columns[keylist->column_len - 1];
359 }
360 else {
361 *first_column = keylist->key_columns.first();
362 *last_column = keylist->key_columns.last();
363 }
364}
365
367{
368 BLI_assert(r_frame_range);
369
370 if (ED_keylist_is_empty(keylist)) {
371 return false;
372 }
373
374 const ActKeyColumn *first_column;
375 const ActKeyColumn *last_column;
376 keylist_first_last(keylist, &first_column, &last_column);
377 r_frame_range->min = first_column->cfra;
378 r_frame_range->max = last_column->cfra;
379
380 return true;
381}
382
384{
385 BLI_assert(r_frame_range);
386
387 if (ED_keylist_is_empty(keylist)) {
388 return false;
389 }
390
391 const ActKeyColumn *first_column;
392 const ActKeyColumn *last_column;
393 keylist_first_last(keylist, &first_column, &last_column);
394 while (first_column && !(first_column->sel & SELECT)) {
395 first_column = first_column->next;
396 }
397 while (last_column && !(last_column->sel & SELECT)) {
398 last_column = last_column->prev;
399 }
400 if (!first_column || !last_column || first_column == last_column) {
401 return false;
402 }
403 r_frame_range->min = first_column->cfra;
404 r_frame_range->max = last_column->cfra;
405
406 return true;
407}
408
409/* Set of references to three logically adjacent keys. */
411 /* Current keyframe. */
413
414 /* Logical neighbors. May be nullptr. */
416};
417
418/* Categorize the interpolation & handle type of the keyframe. */
420{
421 if (bezt->h1 == HD_AUTO_ANIM && bezt->h2 == HD_AUTO_ANIM) {
423 }
424 if (ELEM(bezt->h1, HD_AUTO_ANIM, HD_AUTO) && ELEM(bezt->h2, HD_AUTO_ANIM, HD_AUTO)) {
426 }
427 if (bezt->h1 == HD_VECT && bezt->h2 == HD_VECT) {
429 }
430 if (ELEM(HD_FREE, bezt->h1, bezt->h2)) {
432 }
434}
435
436/* Determine if the keyframe is an extreme by comparing with neighbors.
437 * Ends of fixed-value sections and of the whole curve are also marked.
438 */
440{
441 if (chain->prev == nullptr && chain->next == nullptr) {
443 }
444
445 /* Keyframe values for the current one and neighbors. */
446 const float cur_y = chain->cur->vec[1][1];
447 float prev_y = cur_y, next_y = cur_y;
448
449 if (chain->prev && !IS_EQF(cur_y, chain->prev->vec[1][1])) {
450 prev_y = chain->prev->vec[1][1];
451 }
452 if (chain->next && !IS_EQF(cur_y, chain->next->vec[1][1])) {
453 next_y = chain->next->vec[1][1];
454 }
455
456 /* Static hold. */
457 if (prev_y == cur_y && next_y == cur_y) {
459 }
460
461 /* Middle of an incline. */
462 if ((prev_y < cur_y && next_y > cur_y) || (prev_y > cur_y && next_y < cur_y)) {
464 }
465
466 /* Bezier handle values for the overshoot check. */
467 const bool l_bezier = chain->prev && chain->prev->ipo == BEZT_IPO_BEZ;
468 const bool r_bezier = chain->next && chain->cur->ipo == BEZT_IPO_BEZ;
469 const float handle_l = l_bezier ? chain->cur->vec[0][1] : cur_y;
470 const float handle_r = r_bezier ? chain->cur->vec[2][1] : cur_y;
471
472 /* Detect extremes. One of the neighbors is allowed to be equal to current. */
473 if (prev_y < cur_y || next_y < cur_y) {
474 const bool is_overshoot = (handle_l > cur_y || handle_r > cur_y);
475
477 (is_overshoot ? KEYFRAME_EXTREME_MIXED : 0));
478 }
479
480 if (prev_y > cur_y || next_y > cur_y) {
481 const bool is_overshoot = (handle_l < cur_y || handle_r < cur_y);
482
484 (is_overshoot ? KEYFRAME_EXTREME_MIXED : 0));
485 }
486
488}
489
490/* New node callback used for building ActKeyColumns from BezTripleChain */
492{
493 ActKeyColumn *ak = MEM_new_zeroed<ActKeyColumn>("ActKeyColumn");
494 const BezTripleChain *chain = static_cast<const BezTripleChain *>(data);
495 const BezTriple *bezt = chain->cur;
496
497 /* store settings based on state of BezTriple */
498 ak->cfra = bezt->vec[1][0];
499 ak->sel = BEZT_ISSEL_ANY(bezt) ? SELECT : 0;
500 ak->key_type = BEZKEYTYPE(bezt);
501 ak->handle_type = bezt_handle_type(bezt);
502 ak->extreme_type = bezt_extreme_type(chain);
503
504 /* count keyframes in this column */
505 ak->totkey = 1;
506
507 return ak;
508}
509
510/* Node updater callback used for building ActKeyColumns from BezTripleChain */
511static void nupdate_ak_bezt(ActKeyColumn *ak, void *data)
512{
513 const BezTripleChain *chain = static_cast<const BezTripleChain *>(data);
514 const BezTriple *bezt = chain->cur;
515
516 /* set selection status and 'touched' status */
517 if (BEZT_ISSEL_ANY(bezt)) {
518 ak->sel = SELECT;
519 }
520
521 ak->totkey++;
522
523 /* For keyframe type, 'proper' keyframes have priority over breakdowns
524 * (and other types for now). */
525 if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME) {
527 }
528
529 /* For interpolation type, select the highest value (enum is sorted). */
531
532 /* For extremes, detect when combining different states. */
533 const char new_extreme = bezt_extreme_type(chain);
534
535 if (new_extreme != ak->extreme_type) {
536 /* Replace the flat status without adding mixed. */
538 ak->extreme_type = new_extreme;
539 }
540 else if (new_extreme != KEYFRAME_EXTREME_FLAT) {
541 ak->extreme_type |= (new_extreme | KEYFRAME_EXTREME_MIXED);
542 }
543 }
544}
545
546/* ......... */
547/* New node callback used for building ActKeyColumns from GPencil frames */
549{
550 ActKeyColumn *ak = MEM_new_zeroed<ActKeyColumn>("ActKeyColumnCel");
551 GreasePencilCel &cel = *static_cast<GreasePencilCel *>(data);
552
553 /* Store settings based on state of BezTriple */
554 ak->cfra = cel.frame_number;
555 ak->sel = (cel.frame.flag & SELECT) != 0;
557
558 /* Count keyframes in this column */
559 ak->totkey = 1;
560 /* Set as visible block. */
561 ak->totblock = 1;
562 ak->block.sel = ak->sel;
564
565 return ak;
566}
567
568/* Node updater callback used for building ActKeyColumns from GPencil frames */
569static void nupdate_ak_cel(ActKeyColumn *ak, void *data)
570{
571 GreasePencilCel &cel = *static_cast<GreasePencilCel *>(data);
572
573 /* Update selection status. */
574 if (cel.frame.flag & GP_FRAME_SELECTED) {
575 ak->sel = SELECT;
576 }
577
578 ak->totkey++;
579
580 /* Update keytype status. */
581 if (cel.frame.type == BEZT_KEYTYPE_KEYFRAME) {
583 }
584}
585
586/* ......... */
587
588/* New node callback used for building ActKeyColumns from GPencil frames. */
590{
591 ActKeyColumn *ak = MEM_new_zeroed<ActKeyColumn>("ActKeyColumnGPF");
592 const bGPDframe *gpf = static_cast<bGPDframe *>(data);
593
594 /* store settings based on state of BezTriple */
595 ak->cfra = gpf->framenum;
596 ak->sel = (gpf->flag & GP_FRAME_SELECT) ? SELECT : 0;
598
599 /* Count keyframes in this column. */
600 ak->totkey = 1;
601 /* Set as visible block. */
602 ak->totblock = 1;
603 ak->block.sel = ak->sel;
605
606 return ak;
607}
608
609/* Node updater callback used for building ActKeyColumns from GPencil frames. */
610static void nupdate_ak_gpframe(ActKeyColumn *ak, void *data)
611{
612 bGPDframe *gpf = static_cast<bGPDframe *>(data);
613
614 /* Set selection status and 'touched' status. */
615 if (gpf->flag & GP_FRAME_SELECT) {
616 ak->sel = SELECT;
617 }
618
619 ak->totkey++;
620
621 /* For keyframe type, 'proper' keyframes have priority over breakdowns
622 * (and other types for now). */
623 if (gpf->key_type == BEZT_KEYTYPE_KEYFRAME) {
625 }
626}
627
628/* ......... */
629
630/* Extra struct to pass the timeline frame since the retiming key doesn't contain that and we would
631 * need the scene to get it. */
636
637/* New node callback used for building ActKeyColumns from Sequencer keys. */
639{
640 ActKeyColumn *ak = MEM_new_zeroed<ActKeyColumn>("ActKeyColumnGPF");
641 const SeqAllocateData *allocate_data = static_cast<SeqAllocateData *>(data);
642 const SeqRetimingKey *timing_key = allocate_data->key;
643
644 /* store settings based on state of BezTriple */
645 ak->cfra = allocate_data->timeline_frame;
646 ak->sel = (timing_key->flag & SEQ_KEY_SELECTED) ? SELECT : 0;
648
649 /* Count keyframes in this column. */
650 ak->totkey = 1;
651 /* Set as visible block. */
652 ak->totblock = 1;
653 ak->block.sel = ak->sel;
654 ak->block.flag = 0;
655
656 return ak;
657}
658
659/* Node updater callback used for building ActKeyColumns from Sequencer keys. */
660static void nupdate_ak_seqframe(ActKeyColumn *ak, void *data)
661{
662 SeqAllocateData *allocate_data = static_cast<SeqAllocateData *>(data);
663
664 /* Set selection status and 'touched' status. */
665 if (allocate_data->key->flag & SEQ_KEY_SELECTED) {
666 ak->sel = SELECT;
667 }
668
669 ak->totkey++;
670}
671
672/* ......... */
673
674/* New node callback used for building ActKeyColumns from GPencil frames */
676{
677 ActKeyColumn *ak = MEM_new_zeroed<ActKeyColumn>("ActKeyColumnGPF");
678 const MaskLayerShape *masklay_shape = static_cast<const MaskLayerShape *>(data);
679
680 /* Store settings based on state of BezTriple. */
681 ak->cfra = masklay_shape->frame;
682 ak->sel = (masklay_shape->flag & MASK_SHAPE_SELECT) ? SELECT : 0;
683
684 /* Count keyframes in this column. */
685 ak->totkey = 1;
686
687 return ak;
688}
689
690/* Node updater callback used for building ActKeyColumns from GPencil frames */
692{
693 MaskLayerShape *masklay_shape = static_cast<MaskLayerShape *>(data);
694
695 /* Set selection status and 'touched' status. */
696 if (masklay_shape->flag & MASK_SHAPE_SELECT) {
697 ak->sel = SELECT;
698 }
699
700 ak->totkey++;
701}
702
703/* --------------- */
704using KeylistCreateColumnFunction = std::function<ActKeyColumn *(void *userdata)>;
705using KeylistUpdateColumnFunction = std::function<void(ActKeyColumn *, void *)>;
706
707/* `keylist_find_neighbor_front_to_back` is called before the runtime can be initialized so we
708 * cannot use bin searching. */
710{
711 while (cursor->next && cursor->next->cfra <= cfra) {
712 cursor = cursor->next;
713 }
714 return cursor;
715}
716
717/* `keylist_find_neighbor_back_to_front` is called before the runtime can be initialized so we
718 * cannot use bin searching. */
720{
721 while (cursor->prev && cursor->prev->cfra >= cfra) {
722 cursor = cursor->prev;
723 }
724 return cursor;
725}
726
727/*
728 * `keylist_find_exact_or_neighbor_column` is called before the runtime can be initialized so
729 * we cannot use bin searching.
730 *
731 * This function is called to add or update columns in the keylist.
732 * Typically columns are sorted by frame number so keeping track of the last_accessed_column
733 * reduces searching.
734 */
736{
738 if (ED_keylist_is_empty(keylist)) {
739 return nullptr;
740 }
741
742 ActKeyColumn *cursor = keylist->last_accessed_column.value_or(keylist->key_columns.first());
743 if (!is_cfra_eq(cursor->cfra, cfra)) {
744 const bool walking_direction_front_to_back = cursor->cfra <= cfra;
745 if (walking_direction_front_to_back) {
746 cursor = keylist_find_neighbor_front_to_back(cursor, cfra);
747 }
748 else {
749 cursor = keylist_find_neighbor_back_to_front(cursor, cfra);
750 }
751 }
752
753 keylist->last_accessed_column = cursor;
754 return cursor;
755}
756
758 float cfra,
759 KeylistCreateColumnFunction create_func,
760 KeylistUpdateColumnFunction update_func,
761 void *userdata)
762{
764 !keylist->is_runtime_initialized,
765 "Modifying AnimKeylist isn't allowed after runtime is initialized "
766 "keylist->key_columns/columns_len will get out of sync with runtime.key_columns.");
767 if (ED_keylist_is_empty(keylist)) {
768 ActKeyColumn *key_column = create_func(userdata);
769 BLI_addhead(&keylist->key_columns, key_column);
770 keylist->column_len += 1;
771 keylist->last_accessed_column = key_column;
772 return;
773 }
774
775 ActKeyColumn *nearest = keylist_find_exact_or_neighbor_column(keylist, cfra);
776 if (is_cfra_eq(nearest->cfra, cfra)) {
777 update_func(nearest, userdata);
778 }
779 else if (is_cfra_lt(nearest->cfra, cfra)) {
780 ActKeyColumn *key_column = create_func(userdata);
781 BLI_insertlinkafter(&keylist->key_columns, nearest, key_column);
782 keylist->column_len += 1;
783 keylist->last_accessed_column = key_column;
784 }
785 else {
786 ActKeyColumn *key_column = create_func(userdata);
787 BLI_insertlinkbefore(&keylist->key_columns, nearest, key_column);
788 keylist->column_len += 1;
789 keylist->last_accessed_column = key_column;
790 }
791}
792
793/* Add the given BezTriple to the given 'list' of Keyframes */
795{
796 if (ELEM(nullptr, keylist, bezt)) {
797 return;
798 }
799
800 float cfra = bezt->cur->vec[1][0];
802}
803
804/* Add the given GPencil Frame to the given 'list' of Keyframes */
806{
807 if (ELEM(nullptr, keylist, gpf)) {
808 return;
809 }
810
811 float cfra = gpf->framenum;
813}
814
815/* Add the given MaskLayerShape Frame to the given 'list' of Keyframes */
816static void add_masklay_to_keycolumns_list(AnimKeylist *keylist, MaskLayerShape *masklay_shape)
817{
818 if (ELEM(nullptr, keylist, masklay_shape)) {
819 return;
820 }
821
822 float cfra = masklay_shape->frame;
824 keylist, cfra, nalloc_ak_masklayshape, nupdate_ak_masklayshape, masklay_shape);
825}
826
827/* ActKeyBlocks (Long Keyframes) ------------------------------------------ */
828
830
832 const BezTriple *prev,
833 const BezTriple *beztn)
834{
835 memset(info, 0, sizeof(ActKeyBlockInfo));
836
837 if (BEZKEYTYPE(beztn) == BEZT_KEYTYPE_MOVEHOLD) {
838 /* Animator tagged a "moving hold"
839 * - Previous key must also be tagged as a moving hold, otherwise
840 * we're just dealing with the first of a pair, and we don't
841 * want to be creating any phantom holds...
842 */
843 if (BEZKEYTYPE(prev) == BEZT_KEYTYPE_MOVEHOLD) {
845 }
846 }
847
848 /* Check for same values...
849 * - Handles must have same central value as each other
850 * - Handles which control that section of the curve must be constant
851 */
852 if (IS_EQF(beztn->vec[1][1], prev->vec[1][1])) {
853 bool hold;
854
855 /* Only check handles in case of actual bezier interpolation. */
856 if (prev->ipo == BEZT_IPO_BEZ) {
857 hold = IS_EQF(beztn->vec[1][1], beztn->vec[0][1]) &&
858 IS_EQF(prev->vec[1][1], prev->vec[2][1]);
859 }
860 /* This interpolation type induces movement even between identical columns. */
861 else {
862 hold = !ELEM(prev->ipo, BEZT_IPO_ELASTIC);
863 }
864
865 if (hold) {
867 }
868 }
869
870 /* Remember non-bezier interpolation info. */
871 switch (eBezTriple_Interpolation(prev->ipo)) {
872 case BEZT_IPO_BEZ:
873 break;
874 case BEZT_IPO_LIN:
876 break;
877 case BEZT_IPO_CONST:
879 break;
880 default:
881 /* For automatic bezier interpolations, such as easings (cubic, circular, etc), and dynamic
882 * (back, bounce, elastic). */
884 break;
885 }
886
887 info->sel = BEZT_ISSEL_ANY(prev) || BEZT_ISSEL_ANY(beztn);
888}
889
890static void add_keyblock_info(ActKeyColumn *col, const ActKeyBlockInfo *block)
891{
892 /* New curve and block. */
893 if (col->totcurve <= 1 && col->totblock == 0) {
894 memcpy(&col->block, block, sizeof(ActKeyBlockInfo));
895 }
896 /* Existing curve. */
897 else {
898 col->block.conflict |= (col->block.flag ^ block->flag);
899 col->block.flag |= block->flag;
900 col->block.sel |= block->sel;
901 }
902
903 if (block->flag) {
904 col->totblock++;
905 }
906}
907
908static void add_bezt_to_keyblocks_list(AnimKeylist *keylist, BezTriple *bezt, const int bezt_len)
909{
910 ActKeyColumn *col = keylist->key_columns.first();
911
912 if (bezt && bezt_len >= 2) {
913 ActKeyBlockInfo block;
914
915 /* Find the first key column while inserting dummy blocks. */
916 for (; col != nullptr && is_cfra_lt(col->cfra, bezt[0].vec[1][0]); col = col->next) {
918 }
919
920 BLI_assert(col != nullptr);
921
922 /* Insert real blocks. */
923 for (int v = 1; col != nullptr && v < bezt_len; v++, bezt++) {
924 /* Wrong order of bezier keys: resync position. */
925 if (is_cfra_lt(bezt[1].vec[1][0], bezt[0].vec[1][0])) {
926 /* Backtrack to find the right location. */
927 if (is_cfra_lt(bezt[1].vec[1][0], col->cfra)) {
929
930 BLI_assert(newcol);
931 BLI_assert(newcol->cfra == col->cfra);
932
933 col = newcol;
934 /* The previous keyblock is garbage too. */
935 if (col->prev != nullptr) {
937 }
938 }
939
940 continue;
941 }
942
943 /* In normal situations all keyframes are sorted. However, while keys are transformed, they
944 * may change order and then this assertion no longer holds. The effect is that the drawing
945 * isn't perfect during the transform; the "constant value" bars aren't updated until the
946 * transformation is confirmed. */
947 // BLI_assert(is_cfra_eq(col->cfra, bezt[0].vec[1][0]));
948
949 compute_keyblock_data(&block, bezt, bezt + 1);
950
951 for (; col != nullptr && is_cfra_lt(col->cfra, bezt[1].vec[1][0]); col = col->next) {
952 add_keyblock_info(col, &block);
953 }
954
955 BLI_assert(col != nullptr);
956 }
957 }
958
959 /* Insert dummy blocks at the end. */
960 for (; col != nullptr; col = col->next) {
962 }
963}
964
965/* Walk through columns and propagate blocks and totcurve.
966 *
967 * This must be called even by animation sources that don't generate
968 * keyblocks to keep the data structure consistent after adding columns.
969 */
970static void update_keyblocks(AnimKeylist *keylist, BezTriple *bezt, const int bezt_len)
971{
972 /* Find the curve count. */
973 int max_curve = 0;
974
975 for (ActKeyColumn &col : keylist->key_columns) {
976 max_curve = std::max(max_curve, int(col.totcurve));
977 }
978
979 /* Propagate blocks to inserted keys. */
980 ActKeyColumn *prev_ready = nullptr;
981
982 for (ActKeyColumn &col : keylist->key_columns) {
983 /* Pre-existing column. */
984 if (col.totcurve > 0) {
985 prev_ready = &col;
986 }
987 /* Newly inserted column, so copy block data from previous. */
988 else if (prev_ready != nullptr) {
989 col.totblock = prev_ready->totblock;
990 memcpy(&col.block, &prev_ready->block, sizeof(ActKeyBlockInfo));
991 }
992
993 col.totcurve = max_curve + 1;
994 }
995
996 /* Add blocks on top. */
997 add_bezt_to_keyblocks_list(keylist, bezt, bezt_len);
998}
999
1000/* --------- */
1001
1003{
1004 return ac != nullptr && ac->next != nullptr && ac->totblock > 0;
1005}
1006
1008{
1009 if (!actkeyblock_is_valid(ac)) {
1010 return 0;
1011 }
1012
1014 return (ac->block.flag & ~ac->block.conflict) & hold_mask;
1015}
1016
1017/* *************************** Keyframe List Conversions *************************** */
1018
1020 AnimKeylist *keylist,
1021 const int saction_flag,
1022 float2 range)
1023{
1024 if (!ac) {
1025 return;
1026 }
1027
1028 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1029
1030 /* Get F-Curves to take keyframes from. */
1032 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
1033
1034 /* Loop through each F-Curve, grabbing the keyframes. */
1035 for (const bAnimListElem &ale : anim_data) {
1036 /* Why not use all #eAnim_KeyType here?
1037 * All of the other key types are actually "summaries" themselves,
1038 * and will just end up duplicating stuff that comes up through
1039 * standard filtering of just F-Curves. Given the way that these work,
1040 * there isn't really any benefit at all from including them. - Aligorith */
1041 switch (ale.datatype) {
1042 case ALE_FCURVE:
1043 fcurve_to_keylist(ale.adt,
1044 static_cast<FCurve *>(ale.data),
1045 keylist,
1046 saction_flag,
1047 range,
1049 break;
1050 case ALE_MASKLAY:
1051 mask_to_keylist(ac->ads, static_cast<MaskLayer *>(ale.data), keylist);
1052 break;
1053 case ALE_GPFRAME:
1054 gpl_to_keylist(ac->ads, static_cast<bGPDlayer *>(ale.data), keylist);
1055 break;
1058 ale.adt, static_cast<const GreasePencilLayer *>(ale.data), keylist, saction_flag);
1059 break;
1060 default:
1061 break;
1062 }
1063 }
1064
1065 ANIM_animdata_freelist(&anim_data);
1066}
1067
1069 ID *animated_id,
1070 animrig::Action &action,
1071 const animrig::slot_handle_t slot_handle,
1072 AnimKeylist *keylist,
1073 const int /* eSAction_Flag */ saction_flag,
1074 float2 range)
1075{
1076 /* TODO: downstream code depends on this being non-null (see e.g.
1077 * `ANIM_animfilter_action_slot()` and `animfilter_fcurves_span()`). Either
1078 * change this parameter to be a reference, or modify the downstream code to
1079 * not assume that it's non-null and do something reasonable when it is null. */
1080 BLI_assert(animated_id);
1081
1082 if (!ac) {
1083 return;
1084 }
1085
1086 animrig::Slot *slot = action.slot_for_handle(slot_handle);
1087 if (!slot) {
1088 /* In the Dope Sheet mode of the Dope Sheet, an _Action_ channel actually shows the _Slot_ keys
1089 * in its summary line. When there are animated NLA control curves, that Action channel is also
1090 * shown, even when there is no slot assigned. So this function needs to be able to handle the
1091 * "no slot" case as valid. It just doesn't produce any keys.
1092 *
1093 * Also see `build_channel_keylist()` in `keyframes_draw.cc`. */
1094 return;
1095 }
1096
1097 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1098
1099 /* Get F-Curves to take keyframes from. */
1101 ANIM_animfilter_action_slot(ac, &anim_data, action, *slot, filter, animated_id);
1102
1103 for (const bAnimListElem &ale : anim_data) {
1104 /* As of the writing of this code, Actions ultimately only contain FCurves.
1105 * If/when that changes in the future, this may need to be updated. */
1106 if (ale.datatype != ALE_FCURVE) {
1107 continue;
1108 }
1109 fcurve_to_keylist(ale.adt,
1110 static_cast<FCurve *>(ale.data),
1111 keylist,
1112 saction_flag,
1113 range,
1115 }
1116
1117 ANIM_animdata_freelist(&anim_data);
1118}
1119
1121 bDopeSheet *ads, Scene *sce, AnimKeylist *keylist, const int saction_flag, float2 range)
1122{
1123 bAnimContext ac = {nullptr};
1124 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1125
1126 bAnimListElem dummy_chan = {nullptr};
1127
1128 if (sce == nullptr) {
1129 return;
1130 }
1131
1132 /* Create a dummy wrapper data to work with. */
1133 dummy_chan.type = ANIMTYPE_SCENE;
1134 dummy_chan.data = sce;
1135 dummy_chan.id = &sce->id;
1136 dummy_chan.adt = sce->adt;
1137
1138 ac.ads = ads;
1139 ac.data = &dummy_chan;
1143
1144 /* Get F-Curves to take keyframes from. */
1146
1147 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
1148
1149 /* Loop through each F-Curve, grabbing the keyframes. */
1150 for (const bAnimListElem &ale : anim_data) {
1151 fcurve_to_keylist(ale.adt,
1152 static_cast<FCurve *>(ale.data),
1153 keylist,
1154 saction_flag,
1155 range,
1157 }
1158
1159 ANIM_animdata_freelist(&anim_data);
1160}
1161
1163 bDopeSheet *ads, Object *ob, AnimKeylist *keylist, const int saction_flag, float2 range)
1164{
1165 bAnimContext ac = {nullptr};
1166 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1167
1168 bAnimListElem dummy_chan = {nullptr};
1169 Base dummy_base = {nullptr};
1170
1171 if (ob == nullptr) {
1172 return;
1173 }
1174
1175 /* Create a dummy wrapper data to work with. */
1176 dummy_base.object = ob;
1177
1178 dummy_chan.type = ANIMTYPE_OBJECT;
1179 dummy_chan.data = &dummy_base;
1180 dummy_chan.id = &ob->id;
1181 dummy_chan.adt = ob->adt;
1182
1183 ac.ads = ads;
1184 ac.data = &dummy_chan;
1188
1189 /* Get F-Curves to take keyframes from. */
1191 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
1192
1193 /* Loop through each F-Curve, grabbing the keyframes. */
1194 for (const bAnimListElem &ale : anim_data) {
1195 fcurve_to_keylist(ale.adt,
1196 static_cast<FCurve *>(ale.data),
1197 keylist,
1198 saction_flag,
1199 range,
1201 }
1202
1203 ANIM_animdata_freelist(&anim_data);
1204}
1205
1207 CacheFile *cache_file,
1208 AnimKeylist *keylist,
1209 const int saction_flag)
1210{
1211 if (cache_file == nullptr) {
1212 return;
1213 }
1214
1215 /* Create a dummy wrapper data to work with. */
1216 bAnimListElem dummy_chan = {nullptr};
1217 dummy_chan.type = ANIMTYPE_DSCACHEFILE;
1218 dummy_chan.data = cache_file;
1219 dummy_chan.id = &cache_file->id;
1220 dummy_chan.adt = cache_file->adt;
1221
1222 bAnimContext ac = {nullptr};
1223 ac.ads = ads;
1224 ac.data = &dummy_chan;
1228
1229 /* Get F-Curves to take keyframes from. */
1230 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1232 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
1233
1234 /* Loop through each F-Curve, grabbing the keyframes. */
1235 for (const bAnimListElem &ale : anim_data) {
1236 fcurve_to_keylist(ale.adt,
1237 static_cast<FCurve *>(ale.data),
1238 keylist,
1239 saction_flag,
1240 {-FLT_MAX, FLT_MAX},
1242 }
1243
1244 ANIM_animdata_freelist(&anim_data);
1245}
1246
1247static inline void set_up_beztriple_chain(BezTripleChain &chain,
1248 const FCurve *fcu,
1249 const int key_index,
1250 const bool do_extremes,
1251 const bool is_cyclic)
1252{
1253 chain.cur = &fcu->bezt[key_index];
1254
1255 /* Neighbor columns, accounting for being cyclic. */
1256 if (do_extremes) {
1257 chain.prev = (key_index > 0) ? &fcu->bezt[key_index - 1] :
1258 is_cyclic ? &fcu->bezt[fcu->totvert - 2] :
1259 nullptr;
1260 chain.next = (key_index + 1 < fcu->totvert) ? &fcu->bezt[key_index + 1] :
1261 is_cyclic ? &fcu->bezt[1] :
1262 nullptr;
1263 }
1264}
1265
1267 FCurve *fcu,
1268 AnimKeylist *keylist,
1269 const int saction_flag,
1270 float2 range,
1271 const bool use_nla_remapping)
1272{
1273 /* This is not strictly necessary because `ANIM_nla_mapping_apply_fcurve()`
1274 * will just not do remapping if `adt` is null. Nevertheless, saying that you
1275 * want NLA remapping to be performed while not passing an `adt` (needed for
1276 * NLA remapping) almost certainly indicates a mistake somewhere. */
1277 BLI_assert_msg(!(use_nla_remapping && adt == nullptr),
1278 "Cannot perform NLA time remapping without an adt.");
1279
1280 if (!fcu || fcu->totvert == 0 || !fcu->bezt) {
1281 return;
1282 }
1284
1285 if (use_nla_remapping) {
1286 ANIM_nla_mapping_apply_fcurve(adt, fcu, false, false);
1287 }
1288
1289 const bool is_cyclic = BKE_fcurve_is_cyclic(*fcu) && (fcu->totvert >= 2);
1290 const bool do_extremes = (saction_flag & SACTION_SHOW_EXTREMES) != 0;
1291
1292 BezTripleChain chain = {nullptr};
1293 /* The indices for which keys have been added to the key columns. Initialized as invalid bounds
1294 * for the case that no keyframes get added to the key-columns, which happens when the given
1295 * range doesn't overlap with the existing keyframes. */
1296 Bounds<int> index_bounds(int(fcu->totvert), 0);
1297 /* The following is used to find the keys that are JUST outside the range. This is done so
1298 * drawing in the dope sheet can create lines that extend off-screen. */
1299 float left_outside_key_x = -FLT_MAX;
1300 float right_outside_key_x = FLT_MAX;
1301 int left_outside_key_index = -1;
1302 int right_outside_key_index = -1;
1303 /* Loop through beztriples, making ActKeysColumns. */
1304 for (int v = 0; v < fcu->totvert; v++) {
1305 /* Not using binary search to limit the range because the FCurve might not be sorted e.g. when
1306 * transforming in the Dope Sheet. */
1307 const float x = fcu->bezt[v].vec[1][0];
1308 if (x < range[0] && x > left_outside_key_x) {
1309 left_outside_key_x = x;
1310 left_outside_key_index = v;
1311 }
1312 if (x > range[1] && x < right_outside_key_x) {
1313 right_outside_key_x = x;
1314 right_outside_key_index = v;
1315 }
1316 if (x < range[0] || x > range[1]) {
1317 continue;
1318 }
1319 math::min_max(v, index_bounds.min, index_bounds.max);
1320 set_up_beztriple_chain(chain, fcu, v, do_extremes, is_cyclic);
1321
1322 add_bezt_to_keycolumns_list(keylist, &chain);
1323 }
1324
1325 if (left_outside_key_index >= 0) {
1326 set_up_beztriple_chain(chain, fcu, left_outside_key_index, do_extremes, is_cyclic);
1327 add_bezt_to_keycolumns_list(keylist, &chain);
1328 /* Checking min and max because the FCurve might not be sorted. */
1329 index_bounds.min = math::min(index_bounds.min, left_outside_key_index);
1330 index_bounds.max = math::max(index_bounds.max, left_outside_key_index);
1331 }
1332 if (right_outside_key_index >= 0) {
1333 set_up_beztriple_chain(chain, fcu, right_outside_key_index, do_extremes, is_cyclic);
1334 add_bezt_to_keycolumns_list(keylist, &chain);
1335 index_bounds.min = math::min(index_bounds.min, right_outside_key_index);
1336 index_bounds.max = math::max(index_bounds.max, right_outside_key_index);
1337 }
1338 /* Not using index_bounds.is_empty() because that returns true if min and max are the same. That
1339 * is a valid configuration in this case though. */
1340 if (index_bounds.min <= index_bounds.max) {
1342 keylist, &fcu->bezt[index_bounds.min], (index_bounds.max + 1) - index_bounds.min);
1343 }
1344
1345 if (use_nla_remapping) {
1346 ANIM_nla_mapping_apply_fcurve(adt, fcu, true, false);
1347 }
1348}
1349
1351 AnimData *adt, bActionGroup *agrp, AnimKeylist *keylist, const int saction_flag, float2 range)
1352{
1353 if (!agrp) {
1354 return;
1355 }
1356
1357 /* Layered actions. */
1358 animrig::Channelbag &channelbag = agrp->channelbag->wrap();
1359 Span<FCurve *> fcurves = channelbag.fcurves().slice(agrp->fcurve_range_start,
1360 agrp->fcurve_range_length);
1361 for (FCurve *fcurve : fcurves) {
1362 fcurve_to_keylist(adt, fcurve, keylist, saction_flag, range, true);
1363 }
1364}
1365
1367 AnimData *adt, bAction *dna_action, AnimKeylist *keylist, const int saction_flag, float2 range)
1368{
1369 if (!dna_action) {
1370 return;
1371 }
1372
1373 animrig::Action &action = dna_action->wrap();
1374
1379 BLI_assert(adt);
1380 for (FCurve *fcurve : fcurves_for_action_slot(action, adt->slot_handle)) {
1381 fcurve_to_keylist(adt, fcurve, keylist, saction_flag, range, true);
1382 }
1383}
1384
1385void gpencil_to_keylist(bDopeSheet *ads, bGPdata *gpd, AnimKeylist *keylist, const bool active)
1386{
1387 if (!gpd || !keylist) {
1388 return;
1389 }
1390
1391 /* For now, just aggregate out all the frames, but only for visible layers. */
1392 for (bGPDlayer &gpl : gpd->layers.items_reversed()) {
1393 if (gpl.flag & GP_LAYER_HIDE) {
1394 continue;
1395 }
1396 if ((!active) || ((active) && (gpl.flag & GP_LAYER_SELECT))) {
1397 gpl_to_keylist(ads, &gpl, keylist);
1398 }
1399 }
1400}
1401
1404 AnimKeylist *keylist,
1405 const int saction_flag,
1406 const bool active_layer_only)
1407{
1408 if ((grease_pencil == nullptr) || (keylist == nullptr)) {
1409 return;
1410 }
1411
1412 if (active_layer_only && grease_pencil->has_active_layer()) {
1413 grease_pencil_cels_to_keylist(adt, grease_pencil->get_active_layer(), keylist, saction_flag);
1414 return;
1415 }
1416
1417 for (const bke::greasepencil::Layer *layer : grease_pencil->layers()) {
1418 grease_pencil_cels_to_keylist(adt, layer, keylist, saction_flag);
1419 }
1420}
1421
1423 const GreasePencilLayer *gpl,
1424 AnimKeylist *keylist,
1425 int /*saction_flag*/)
1426{
1427 using namespace blender::bke::greasepencil;
1428 const Layer &layer = gpl->wrap();
1429 for (auto item : layer.frames().items()) {
1430 GreasePencilCel cel{};
1431 cel.frame_number = item.key;
1432 cel.frame = item.value;
1433
1434 float cfra = float(item.key);
1436 keylist, cfra, nalloc_ak_cel, nupdate_ak_cel, static_cast<void *>(&cel));
1437 }
1438}
1439
1441 const GreasePencilLayerTreeGroup *layer_group,
1442 AnimKeylist *keylist,
1443 const int saction_flag)
1444{
1445 if ((layer_group == nullptr) || (keylist == nullptr)) {
1446 return;
1447 }
1448
1449 for (const GreasePencilLayerTreeNode &node_ : layer_group->children.items_reversed()) {
1450 const bke::greasepencil::TreeNode &node = node_.wrap();
1451 if (node.is_group()) {
1452 grease_pencil_layer_group_to_keylist(adt, &node.as_group(), keylist, saction_flag);
1453 }
1454 else if (node.is_layer()) {
1455 grease_pencil_cels_to_keylist(adt, &node.as_layer(), keylist, saction_flag);
1456 }
1457 }
1458}
1459
1460void gpl_to_keylist(bDopeSheet * /*ads*/, bGPDlayer *gpl, AnimKeylist *keylist)
1461{
1462 if (!gpl || !keylist) {
1463 return;
1464 }
1465
1467 /* Although the frames should already be in an ordered list,
1468 * they are not suitable for displaying yet. */
1469 for (bGPDframe &gpf : gpl->frames) {
1470 add_gpframe_to_keycolumns_list(keylist, &gpf);
1471 }
1472
1473 update_keyblocks(keylist, nullptr, 0);
1474}
1475
1476void mask_to_keylist(bDopeSheet * /*ads*/, MaskLayer *masklay, AnimKeylist *keylist)
1477{
1478 if (!masklay || !keylist) {
1479 return;
1480 }
1482 for (MaskLayerShape &masklay_shape : masklay->splines_shapes) {
1483 add_masklay_to_keycolumns_list(keylist, &masklay_shape);
1484 }
1485
1486 update_keyblocks(keylist, nullptr, 0);
1487}
1488
1489void sequencer_strip_to_keylist(const Strip &strip, AnimKeylist &keylist, Scene &scene)
1490{
1491 if (!seq::retiming_has_keys(&strip)) {
1492 return;
1493 }
1495 for (const SeqRetimingKey &retime_key : seq::retiming_keys_get(&strip)) {
1496 const float cfra = seq::retiming_key_frame_get(&scene, &strip, &retime_key);
1497 SeqAllocateData allocate_data = {&retime_key, cfra};
1499 &keylist, cfra, nalloc_ak_seqframe, nupdate_ak_seqframe, &allocate_data);
1500 }
1501 update_keyblocks(&keylist, nullptr, 0);
1502}
1503
1504} // namespace blender
Functions and classes to work with Actions.
#define BEZT_BINARYSEARCH_THRESH
Low-level operations for grease pencil.
#define SELECT
Definition BKE_mask.hh:19
#define BEZT_ISSEL_ANY(bezt)
#define BEZKEYTYPE(bezt)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define BLI_INLINE
#define ELEM(...)
#define IS_EQF(a, b)
#define BLI_assert_msg(a, msg)
#define IS_EQT(a, b, c)
Array(Allocator allocator={}) noexcept
Definition BLI_array.hh:78
Slot * slot_for_handle(slot_handle_t handle)
Span< const FCurve * > fcurves() const
#define FLT_MAX
#define layer
decltype(blender::ActionSlot::handle) slot_handle_t
Span< FCurve * > fcurves_for_action_slot(Action &action, slot_handle_t slot_handle)
T min(const T &a, const T &b)
void min_max(const T &value, T &min, T &max)
T max(const T &a, const T &b)
MutableSpan< SeqRetimingKey > retiming_keys_get(const Strip *strip)
int retiming_key_frame_get(const Scene *scene, const Strip *strip, const SeqRetimingKey *key)
bool retiming_has_keys(const Strip *strip)
BMesh Iterators.
static void keylist_first_last(const AnimKeylist *keylist, const ActKeyColumn **first_column, const ActKeyColumn **last_column)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ BEZT_KEYTYPE_MOVEHOLD
@ BEZT_KEYTYPE_KEYFRAME
void action_to_keylist(AnimData *adt, bAction *dna_action, AnimKeylist *keylist, const int saction_flag, float2 range)
void grease_pencil_cels_to_keylist(AnimData *, const GreasePencilLayer *gpl, AnimKeylist *keylist, int)
std::function< ActKeyColumn *(void *userdata)> KeylistCreateColumnFunction
__int64 int64_t
Definition BKE_text.h:90
void gpl_to_keylist(bDopeSheet *, bGPDlayer *gpl, AnimKeylist *keylist)
static ActKeyColumn * nalloc_ak_bezt(void *data)
bool actkeyblock_is_valid(const ActKeyColumn *ac)
static void nupdate_ak_bezt(ActKeyColumn *ak, void *data)
@ ANIMCONT_CHANNEL
void grease_pencil_layer_group_to_keylist(AnimData *adt, const GreasePencilLayerTreeGroup *layer_group, AnimKeylist *keylist, const int saction_flag)
static void keylist_runtime_init_listbase(AnimKeylist *keylist)
static void add_keyblock_info(ActKeyColumn *col, const ActKeyBlockInfo *block)
static ActKeyColumn * keylist_find_neighbor_back_to_front(ActKeyColumn *cursor, float cfra)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
bool ED_keylist_selected_keys_frame_range(const AnimKeylist *keylist, Bounds< float > *r_frame_range)
void sequencer_strip_to_keylist(const Strip &strip, AnimKeylist &keylist, Scene &scene)
static const ActKeyColumn * keylist_find_upper_bound(const AnimKeylist *keylist, const float cfra)
static void nupdate_ak_masklayshape(ActKeyColumn *ak, void *data)
std::function< void(ActKeyColumn *, void *)> KeylistUpdateColumnFunction
const ActKeyColumn * ED_keylist_find_prev(const AnimKeylist *keylist, const float cfra)
static void compute_keyblock_data(ActKeyBlockInfo *info, const BezTriple *prev, const BezTriple *beztn)
static void nupdate_ak_cel(ActKeyColumn *ak, void *data)
BLI_INLINE bool is_cfra_eq(const float a, const float b)
void summary_to_keylist(bAnimContext *ac, AnimKeylist *keylist, const int saction_flag, float2 range)
ATTR_WARN_UNUSED_RESULT const BMVert * v
bool ED_keylist_is_empty(const AnimKeylist *keylist)
static ActKeyColumn * nalloc_ak_masklayshape(void *data)
static void keylist_runtime_update_key_column_next_prev(AnimKeylist *keylist)
bool ANIM_nla_mapping_allowed(const bAnimListElem *ale)
Definition anim_draw.cc:279
static void set_up_beztriple_chain(BezTripleChain &chain, const FCurve *fcu, const int key_index, const bool do_extremes, const bool is_cyclic)
@ ANIMTYPE_OBJECT
@ ANIMTYPE_DSCACHEFILE
static void keylist_runtime_init(AnimKeylist *keylist)
static void add_masklay_to_keycolumns_list(AnimKeylist *keylist, MaskLayerShape *masklay_shape)
const ActKeyColumn * ED_keylist_find_exact(const AnimKeylist *keylist, const float cfra)
static void keylist_add_or_update_column(AnimKeylist *keylist, float cfra, KeylistCreateColumnFunction create_func, KeylistUpdateColumnFunction update_func, void *userdata)
const ActKeyColumn * ED_keylist_array(const AnimKeylist *keylist)
const ActKeyColumn * ED_keylist_find_next(const AnimKeylist *keylist, const float cfra)
static void keylist_reset_last_accessed(AnimKeylist *keylist)
void fcurve_to_keylist(AnimData *adt, FCurve *fcu, AnimKeylist *keylist, const int saction_flag, float2 range, const bool use_nla_remapping)
static const ActKeyColumn * keylist_find_lower_bound(const AnimKeylist *keylist, const float cfra)
@ ALE_GREASE_PENCIL_CEL
VecBase< float, 2 > float2
void gpencil_to_keylist(bDopeSheet *ads, bGPdata *gpd, AnimKeylist *keylist, const bool active)
size_t ANIM_animdata_filter(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode, void *data, const eAnimCont_Types datatype)
static ActKeyColumn * nalloc_ak_gpframe(void *data)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
@ ANIMFILTER_FCURVESONLY
@ ANIMFILTER_DATA_VISIBLE
void grease_pencil_data_block_to_keylist(AnimData *adt, const GreasePencil *grease_pencil, AnimKeylist *keylist, const int saction_flag, const bool active_layer_only)
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
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:339
static void update_keyblocks(AnimKeylist *keylist, BezTriple *bezt, const int bezt_len)
static const ActKeyBlockInfo dummy_keyblock
static eKeyframeHandleDrawOpts bezt_handle_type(const BezTriple *bezt)
static void add_bezt_to_keycolumns_list(AnimKeylist *keylist, BezTripleChain *bezt)
static void keylist_convert_key_columns_to_array(AnimKeylist *keylist)
void action_group_to_keylist(AnimData *adt, bActionGroup *agrp, AnimKeylist *keylist, const int saction_flag, float2 range)
void ED_keylist_prepare_for_direct_access(AnimKeylist *keylist)
static void nupdate_ak_seqframe(ActKeyColumn *ak, void *data)
void action_slot_summary_to_keylist(bAnimContext *ac, ID *animated_id, animrig::Action &action, const animrig::slot_handle_t slot_handle, AnimKeylist *keylist, const int saction_flag, float2 range)
BLI_INLINE bool is_cfra_lt(const float a, const float b)
AnimKeylist * ED_keylist_create()
static void add_bezt_to_keyblocks_list(AnimKeylist *keylist, BezTriple *bezt, const int bezt_len)
static void add_gpframe_to_keycolumns_list(AnimKeylist *keylist, bGPDframe *gpf)
int64_t ED_keylist_array_len(const AnimKeylist *keylist)
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:378
void ob_to_keylist(bDopeSheet *ads, Object *ob, AnimKeylist *keylist, const int saction_flag, float2 range)
const ActKeyColumn * ED_keylist_find_any_between(const AnimKeylist *keylist, const Bounds< float > frame_range)
bool BKE_fcurve_is_cyclic(const FCurve &fcu)
void scene_to_keylist(bDopeSheet *ads, Scene *sce, AnimKeylist *keylist, const int saction_flag, float2 range)
static ActKeyColumn * nalloc_ak_cel(void *data)
iter begin(iter)
void ANIM_animdata_freelist(ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:472
void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, bool only_keys)
Definition anim_draw.cc:379
void cachefile_to_keylist(bDopeSheet *ads, CacheFile *cache_file, AnimKeylist *keylist, const int saction_flag)
void mask_to_keylist(bDopeSheet *, MaskLayer *masklay, AnimKeylist *keylist)
void ED_keylist_free(AnimKeylist *keylist)
const ActKeyColumn * ED_keylist_find_closest(const AnimKeylist *keylist, const float cfra)
static eKeyframeExtremeDrawOpts bezt_extreme_type(const BezTripleChain *chain)
const ListBaseT< ActKeyColumn > * ED_keylist_listbase(const AnimKeylist *keylist)
static ActKeyColumn * keylist_find_neighbor_front_to_back(ActKeyColumn *cursor, float cfra)
static ActKeyColumn * nalloc_ak_seqframe(void *data)
static void nupdate_ak_gpframe(ActKeyColumn *ak, void *data)
bool ED_keylist_all_keys_frame_range(const AnimKeylist *keylist, Bounds< float > *r_frame_range)
static ActKeyColumn * keylist_find_exact_or_neighbor_column(AnimKeylist *keylist, float cfra)
int actkeyblock_get_valid_hold(const ActKeyColumn *ac)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBezTriple_KeyframeType key_type
ListBaseT< ActKeyColumn > list_wrapper
struct blender::AnimKeylist::@334325201336360256323362141120236122002226222204 runtime
std::optional< ActKeyColumn * > last_accessed_column
ListBaseT< ActKeyColumn > key_columns
struct Object * object
eBezTriple_Handle h2
eBezTriple_Interpolation ipo
eBezTriple_Handle h1
struct AnimData * adt
unsigned int totvert
ListBaseT< GreasePencilLayerTreeNode > children
MaskLayerShapeFlag flag
ListBaseT< MaskLayerShape > splines_shapes
struct AnimData * adt
struct AnimData * adt
const SeqRetimingKey * key
struct ActionChannelbag * channelbag
struct blender::bAnimContext::@354357007254244122245111034311231000121111260015 filters
eAnimCont_Types datatype
eAnim_ChannelType type
eDopeSheet_FilterFlag2 filterflag2
eDopeSheet_FilterFlag filterflag
ListBaseT< bGPDframe > frames
ListBaseT< bGPDlayer > layers