Blender V5.3
action_edit.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cfloat>
10#include <cmath>
11#include <cstdlib>
12#include <cstring>
13
14#include "BLI_listbase.hh"
15#include "BLI_map.hh"
16#include "BLI_math_base_c.hh"
17#include "BLI_string.hh"
18#include "BLI_utildefines.hh"
19
20#include "BLT_translation.hh"
21
22#include "DEG_depsgraph.hh"
23
24#include "DNA_anim_types.h"
26#include "DNA_mask_types.h"
27#include "DNA_scene_types.h"
28
29#include "RNA_access.hh"
30#include "RNA_define.hh"
31#include "RNA_enum_types.hh"
32#include "RNA_prototypes.hh"
33
34#include "BKE_animsys.hh"
35#include "BKE_annotations.h"
36#include "BKE_context.hh"
37#include "BKE_fcurve.hh"
38#include "BKE_global.hh"
39#include "BKE_grease_pencil.hh"
40#include "BKE_nla.hh"
41#include "BKE_report.hh"
42
43#include "UI_interface_icons.hh"
44#include "UI_view2d.hh"
45
46#include "ANIM_action.hh"
47#include "ANIM_animdata.hh"
48#include "ANIM_fcurve.hh"
49#include "ANIM_keyframing.hh"
50#include "ED_anim_api.hh"
51#include "ED_gpencil_legacy.hh"
52#include "ED_grease_pencil.hh"
53#include "ED_keyframes_edit.hh"
54#include "ED_keyframing.hh"
55#include "ED_markers.hh"
56#include "ED_mask.hh"
57#include "ED_screen.hh"
58
59#include "WM_api.hh"
60#include "WM_types.hh"
61
62#include "action_intern.hh"
63
64namespace blender {
65
66/* -------------------------------------------------------------------- */
69
70/* ensure that there is:
71 * 1) an active action editor
72 * 2) that the set of markers being shown are the scene markers, not the list we're merging
73 * 3) that the mode will have an active action available
74 * 4) that there are some selected markers
75 * 5) that the markers are not locked
76 */
78{
80
81 /* 1) */
82 if (sact == nullptr) {
83 return false;
84 }
85
86 /* 2) */
87 if (sact->flag & SACTION_POSEMARKERS_SHOW) {
88 return false;
89 }
90
91 /* 3) */
92 const Main *bmain = CTX_data_main(C);
95 if (!active_action) {
96 return false;
97 }
98
99 /* 4) */
101 return false;
102 }
103
104 /* 5) */
106 return !ts->lock_markers;
107}
108
110{
111 ListBaseT<TimeMarker> *markers = ED_context_get_markers(C);
112 const Main *bmain = CTX_data_main(C);
115
116 TimeMarker *marker, *markern = nullptr;
117
118 /* sanity checks */
119 if (ELEM(nullptr, markers, act)) {
120 return OPERATOR_CANCELLED;
121 }
122
123 /* migrate markers */
124 for (marker = markers->first(); marker; marker = markern) {
125 markern = marker->next;
126
127 /* move if marker is selected */
128 if (marker->flag & SELECT) {
129 BLI_remlink(markers, marker);
130 BLI_addtail(&act->markers, marker);
131 }
132 }
133
134 /* Now enable the "show pose-markers only" setting,
135 * so that we can see that something did happen. */
138
139 /* notifiers - both sets, as this change affects both */
142
143 return OPERATOR_FINISHED;
144}
145
147{
148 /* identifiers */
149 ot->name = "Convert to Pose Markers";
150 ot->idname = "ACTION_OT_markers_make_local";
151 ot->description = "Move selected scene markers to the active action as pose markers";
152
153 /* callbacks */
156
157 /* flags */
159}
160
162
163/* -------------------------------------------------------------------- */
166
167/* Get the min/max keyframes. */
168static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const short onlySel)
169{
170 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
172 bool found = false;
173
174 /* Get data to filter, from Action or Dope-sheet. */
175 /* XXX: what is sel doing here?!
176 * Commented it, was breaking things (eg. the "auto preview range" tool). */
177 filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /* | ANIMFILTER_SEL */ |
179 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
180
181 /* set large values to try to override */
182 *min = 999999999.0f;
183 *max = -999999999.0f;
184
185 /* check if any channels to set range with */
186 if (anim_data.first_) {
187 /* go through channels, finding max extents */
188 for (bAnimListElem &ale : anim_data) {
189 if (ale.datatype == ALE_GPFRAME) {
190 bGPDlayer *gpl = static_cast<bGPDlayer *>(ale.data);
191
192 /* Find GP-frame which is less than or equal to current-frame. */
193 for (bGPDframe &gpf : gpl->frames) {
194 if (!onlySel || (gpf.flag & GP_FRAME_SELECT)) {
195 const float framenum = float(gpf.framenum);
196 *min = min_ff(*min, framenum);
197 *max = max_ff(*max, framenum);
198 found = true;
199 }
200 }
201 }
202 else if (ale.datatype == ALE_MASKLAY) {
203 MaskLayer *masklay = static_cast<MaskLayer *>(ale.data);
204 /* Find mask layer which is less than or equal to current-frame. */
205 for (MaskLayerShape &masklay_shape : masklay->splines_shapes) {
206 const float framenum = float(masklay_shape.frame);
207 *min = min_ff(*min, framenum);
208 *max = max_ff(*max, framenum);
209 found = true;
210 }
211 }
212 else if (ale.datatype == ALE_GREASE_PENCIL_CEL) {
213 const bke::greasepencil::Layer &layer = static_cast<GreasePencilLayer *>(ale.data)->wrap();
214
215 for (const auto [key, frame] : layer.frames().items()) {
216 if (onlySel && !frame.is_selected()) {
217 continue;
218 }
219 *min = min_ff(*min, float(key));
220 *max = max_ff(*max, float(key));
221 found = true;
222 }
223 }
224 else {
225 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
226 float tmin, tmax;
227
228 /* get range and apply necessary scaling before processing */
229 if (BKE_fcurve_calc_range(fcu, &tmin, &tmax, onlySel)) {
232
233 /* Try to set cur using these values,
234 * if they're more extreme than previously set values. */
235 *min = min_ff(*min, tmin);
236 *max = max_ff(*max, tmax);
237 found = true;
238 }
239 }
240 }
241
242 if (fabsf(*max - *min) < 0.001f) {
243 *min -= 0.0005f;
244 *max += 0.0005f;
245 }
246
247 /* free memory */
248 ANIM_animdata_freelist(&anim_data);
249 }
250 else {
251 /* set default range */
252 if (ac->scene) {
253 *min = float(ac->scene->r.sfra);
254 *max = float(ac->scene->r.efra);
255 }
256 else {
257 *min = -5;
258 *max = 100;
259 }
260 }
261
262 return found;
263}
264
266
267/* -------------------------------------------------------------------- */
270
272{
273 bAnimContext ac;
274 Scene *scene;
275 float min, max;
276
277 /* get editor data */
278 if (ANIM_animdata_get_context(C, &ac) == 0) {
279 return OPERATOR_CANCELLED;
280 }
281 if (ac.scene == nullptr) {
282 return OPERATOR_CANCELLED;
283 }
284
285 /* set the range directly */
286 if (!get_keyframe_extents(&ac, &min, &max, true)) {
287 return OPERATOR_CANCELLED;
288 }
289 scene = ac.scene;
290 scene->r.flag |= SCER_PRV_RANGE;
291 scene->r.psfra = floorf(min);
292 scene->r.pefra = ceilf(max);
293
294 if (scene->r.psfra == scene->r.pefra) {
295 scene->r.pefra = scene->r.psfra + 1;
296 }
297
298 /* set notifier that things have changed */
299 /* XXX err... there's nothing for frame ranges yet, but this should do fine too */
301
302 return OPERATOR_FINISHED;
303}
304
306{
307 /* identifiers */
308 ot->name = "Set Preview Range to Selected";
309 ot->idname = "ACTION_OT_previewrange_set";
310 ot->description = "Set Preview Range based on extents of selected Keyframes";
311
312 /* API callbacks. */
315
316 /* flags */
318}
319
321
322/* -------------------------------------------------------------------- */
325
333static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *r_min, float *r_max)
334{
335 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
336 bAnimListElem *ale;
338
339 /* NOTE: not bool, since we want prioritize individual channels over expanders. */
340 short found = 0;
341
342 /* get all items - we need to do it this way */
344 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
345
346 /* loop through all channels, finding the first one that's selected */
347 float ymax = ANIM_UI_get_first_channel_top(&ac->region->v2d);
348 const float channel_step = ANIM_UI_get_channel_step();
349 for (ale = anim_data.first(); ale; ale = ale->next, ymax -= channel_step) {
351
352 /* must be selected... */
353 if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
355 {
356 /* update best estimate */
357 *r_min = ymax - ANIM_UI_get_channel_height();
358 *r_max = ymax;
359
360 /* is this high enough priority yet? */
361 found = acf->channel_role;
362
363 /* only stop our search when we've found an actual channel
364 * - data-block expanders get less priority so that we don't abort prematurely
365 */
366 if (found == ACHANNEL_ROLE_CHANNEL) {
367 break;
368 }
369 }
370 }
371
372 /* free all temp data */
373 ANIM_animdata_freelist(&anim_data);
374
375 return (found != 0);
376}
377
378static wmOperatorStatus actkeys_viewall(bContext *C, const bool only_sel)
379{
380 bAnimContext ac;
381 View2D *v2d;
382 float min, max;
383 bool found;
384
385 /* get editor data */
386 if (ANIM_animdata_get_context(C, &ac) == 0) {
387 return OPERATOR_CANCELLED;
388 }
389 v2d = &ac.region->v2d;
390
391 /* set the horizontal range, with an extra offset so that the extreme keys will be in view */
392 found = get_keyframe_extents(&ac, &min, &max, only_sel);
393
394 if (only_sel && (found == false)) {
395 return OPERATOR_CANCELLED;
396 }
397
398 if (fabsf(max - min) < 1.0f) {
399 /* Exception - center the single keyframe. */
400 float xwidth = BLI_rctf_size_x(&v2d->cur);
401
402 v2d->cur.xmin = min - xwidth / 2.0f;
403 v2d->cur.xmax = max + xwidth / 2.0f;
404 }
405 else {
406 /* Normal case - stretch the two keyframes out to fill the space, with extra spacing */
407 v2d->cur.xmin = min;
408 v2d->cur.xmax = max;
409
411 }
412
413 /* set vertical range */
414 if (only_sel == false) {
415 /* view all -> the summary channel is usually the shows everything,
416 * and resides right at the top... */
417 v2d->cur.ymax = 0.0f;
418 v2d->cur.ymin = float(-BLI_rcti_size_y(&v2d->mask));
419 }
420 else {
421 /* locate first selected channel (or the active one), and frame those */
422 float ymin = v2d->cur.ymin;
423 float ymax = v2d->cur.ymax;
424
425 if (actkeys_channels_get_selected_extents(&ac, &ymin, &ymax)) {
426 /* recenter the view so that this range is in the middle */
427 float ymid = (ymax - ymin) / 2.0f + ymin;
428 float x_center;
429
430 ui::view2d_center_get(v2d, &x_center, nullptr);
431 ui::view2d_center_set(v2d, x_center, ymid);
432 }
433 }
434
435 /* do View2D syncing */
437
438 /* just redraw this view */
440
441 return OPERATOR_FINISHED;
442}
443
444/* ......... */
445
447{
448 /* whole range */
449 return actkeys_viewall(C, false);
450}
451
453{
454 /* only selected */
455 return actkeys_viewall(C, true);
456}
457
458/* ......... */
459
461{
462 /* identifiers */
463 ot->name = "Frame All";
464 ot->idname = "ACTION_OT_view_all";
465 ot->description = "Reset viewable area to show full keyframe range";
466
467 /* API callbacks. */
470
471 /* flags */
472 ot->flag = 0;
473}
474
476{
477 /* identifiers */
478 ot->name = "Frame Selected";
479 ot->idname = "ACTION_OT_view_selected";
480 ot->description = "Reset viewable area to show selected keyframes range";
481
482 /* API callbacks. */
485
486 /* flags */
487 ot->flag = 0;
488}
489
491
492/* -------------------------------------------------------------------- */
495
497{
498 const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
499 ANIM_center_frame(C, smooth_viewtx);
500
501 return OPERATOR_FINISHED;
502}
503
505{
506 /* identifiers */
507 ot->name = "Go to Current Frame";
508 ot->idname = "ACTION_OT_view_frame";
509 ot->description = "Move the view to the current frame";
510
511 /* API callbacks. */
514
515 /* flags */
516 ot->flag = 0;
517}
518
520
521/* -------------------------------------------------------------------- */
524
525/* NOTE: the backend code for this is shared with the graph editor */
526
528{
529 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
531
532 /* filter data */
535 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
536
537 /* copy keyframes */
538 const bool ok = copy_animedit_keys(ac, &anim_data);
539
540 /* clean up */
541 ANIM_animdata_freelist(&anim_data);
542
543 return ok;
544}
545
547 const eKeyPasteOffset offset_mode,
548 const eKeyMergeMode merge_mode,
549 bool flip)
550{
551 /* TODO: deduplicate this function and `paste_graph_keys()` in `graph_edit.cc`, */
552
553 /* Determine paste context. */
554 KeyframePasteContext paste_context{};
555 paste_context.offset_mode = offset_mode;
556 /* Value offset is always None because the user cannot see the effect of it. */
558 paste_context.merge_mode = merge_mode;
559 paste_context.flip = flip;
560
561 /* See how many slots are selected to paste into. This determines how slot matching is done:
562 * - Copied from one slot, paste into multiple: duplicate into each slot.
563 * - Otherwise: match slots by name. */
564 {
565 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
569 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
570 for (const bAnimListElem &ale : anim_data) {
571 if (ale.datatype == ALE_ACTION_SLOT) {
572 paste_context.num_slots_selected++;
573 }
574 }
575 ANIM_animdata_freelist(&anim_data);
576 }
577
578 /* Find F-Curves to paste into, in two stages.
579 * - First time we try to filter more strictly, allowing only selected channels
580 * to allow copying animation between channels
581 * - Second time, we loosen things up if nothing was found the first time, allowing
582 * users to just paste keyframes back into the original curve again #31670.
583 */
584 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
585 {
590 ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype);
591 if (paste_context.num_fcurves_selected == 0) {
592 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
593 }
594 }
595
596 const eKeyPasteError ok = paste_animedit_keys(ac, &anim_data, paste_context);
597
598 /* clean up */
599 ANIM_animdata_freelist(&anim_data);
600
601 return ok;
602}
603
604/* ------------------- */
605
611
613{
614 bAnimContext ac;
615
616 /* get editor data */
617 if (ANIM_animdata_get_context(C, &ac) == 0) {
618 return OPERATOR_CANCELLED;
619 }
620
621 /* copy keyframes */
622 if (ac.datatype == ANIMCONT_GPENCIL) {
623 if (ED_gpencil_anim_copybuf_copy(&ac) == false &&
626 {
627 /* check if anything ended up in the buffer */
628 BKE_report(op->reports, RPT_ERROR, "No keyframes copied to the internal clipboard");
629 return OPERATOR_CANCELLED;
630 }
631 }
632 else if (ac.datatype == ANIMCONT_MASK) {
633 /* FIXME: support this case. */
634 BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for mask mode");
635 return OPERATOR_CANCELLED;
636 }
637 else {
638 /* Both copy function needs to be evaluated to account for mixed selection */
639 const bool kf_ok = copy_action_keys(&ac);
640 const bool gpf_ok = ED_gpencil_anim_copybuf_copy(&ac) ||
643
644 if (!kf_ok && !gpf_ok) {
645 BKE_report(op->reports, RPT_ERROR, "No keyframes copied to the internal clipboard");
646 return OPERATOR_CANCELLED;
647 }
648 }
649
650 return OPERATOR_FINISHED;
651}
652
654{
655 /* identifiers */
656 ot->name = "Copy Keyframes";
657 ot->idname = "ACTION_OT_copy";
658 ot->description = "Copy selected keyframes to the internal clipboard";
659
660 /* API callbacks. */
663
664 /* flags */
666}
667
669{
670 bAnimContext ac;
671
672 const eKeyPasteOffset offset_mode = eKeyPasteOffset(RNA_enum_get(op->ptr, "offset"));
673 const eKeyMergeMode merge_mode = eKeyMergeMode(RNA_enum_get(op->ptr, "merge"));
674 const bool flipped = RNA_boolean_get(op->ptr, "flipped");
675
676 bool gpframes_inbuf = false;
677
678 /* get editor data */
679 if (ANIM_animdata_get_context(C, &ac) == 0) {
680 return OPERATOR_CANCELLED;
681 }
682
683 /* ac.reports by default will be the global reports list, which won't show warnings */
684 ac.reports = op->reports;
685
686 /* paste keyframes */
687 if (ac.datatype == ANIMCONT_GPENCIL) {
688 if (ED_gpencil_anim_copybuf_paste(&ac, offset_mode) == false &&
690 &ac, offset_mode, merge_mode, get_grease_pencil_keyframe_clipboard()) == false)
691 {
692 BKE_report(op->reports, RPT_ERROR, "No data in the internal clipboard to paste");
693 return OPERATOR_CANCELLED;
694 }
695 }
696 else if (ac.datatype == ANIMCONT_MASK) {
697 /* FIXME: support this case. */
699 RPT_ERROR,
700 "Keyframe pasting is not available for Grease Pencil or mask mode");
701 return OPERATOR_CANCELLED;
702 }
703 else {
704 /* Both paste function needs to be evaluated to account for mixed selection */
705 const eKeyPasteError kf_empty = paste_action_keys(&ac, offset_mode, merge_mode, flipped);
706 /* non-zero return means an error occurred while trying to paste */
707 gpframes_inbuf = ED_gpencil_anim_copybuf_paste(&ac, offset_mode) ||
709 &ac, offset_mode, merge_mode, get_grease_pencil_keyframe_clipboard());
710
711 /* Only report an error if nothing was pasted, i.e. when both FCurve and GPencil failed. */
712 if (!gpframes_inbuf) {
713 switch (kf_empty) {
715 /* FCurve paste was ok, so it's all good. */
716 break;
717
719 BKE_report(op->reports, RPT_ERROR, "No selected F-Curves to paste into");
720 return OPERATOR_CANCELLED;
721
723 BKE_report(op->reports, RPT_ERROR, "No data in the internal clipboard to paste");
724 return OPERATOR_CANCELLED;
725 }
726 }
727 }
728
729 /* Grease Pencil needs extra update to refresh the added keyframes. */
730 if (ac.datatype == ANIMCONT_GPENCIL || gpframes_inbuf) {
732 }
733 /* set notifier that keyframes have changed */
735
736 return OPERATOR_FINISHED;
737}
738
739static std::string actkeys_paste_get_description(bContext * /*C*/,
740 wmOperatorType * /*ot*/,
741 PointerRNA *ptr)
742{
743 /* Custom description if the 'flipped' option is used. */
744 if (RNA_boolean_get(ptr, "flipped")) {
745 return BLI_strdup(TIP_("Paste keyframes from mirrored bones if they exist"));
746 }
747
748 /* Use the default description in the other cases. */
749 return "";
750}
751
753{
754 PropertyRNA *prop;
755 /* identifiers */
756 ot->name = "Paste Keyframes";
757 ot->idname = "ACTION_OT_paste";
758 ot->description =
759 "Paste keyframes from the internal clipboard for the selected channels, starting on the "
760 "current "
761 "frame";
762
763 /* API callbacks. */
764 // ot->invoke = WM_operator_props_popup; /* Better wait for action redo panel. */
768
769 /* flags */
771
772 /* props */
773 RNA_def_enum(ot->srna,
774 "offset",
777 "Offset",
778 "Paste time offset of keys");
779 RNA_def_enum(ot->srna,
780 "merge",
783 "Type",
784 "Method of merging pasted keys and existing");
785 prop = RNA_def_boolean(
786 ot->srna, "flipped", false, "Flipped", "Paste keyframes from mirrored bones if they exist");
788}
789
791
792/* -------------------------------------------------------------------- */
795
796/* defines for insert keyframes tool */
798 {1, "ALL", 0, "All Channels", ""},
799 {2, "SEL", 0, "Only Selected Channels", ""},
800 /* XXX not in all cases. */
801 {3, "GROUP", 0, "In Active Group", ""},
802 {0, nullptr, 0, nullptr, nullptr},
803};
804
806 bAnimListElem *ale,
807 const eGP_GetFrame_Mode add_frame_mode,
808 bGPdata **gpd_old)
809{
810 Scene *scene = ac->scene;
811 bGPdata *gpd = id_cast<bGPdata *>(ale->id);
812 bGPDlayer *gpl = static_cast<bGPDlayer *>(ale->data);
813 BKE_annotations_layer_frame_get(gpl, scene->r.cfra, add_frame_mode);
814 /* Check if the gpd changes to tag only once. */
815 if (gpd != *gpd_old) {
817 *gpd_old = gpd;
818 }
819}
820
822 bAnimListElem *ale,
823 const bool hold_previous)
824{
825 using namespace blender::bke::greasepencil;
826 Layer *layer = static_cast<Layer *>(ale->data);
827 GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(ale->id);
828 const int current_frame_number = ac->scene->r.cfra;
829
830 if (layer->frames().contains(current_frame_number)) {
831 return;
832 }
833
834 bool changed = false;
835 if (hold_previous) {
836 const std::optional<int> active_frame_number = layer->start_frame_at(current_frame_number);
837 if (!active_frame_number) {
838 /* There is no active frame to hold to, or it's an end frame. Therefore just insert a blank
839 * frame. */
840 changed |= grease_pencil->insert_frame(*layer, current_frame_number) != nullptr;
841 }
842 else {
843 /* Duplicate the active frame. */
844 changed = grease_pencil->insert_duplicate_frame(
845 *layer, *active_frame_number, current_frame_number, false);
846 }
847 }
848 else {
849 /* Insert a blank frame. */
850 changed |= grease_pencil->insert_frame(*layer, current_frame_number) != nullptr;
851 }
852
853 if (changed) {
855 }
856}
857
859 bAnimListElem *ale,
860 const AnimationEvalContext anim_eval_context,
861 eInsertKeyFlags flag)
862{
863 using namespace blender::animrig;
864 FCurve *fcu = static_cast<FCurve *>(ale->key_data);
865
866 ReportList *reports = ac->reports;
867 Scene *scene = ac->scene;
868 ToolSettings *ts = scene->toolsettings;
869
870 /* These asserts are ensuring that the fcurve we're keying lives on an Action,
871 * rather than being e.g. an fcurve a driver or NLA Strip. This should
872 * always hold true for this function, since all the other cases take
873 * different code paths before getting here. */
874 BLI_assert(ale->owner == nullptr);
875 BLI_assert(ale->fcurve_owner_id != nullptr);
877
878 bAction *action = reinterpret_cast<bAction *>(ale->fcurve_owner_id);
879 ID *id = action_slot_get_id_for_keying(*ale->bmain, action->wrap(), ale->slot_handle, ale->id);
880
881 /* If we found an unambiguous ID to use for keying the channel, go through the
882 * normal keyframing code path. Otherwise, just directly key the fcurve
883 * itself. */
884 if (id) {
885 const std::optional<StringRefNull> channel_group = fcu->grp ? std::optional(fcu->grp->name) :
886 std::nullopt;
887 PointerRNA id_rna_pointer = RNA_id_pointer_create(id);
889 &id_rna_pointer,
890 channel_group,
891 {{fcu->rna_path(), {}, fcu->array_index}},
892 std::nullopt,
893 anim_eval_context,
895 flag);
896 if (result.get_count(SingleKeyingResult::SUCCESS) == 0) {
897 result.generate_reports(reports);
898 }
899 }
900 else {
901 /* TODO: when layered action strips are allowed to have time offsets, that
902 * mapping will need to be handled here. */
903 assert_baklava_phase_1_invariants(action->wrap());
904
905 /* Adjust current frame for NLA-scaling. */
906 const float cfra = ANIM_nla_tweakedit_remap(
907 ale, anim_eval_context.eval_time, NLATIME_CONVERT_UNMAP);
908
909 const float curval = evaluate_fcurve(fcu, cfra);
911 settings.keyframe_type = eBezTriple_KeyframeType(ts->keyframe_type);
912 insert_vert_fcurve(fcu, {cfra, curval}, settings, eInsertKeyFlags{});
913 }
914
915 ale->update |= ANIM_UPDATE_DEFAULT;
916}
917
919 const AnimationEvalContext &anim_eval_context,
920 const eInsertKeyFlags flag)
921{
922 using namespace blender::animrig;
923 NlaStrip *strip = static_cast<NlaStrip *>(ale.owner);
924 FCurve *fcu = static_cast<FCurve *>(ale.data);
925 PointerRNA ptr = RNA_pointer_create_discrete(ale.id, RNA_NlaStrip, strip);
926 PropertyRNA *prop = RNA_struct_find_property(&ptr, fcu->rna_path().c_str());
927 if (!prop) {
928 return;
929 }
930
931 const KeyframeSettings key_settings = get_keyframe_settings((flag & INSERTKEY_NO_USERPREF) == 0);
932 const Vector<float> rna_values = get_property_values(&ptr, prop, /* visual_keyframing= */ false);
933 if (fcu->array_index >= rna_values.size()) {
934 return;
935 }
936
938 fcu, {anim_eval_context.eval_time, rna_values[fcu->array_index]}, key_settings, flag);
939
942 }
943}
944
945/* this function is responsible for inserting new keyframes */
946static void insert_action_keys(bAnimContext *ac, short mode)
947{
948 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
950
951 Scene *scene = ac->scene;
952 ToolSettings *ts = scene->toolsettings;
953 eInsertKeyFlags flag;
954
955 eGP_GetFrame_Mode add_frame_mode;
956 bGPdata *gpd_old = nullptr;
957
958 /* filter data */
961 if (mode == 2) {
963 }
964 else if (mode == 3) {
966 }
967
968 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
969
970 /* Init keyframing flag. */
971 flag = animrig::get_keyframing_flags(scene);
972
973 /* GPLayers specific flags */
975 add_frame_mode = GP_GETFRAME_ADD_COPY;
976 }
977 else {
978 add_frame_mode = GP_GETFRAME_ADD_NEW;
979 }
980 const bool grease_pencil_hold_previous = ((ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) != 0);
981
982 /* insert keyframes */
984 ac->depsgraph, float(scene->r.cfra));
985 for (bAnimListElem &ale : anim_data) {
986 switch (ale.type) {
987 case ANIMTYPE_GPLAYER:
988 insert_gpencil_key(ac, &ale, add_frame_mode, &gpd_old);
989 break;
990
992 insert_grease_pencil_key(ac, &ale, grease_pencil_hold_previous);
993 break;
994
995 case ANIMTYPE_FCURVE:
996 insert_fcurve_key(ac, &ale, anim_eval_context, flag);
997 break;
998
1000 insert_nla_curve_key(ale, anim_eval_context, flag);
1001 break;
1002
1003 default:
1004 BLI_assert_msg(false, "Keys cannot be inserted into this animation type.");
1005 }
1006 }
1007
1008 ANIM_animdata_update(ac, &anim_data);
1009 ANIM_animdata_freelist(&anim_data);
1010}
1011
1012/* ------------------- */
1013
1015{
1016 bAnimContext ac;
1017 short mode;
1018
1019 /* get editor data */
1020 if (ANIM_animdata_get_context(C, &ac) == 0) {
1021 return OPERATOR_CANCELLED;
1022 }
1023
1024 if (ac.datatype == ANIMCONT_MASK) {
1025 BKE_report(op->reports, RPT_ERROR, "Insert Keyframes is not yet implemented for this mode");
1026 return OPERATOR_CANCELLED;
1027 }
1028
1029 /* what channels to affect? */
1030 mode = RNA_enum_get(op->ptr, "type");
1031
1033
1034 /* insert keyframes */
1035 insert_action_keys(&ac, mode);
1036
1037 /* set notifier that keyframes have changed */
1038 if (ac.datatype == ANIMCONT_GPENCIL) {
1040 }
1042
1043 return OPERATOR_FINISHED;
1044}
1045
1047{
1048 /* identifiers */
1049 ot->name = "Insert Keyframes";
1050 ot->idname = "ACTION_OT_keyframe_insert";
1051 ot->description = "Insert keyframes for the specified channels";
1052
1053 /* API callbacks. */
1054 ot->invoke = WM_menu_invoke;
1057
1058 /* flags */
1060
1061 /* id-props */
1062 ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_insertkey_types, 0, "Type", "");
1063}
1064
1066
1067/* -------------------------------------------------------------------- */
1070
1072{
1073 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1075 bool changed = false;
1076
1077 /* filter data */
1080 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1081
1082 /* loop through filtered data and delete selected keys */
1083 for (bAnimListElem &ale : anim_data) {
1084 if (ELEM(ale.type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
1085 changed |= duplicate_fcurve_keys(static_cast<FCurve *>(ale.key_data));
1086 }
1087 else if (ale.type == ANIMTYPE_GPLAYER) {
1088 ED_gpencil_layer_frames_duplicate(static_cast<bGPDlayer *>(ale.data));
1089 changed |= ED_gpencil_layer_frame_select_check(static_cast<bGPDlayer *>(ale.data));
1090 }
1091 else if (ale.type == ANIMTYPE_GREASE_PENCIL_LAYER) {
1093 *reinterpret_cast<GreasePencil *>(ale.id),
1094 static_cast<GreasePencilLayer *>(ale.data)->wrap());
1095 }
1096 else if (ale.type == ANIMTYPE_MASKLAYER) {
1097 changed |= ED_masklayer_frames_duplicate(ac->bmain, static_cast<MaskLayer *>(ale.data));
1098 }
1099 else {
1100 BLI_assert(0);
1101 }
1102
1103 ale.update |= ANIM_UPDATE_DEFAULT;
1104 }
1105
1106 ANIM_animdata_update(ac, &anim_data);
1107 ANIM_animdata_freelist(&anim_data);
1108
1109 return changed;
1110}
1111
1112/* ------------------- */
1113
1115{
1116 bAnimContext ac;
1117
1118 /* get editor data */
1119 if (ANIM_animdata_get_context(C, &ac) == 0) {
1120 return OPERATOR_CANCELLED;
1121 }
1122
1123 /* duplicate keyframes */
1124 if (!duplicate_action_keys(&ac)) {
1125 return OPERATOR_CANCELLED;
1126 }
1127
1128 /* set notifier that keyframes have changed */
1130
1131 return OPERATOR_FINISHED;
1132}
1133
1135{
1136 /* identifiers */
1137 ot->name = "Duplicate Keyframes";
1138 ot->idname = "ACTION_OT_duplicate";
1139 ot->description = "Make a copy of all selected keyframes";
1140
1141 /* API callbacks. */
1144
1145 /* flags */
1147}
1148
1150
1151/* -------------------------------------------------------------------- */
1154
1156{
1157 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1159 bool changed_final = false;
1160
1161 /* filter data */
1164 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1165
1166 /* loop through filtered data and delete selected keys */
1167 for (bAnimListElem &ale : anim_data) {
1168 bool changed = false;
1169
1170 if (ale.type == ANIMTYPE_GPLAYER) {
1171 changed = ED_gpencil_layer_frames_delete(static_cast<bGPDlayer *>(ale.data));
1172 }
1173 else if (ale.type == ANIMTYPE_GREASE_PENCIL_LAYER) {
1174 GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(ale.id);
1176 *grease_pencil, static_cast<GreasePencilLayer *>(ale.data)->wrap());
1177
1178 if (changed) {
1180 }
1181 }
1182 else if (ale.type == ANIMTYPE_MASKLAYER) {
1183 changed = ED_masklayer_frames_delete(ac->bmain, static_cast<MaskLayer *>(ale.data));
1184 }
1185 else {
1186 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
1187 if (fcu) {
1188 changed = BKE_fcurve_delete_keys_selected(*fcu);
1189 }
1190
1191 if (changed && BKE_fcurve_is_empty(fcu)) {
1192 ED_anim_ale_fcurve_delete(*ac, ale);
1193 ale.key_data = nullptr;
1194 }
1195 }
1196
1197 if (changed) {
1198 ale.update |= ANIM_UPDATE_DEFAULT;
1199 changed_final = true;
1200 }
1201 }
1202
1203 ANIM_animdata_update(ac, &anim_data);
1204 ANIM_animdata_freelist(&anim_data);
1205
1206 return changed_final;
1207}
1208
1209/* ------------------- */
1210
1212{
1213 bAnimContext ac;
1214
1215 /* get editor data */
1216 if (ANIM_animdata_get_context(C, &ac) == 0) {
1217 return OPERATOR_CANCELLED;
1218 }
1219
1220 /* delete keyframes */
1221 if (!delete_action_keys(&ac)) {
1222 return OPERATOR_CANCELLED;
1223 }
1224
1225 /* set notifier that keyframes have changed */
1227
1228 return OPERATOR_FINISHED;
1229}
1230
1232 wmOperator *op,
1233 const wmEvent * /*event*/)
1234{
1235 if (RNA_boolean_get(op->ptr, "confirm")) {
1237 op,
1238 IFACE_("Delete selected keyframes?"),
1239 nullptr,
1240 IFACE_("Delete"),
1242 false);
1243 }
1244 return actkeys_delete_exec(C, op);
1245}
1246
1248{
1249 /* identifiers */
1250 ot->name = "Delete Keyframes";
1251 ot->idname = "ACTION_OT_delete";
1252 ot->description = "Remove all selected keyframes";
1253
1254 /* API callbacks. */
1258
1259 /* flags */
1262}
1263
1265
1266/* -------------------------------------------------------------------- */
1269
1270static void clean_action_keys(bAnimContext *ac, float thresh, bool clean_chan)
1271{
1272 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1274
1275 /* filter data */
1278
1279 if (clean_chan) {
1281 }
1282
1283 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1284
1285 const bool only_selected_keys = !clean_chan;
1286 /* loop through filtered data and clean curves */
1287 for (bAnimListElem &ale : anim_data) {
1288 clean_fcurve(&ale, thresh, clean_chan, only_selected_keys);
1289
1290 ale.update |= ANIM_UPDATE_DEFAULT;
1291 }
1292
1293 ANIM_animdata_update(ac, &anim_data);
1294 ANIM_animdata_freelist(&anim_data);
1295}
1296
1297/* ------------------- */
1298
1300{
1301 bAnimContext ac;
1302 float thresh;
1303 bool clean_chan;
1304
1305 /* get editor data */
1306 if (ANIM_animdata_get_context(C, &ac) == 0) {
1307 return OPERATOR_CANCELLED;
1308 }
1309
1311 BKE_report(op->reports, RPT_ERROR, "Not implemented");
1312 return OPERATOR_PASS_THROUGH;
1313 }
1314
1315 /* get cleaning threshold */
1316 thresh = RNA_float_get(op->ptr, "threshold");
1317 clean_chan = RNA_boolean_get(op->ptr, "channels");
1318
1319 /* clean keyframes */
1320 clean_action_keys(&ac, thresh, clean_chan);
1321
1322 /* set notifier that keyframes have changed */
1324
1325 return OPERATOR_FINISHED;
1326}
1327
1328static std::string actkeys_clean_get_description(bContext * /*C*/,
1329 wmOperatorType * /*ot*/,
1330 PointerRNA *ptr)
1331{
1332 /* Custom description based on the 'channels' property */
1333 if (RNA_boolean_get(ptr, "channels")) {
1334 return TIP_("Simplify F-Curves and remove empty or redundant channels.");
1335 }
1336
1337 /* Use the default description in the other case. */
1338 return "";
1339}
1340
1342{
1343 /* identifiers */
1344 ot->name = "Clean Keyframes";
1345 ot->idname = "ACTION_OT_clean";
1346 ot->description = "Simplify F-Curves by removing closely spaced keyframes";
1347
1348 /* API callbacks. */
1349 // ot->invoke = /* XXX we need that number popup for this! */
1353
1354 /* flags */
1356
1357 /* properties */
1358 ot->prop = RNA_def_float(
1359 ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f);
1360 RNA_def_boolean(ot->srna, "channels", false, "Channels", "");
1361}
1362
1364
1365/* -------------------------------------------------------------------- */
1368
1369/* Evaluates the curves between each selected keyframe on each frame, and keys the value. */
1371{
1372 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1374
1375 /* filter data */
1378 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1379
1380 /* Loop through filtered data and add keys between selected keyframes on every frame. */
1381 for (bAnimListElem &ale : anim_data) {
1382 animrig::bake_fcurve_segments(static_cast<FCurve *>(ale.key_data));
1383
1384 ale.update |= ANIM_UPDATE_DEPS;
1385 }
1386
1387 ANIM_animdata_update(ac, &anim_data);
1388 ANIM_animdata_freelist(&anim_data);
1389}
1390
1391/* ------------------- */
1392
1394{
1395 bAnimContext ac;
1396
1397 /* get editor data */
1398 if (ANIM_animdata_get_context(C, &ac) == 0) {
1399 return OPERATOR_CANCELLED;
1400 }
1401
1403 BKE_report(op->reports, RPT_ERROR, "Not implemented");
1404 return OPERATOR_PASS_THROUGH;
1405 }
1406
1407 /* sample keyframes */
1408 bake_action_keys(&ac);
1409
1410 /* set notifier that keyframes have changed */
1412
1413 return OPERATOR_FINISHED;
1414}
1415
1417{
1418 /* identifiers */
1419 ot->name = "Bake Keyframes";
1420 ot->idname = "ACTION_OT_bake_keys";
1421 ot->description = "Add keyframes on every frame between the selected keyframes";
1422
1423 /* API callbacks. */
1424 ot->exec = actkeys_bake_exec;
1426
1427 /* flags */
1429}
1430
1432
1433/* -------------------------------------------------------------------- */
1436
1437/* defines for make/clear cyclic extrapolation tools */
1438#define MAKE_CYCLIC_EXPO -1
1439#define CLEAR_CYCLIC_EXPO -2
1440
1441/* defines for set extrapolation-type for selected keyframes tool */
1444 "CONSTANT",
1445 0,
1446 "Constant Extrapolation",
1447 "Values on endpoint keyframes are held"},
1449 "LINEAR",
1450 0,
1451 "Linear Extrapolation",
1452 "Straight-line slope of end segments are extended past the endpoint keyframes"},
1453
1455 "MAKE_CYCLIC",
1456 0,
1457 "Make Cyclic (F-Modifier)",
1458 "Add Cycles F-Modifier if one does not exist already"},
1460 "CLEAR_CYCLIC",
1461 0,
1462 "Clear Cyclic (F-Modifier)",
1463 "Remove Cycles F-Modifier if not needed anymore"},
1464 {0, nullptr, 0, nullptr, nullptr},
1465};
1466
1467/* this function is responsible for setting extrapolation mode for keyframes */
1468static void setexpo_action_keys(bAnimContext *ac, short mode)
1469{
1470 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1472
1473 /* filter data */
1476 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1477
1478 /* loop through setting mode per F-Curve */
1479 for (bAnimListElem &ale : anim_data) {
1480 FCurve *fcu = static_cast<FCurve *>(ale.data);
1481
1482 if (mode >= 0) {
1483 /* just set mode setting */
1484 fcu->extend = eFCurve_Extend(mode);
1485 }
1486 else {
1487 /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation
1488 * without having to go through FModifier UI in Graph Editor to do so
1489 */
1490 if (mode == MAKE_CYCLIC_EXPO) {
1491 /* only add if one doesn't exist */
1493 /* TODO: add some more preset versions which set different extrapolation options? */
1495 }
1496 }
1497 else if (mode == CLEAR_CYCLIC_EXPO) {
1498 /* remove all the modifiers fitting this description */
1499 FModifier *fcm, *fcn = nullptr;
1500
1501 for (fcm = fcu->modifiers.first(); fcm; fcm = fcn) {
1502 fcn = fcm->next;
1503
1504 if (fcm->type == FMODIFIER_TYPE_CYCLES) {
1505 remove_fmodifier(&fcu->modifiers, fcm);
1506 }
1507 }
1508 }
1509 }
1510
1511 ale.update |= ANIM_UPDATE_DEFAULT;
1512 }
1513
1514 ANIM_animdata_update(ac, &anim_data);
1515 ANIM_animdata_freelist(&anim_data);
1516}
1517
1518/* ------------------- */
1519
1521{
1522 bAnimContext ac;
1523 short mode;
1524
1525 /* get editor data */
1526 if (ANIM_animdata_get_context(C, &ac) == 0) {
1527 return OPERATOR_CANCELLED;
1528 }
1529
1531 BKE_report(op->reports, RPT_ERROR, "Not implemented");
1532 return OPERATOR_PASS_THROUGH;
1533 }
1534
1535 /* get handle setting mode */
1536 mode = RNA_enum_get(op->ptr, "type");
1537
1538 /* set handle type */
1539 setexpo_action_keys(&ac, mode);
1540
1541 /* set notifier that keyframe properties have changed */
1543
1544 return OPERATOR_FINISHED;
1545}
1546
1548{
1549 /* identifiers */
1550 ot->name = "Set F-Curve Extrapolation";
1551 ot->idname = "ACTION_OT_extrapolation_type";
1552 ot->description = "Set extrapolation mode for selected F-Curves";
1553
1554 /* API callbacks. */
1555 ot->invoke = WM_menu_invoke;
1556 ot->exec = actkeys_expo_exec;
1558
1559 /* flags */
1561
1562 /* id-props */
1563 ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_expo_types, 0, "Type", "");
1564}
1565
1567
1568/* -------------------------------------------------------------------- */
1571
1573{
1574 bAnimContext ac;
1575 short mode;
1576
1577 /* get editor data */
1578 if (ANIM_animdata_get_context(C, &ac) == 0) {
1579 return OPERATOR_CANCELLED;
1580 }
1581
1583 BKE_report(op->reports, RPT_ERROR, "Not implemented");
1584 return OPERATOR_PASS_THROUGH;
1585 }
1586
1587 /* get handle setting mode */
1588 mode = RNA_enum_get(op->ptr, "type");
1589
1590 /* set handle type */
1596
1597 /* set notifier that keyframe properties have changed */
1599
1600 return OPERATOR_FINISHED;
1601}
1602
1604{
1605 /* identifiers */
1606 ot->name = "Set Keyframe Interpolation";
1607 ot->idname = "ACTION_OT_interpolation_type";
1608 ot->description =
1609 "Set interpolation mode for the F-Curve segments starting from the selected keyframes";
1610
1611 /* API callbacks. */
1612 ot->invoke = WM_menu_invoke;
1613 ot->exec = actkeys_ipo_exec;
1615
1616 /* flags */
1618
1619 /* id-props */
1620 ot->prop = RNA_def_enum(
1621 ot->srna, "type", rna_enum_beztriple_interpolation_mode_items, 0, "Type", "");
1623}
1624
1626
1627/* -------------------------------------------------------------------- */
1630
1632{
1633 bAnimContext ac;
1634 short mode;
1635
1636 /* get editor data */
1637 if (ANIM_animdata_get_context(C, &ac) == 0) {
1638 return OPERATOR_CANCELLED;
1639 }
1640
1641 /* get handle setting mode */
1642 mode = RNA_enum_get(op->ptr, "type");
1643
1644 /* set handle type */
1650
1651 /* set notifier that keyframe properties have changed */
1653
1654 return OPERATOR_FINISHED;
1655}
1656
1658{
1659 /* identifiers */
1660 ot->name = "Set Keyframe Easing Type";
1661 ot->idname = "ACTION_OT_easing_type";
1662 ot->description =
1663 "Set easing type for the F-Curve segments starting from the selected keyframes";
1664
1665 /* API callbacks. */
1666 ot->invoke = WM_menu_invoke;
1669
1670 /* flags */
1672
1673 /* id-props */
1674 ot->prop = RNA_def_enum(
1675 ot->srna, "type", rna_enum_beztriple_interpolation_easing_items, 0, "Type", "");
1676}
1677
1679
1680/* -------------------------------------------------------------------- */
1683
1684/* this function is responsible for setting handle-type of selected keyframes */
1685static void sethandles_action_keys(bAnimContext *ac, short mode)
1686{
1687 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1689
1692
1693 /* filter data */
1696 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1697
1698 /* Loop through setting flags for handles
1699 * NOTE: we do not supply KeyframeEditData to the looper yet.
1700 * Currently that's not necessary here.
1701 */
1702 for (bAnimListElem &ale : anim_data) {
1703 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
1704
1705 /* any selected keyframes for editing? */
1706 if (ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, sel_cb, nullptr)) {
1707 /* change type of selected handles */
1708 ANIM_fcurve_keyframes_loop(nullptr, fcu, nullptr, edit_cb, BKE_fcurve_handles_recalc);
1709
1710 ale.update |= ANIM_UPDATE_DEFAULT;
1711 }
1712 }
1713
1714 ANIM_animdata_update(ac, &anim_data);
1715 ANIM_animdata_freelist(&anim_data);
1716}
1717
1718/* ------------------- */
1719
1721{
1722 bAnimContext ac;
1723 short mode;
1724
1725 /* get editor data */
1726 if (ANIM_animdata_get_context(C, &ac) == 0) {
1727 return OPERATOR_CANCELLED;
1728 }
1729
1731 BKE_report(op->reports, RPT_ERROR, "Not implemented");
1732 return OPERATOR_PASS_THROUGH;
1733 }
1734
1735 /* get handle setting mode */
1736 mode = RNA_enum_get(op->ptr, "type");
1737
1738 /* set handle type */
1739 sethandles_action_keys(&ac, mode);
1740
1741 /* set notifier that keyframe properties have changed */
1743
1744 return OPERATOR_FINISHED;
1745}
1746
1748{
1749 /* identifiers */
1750 ot->name = "Set Keyframe Handle Type";
1751 ot->idname = "ACTION_OT_handle_type";
1752 ot->description = "Set type of handle for selected keyframes";
1753
1754 /* API callbacks. */
1755 ot->invoke = WM_menu_invoke;
1758
1759 /* flags */
1761
1762 /* id-props */
1763 ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_keyframe_handle_type_items, 0, "Type", "");
1764}
1765
1767
1768/* -------------------------------------------------------------------- */
1771
1772/* this function is responsible for setting keyframe type for keyframes */
1774{
1775 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1778
1779 /* filter data */
1782 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
1783
1784 /* Loop through setting BezTriple interpolation
1785 * NOTE: we do not supply KeyframeEditData to the looper yet.
1786 * Currently that's not necessary here.
1787 */
1788 for (bAnimListElem &ale : anim_data) {
1789 switch (ale.type) {
1790 case ANIMTYPE_GPLAYER:
1791 ED_gpencil_layer_frames_keytype_set(static_cast<bGPDlayer *>(ale.data), mode);
1792 ale.update |= ANIM_UPDATE_DEPS;
1793 break;
1794
1797 static_cast<GreasePencilLayer *>(ale.data)->wrap(), mode);
1798 ale.update |= ANIM_UPDATE_DEPS;
1799 break;
1800
1801 case ANIMTYPE_FCURVE:
1802 case ANIMTYPE_NLACURVE:
1804 nullptr, static_cast<FCurve *>(ale.key_data), nullptr, set_cb, nullptr);
1805 ale.update |= ANIM_UPDATE_DEPS | ANIM_UPDATE_HANDLES;
1806 break;
1807
1808 default:
1809 BLI_assert_msg(false, "Keytype cannot be set into this animation type.");
1810 }
1811 }
1812
1813 ANIM_animdata_update(ac, &anim_data);
1814 ANIM_animdata_freelist(&anim_data);
1815}
1816
1817/* ------------------- */
1818
1820{
1821 bAnimContext ac;
1822
1823 /* get editor data */
1824 if (ANIM_animdata_get_context(C, &ac) == 0) {
1825 return OPERATOR_CANCELLED;
1826 }
1827
1828 if (ac.datatype == ANIMCONT_MASK) {
1829 BKE_report(op->reports, RPT_ERROR, "Not implemented for Masks");
1830 return OPERATOR_PASS_THROUGH;
1831 }
1832
1833 const int mode = RNA_enum_get(op->ptr, "type");
1835
1836 /* set notifier that keyframe properties have changed */
1838
1839 return OPERATOR_FINISHED;
1840}
1841
1843{
1844 /* identifiers */
1845 ot->name = "Set Keyframe Type";
1846 ot->idname = "ACTION_OT_keyframe_type";
1847 ot->description = "Set type of keyframe for the selected keyframes";
1848
1849 /* API callbacks. */
1850 ot->invoke = WM_menu_invoke;
1853
1854 /* flags */
1856
1857 /* id-props */
1858 ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_keyframe_type_items, 0, "Type", "");
1859}
1860
1862
1863/* -------------------------------------------------------------------- */
1866
1868{
1869 /* prevent changes during render */
1870 if (G.is_rendering) {
1871 return false;
1872 }
1873
1875}
1876
1877/* snap current-frame indicator to 'average time' of selected keyframe */
1879{
1880 bAnimContext ac;
1881 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1883 KeyframeEditData ked = {{nullptr}};
1884
1885 /* get editor data */
1886 if (ANIM_animdata_get_context(C, &ac) == 0) {
1887 return OPERATOR_CANCELLED;
1888 }
1889
1890 /* init edit data */
1891 /* loop over action data, averaging values */
1893 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1894
1895 for (bAnimListElem &ale : anim_data) {
1896 switch (ale.datatype) {
1897 case ALE_GPFRAME: {
1898 bGPDlayer *gpl = static_cast<bGPDlayer *>(ale.data);
1899
1900 for (bGPDframe &gpf : gpl->frames) {
1901 /* only if selected */
1902 if (!(gpf.flag & GP_FRAME_SELECT)) {
1903 continue;
1904 }
1905 /* store average time in float 1 (only do rounding at last step) */
1906 ked.f1 += gpf.framenum;
1907
1908 /* increment number of items */
1909 ked.i1++;
1910 }
1911 break;
1912 }
1913
1914 case ALE_GREASE_PENCIL_CEL: {
1915 using namespace blender::bke::greasepencil;
1916 const Layer &layer = *static_cast<Layer *>(ale.data);
1917 for (auto [frame_number, frame] : layer.frames().items()) {
1918 if (!frame.is_selected()) {
1919 continue;
1920 }
1921 ked.f1 += frame_number;
1922 ked.i1++;
1923 }
1924 break;
1925 }
1926
1927 case ALE_FCURVE: {
1928 FCurve *fcurve = static_cast<FCurve *>(ale.key_data);
1929 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcurve, false, true);
1930 ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, bezt_calc_average, nullptr);
1931 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcurve, true, true);
1932 break;
1933 }
1934
1935 default:
1936 BLI_assert_msg(false, "Cannot jump to keyframe into this animation type.");
1937 }
1938 }
1939
1940 ANIM_animdata_freelist(&anim_data);
1941
1942 /* set the new current frame value, based on the average time */
1943 if (ked.i1) {
1944 Scene *scene = ac.scene;
1945 scene->r.cfra = round_fl_to_int(ked.f1 / ked.i1);
1946 scene->r.subframe = 0.0f;
1947 }
1948
1949 /* set notifier that things have changed */
1951
1952 return OPERATOR_FINISHED;
1953}
1954
1956{
1957 /* identifiers */
1958 ot->name = "Jump to Keyframes";
1959 ot->idname = "ACTION_OT_frame_jump";
1960 ot->description = "Set the current frame to the average frame value of selected keyframes";
1961
1962 /* API callbacks. */
1965
1966 /* flags */
1968}
1969
1971
1972/* -------------------------------------------------------------------- */
1975
1976/* defines for snap keyframes tool */
1979 "CFRA",
1980 0,
1981 "Selection to Current Frame",
1982 "Snap selected keyframes to the current frame"},
1984 "NEAREST_FRAME",
1985 0,
1986 "Selection to Nearest Frame",
1987 "Snap selected keyframes to the nearest (whole) frame "
1988 "(use to fix accidental subframe offsets)"},
1990 "NEAREST_SECOND",
1991 0,
1992 "Selection to Nearest Second",
1993 "Snap selected keyframes to the nearest second"},
1995 "NEAREST_MARKER",
1996 0,
1997 "Selection to Nearest Marker",
1998 "Snap selected keyframes to the nearest marker"},
1999 {0, nullptr, 0, nullptr, nullptr},
2000};
2001
2002/* this function is responsible for snapping keyframes to frame-times */
2003static void snap_action_keys(bAnimContext *ac, short mode)
2004{
2005 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2007
2008 KeyframeEditData ked = {{nullptr}};
2009 KeyframeEditFunc edit_cb;
2010
2011 /* filter data */
2014 }
2015 else {
2018 }
2019 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
2020
2021 /* get beztriple editing callbacks */
2022 edit_cb = ANIM_editkeyframes_snap(mode);
2023
2024 ked.scene = ac->scene;
2025 if (mode == ACTKEYS_SNAP_NEAREST_MARKER) {
2026 ked.time_marker_list.first_ = (ac->markers) ? ac->markers->first_ : nullptr;
2027 ked.time_marker_list.last_ = (ac->markers) ? ac->markers->last() : nullptr;
2028 }
2029
2030 /* snap keyframes */
2031 for (bAnimListElem &ale : anim_data) {
2032 if (ale.type == ANIMTYPE_GPLAYER) {
2033 ED_gpencil_layer_snap_frames(static_cast<bGPDlayer *>(ale.data), ac->scene, mode);
2034 }
2035 else if (ale.type == ANIMTYPE_GREASE_PENCIL_LAYER) {
2036 GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(ale.id);
2037 GreasePencilLayer *layer = static_cast<GreasePencilLayer *>(ale.data);
2038
2039 const bool changed = ed::greasepencil::snap_selected_frames(
2040 *grease_pencil, layer->wrap(), *(ac->scene), static_cast<eEditKeyframes_Snap>(mode));
2041
2042 if (changed) {
2044 }
2045 }
2046 else if (ale.type == ANIMTYPE_MASKLAYER) {
2047 ED_masklayer_snap_frames(static_cast<MaskLayer *>(ale.data), ac->scene, mode);
2048 }
2049 else {
2050 FCurve *fcurve = static_cast<FCurve *>(ale.key_data);
2051 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcurve, false, false);
2052 ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, edit_cb, BKE_fcurve_handles_recalc);
2054 fcurve, SELECT, false); /* only use handles in graph editor */
2055 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcurve, true, false);
2056 }
2057
2058 ale.update |= ANIM_UPDATE_DEFAULT;
2059 }
2060
2061 ANIM_animdata_update(ac, &anim_data);
2062 ANIM_animdata_freelist(&anim_data);
2063}
2064
2065/* ------------------- */
2066
2068{
2069 bAnimContext ac;
2070 short mode;
2071
2072 /* get editor data */
2073 if (ANIM_animdata_get_context(C, &ac) == 0) {
2074 return OPERATOR_CANCELLED;
2075 }
2076
2077 /* get snapping mode */
2078 mode = RNA_enum_get(op->ptr, "type");
2079
2080 /* snap keyframes */
2081 snap_action_keys(&ac, mode);
2082
2083 /* set notifier that keyframes have changed */
2085
2086 return OPERATOR_FINISHED;
2087}
2088
2090{
2091 /* identifiers */
2092 ot->name = "Snap Keys";
2093 ot->idname = "ACTION_OT_snap";
2094 ot->description = "Snap selected keyframes to the times specified";
2095
2096 /* API callbacks. */
2097 ot->invoke = WM_menu_invoke;
2098 ot->exec = actkeys_snap_exec;
2100
2101 /* flags */
2103
2104 /* id-props */
2105 ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_snap_types, 0, "Type", "");
2106}
2107
2109
2110/* -------------------------------------------------------------------- */
2113
2114/* defines for mirror keyframes tool */
2117 "CFRA",
2118 0,
2119 "By Times Over Current Frame",
2120 "Flip times of selected keyframes using the current frame as the mirror line"},
2122 "MARKER",
2123 0,
2124 "By Times Over First Selected Marker",
2125 "Flip times of selected keyframes using the first selected marker as the reference point"},
2128 "XAXIS",
2129 0,
2130 "By Values Over Zero Value",
2131 "Flip values of selected keyframes (i.e. negative values become positive, and vice versa)"},
2132 {0, nullptr, 0, nullptr, nullptr},
2133};
2134
2135/* this function is responsible for mirroring keyframes */
2136static void mirror_action_keys(bAnimContext *ac, short mode)
2137{
2138 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2140
2141 KeyframeEditData ked = {{nullptr}};
2142 KeyframeEditFunc edit_cb;
2143
2144 /* get beztriple editing callbacks */
2145 edit_cb = ANIM_editkeyframes_mirror(mode);
2146
2147 ked.scene = ac->scene;
2148
2149 /* for 'first selected marker' mode, need to find first selected marker first! */
2150 /* XXX should this be made into a helper func in the API? */
2151 if (mode == ACTKEYS_MIRROR_MARKER) {
2153
2154 if (marker) {
2155 ked.f1 = float(marker->frame);
2156 }
2157 else {
2158 return;
2159 }
2160 }
2161
2162 /* filter data */
2165 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
2166
2167 /* mirror keyframes */
2168 for (bAnimListElem &ale : anim_data) {
2169 if (ale.type == ANIMTYPE_GPLAYER) {
2170 ED_gpencil_layer_mirror_frames(static_cast<bGPDlayer *>(ale.data), ac->scene, mode);
2171 }
2172 else if (ale.type == ANIMTYPE_GREASE_PENCIL_LAYER) {
2173 GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(ale.id);
2174 GreasePencilLayer *layer = static_cast<GreasePencilLayer *>(ale.data);
2175
2176 const bool changed = ed::greasepencil::mirror_selected_frames(
2177 *grease_pencil, layer->wrap(), *(ac->scene), static_cast<eEditKeyframes_Mirror>(mode));
2178
2179 if (changed) {
2181 }
2182 }
2183 else if (ale.type == ANIMTYPE_MASKLAYER) {
2184 /* TODO */
2185 }
2186 else {
2187 FCurve *fcurve = static_cast<FCurve *>(ale.key_data);
2188 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcurve, false, false);
2189 ANIM_fcurve_keyframes_loop(&ked, fcurve, nullptr, edit_cb, BKE_fcurve_handles_recalc);
2190 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcurve, true, false);
2191 }
2192
2193 ale.update |= ANIM_UPDATE_DEFAULT;
2194 }
2195
2196 ANIM_animdata_update(ac, &anim_data);
2197 ANIM_animdata_freelist(&anim_data);
2198}
2199
2200/* ------------------- */
2201
2203{
2204 bAnimContext ac;
2205 short mode;
2206
2207 /* get editor data */
2208 if (ANIM_animdata_get_context(C, &ac) == 0) {
2209 return OPERATOR_CANCELLED;
2210 }
2211
2212 /* get mirroring mode */
2213 mode = RNA_enum_get(op->ptr, "type");
2214
2215 /* mirror keyframes */
2216 mirror_action_keys(&ac, mode);
2217
2218 /* set notifier that keyframes have changed */
2220
2221 return OPERATOR_FINISHED;
2222}
2223
2225{
2226 /* identifiers */
2227 ot->name = "Mirror Keys";
2228 ot->idname = "ACTION_OT_mirror";
2229 ot->description = "Flip selected keyframes over the selected mirror line";
2230
2231 /* API callbacks. */
2232 ot->invoke = WM_menu_invoke;
2235
2236 /* flags */
2238
2239 /* id-props */
2240 ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_mirror_types, 0, "Type", "");
2241}
2242
2244
2245} // namespace blender
Functions and classes to work with Actions.
Functions to work with AnimData.
Functions to modify FCurves.
Functions to insert, delete or modify keyframes.
Low-level operations for grease pencil.
#define SELECT
Definition BKE_mask.hh:19
#define BLT_I18NCONTEXT_ID_ACTION
#define TIP_(msgid)
#define IFACE_(msgid)
#define ANIM_UPDATE_DEFAULT
#define RNA_ENUM_ITEM_SEPR
Definition RNA_types.hh:762
#define C
Definition RandGen.cpp:29
#define V2D_LOCK_COPY
Definition UI_view2d.hh:110
#define ND_DATA
Definition WM_types.hh:552
#define NC_ANIMATION
Definition WM_types.hh:401
#define NC_SCENE
Definition WM_types.hh:391
#define NA_ADDED
Definition WM_types.hh:636
#define NA_EDITED
Definition WM_types.hh:634
#define ND_KEYFRAME_PROP
Definition WM_types.hh:538
#define ND_MARKERS
Definition WM_types.hh:452
#define ND_FRAME
Definition WM_types.hh:453
#define NA_REMOVED
Definition WM_types.hh:637
#define NC_GPENCIL
Definition WM_types.hh:412
#define ND_KEYFRAME
Definition WM_types.hh:537
#define MAKE_CYCLIC_EXPO
#define CLEAR_CYCLIC_EXPO
#define ELEM(...)
#define BLI_assert_msg(a, msg)
btScalar max
int64_t size() const
#define FLT_MAX
#define layer
void assert_baklava_phase_1_invariants(const Action &action)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
Vector< float > get_property_values(PointerRNA *ptr, PropertyRNA *prop, bool visual_key)
SingleKeyingResult insert_vert_fcurve(FCurve *fcu, const float2 position, const KeyframeSettings &settings, eInsertKeyFlags flag)
Main Key-framing API call.
ID * action_slot_get_id_for_keying(Main &bmain, Action &action, slot_handle_t slot_handle, ID *primary_id)
void bake_fcurve_segments(FCurve *fcu)
eInsertKeyFlags get_keyframing_flags(Scene *scene)
CombinedKeyingResult insert_keyframes(Main *bmain, PointerRNA *struct_pointer, std::optional< StringRefNull > channel_group, const Span< RNAPath > rna_paths, std::optional< float > scene_frame, const AnimationEvalContext &anim_eval_context, eBezTriple_KeyframeType key_type, eInsertKeyFlags insert_key_flags)
Main key-frame insertion API.
bool remove_all_selected_frames(GreasePencil &grease_pencil, bke::greasepencil::Layer &layer)
bool grease_pencil_copy_keyframes(bAnimContext *ac, KeyframeClipboard &clipboard)
bool grease_pencil_paste_keyframes(bAnimContext *ac, const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, const KeyframeClipboard &clipboard)
void set_selected_frames_type(bke::greasepencil::Layer &layer, const eBezTriple_KeyframeType key_type)
bool mirror_selected_frames(GreasePencil &grease_pencil, bke::greasepencil::Layer &layer, Scene &scene, const eEditKeyframes_Mirror mode)
bool duplicate_selected_frames(GreasePencil &grease_pencil, bke::greasepencil::Layer &layer)
bool snap_selected_frames(GreasePencil &grease_pencil, bke::greasepencil::Layer &layer, Scene &scene, const eEditKeyframes_Snap mode)
BLI_INLINE Texture * wrap(MTLTexture *texture)
void view2d_center_set(View2D *v2d, float x, float y)
Definition view2d.cc:1939
void view2d_center_get(const View2D *v2d, float *r_x, float *r_y)
Definition view2d.cc:1929
void view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
Definition view2d.cc:850
BMesh Iterators.
MINLINE float min_ff(float a, float b)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ KEYFRAME_PASTE_NOTHING_TO_PASTE
@ KEYFRAME_PASTE_NOWHERE_TO_PASTE
static wmOperatorStatus actkeys_delete_exec(bContext *C, wmOperator *)
static wmOperatorStatus actkeys_copy_exec(bContext *C, wmOperator *op)
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
static void snap_action_keys(bAnimContext *ac, short mode)
ScrArea * CTX_wm_area(const bContext *C)
short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
static wmOperatorStatus actkeys_delete_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool BKE_fcurve_calc_range(const FCurve *fcu, float *r_min, float *r_max, bool selected_keys_only)
SpaceAction * CTX_wm_space_action(const bContext *C)
int RNA_enum_get(PointerRNA *ptr, const char *name)
static const EnumPropertyItem prop_actkeys_insertkey_types[]
static wmOperatorStatus actkeys_view_frame_exec(bContext *C, wmOperator *op)
void ACTION_OT_view_frame(wmOperatorType *ot)
bool BKE_fcurve_delete_keys_selected(FCurve &fcu)
static ed::greasepencil::KeyframeClipboard & get_grease_pencil_keyframe_clipboard()
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
static wmOperatorStatus actkeys_keytype_exec(bContext *C, wmOperator *op)
const bAnimChannelType * ANIM_channel_get_typeinfo(const bAnimListElem *ale)
KeyframeEditFunc ANIM_editkeyframes_ipo(short mode)
struct bGPDframe * BKE_annotations_layer_frame_get(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
@ ANIMCONT_GPENCIL
void ACTION_OT_easing_type(wmOperatorType *ot)
KeyframeEditFunc ANIM_editkeyframes_handles(short mode)
static bool delete_action_keys(bAnimContext *ac)
ListBaseT< TimeMarker > * ED_context_get_markers(const bContext *C)
MINLINE int round_fl_to_int(float a)
PointerRNA RNA_id_pointer_create(ID *id)
static const EnumPropertyItem prop_actkeys_mirror_types[]
void ACTION_OT_extrapolation_type(wmOperatorType *ot)
void ACTION_OT_clean(wmOperatorType *ot)
void ED_gpencil_layer_mirror_frames(bGPDlayer *gpl, Scene *scene, short mode)
static void setexpo_action_keys(bAnimContext *ac, short mode)
static bool act_markers_make_local_poll(bContext *C)
@ NLATIME_CONVERT_UNMAP
Definition BKE_nla.hh:560
@ NLATIME_CONVERT_MAP
Definition BKE_nla.hh:563
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
void clean_fcurve(bAnimListElem *ale, float thresh, bool cleardefault, const bool only_selected_keys)
void ACTION_OT_view_selected(wmOperatorType *ot)
int WM_operator_smooth_viewtx_get(const wmOperator *op)
static wmOperatorStatus actkeys_viewall_exec(bContext *C, wmOperator *)
float ANIM_nla_tweakedit_remap(bAnimListElem *ale, const float cframe, const eNlaTime_ConvertModes mode)
Definition anim_draw.cc:329
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
bool ED_masklayer_frames_duplicate(Main *main, MaskLayer *mask_layer)
void ACTION_OT_delete(wmOperatorType *ot)
void ED_masklayer_snap_frames(MaskLayer *mask_layer, Scene *scene, short mode)
static void clean_action_keys(bAnimContext *ac, float thresh, bool clean_chan)
static wmOperatorStatus act_markers_make_local_exec(bContext *C, wmOperator *)
static wmOperatorStatus actkeys_expo_exec(bContext *C, wmOperator *op)
@ ACTKEYS_MIRROR_CFRA
@ ACTKEYS_MIRROR_XAXIS
@ ACTKEYS_MIRROR_MARKER
static wmOperatorStatus actkeys_insertkey_exec(bContext *C, wmOperator *op)
const EnumPropertyItem rna_enum_keyframe_paste_merge_items[]
FModifier * add_fmodifier(ListBaseT< FModifier > *modifiers, int type, FCurve *owner_fcu)
rctf ANIM_frame_range_view2d_add_xmargin(const View2D &view_2d, const rctf view_rect)
Definition anim_draw.cc:848
bool duplicate_fcurve_keys(FCurve *fcu)
@ ANIMTYPE_NLACURVE
@ ANIMTYPE_FCURVE
@ ANIMTYPE_GPLAYER
@ ANIMTYPE_GREASE_PENCIL_LAYER
@ ANIMTYPE_MASKLAYER
void ACTION_OT_view_all(wmOperatorType *ot)
static std::string actkeys_clean_get_description(bContext *, wmOperatorType *, PointerRNA *ptr)
static bool actkeys_framejump_poll(bContext *C)
void ACTION_OT_paste(wmOperatorType *ot)
static void insert_gpencil_key(bAnimContext *ac, bAnimListElem *ale, const eGP_GetFrame_Mode add_frame_mode, bGPdata **gpd_old)
bAction * ANIM_active_action_from_area(const Main &bmain, Scene *scene, ViewLayer *view_layer, const ScrArea *area, ID **r_action_user)
bool list_has_suitable_fmodifier(const ListBaseT< FModifier > *modifiers, int mtype, short acttype)
static wmOperatorStatus actkeys_ipo_exec(bContext *C, wmOperator *op)
static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const short onlySel)
@ KEYFRAME_PASTE_OFFSET_CFRA_START
short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
bool remove_fmodifier(ListBaseT< FModifier > *modifiers, FModifier *fcm)
static wmOperatorStatus actkeys_easing_exec(bContext *C, wmOperator *op)
static void insert_nla_curve_key(bAnimListElem &ale, const AnimationEvalContext &anim_eval_context, const eInsertKeyFlags flag)
void ANIM_nla_mapping_apply_if_needed_fcurve(bAnimListElem *ale, FCurve *fcu, const bool restore, const bool only_keys)
Definition anim_draw.cc:406
void ANIM_animdata_update(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:365
ViewLayer * CTX_data_view_layer(const bContext *C)
AnimationEvalContext BKE_animsys_eval_context_construct(Depsgraph *depsgraph, float eval_time) ATTR_WARN_UNUSED_RESULT
Definition anim_sys.cc:602
@ ACHANNEL_ROLE_CHANNEL
@ ACTKEYS_SNAP_NEAREST_SECOND
@ ACTKEYS_SNAP_NEAREST_FRAME
@ ACTKEYS_SNAP_NEAREST_MARKER
static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *r_min, float *r_max)
void ACTION_OT_bake_keys(wmOperatorType *ot)
float ANIM_UI_get_channel_height()
void BKE_fcurve_merge_duplicate_keys(FCurve *fcu, const int sel_flag, const bool use_handle)
static const EnumPropertyItem prop_actkeys_snap_types[]
Global G
Definition blender.cc:57
bool ED_operator_action_active(bContext *C)
static bool copy_action_keys(bAnimContext *ac)
@ FMODIFIER_TYPE_CYCLES
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
static wmOperatorStatus actkeys_snap_exec(bContext *C, wmOperator *op)
@ INSERTKEY_NO_USERPREF
float ANIM_UI_get_first_channel_top(View2D *v2d)
@ GP_TOOL_FLAG_RETAIN_LAST
@ ACHANNEL_SETTING_SELECT
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
@ ALE_ACTION_SLOT
@ ALE_GREASE_PENCIL_CEL
bool copy_animedit_keys(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data)
void ANIM_center_frame(bContext *C, int smooth_viewtx)
Definition anim_draw.cc:801
bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac)
size_t ANIM_animdata_filter(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode, void *data, const eAnimCont_Types datatype)
@ ANIMFILTER_FCURVESONLY
@ ANIMFILTER_FOREDIT
@ ANIMFILTER_LIST_VISIBLE
@ ANIMFILTER_DATA_VISIBLE
@ ANIMFILTER_ACTGROUPED
@ ANIMFILTER_NODUPLIS
@ ANIMFILTER_LIST_CHANNELS
void BKE_fcurve_handles_recalc(FCurve &fcu)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
static void bake_action_keys(bAnimContext *ac)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
void ACTION_OT_handle_type(wmOperatorType *ot)
static wmOperatorStatus actkeys_viewall(bContext *C, const bool only_sel)
void ANIM_deselect_keys_in_animation_editors(bContext *C)
Definition anim_deps.cc:487
static bool duplicate_action_keys(bAnimContext *ac)
void ACTION_OT_copy(wmOperatorType *ot)
const EnumPropertyItem rna_enum_beztriple_interpolation_easing_items[]
bool ED_gpencil_layer_frame_select_check(const bGPDlayer *gpl)
const EnumPropertyItem rna_enum_beztriple_keyframe_type_items[]
Definition rna_fcurve.cc:84
TimeMarker * ED_markers_get_first_selected(ListBaseT< TimeMarker > *markers)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void ED_gpencil_layer_frames_keytype_set(bGPDlayer *gpl, short type)
void ACTION_OT_previewrange_set(wmOperatorType *ot)
ToolSettings * CTX_data_tool_settings(const bContext *C)
static void insert_action_keys(bAnimContext *ac, short mode)
bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
bool ED_gpencil_layer_frames_delete(bGPDlayer *gpl)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, ui::AlertIcon icon, bool cancel_default)
void ACTION_OT_keyframe_type(wmOperatorType *ot)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
bool ED_masklayer_frames_delete(Main *main, MaskLayer *mask_layer)
void ACTION_OT_snap(wmOperatorType *ot)
static wmOperatorStatus actkeys_bake_exec(bContext *C, wmOperator *op)
void ED_anim_ale_fcurve_delete(bAnimContext &ac, bAnimListElem &ale)
short(*)(KeyframeEditData *ked, BezTriple *bezt) KeyframeEditFunc
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
static wmOperatorStatus actkeys_viewsel_exec(bContext *C, wmOperator *)
bool ED_operator_region_action_active(bContext *C)
@ KEYFRAME_PASTE_VALUE_OFFSET_NONE
void ACTION_OT_duplicate(wmOperatorType *ot)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void ED_gpencil_layer_frames_duplicate(bGPDlayer *gpl)
void ACTION_OT_frame_jump(wmOperatorType *ot)
void ACTION_OT_markers_make_local(wmOperatorType *ot)
static void setkeytype_action_keys(bAnimContext *ac, eBezTriple_KeyframeType mode)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
void BKE_annotations_tag(struct bGPdata *gpd)
const EnumPropertyItem rna_enum_beztriple_interpolation_mode_items[]
Definition rna_curve.cc:66
Main * CTX_data_main(const bContext *C)
static eKeyPasteError paste_action_keys(bAnimContext *ac, const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
void ACTION_OT_interpolation_type(wmOperatorType *ot)
MINLINE float max_ff(float a, float b)
void ED_gpencil_layer_snap_frames(bGPDlayer *gpl, Scene *scene, short mode)
void ANIM_animdata_freelist(ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:472
KeyframeEditFunc ANIM_editkeyframes_snap(short mode)
KeyframeEditFunc ANIM_editkeyframes_keytype(const eBezTriple_KeyframeType keyframe_type)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
const EnumPropertyItem rna_enum_keyframe_paste_offset_items[]
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
static wmOperatorStatus actkeys_handletype_exec(bContext *C, wmOperator *op)
void ACTION_OT_mirror(wmOperatorType *ot)
eKeyPasteError paste_animedit_keys(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const KeyframePasteContext &paste_context)
static void sethandles_action_keys(bAnimContext *ac, short mode)
static const EnumPropertyItem prop_actkeys_expo_types[]
static void mirror_action_keys(bAnimContext *ac, short mode)
Scene * CTX_data_scene(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
static wmOperatorStatus actkeys_previewrange_exec(bContext *C, wmOperator *)
KeyframeEditFunc ANIM_editkeyframes_easing(short mode)
@ SACTION_POSEMARKERS_SHOW
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
bool BKE_fcurve_is_empty(const FCurve *fcu)
short bezt_calc_average(KeyframeEditData *ked, BezTriple *bezt)
void ACTION_OT_keyframe_insert(wmOperatorType *ot)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
static void insert_fcurve_key(bAnimContext *ac, bAnimListElem *ale, const AnimationEvalContext anim_eval_context, eInsertKeyFlags flag)
static wmOperatorStatus actkeys_clean_exec(bContext *C, wmOperator *op)
static wmOperatorStatus actkeys_paste_exec(bContext *C, wmOperator *op)
void ANIM_animdata_keyframe_callback(bAnimContext *ac, eAnimFilter_Flags filter, KeyframeEditFunc callback_fn)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
@ FCURVE_EXTRAPOLATE_CONSTANT
@ FCURVE_EXTRAPOLATE_LINEAR
static wmOperatorStatus actkeys_mirror_exec(bContext *C, wmOperator *op)
float ANIM_UI_get_channel_step()
@ ANIM_UPDATE_DEPS
@ ANIM_UPDATE_HANDLES
float RNA_float_get(PointerRNA *ptr, const char *name)
static wmOperatorStatus actkeys_duplicate_exec(bContext *C, wmOperator *)
static wmOperatorStatus actkeys_framejump_exec(bContext *C, wmOperator *)
static std::string actkeys_paste_get_description(bContext *, wmOperatorType *, PointerRNA *ptr)
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:784
float evaluate_fcurve(const FCurve *fcu, float evaltime)
static void insert_grease_pencil_key(bAnimContext *ac, bAnimListElem *ale, const bool hold_previous)
KeyframeEditFunc ANIM_editkeyframes_mirror(short mode)
const EnumPropertyItem rna_enum_keyframe_handle_type_items[]
Definition rna_curve.cc:38
#define floorf
#define fabsf
#define ceilf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
bActionGroup * grp
eFCurve_Extend extend
ListBaseT< FModifier > modifiers
struct FModifier * next
eFModifier_Types type
char name[258]
Definition DNA_ID.h:433
ListBaseT< TimeMarker > time_marker_list
eKeyPasteValueOffset value_offset_mode
ListBaseT< MaskLayerShape > splines_shapes
struct RenderData r
struct ToolSettings * toolsettings
struct TimeMarker * next
eGPencil_Flags gpencil_flags
eBezTriple_KeyframeType keyframe_type
ListBaseT< struct TimeMarker > markers
bool(*) has_setting(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
eAnimChannel_Role channel_role
ListBaseT< TimeMarker > * markers
eAnimCont_Types datatype
eAnim_Update_Flags update
bAnimListElem * next
ListBaseT< bGPDframe > frames
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
std::string(*) get_description(bContext *C, wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1197
struct ReportList * reports