Blender V5.3
anim_ops.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <algorithm>
10#include <cinttypes>
11#include <cmath>
12#include <cstdlib>
13#include <optional>
14
15#include "BLI_listbase.hh"
16#include "BLI_math_base_c.hh"
17#include "BLI_utildefines.hh"
18#include "BLI_vector.hh"
19
20#include "DNA_ID.h"
21#include "DNA_scene_types.h"
22
23#include "BKE_anim_data.hh"
24#include "BKE_armature.hh"
25#include "BKE_context.hh"
26#include "BKE_global.hh"
27#include "BKE_lib_id.hh"
28#include "BKE_lib_query.hh"
29#include "BKE_library.hh"
30#include "BKE_main.hh"
31#include "BKE_node.hh"
32#include "BKE_report.hh"
33#include "BKE_scene.hh"
34#include "BKE_scene_context.hh"
35
36#include "BLT_translation.hh"
37
38#include "UI_interface_c.hh"
40#include "UI_resources.hh"
41#include "UI_view2d.hh"
42
43#include "RNA_access.hh"
44#include "RNA_define.hh"
45#include "RNA_enum_types.hh"
46
47#include "WM_api.hh"
48#include "WM_types.hh"
49
50#include "ED_anim_api.hh"
53#include "ED_markers.hh"
54#include "ED_screen.hh"
55#include "ED_sequencer.hh"
56#include "ED_space_graph.hh"
57#include "ED_time_scrub_ui.hh"
58
59#include "DEG_depsgraph.hh"
61
62#include "SEQ_iterator.hh"
63#include "SEQ_retiming.hh"
64#include "SEQ_sequencer.hh"
65#include "SEQ_time.hh"
66
67#include "ANIM_action.hh"
69#include "ANIM_animdata.hh"
70
71#include "anim_intern.hh"
72
73namespace blender {
74
75/* -------------------------------------------------------------------- */
78
85 public:
88 std::optional<PreScrubbingState> pre_scrubbing;
90 float initial_frame = 0.0f;
91
93 {
94 keylist = nullptr;
95 }
96
98 {
99 if (keylist) {
101 }
102 }
103};
104
107 float pos;
113};
114
115/* Check if the operator can be run from the current context */
117{
118 ScrArea *area = CTX_wm_area(C);
119
120 /* XXX temp? prevent changes during render */
121 if (G.is_rendering) {
122 return false;
123 }
124
125 /* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
126 * this shouldn't show up in 3D editor (or others without 2D timeline view) via search
127 */
128 if (area) {
130 return true;
131 }
132 if (area->spacetype == SPACE_SEQ) {
134 return false;
135 }
136 /* In the combined sequencer/preview view, both window and preview regions share an active
137 * tool, so check the type to avoid conflicts with actions which can have the same key bound
138 * (2D cursor for example). */
139 const ARegion *region = CTX_wm_region(C);
140 if (region && ELEM(region->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_SCRUBBING)) {
141 return true;
142 }
143 }
144 if (area->spacetype == SPACE_GRAPH) {
145 const SpaceGraph *sipo = area->spacedata.first_as<SpaceGraph>();
146 /* Driver Editor's X axis is not time. */
147 if (sipo->mode != SIPO_MODE_DRIVERS) {
148 return true;
149 }
150 }
151 }
152
153 CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");
154 return false;
155}
156
157/* Returns the playhead snap threshold in frames. Of course that depends on the zoom level of the
158 * editor. */
159static float get_snap_threshold(const ToolSettings *tool_settings, const ARegion *region)
160{
161 const int snap_threshold = tool_settings->playhead_snap_distance;
162 return ui::view2d_region_to_view_x(&region->v2d, snap_threshold) -
163 ui::view2d_region_to_view_x(&region->v2d, 0);
164}
165
167{
168 /* Only populate data once. */
169 if (op_data.keylist != nullptr) {
170 return;
171 }
172
173 ScrArea *area = CTX_wm_area(C);
174
175 if (area->spacetype == SPACE_SEQ) {
176 /* Special case for the sequencer since it has retiming keys, but those have no bAnimListElem
177 * representation. Need to manually add entries to keylist. */
178 op_data.keylist = ED_keylist_create();
180 if (!scene) {
181 return;
182 }
183
184 ListBaseT<Strip> *seqbase = seq::active_seqbase_get(seq::editing_get(scene));
185 for (Strip &strip : *seqbase) {
186 sequencer_strip_to_keylist(strip, *op_data.keylist, *scene);
187 }
189 return;
190 }
191
192 op_data.keylist = ED_keylist_create();
193
194 bAnimContext ac;
195 if (!ANIM_animdata_get_context(C, &ac)) {
196 /* If there is no action, getting the anim context fails in the action editor. */
198 return;
199 }
200
201 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
202
203 switch (area->spacetype) {
204 case SPACE_ACTION: {
206 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
207 break;
208 }
209
210 case SPACE_GRAPH:
211 anim_data = ed::graph::get_editable_fcurves(ac);
212 break;
213
214 default:
216 break;
217 }
218
219 for (bAnimListElem &ale : anim_data) {
220 switch (ale.datatype) {
221 case ALE_FCURVE: {
222 FCurve *fcurve = static_cast<FCurve *>(ale.data);
223 fcurve_to_keylist(ale.adt, fcurve, op_data.keylist, 0, {-FLT_MAX, FLT_MAX}, true);
224 break;
225 }
226
227 case ALE_GPFRAME: {
228 gpl_to_keylist(nullptr, static_cast<bGPDlayer *>(ale.data), op_data.keylist);
229 break;
230 }
231
234 ale.adt, static_cast<const GreasePencilLayer *>(ale.data), op_data.keylist, 0);
235 break;
236 }
237
238 default:
239 break;
240 }
241 }
242 ANIM_animdata_freelist(&anim_data);
243
245}
246
248 FrameChangeModalData &op_data,
249 const float timeline_frame,
250 Vector<SnapTarget> &r_targets)
251{
253 const ActKeyColumn *closest_column = ED_keylist_find_closest(op_data.keylist, timeline_frame);
254 if (!closest_column) {
255 return;
256 }
257 r_targets.append({closest_column->cfra, true});
258}
259
261 const float timeline_frame,
262 Vector<SnapTarget> &r_targets)
263{
264 if (scene->markers.is_empty()) {
265 /* This check needs to be here because #ED_markers_find_nearest_marker_time returns the
266 * current frame if there are no markers. */
267 return;
268 }
269 const float nearest_marker = ED_markers_find_nearest_marker_time(&scene->markers,
270 timeline_frame);
271 r_targets.append({nearest_marker, true});
272}
273
275 const float timeline_frame,
276 const int step,
277 Vector<SnapTarget> &r_targets)
278{
279 const int start_frame = scene->r.sfra;
280 const float snap_frame = BKE_scene_frame_snap_by_seconds(
281 scene, step, timeline_frame - start_frame) +
282 start_frame;
283 r_targets.append({snap_frame, false});
284}
285
286static void append_frame_snap_target(const Scene *scene,
287 const float timeline_frame,
288 const int step,
289 Vector<SnapTarget> &r_targets)
290{
291 const int start_frame = scene->r.sfra;
292 const float snap_frame = (round((timeline_frame - start_frame) / float(step)) * step) +
293 start_frame;
294 r_targets.append({snap_frame, false});
295}
296
297static void seq_frame_snap_update_best(const float position,
298 const float timeline_frame,
299 float *r_best_frame,
300 float *r_best_distance)
301{
302 if (abs(position - timeline_frame) < *r_best_distance) {
303 *r_best_distance = abs(position - timeline_frame);
304 *r_best_frame = position;
305 }
306}
307
309 const float timeline_frame,
310 Vector<SnapTarget> &r_targets)
311{
312 Editing *ed = seq::editing_get(scene);
313 float best_frame = FLT_MAX;
314 float best_distance = FLT_MAX;
315
316 for (Strip &strip : *seq::active_seqbase_get(ed)) {
317 seq_frame_snap_update_best(strip.left_handle(), timeline_frame, &best_frame, &best_distance);
319 strip.right_handle(scene), timeline_frame, &best_frame, &best_distance);
320 }
321
322 /* best_frame will be FLT_MAX if no target was found. */
323 if (best_distance != FLT_MAX) {
324 r_targets.append({best_frame, true});
325 }
326}
327
329 const float timeline_frame,
330 Vector<SnapTarget> &r_targets)
331{
332
333 bAnimContext ac;
334 if (!ANIM_animdata_get_context(C, &ac)) {
336 }
337
338 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
341 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
342
343 float best_frame = FLT_MAX;
344 float best_distance = FLT_MAX;
345
346 for (bAnimListElem &ale : anim_data) {
347 if (ale.type != ANIMTYPE_NLATRACK) {
348 continue;
349 }
350 NlaTrack *track = static_cast<NlaTrack *>(ale.data);
351 for (NlaStrip &strip : track->strips) {
352 if (abs(strip.start - timeline_frame) < best_distance) {
353 best_distance = abs(strip.start - timeline_frame);
354 best_frame = strip.start;
355 }
356 if (abs(strip.end - timeline_frame) < best_distance) {
357 best_distance = abs(strip.end - timeline_frame);
358 best_frame = strip.end;
359 }
360 }
361 }
362 ANIM_animdata_freelist(&anim_data);
363
364 /* If no strip was found, best_frame will be FLT_MAX. */
365 if (best_frame != FLT_MAX) {
366 r_targets.append({best_frame, true});
367 }
368}
369
370/* ---- */
371
373 FrameChangeModalData &op_data,
374 const float timeline_frame)
375{
377 if (!scene) {
378 return {};
379 }
380
381 ToolSettings *tool_settings = scene->toolsettings;
382 Editing *ed = seq::editing_get(scene);
383
384 if (ed == nullptr) {
385 return {};
386 }
387
388 Vector<SnapTarget> targets;
389
390 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_STRIPS) {
391 append_sequencer_strip_snap_target(scene, timeline_frame, targets);
392 }
393
394 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_MARKERS) {
395 append_marker_snap_target(scene, timeline_frame, targets);
396 }
397
398 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_KEYS) {
399 append_keyframe_snap_target(C, op_data, timeline_frame, targets);
400 }
401
402 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_SECOND) {
403 append_second_snap_target(scene, timeline_frame, tool_settings->snap_step_seconds, targets);
404 }
405
406 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_FRAME) {
407 append_frame_snap_target(scene, timeline_frame, tool_settings->snap_step_frames, targets);
408 }
409
410 return targets;
411}
412
413static Vector<SnapTarget> nla_get_snap_targets(bContext *C, const float timeline_frame)
414{
415 Scene *scene = CTX_data_scene(C);
416 ToolSettings *tool_settings = scene->toolsettings;
417
418 Vector<SnapTarget> targets;
419
420 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_STRIPS) {
421 append_nla_strip_snap_target(C, timeline_frame, targets);
422 }
423
424 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_MARKERS) {
425 append_marker_snap_target(scene, timeline_frame, targets);
426 }
427
428 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_SECOND) {
429 append_second_snap_target(scene, timeline_frame, tool_settings->snap_step_seconds, targets);
430 }
431
432 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_FRAME) {
433 append_frame_snap_target(scene, timeline_frame, tool_settings->snap_step_frames, targets);
434 }
435
436 return targets;
437}
438
440 FrameChangeModalData &op_data,
441 const float timeline_frame)
442{
443 Scene *scene = CTX_data_scene(C);
444 ToolSettings *tool_settings = scene->toolsettings;
445
446 Vector<SnapTarget> targets;
447
448 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_MARKERS) {
449 append_marker_snap_target(scene, timeline_frame, targets);
450 }
451
452 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_KEYS) {
453 append_keyframe_snap_target(C, op_data, timeline_frame, targets);
454 }
455
456 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_SECOND) {
457 append_second_snap_target(scene, timeline_frame, tool_settings->snap_step_seconds, targets);
458 }
459
460 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_FRAME) {
461 append_frame_snap_target(scene, timeline_frame, tool_settings->snap_step_frames, targets);
462 }
463
464 return targets;
465}
466
468 FrameChangeModalData &op_data,
469 const float timeline_frame)
470{
471 Scene *scene = CTX_data_scene(C);
472 ToolSettings *tool_settings = scene->toolsettings;
473
474 Vector<SnapTarget> targets;
475
476 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_MARKERS) {
477 append_marker_snap_target(scene, timeline_frame, targets);
478 }
479
480 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_KEYS) {
481 append_keyframe_snap_target(C, op_data, timeline_frame, targets);
482 }
483
484 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_SECOND) {
485 append_second_snap_target(scene, timeline_frame, tool_settings->snap_step_seconds, targets);
486 }
487
488 if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_FRAME) {
489 append_frame_snap_target(scene, timeline_frame, tool_settings->snap_step_frames, targets);
490 }
491
492 return targets;
493}
494
495/* ---- */
496
497/* Returns a frame that is snapped to the closest point of interest defined by the area. If no
498 * point of interest is nearby, the frame is returned unmodified. */
499static float apply_frame_snap(bContext *C, FrameChangeModalData &op_data, const float frame)
500{
501 ScrArea *area = CTX_wm_area(C);
502
503 Vector<SnapTarget> targets;
505 if (!scene) {
506 return frame;
507 }
508
509 switch (area->spacetype) {
510 case SPACE_SEQ:
511 targets = seq_get_snap_targets(C, op_data, frame);
512 break;
513 case SPACE_ACTION:
514 targets = action_get_snap_targets(C, op_data, frame);
515 break;
516 case SPACE_GRAPH:
517 targets = graph_get_snap_targets(C, op_data, frame);
518 break;
519 case SPACE_NLA:
520 targets = nla_get_snap_targets(C, frame);
521 break;
522
523 default:
524 break;
525 }
526
527 float snap_frame = FLT_MAX;
528
529 /* Find closest frame of all targets. */
530 for (const SnapTarget &target : targets) {
531 if (abs(target.pos - frame) < abs(snap_frame - frame)) {
532 snap_frame = target.pos;
533 }
534 }
535
536 const ARegion *region = CTX_wm_region(C);
537 if (abs(snap_frame - frame) < get_snap_threshold(scene->toolsettings, region)) {
538 return snap_frame;
539 }
540
541 snap_frame = FLT_MAX;
542 /* No frame is close enough to the snap threshold. Hard snap to targets without a threshold. */
543 for (const SnapTarget &target : targets) {
544 if (target.use_snap_treshold) {
545 continue;
546 }
547 if (abs(target.pos - frame) < abs(snap_frame - frame)) {
548 snap_frame = target.pos;
549 }
550 }
551
552 if (snap_frame != FLT_MAX) {
553 return snap_frame;
554 }
555
556 return frame;
557}
558
559/* Set the new frame number */
560static void change_frame_apply(bContext *C, wmOperator *op, const bool always_update)
561{
563 if (!scene) {
564 return;
565 }
566 float frame = RNA_float_get(op->ptr, "frame");
567 bool do_snap = RNA_boolean_get(op->ptr, "snap");
568
569 const int old_frame = scene->r.cfra;
570 const float old_subframe = scene->r.subframe;
571
572 if (do_snap) {
573 /* Only valid when running modally, unlikely it's null
574 * but nothing prevents `snap` being enabled when running non-modally. */
575 if (FrameChangeModalData *op_data = static_cast<FrameChangeModalData *>(op->customdata)) {
576 frame = apply_frame_snap(C, *op_data, frame);
577 }
578 }
579
580 /* set the new frame number */
581 if (scene->r.flag & SCER_SHOW_SUBFRAME) {
582 scene->r.cfra = int(frame);
583 scene->r.subframe = frame - int(frame);
584 }
585 else {
586 scene->r.cfra = round_fl_to_int(frame);
587 scene->r.subframe = 0.0f;
588 }
590 if (screen->animtimer) {
591 wmTimer *wt = screen->animtimer;
592 ScreenAnimData *sad = static_cast<ScreenAnimData *>(wt->customdata);
594 }
595 }
597
599
600 /* do updates */
601 const bool frame_changed = (old_frame != scene->r.cfra) || (old_subframe != scene->r.subframe);
602 if (frame_changed || always_update) {
605 }
606}
607
608/* ---- */
609
610/* Non-modal callback for running operator without user input */
612{
613 change_frame_apply(C, op, true);
614
615 return OPERATOR_FINISHED;
616}
617
618/* ---- */
619
620/* Get frame from mouse coordinates */
621static float frame_from_event(bContext *C, const wmEvent *event)
622{
623 ARegion *region = CTX_wm_region(C);
625 float frame;
626
627 /* convert from region coordinates to View2D 'tot' space */
628 frame = ui::view2d_region_to_view_x(&region->v2d, event->mval[0]);
629
630 /* respect preview range restrictions (if only allowed to move around within that range) */
631 if ((scene->r.flag & SCER_LOCK_FRAME_SELECTION) || (region->regiontype == RGN_TYPE_SCRUBBING)) {
632 const ScenePlaybackRange playback_range = BKE_scene_get_playback_range(scene);
633 CLAMP(frame, playback_range.start_frame, playback_range.end_frame);
634 }
635
636 return frame;
637}
638
639static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event, SpaceSeq *sseq)
640{
641 BLI_assert(sseq != nullptr);
642 ARegion *region = CTX_wm_region(C);
643 if (ed::vse::check_show_strip(*sseq) && !ED_time_scrub_event_in_region(region, event)) {
645 }
646}
647
649{
650 BLI_assert(sseq != nullptr);
651 UNUSED_VARS_NDEBUG(sseq);
652 if (ed::vse::special_preview_get() != nullptr) {
654 }
655}
656
658{
660 if (!scene) {
661 return false;
662 }
663
664 ScrArea *area = CTX_wm_area(C);
665
666 if (area->spacetype == SPACE_GRAPH) {
667 SpaceGraph *graph_editor = area->spacedata.first_as<SpaceGraph>();
668 /* Snapping is disabled for driver mode. Need to evaluate if it makes sense there and what form
669 * it should take. */
670 if (graph_editor->mode == SIPO_MODE_DRIVERS) {
671 return false;
672 }
673 }
674
676}
677
678static bool sequencer_is_mouse_over_handle(const bContext *C, const wmEvent *event)
679{
681 if (!seq::editing_get(scene)) {
682 return false;
683 }
684
685 const View2D *v2d = ui::view2d_fromcontext(C);
686
687 float mouse_co[2];
688 ui::view2d_region_to_view(v2d, event->mval[0], event->mval[1], &mouse_co[0], &mouse_co[1]);
689
690 ed::vse::StripSelection selection = ed::vse::pick_strip_and_handle(scene, v2d, mouse_co);
691
692 return selection.handle != ed::vse::STRIP_HANDLE_NONE;
693}
694
695/* Modal Operator init */
697{
698 bScreen *screen = CTX_wm_screen(C);
699 FrameChangeModalData *op_data = MEM_new<FrameChangeModalData>(__func__);
700 op->customdata = op_data;
701
702 {
703 const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
704 const Scene *scene = is_sequencer ? CTX_data_sequencer_scene(C) : CTX_data_scene(C);
705
706 if (scene) {
707 op_data->initial_frame = BKE_scene_frame_get(scene);
708 }
709 }
710
711 /* This check is done in case scrubbing and strip tweaking in the sequencer are bound to the same
712 * event (e.g. RCS keymap where both are activated on left mouse press). Tweaking should take
713 * precedence. */
714 if (RNA_boolean_get(op->ptr, "pass_through_on_strip_handles") && CTX_wm_space_seq(C) &&
716 {
718 }
719
720 /* Change to frame that mouse is over before adding modal handler,
721 * as user could click on a single frame (jump to frame) as well as
722 * click-dragging over a range (modal scrubbing).
723 */
724 RNA_float_set(op->ptr, "frame", frame_from_event(C, event));
725
727 RNA_boolean_set(op->ptr, "snap", true);
728 }
729
730 op_data->pre_scrubbing = ED_screen_scrubbing_enable(*C, *screen);
731
732 if (RNA_boolean_get(op->ptr, "seq_solo_preview")) {
733 SpaceSeq *sseq = CTX_wm_space_seq(C);
734 if (sseq) {
735 change_frame_seq_preview_begin(C, event, sseq);
736 }
737 }
738
739 change_frame_apply(C, op, true);
740
741 /* add temp handler */
743
745}
746
748{
749 if (CTX_wm_space_seq(C)) {
750 /* During scrubbing in the sequencer, a preview of the final video might be drawn. After
751 * scrubbing, the actual result should be shown again. */
752 return true;
753 }
754 Scene *scene = CTX_data_scene(C);
755 if (scene->eevee.taa_samples != 1) {
756 return true;
757 }
758 return false;
759}
760
762{
763 FrameChangeModalData *op_data = static_cast<FrameChangeModalData *>(op->customdata);
764 bScreen *screen = CTX_wm_screen(C);
765 if (screen) {
766 ED_screen_scrubbing_disable(*C, *screen, op_data->pre_scrubbing);
767 }
768
769 if (RNA_boolean_get(op->ptr, "seq_solo_preview")) {
770 SpaceSeq *sseq = CTX_wm_space_seq(C);
771 if (sseq != nullptr) {
773 }
774 }
775
777 Scene *scene = CTX_data_scene(C);
779 }
780}
781
783{
784 FrameChangeModalData *op_data = static_cast<FrameChangeModalData *>(op->customdata);
785 RNA_float_set(op->ptr, "frame", op_data->initial_frame);
786 change_frame_apply(C, op, true);
787}
788
789/* Modal event handling of frame changing */
791{
793 /* execute the events */
794 switch (event->type) {
795 case EVT_ESCKEY:
798 break;
799
800 case MOUSEMOVE:
801 RNA_float_set(op->ptr, "frame", frame_from_event(C, event));
802 change_frame_apply(C, op, false);
803 break;
804
805 case LEFTMOUSE:
806 case MIDDLEMOUSE:
807 /* We check for either mouse-button to end, to work with all user keymaps. */
808 if (event->val == KM_RELEASE) {
810 }
811 break;
812
813 case RIGHTMOUSE:
814 if (event->val == KM_PRESS) {
817 }
818 else if (event->val == KM_RELEASE) {
820 }
821 break;
822
823 case EVT_LEFTCTRLKEY:
824 case EVT_RIGHTCTRLKEY:
825 /* Use Ctrl key to invert snapping in sequencer. */
827 if (event->val == KM_RELEASE) {
828 RNA_boolean_set(op->ptr, "snap", true);
829 }
830 else if (event->val == KM_PRESS) {
831 RNA_boolean_set(op->ptr, "snap", false);
832 }
833 }
834 else {
835 if (event->val == KM_RELEASE) {
836 RNA_boolean_set(op->ptr, "snap", false);
837 }
838 else if (event->val == KM_PRESS) {
839 RNA_boolean_set(op->ptr, "snap", true);
840 }
841 }
842 break;
843 default: {
844 break;
845 }
846 }
847
848 WorkspaceStatus status(C);
849 status.item(IFACE_("Toggle Snapping"), ICON_EVENT_CTRL);
850
852 ED_workspace_status_text(C, nullptr);
853 bScreen *screen = CTX_wm_screen(C);
854 FrameChangeModalData *op_data = static_cast<FrameChangeModalData *>(op->customdata);
855 if (screen) {
856 const std::optional<PreScrubbingState> resume = (ret == OPERATOR_CANCELLED) ?
857 std::nullopt :
858 op_data->pre_scrubbing;
859 ED_screen_scrubbing_disable(*C, *screen, resume);
860 }
861 MEM_delete(op_data);
862 op->customdata = nullptr;
863
864 if (RNA_boolean_get(op->ptr, "seq_solo_preview")) {
865 SpaceSeq *sseq = CTX_wm_space_seq(C);
866 if (sseq != nullptr) {
868 }
869 }
870
872 Scene *scene = CTX_data_scene(C);
874 }
875 }
876
877 return ret;
878}
879
880static std::string change_frame_get_name(wmOperatorType * /*ot*/, PointerRNA *ptr)
881{
882 if (RNA_boolean_get(ptr, "seq_solo_preview")) {
883 return CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Set Frame (Strip Preview)");
884 }
885
886 return {};
887}
888
890{
891 PropertyRNA *prop;
892
893 /* identifiers */
894 ot->name = "Change Frame";
895 ot->idname = "ANIM_OT_change_frame";
896 ot->description = "Interactively change the current frame number";
897
898 /* API callbacks. */
905
906 /* flags */
908 ot->undo_group = "Frame Change";
909
910 /* rna */
911 ot->prop = RNA_def_float(
912 ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);
913 prop = RNA_def_boolean(ot->srna, "snap", false, "Snap", "");
915 prop = RNA_def_boolean(ot->srna, "seq_solo_preview", false, "Strip Preview", "");
916 prop = RNA_def_boolean(ot->srna,
917 "pass_through_on_strip_handles",
918 false,
919 "Pass Through on Strip Handles",
920 "Allow another operator to operate on strip handles");
921}
922
924
925/* -------------------------------------------------------------------- */
928
930{
931 ScrArea *area = CTX_wm_area(C);
932
933 /* XXX temp? prevent changes during render */
934 if (G.is_rendering) {
935 return false;
936 }
937
938 /* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
939 * this shouldn't show up in 3D editor (or others without 2D timeline view) via search
940 */
941 if (area) {
943 return true;
944 }
945 }
946
947 CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");
948 return false;
949}
950
952{
954 int frame;
955
956 if (scene == nullptr) {
957 return OPERATOR_CANCELLED;
958 }
959
960 frame = scene->r.cfra;
961
962 /* if Preview Range is defined, set the 'start' frame for that */
963 if (PRVRANGEON) {
964 scene->r.psfra = frame;
965 }
966 else {
967 /* Clamping should be in sync with 'rna_Scene_start_frame_set()'. */
968 int frame_clamped = frame;
969 CLAMP(frame_clamped, MINFRAME, MAXFRAME);
970 if (frame_clamped != frame) {
971 BKE_report(op->reports, RPT_WARNING, "Start frame clamped to valid rendering range");
972 }
973 frame = frame_clamped;
974 scene->r.sfra = frame;
975 }
976
977 if (scene->playback_end() < frame) {
978 if (PRVRANGEON) {
979 scene->r.pefra = frame;
980 }
981 else {
982 scene->r.efra = frame;
983 }
984 }
985
987
988 return OPERATOR_FINISHED;
989}
990
992{
993 /* identifiers */
994 ot->name = "Set Start Frame";
995 ot->idname = "ANIM_OT_start_frame_set";
996 ot->description = "Set the current frame as the preview or scene start frame";
997
998 /* API callbacks. */
1001
1002 /* flags */
1004}
1005
1007{
1009 int frame;
1010
1011 if (scene == nullptr) {
1012 return OPERATOR_CANCELLED;
1013 }
1014
1015 frame = scene->r.cfra;
1016
1017 /* if Preview Range is defined, set the 'end' frame for that */
1018 if (PRVRANGEON) {
1019 scene->r.pefra = frame;
1020 }
1021 else {
1022 /* Clamping should be in sync with 'rna_Scene_end_frame_set()'. */
1023 int frame_clamped = frame;
1024 CLAMP(frame_clamped, MINFRAME, MAXFRAME);
1025 if (frame_clamped != frame) {
1026 BKE_report(op->reports, RPT_WARNING, "End frame clamped to valid rendering range");
1027 }
1028 frame = frame_clamped;
1029 scene->r.efra = frame;
1030 }
1031
1032 if (scene->playback_start() > frame) {
1033 if (PRVRANGEON) {
1034 scene->r.psfra = frame;
1035 }
1036 else {
1037 scene->r.sfra = frame;
1038 }
1039 }
1040
1042
1043 return OPERATOR_FINISHED;
1044}
1045
1047{
1048 /* identifiers */
1049 ot->name = "Set End Frame";
1050 ot->idname = "ANIM_OT_end_frame_set";
1051 ot->description = "Set the current frame as the preview or scene end frame";
1052
1053 /* API callbacks. */
1056
1057 /* flags */
1059}
1060
1062
1063/* -------------------------------------------------------------------- */
1066
1068{
1070 if (!scene) {
1071 return OPERATOR_CANCELLED;
1072 }
1073 ARegion *region = CTX_wm_region(C);
1074 float sfra, efra;
1075 rcti rect;
1076
1077 /* get min/max values from box select rect (already in region coordinates, not screen) */
1079
1080 /* convert min/max values to frames (i.e. region to 'tot' rect) */
1081 sfra = ui::view2d_region_to_view_x(&region->v2d, rect.xmin);
1082 efra = ui::view2d_region_to_view_x(&region->v2d, rect.xmax);
1083
1084 /* set start/end frames for preview-range
1085 * - must clamp within allowable limits
1086 * - end must not be before start (though this won't occur most of the time)
1087 */
1090 efra = std::max(efra, sfra);
1091
1092 scene->r.flag |= SCER_PRV_RANGE;
1093 scene->r.psfra = round_fl_to_int(sfra);
1094 scene->r.pefra = round_fl_to_int(efra);
1095
1096 /* send notifiers */
1098
1099 return OPERATOR_FINISHED;
1100}
1101
1103{
1104 /* identifiers */
1105 ot->name = "Set Preview Range";
1106 ot->idname = "ANIM_OT_previewrange_set";
1107 ot->description = "Interactively define frame range used for playback";
1108
1109 /* API callbacks. */
1114
1116
1117 /* flags */
1119
1120 /* rna */
1121 /* used to define frame range.
1122 *
1123 * NOTE: border Y values are not used,
1124 * but are needed by box_select gesture operator stuff */
1126}
1127
1129
1130/* -------------------------------------------------------------------- */
1133
1135{
1137 ScrArea *curarea = CTX_wm_area(C);
1138
1139 /* sanity checks */
1140 if (ELEM(nullptr, scene, curarea)) {
1141 return OPERATOR_CANCELLED;
1142 }
1143
1144 /* simply clear values */
1145 scene->r.flag &= ~SCER_PRV_RANGE;
1146 scene->r.psfra = 0;
1147 scene->r.pefra = 0;
1148
1149 ED_area_tag_redraw(curarea);
1150
1151 /* send notifiers */
1153
1154 return OPERATOR_FINISHED;
1155}
1156
1158{
1159 /* identifiers */
1160 ot->name = "Clear Preview Range";
1161 ot->idname = "ANIM_OT_previewrange_clear";
1162 ot->description = "Clear preview range";
1163
1164 /* API callbacks. */
1166
1168
1169 /* flags */
1171}
1172
1174
1175/* -------------------------------------------------------------------- */
1178
1179#ifndef NDEBUG
1181{
1182 bAnimContext ac;
1183 if (ANIM_animdata_get_context(C, &ac) == 0) {
1184 return OPERATOR_CANCELLED;
1185 }
1186
1187 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1188 /* Same filter flags as in action_channel_region_draw() in
1189 * `source/blender/editors/space_action/space_action.cc`. */
1192 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1193
1194 printf("==============================================\n");
1195 printf("Animation Channel List:\n");
1196 printf("----------------------------------------------\n");
1197
1198 for (bAnimListElem &ale : anim_data) {
1199 ANIM_channel_debug_print_info(ac, &ale, 1);
1200 }
1201
1202 printf("==============================================\n");
1203
1204 ANIM_animdata_freelist(&anim_data);
1205 return OPERATOR_FINISHED;
1206}
1207
1209{
1210 ot->name = "Debug Channel List";
1211 ot->idname = "ANIM_OT_debug_channel_list";
1212 ot->description =
1213 "Log the channel list info in the terminal. This operator is only available in debug builds "
1214 "of Blender";
1215
1218
1219 ot->flag = OPTYPE_REGISTER;
1220}
1221#endif /* !NDEBUG */
1222
1224
1225/* -------------------------------------------------------------------- */
1228
1230{
1232 if (!scene) {
1233 return OPERATOR_CANCELLED;
1234 }
1235 ARegion *region = CTX_wm_region(C);
1236 View2D &v2d = region->v2d;
1237 const ScenePlaybackRange playback_range = BKE_scene_get_playback_range(scene);
1238 v2d.cur.xmin = playback_range.start_frame;
1239 v2d.cur.xmax = playback_range.end_frame;
1240
1242
1245
1246 return OPERATOR_FINISHED;
1247}
1248
1250{
1251 ot->name = "Frame Scene/Preview Range";
1252 ot->idname = "ANIM_OT_scene_range_frame";
1253 ot->description =
1254 "Reset the horizontal view to the current scene frame range, taking the preview range into "
1255 "account if it is active";
1256
1259
1260 ot->flag = OPTYPE_REGISTER;
1261}
1262
1264
1265/* -------------------------------------------------------------------- */
1268
1270{
1271 Object *object = CTX_data_active_object(C);
1272 if (!object) {
1273 CTX_wm_operator_poll_msg_set(C, "No active object");
1274 return false;
1275 }
1277 if (!action) {
1278 CTX_wm_operator_poll_msg_set(C, "Active object has no action");
1279 return false;
1280 }
1281 if (!BKE_id_is_editable(CTX_data_main(C), &action->id)) {
1282 return false;
1283 }
1284 return true;
1285}
1286
1288{
1289 using namespace blender::animrig;
1290 Object *active_object = CTX_data_active_object(C);
1291 /* Those cases are caught by the poll. */
1292 BLI_assert(active_object != nullptr);
1293 BLI_assert(active_object->adt->action != nullptr);
1294
1295 Action &active_action = active_object->adt->action->wrap();
1296
1297 Vector<PointerRNA> selection;
1298 if (!CTX_data_selected_objects(C, &selection)) {
1299 return OPERATOR_CANCELLED;
1300 }
1301
1302 Main *bmain = CTX_data_main(C);
1303 int moved_slots_count = 0;
1304 for (const PointerRNA &ptr : selection) {
1305 Vector<ID *> related_ids = find_related_ids(*bmain, *ptr.owner_id);
1306 for (ID *related_id : related_ids) {
1307 Action *action = get_action(*related_id);
1308 if (!action) {
1309 continue;
1310 }
1311 if (action == &active_action) {
1312 /* Object is already animated by the same action, no point in moving. */
1313 continue;
1314 }
1315 if (!BKE_id_is_editable(bmain, &action->id)) {
1316 BKE_reportf(op->reports, RPT_WARNING, "The action %s is not editable", action->id.name);
1317 continue;
1318 }
1319 AnimData *id_anim_data = BKE_animdata_ensure_id(related_id);
1320 /* Since we already get an action from the ID the animdata has to exist. */
1321 BLI_assert(id_anim_data);
1322 Slot *slot = action->slot_for_handle(id_anim_data->slot_handle);
1323 if (!slot) {
1324 continue;
1325 }
1326 animrig::move_slot(*bmain, *slot, *action, active_action);
1327 moved_slots_count++;
1328 ANIM_id_update(bmain, related_id);
1330 }
1331 }
1332
1333 if (moved_slots_count > 0) {
1334 BKE_reportf(op->reports,
1335 RPT_INFO,
1336 "Moved %i slot(s) into the action of the active object",
1337 moved_slots_count);
1338 }
1339 else {
1340 BKE_reportf(op->reports,
1341 RPT_ERROR,
1342 "Failed to merge any animation. Note that NLA strips cannot be merged");
1343 }
1344
1345 /* `ID_RECALC_ANIMATION_NO_FLUSH` is used here (and above), as the actual animation values do not
1346 * change, so there is no need to flush to the animated IDs. The Action itself does need to be
1347 * re-evaluated to get an up-to-date evaluated copy with the new slots & channelbags. Without
1348 * this, future animation evaluation will break. */
1350
1353
1354 return OPERATOR_FINISHED;
1355}
1356
1358{
1359 ot->name = "Merge Animation";
1360 ot->idname = "ANIM_OT_merge_animation";
1361 ot->description =
1362 "Merge the animation of the selected objects into the action of the active object. Actions "
1363 "are not deleted by this, but might end up with zero users";
1364
1367
1369}
1370
1372
1373/* -------------------------------------------------------------------- */
1376
1377static void replace_action_on_id(ID *id,
1378 const bAction &old_action,
1379 bAction &new_action,
1380 Vector<ID *> &r_failures)
1381{
1382 AnimData *adt = BKE_animdata_from_id(id);
1383 if (!adt || !adt->action || adt->action != &old_action) {
1384 return;
1385 }
1386 if (!ID_IS_EDITABLE(id) && !ID_IS_OVERRIDE_LIBRARY(id)) {
1387 return;
1388 }
1389 const bool success = animrig::assign_action(&new_action, {*id, *adt});
1390 if (!success) {
1391 r_failures.append(id);
1392 }
1394};
1395
1397{
1398 Object *active_object = CTX_data_active_object(C);
1399 if (!active_object) {
1400 return false;
1401 }
1402 AnimData *adt = active_object->adt;
1403 if (!adt || !adt->action) {
1404 return false;
1405 }
1406 return true;
1407}
1408
1410{
1411 if (failures.size() == 0) {
1412 return;
1413 }
1414 std::string report = "Replacing the action failed on: ";
1415 for (ID *id : failures) {
1416 report += id->name + 2;
1417 }
1418 BKE_report(&reports, RPT_WARNING, report.c_str());
1419}
1420
1426 const animrig::Action &old_action,
1427 animrig::Action &new_action)
1428{
1429 Vector<ID *> failures;
1430 ID *id;
1431 /* Cannot use the Action Slot user map because some action assignments may be missing a slot
1432 * assignment and those should also be remapped. */
1433 FOREACH_MAIN_ID_BEGIN (&bmain, id) {
1434 replace_action_on_id(id, old_action, new_action, failures);
1435 if (bNodeTree *node_tree = bke::node_tree_from_id(id)) {
1436 replace_action_on_id(&node_tree->id, old_action, new_action, failures);
1437 }
1438 }
1440
1442 DEG_id_tag_update(&new_action.id, ID_RECALC_ALL);
1443 return failures;
1444}
1445
1447{
1448 Main *bmain = CTX_data_main(C);
1449 const uint32_t old_session_uid = RNA_int_get(op->ptr, "old_session_uid");
1450 const uint32_t new_session_uid = RNA_int_get(op->ptr, "new_session_uid");
1451 bAction *old_action = reinterpret_cast<bAction *>(
1452 BKE_libblock_find_session_uid(bmain, ID_AC, old_session_uid));
1453 bAction *new_action = reinterpret_cast<bAction *>(
1454 BKE_libblock_find_session_uid(bmain, ID_AC, new_session_uid));
1455
1456 if (!old_action || !new_action) {
1457 BKE_reportf(op->reports,
1459 "Invalid old/new Action pair ('%s' / '%s')",
1460 old_action ? old_action->id.name + 2 : "Invalid UID",
1461 new_action ? new_action->id.name + 2 : "Invalid UID");
1462 return OPERATOR_CANCELLED;
1463 }
1464 if (old_action == new_action) {
1465 BKE_reportf(op->reports,
1467 "Cannot replace Action with itself ('%s')",
1468 old_action->id.name + 2);
1469 return OPERATOR_CANCELLED;
1470 }
1471
1472 Vector<ID *> failures = replace_action(*bmain, old_action->wrap(), new_action->wrap());
1474
1476
1477 return OPERATOR_FINISHED;
1478}
1479
1481 wmOperator *op,
1482 const blender::wmEvent * /* event */)
1483{
1484 Object *active_object = CTX_data_active_object(C);
1485 BLI_assert(active_object != nullptr);
1486 AnimData *adt = BKE_animdata_from_id(&active_object->id);
1487 bAction *dna_action = adt->action;
1488 BLI_assert(dna_action != nullptr);
1489 RNA_int_set(op->ptr, "old_session_uid", int(dna_action->id.session_uid));
1490 /* Setting the new_id here means the UI will open up with that ID selected. That makes it
1491 * conceptually clear from which action the user is switching away. */
1492 RNA_int_set(op->ptr, "new_session_uid", int(dna_action->id.session_uid));
1493
1494 return WM_operator_props_dialog_popup(C, op, 400, IFACE_("Replace Action"), IFACE_("Replace"));
1495}
1496
1498{
1499 ui::Layout &layout = *op->layout;
1500 layout.use_property_split_set(true);
1501 ui::template_ID_session_uid(layout, C, op->ptr, "new_session_uid", ID_AC);
1502}
1503
1504/* Note that this operator is similar to "OUTLINER_OT_id_remap" but narrowed in scope to only work
1505 * with actions of `AnimData.action`. */
1507{
1508 ot->name = "Replace Action";
1509 ot->idname = "ANIM_OT_replace_action";
1510 ot->description =
1511 "Swap all users of one action to another one. The normal action slot assignment rules "
1512 "apply. This ignores the NLA and Action Constraints";
1513
1516 ot->ui = replace_action_ui;
1518
1520
1521 PropertyRNA *prop = RNA_def_int(ot->srna,
1522 "old_session_uid",
1523 0,
1524 0,
1525 0,
1526 "Old Action",
1527 "Old Action's session uid to replace",
1528 0,
1529 0);
1531
1532 ot->prop = RNA_def_int(
1533 ot->srna,
1534 "new_session_uid",
1535 0,
1536 0,
1537 0,
1538 "Replacement Action",
1539 "The replacement Action's session uid to remap all selected Action's users to",
1540 0,
1541 0);
1542}
1543
1545{
1546 Main *bmain = CTX_data_main(C);
1547 const uint32_t old_session_uid = RNA_int_get(op->ptr, "old_session_uid");
1548 bAction *dna_action = reinterpret_cast<bAction *>(
1549 BKE_libblock_find_session_uid(bmain, ID_AC, old_session_uid));
1550
1551 if (!dna_action) {
1552 BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Invalid UID for old Action");
1553 return OPERATOR_CANCELLED;
1554 }
1555
1556 bAction *dna_copy = id_cast<bAction *>(BKE_id_copy(bmain, &dna_action->id));
1557 /* `BKE_id_copy` returns an ID with a user count of 1 although no user has yet been assigned. */
1558 id_us_min(&dna_copy->id);
1559 BLI_assert(dna_copy->id.us == 0);
1560
1561 Vector<ID *> failures = replace_action(*bmain, dna_action->wrap(), dna_copy->wrap());
1563
1565
1566 return OPERATOR_FINISHED;
1567}
1568
1570 wmOperator *op,
1571 const blender::wmEvent * /* event */)
1572{
1573 Object *active_object = CTX_data_active_object(C);
1574 BLI_assert(active_object != nullptr);
1575 AnimData *adt = BKE_animdata_from_id(&active_object->id);
1576 bAction *dna_action = adt->action;
1577 BLI_assert(dna_action != nullptr);
1578 RNA_int_set(op->ptr, "old_session_uid", int(dna_action->id.session_uid));
1579
1580 return replace_action_duplicate_exec(C, op);
1581}
1582
1584{
1585 ot->name = "Replace with Duplicate Action";
1586 ot->idname = "ANIM_OT_replace_action_duplicate";
1587 ot->description =
1588 "Duplicates the action of the active object and swaps all users of that action to that "
1589 "duplicate";
1590
1594
1596
1597 PropertyRNA *prop = RNA_def_int(ot->srna,
1598 "old_session_uid",
1599 0,
1600 0,
1601 0,
1602 "Old Action",
1603 "Old Action's session uid to replace",
1604 0,
1605 0);
1607}
1608
1610{
1611 Main *bmain = CTX_data_main(C);
1612 const uint32_t old_session_uid = RNA_int_get(op->ptr, "old_session_uid");
1613 bAction *old_dna_action = reinterpret_cast<bAction *>(
1614 BKE_libblock_find_session_uid(bmain, ID_AC, old_session_uid));
1615
1616 if (!old_dna_action) {
1617 BKE_report(op->reports, RPT_ERROR_INVALID_INPUT, "Invalid UID for old Action");
1618 return OPERATOR_CANCELLED;
1619 }
1620
1621 animrig::Action &old_action = old_dna_action->wrap();
1622 animrig::Action &new_action = animrig::action_add(*bmain, DATA_("Action"));
1623 for (animrig::Slot *old_slot : old_action.slots()) {
1624 animrig::Slot &new_slot = new_action.slot_add();
1625 new_action.slot_identifier_define(new_slot, old_slot->identifier);
1626 }
1627
1628 Vector<ID *> failures = replace_action(*bmain, old_action, new_action);
1630
1632
1633 return OPERATOR_FINISHED;
1634}
1635
1637 wmOperator *op,
1638 const blender::wmEvent * /* event */)
1639{
1640 Object *active_object = CTX_data_active_object(C);
1641 BLI_assert(active_object != nullptr);
1642 AnimData *adt = BKE_animdata_from_id(&active_object->id);
1643 bAction *dna_action = adt->action;
1644 BLI_assert(dna_action != nullptr);
1645 RNA_int_set(op->ptr, "old_session_uid", int(dna_action->id.session_uid));
1646
1647 return replace_action_new_exec(C, op);
1648}
1649
1654{
1655 ot->name = "Replace with New Action";
1656 ot->idname = "ANIM_OT_replace_action_new";
1657 ot->description =
1658 "Swap all users of one action to a new action. This ignores the NLA and Action Constraints";
1659
1663
1665
1666 PropertyRNA *prop = RNA_def_int(ot->srna,
1667 "old_session_uid",
1668 0,
1669 0,
1670 0,
1671 "Old Action",
1672 "Old Action's session uid to replace",
1673 0,
1674 0);
1676}
1677
1679/* -------------------------------------------------------------------- */
1682
1683/* Uniquely identifies an AnimTransformable for a Slot. The StringRefNull is the `rna_path()` of
1684 * the AnimTransformable. */
1685using SlotTransformableID = std::pair<const animrig::Slot *, StringRefNull>;
1686
1688 const Map<SlotTransformableID, int> &num_slot_users_to_visit)
1689{
1690 int unmodified_count = 0;
1691 std::string unmodified_message;
1692 for (const auto &[identifier, value] : num_slot_users_to_visit.items()) {
1693 if (value <= 0) {
1694 continue;
1695 }
1696 if (!unmodified_message.empty()) {
1697 unmodified_message.append(", ");
1698 }
1699 if (identifier.second.is_empty()) {
1700 /* Objects don't have an rna path. Use the slot display name. */
1701 unmodified_message.append(identifier.first->identifier_without_prefix());
1702 }
1703 else {
1704 unmodified_message.append(identifier.second);
1705 }
1706 unmodified_count++;
1707 if (unmodified_count == 3) {
1708 /* The user may modify a lot of transformables at once. More than 3 names will probably
1709 * be just noise. */
1710 unmodified_message.append(", ...");
1711 break;
1712 }
1713 }
1714 return unmodified_message;
1715}
1716
1718{
1719
1720 const eRotationModes mode = eRotationModes(RNA_enum_get(op->ptr, "mode"));
1721 const bool bake = RNA_boolean_get(op->ptr, "bake");
1722 ID *prev_id = nullptr;
1723
1724 /* A map built per action+slot to make it quicker to find the FCurves by RNA path. */
1726 int skipped_datablocks = 0;
1727
1728 /* We need to keep track of the modified rna paths per Slot. That is to
1729 * avoid modifying the same data twice if two transformables with the same rna path share an
1730 * action and slot. The integer value is used to warn the artist that they modified only a subset
1731 * of all users for an rna path in a slot. We store the slot user count when adding elements and
1732 * decrement for each user we visit. */
1733 Map<SlotTransformableID, int> num_slot_users_to_visit;
1734 Set<animrig::Action *> skipped_actions;
1735
1736 Main *bmain = CTX_data_main(C);
1737
1739 *C);
1740 for (ed::AnimTransformable &transformable : selected_transformables) {
1741 /* We cannot skip transformables based on their current rotation mode since that may be
1742 * animated. So `transformable.get_rotation_mode() == mode -> continue` won't work.*/
1743 ID *owner_id = transformable.owner_id();
1744 if (!BKE_id_is_editable(bmain, owner_id)) {
1745 skipped_datablocks++;
1746 continue;
1747 }
1749 *owner_id, [&](animrig::Action &action, const animrig::slot_handle_t slot_handle) {
1750 if (!BKE_id_is_editable(bmain, &action.id)) {
1751 skipped_actions.add(&action);
1752 return true;
1753 }
1754 const animrig::Slot *slot = action.slot_for_handle(slot_handle);
1755 BLI_assert(slot != nullptr);
1756 SlotTransformableID identifier = {slot, transformable.rna_path()};
1757 int *unmodified_count = num_slot_users_to_visit.lookup_ptr(identifier);
1758 if (unmodified_count) {
1759 (*unmodified_count)--;
1760 BLI_assert((*unmodified_count) >= 0);
1761 /* We already modified the given rna path for the slot. Don't do it twice! */
1762 return true;
1763 }
1764 else {
1765 const int slot_user_count = slot->users(*bmain).size();
1766 num_slot_users_to_visit.add(identifier, slot_user_count - 1);
1767 }
1768
1769 if (!data_map.contains({&action, slot_handle})) {
1770 ChannelbagFCurveMap fcurve_map = build_rotation_fcurve_map(action, slot_handle);
1771 data_map.add({&action, slot_handle}, std::move(fcurve_map));
1772 }
1773 ChannelbagFCurveMap &channelbag_fcurve_map = data_map.lookup({&action, slot_handle});
1774 if (bake) {
1775 bake_rotation_fcurves(channelbag_fcurve_map, transformable);
1776 }
1777 convert_rotation_keys(transformable, channelbag_fcurve_map, mode);
1779 return true;
1780 });
1781
1782 /* Convert the property values themselves, regardless of whether they're animated or not. */
1783 ed::Rotation current_rotation = transformable.get_rotation();
1784 transformable.set_rotation_mode(mode);
1785 transformable.set_rotation(current_rotation.converted_to_mode(mode));
1786
1787 if (prev_id != owner_id) {
1790 prev_id = owner_id;
1791 }
1792 }
1793
1794 std::string unmodified_message = visited_slot_users_to_message(num_slot_users_to_visit);
1795 if (!unmodified_message.empty()) {
1796 BKE_reportf(op->reports,
1798 "Multiple users of an action and not all were selected: %s",
1799 unmodified_message.data());
1800 }
1801
1802 if (skipped_datablocks > 0) {
1803 BKE_reportf(op->reports,
1805 "Skipped animated data-blocks because they cannot be edited: %d",
1806 skipped_datablocks);
1807 }
1808
1809 if (skipped_actions.size() > 0) {
1810 BKE_reportf(op->reports,
1812 "Skipped actions because they cannot be edited: %" PRId64,
1813 skipped_actions.size());
1814 }
1815
1816 /* Update the 3d viewport so gizmos are correct. */
1818 return OPERATOR_FINISHED;
1819}
1820
1825
1827{
1828 ot->name = "Convert Rotation Mode";
1829 ot->idname = "ANIM_OT_rotation_mode_convert";
1830 ot->description =
1831 "On all selected, change the rotation mode and convert any existing animation into that new "
1832 "mode";
1833
1834 ot->invoke = WM_menu_invoke;
1837
1839
1840 ot->prop = RNA_def_enum(ot->srna,
1841 "mode",
1844 "Rotation Mode",
1845 "The rotation mode to convert the selection to");
1847 "bake",
1848 false,
1849 "Bake",
1850 "Creates a key on every frame before conversion so interpolation is preserved "
1851 "in the new mode");
1852}
1853
1855
1856/* -------------------------------------------------------------------- */
1859
1861{
1862 /* Animation Editors only -------------------------- */
1864
1867
1870
1872
1873#ifndef NDEBUG
1875#endif
1876
1877 /* Entire UI --------------------------------------- */
1890
1896
1899
1904
1906
1911
1913
1917
1920}
1921
1923{
1924 WM_keymap_ensure(keyconf, "Animation", SPACE_EMPTY, RGN_TYPE_WINDOW);
1925}
1926
1928
1929} // namespace blender
Functions and classes to work with Actions.
Functionality to iterate an Action in various ways.
Functions to work with AnimData.
#define FOREACH_MAIN_ID_END
Definition BKE_main.hh:735
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
Definition BKE_main.hh:729
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define IFACE_(msgid)
#define DATA_(msgid)
ID and Library types, which are fundamental for SDNA.
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
#define MINFRAME
#define MINAFRAME
#define PRVRANGEON
#define MAXFRAME
#define FRAMENUMBER_MIN_CLAMP(cfra)
Defines an abstraction around various structs to modify their transform properties via a unified API ...
#define C
Definition RandGen.cpp:29
#define V2D_LOCK_COPY
Definition UI_view2d.hh:110
#define ND_NLA_ACTCHANGE
Definition WM_types.hh:541
#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 ND_FRAME
Definition WM_types.hh:453
#define ND_SPACE_VIEW3D
Definition WM_types.hh:571
#define ND_KEYFRAME
Definition WM_types.hh:537
#define NC_SPACE
Definition WM_types.hh:405
#define CLAMP(a, b, c)
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
#define ELEM(...)
std::optional< PreScrubbingState > pre_scrubbing
Definition anim_ops.cc:88
const Value * lookup_ptr(const Key &key) const
Definition BLI_map.hh:508
bool add(const Key &key, const Value &value)
Definition BLI_map.hh:295
const Value & lookup(const Key &key) const
Definition BLI_map.hh:545
bool contains(const Key &key) const
Definition BLI_map.hh:353
ItemIterator items() const &
Definition BLI_map.hh:902
int64_t size() const
Definition BLI_set.hh:606
bool add(const Key &key)
Definition BLI_set.hh:248
constexpr int64_t size() const
Definition BLI_span.hh:256
void append(const T &value)
void item(std::string text, int icon1, int icon2=0)
Definition area.cc:1076
Span< const Slot * > slots() const
void slot_identifier_define(Slot &slot, StringRefNull new_identifier)
Slot * slot_for_handle(slot_handle_t handle)
Span< ID * > users(Main &bmain) const
#define FLT_MAX
#define position
#define round
#define abs
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
#define PRId64
Definition inttypes.h:78
decltype(blender::ActionSlot::handle) slot_handle_t
Vector< ID * > find_related_ids(Main &bmain, ID &id)
Definition animdata.cc:62
bool foreach_action_slot_use(const ID &animated_id, FunctionRef< bool(Action &action, slot_handle_t slot_handle)> callback)
Action & action_add(Main &bmain, StringRefNull name)
Action * get_action(ID &animated_id)
bool assign_action(bAction *action, ID &animated_id)
void move_slot(Main &bmain, Slot &slot, Action &from_action, Action &to_action)
Scene * scene_or_sequencer_scene_from_context(const bContext &C)
bNodeTree * node_tree_from_id(ID *id)
Definition node.cc:5337
void POSELIB_OT_asset_delete(wmOperatorType *ot)
void POSELIB_OT_create_pose_asset(wmOperatorType *ot)
void ANIM_OT_world_space_paste(wmOperatorType *ot)
void POSELIB_OT_asset_modify(wmOperatorType *ot)
void ANIM_OT_world_space_copy(wmOperatorType *ot)
ListBaseT< bAnimListElem > get_editable_fcurves(bAnimContext &ac)
bool check_show_strip(const SpaceSeq &sseq)
StripSelection pick_strip_and_handle(const struct Scene *scene, const View2D *v2d, float mouse_co[2])
void sync_active_scene_and_time_with_scene_strip(bContext &C)
void special_preview_set(bContext *C, const int mval[2])
Vector< ed::AnimTransformable > selected_transformables_from_context(bContext &C)
ListBaseT< Strip > * active_seqbase_get(const Editing *ed)
Definition sequencer.cc:463
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:304
void template_ID_session_uid(Layout &layout, bContext *C, PointerRNA *ptr, StringRefNull propname, short idcode)
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1651
float view2d_region_to_view_x(const View2D *v2d, float x)
Definition view2d.cc:1640
void view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
Definition view2d.cc:850
View2D * view2d_fromcontext(const bContext *C)
Definition view2d.cc:1836
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
static void replace_action_common_failure_report(const Span< ID * > failures, ReportList &reports)
Definition anim_ops.cc:1409
static void append_nla_strip_snap_target(bContext *C, const float timeline_frame, Vector< SnapTarget > &r_targets)
Definition anim_ops.cc:328
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static bool merge_actions_selection_poll(bContext *C)
Definition anim_ops.cc:1269
static wmOperatorStatus previewrange_define_exec(bContext *C, wmOperator *op)
Definition anim_ops.cc:1067
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
void grease_pencil_cels_to_keylist(AnimData *, const GreasePencilLayer *gpl, AnimKeylist *keylist, int)
static wmOperatorStatus replace_action_new_invoke(bContext *C, wmOperator *op, const blender::wmEvent *)
Definition anim_ops.cc:1636
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool ED_operator_animview_active(bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
static void replace_action_ui(bContext *C, wmOperator *op)
Definition anim_ops.cc:1497
std::pair< const animrig::Slot *, StringRefNull > SlotTransformableID
Definition anim_ops.cc:1685
int RNA_enum_get(PointerRNA *ptr, const char *name)
void gpl_to_keylist(bDopeSheet *, bGPDlayer *gpl, AnimKeylist *keylist)
@ RPT_ERROR_INVALID_INPUT
Definition BKE_report.hh:42
@ RPT_WARNING
Definition BKE_report.hh:40
Scene * CTX_data_sequencer_scene(const bContext *C)
void ANIM_OT_keyframe_insert_by_name(wmOperatorType *ot)
void BKE_scene_frame_clamp_for_playback(Scene *scene, bool is_playing_forward)
Definition scene.cc:2615
static void ensure_change_frame_keylist(bContext *C, FrameChangeModalData &op_data)
Definition anim_ops.cc:166
static bool need_extra_redraw_after_scrubbing_ends(bContext *C)
Definition anim_ops.cc:747
wmOperatorStatus WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus replace_action_invoke(bContext *C, wmOperator *op, const blender::wmEvent *)
Definition anim_ops.cc:1480
void ED_keymap_anim(wmKeyConfig *keyconf)
Definition anim_ops.cc:1922
MINLINE int round_fl_to_int(float a)
void ANIM_OT_keyframe_delete_by_name(wmOperatorType *ot)
void sequencer_strip_to_keylist(const Strip &strip, AnimKeylist &keylist, Scene &scene)
ID * BKE_libblock_find_session_uid(Main *bmain, short type, uint32_t session_uid)
Definition lib_id.cc:1826
static void ANIM_OT_scene_range_frame(wmOperatorType *ot)
Definition anim_ops.cc:1249
void ANIM_OT_driver_button_remove(wmOperatorType *ot)
Definition drivers.cc:1089
static void ANIM_OT_replace_action_duplicate(wmOperatorType *ot)
Definition anim_ops.cc:1583
static void append_second_snap_target(Scene *scene, const float timeline_frame, const int step, Vector< SnapTarget > &r_targets)
Definition anim_ops.cc:274
static void replace_action_on_id(ID *id, const bAction &old_action, bAction &new_action, Vector< ID * > &r_failures)
Definition anim_ops.cc:1377
static void ANIM_OT_change_frame(wmOperatorType *ot)
Definition anim_ops.cc:889
void ANIM_OT_keying_set_path_remove(wmOperatorType *ot)
static bool replace_action_common_poll(bContext *C)
Definition anim_ops.cc:1396
bool ED_time_scrub_event_in_region(const ARegion *region, const wmEvent *event)
static wmOperatorStatus merge_actions_selection_exec(bContext *C, wmOperator *op)
Definition anim_ops.cc:1287
static wmOperatorStatus previewrange_clear_exec(bContext *C, wmOperator *)
Definition anim_ops.cc:1134
const EnumPropertyItem rna_enum_object_rotation_mode_items[]
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
static float get_snap_threshold(const ToolSettings *tool_settings, const ARegion *region)
Definition anim_ops.cc:159
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void WM_operator_properties_border(wmOperatorType *ot)
void ANIM_OT_keyframe_delete_button(wmOperatorType *ot)
void ANIM_OT_keying_set_active_set(wmOperatorType *ot)
int RNA_int_get(PointerRNA *ptr, const char *name)
void ANIM_OT_keyingset_button_add(wmOperatorType *ot)
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
rctf ANIM_frame_range_view2d_add_xmargin(const View2D &view_2d, const rctf view_rect)
Definition anim_draw.cc:848
@ ANIMTYPE_NLATRACK
static wmOperatorStatus replace_action_new_exec(bContext *C, wmOperator *op)
Definition anim_ops.cc:1609
@ CTX_MODE_OBJECT
SpaceSeq * CTX_wm_space_seq(const bContext *C)
AnimData * BKE_animdata_ensure_id(ID *id)
Definition anim_data.cc:107
void ED_operatortypes_anim()
Definition anim_ops.cc:1860
ScenePlaybackRange BKE_scene_get_playback_range(const Scene *scene)
Definition scene.cc:2607
static void append_marker_snap_target(Scene *scene, const float timeline_frame, Vector< SnapTarget > &r_targets)
Definition anim_ops.cc:260
Global G
Definition blender.cc:57
static std::string change_frame_get_name(wmOperatorType *, PointerRNA *ptr)
Definition anim_ops.cc:880
static void ANIM_OT_rotation_mode_convert(wmOperatorType *ot)
Definition anim_ops.cc:1826
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:93
static void ANIM_OT_replace_action_new(wmOperatorType *ot)
Definition anim_ops.cc:1653
void ANIM_OT_keyingset_button_remove(wmOperatorType *ot)
void ANIM_id_update(Main *bmain, ID *id)
Definition anim_deps.cc:105
unsigned int uint32_t
Definition BKE_text.h:81
bool ED_operator_region_animview_active(bContext *C)
void fcurve_to_keylist(AnimData *adt, FCurve *fcu, AnimKeylist *keylist, const int saction_flag, float2 range, const bool use_nla_remapping)
static wmOperatorStatus debug_channel_list_exec(bContext *C, wmOperator *)
Definition anim_ops.cc:1180
@ ALE_GREASE_PENCIL_CEL
ChannelbagFCurveMap build_rotation_fcurve_map(animrig::Action &action, const animrig::slot_handle_t slot_handle)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags)
static wmOperatorStatus rotation_mode_convert_exec(bContext *C, wmOperator *op)
Definition anim_ops.cc:1717
size_t ANIM_animdata_filter(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode, void *data, const eAnimCont_Types datatype)
std::optional< PreScrubbingState > ED_screen_scrubbing_enable(bContext &C, bScreen &screen)
@ ANIMFILTER_FCURVESONLY
@ ANIMFILTER_LIST_VISIBLE
@ ANIMFILTER_DATA_VISIBLE
@ ANIMFILTER_LIST_CHANNELS
static bool use_playhead_snapping(bContext *C)
Definition anim_ops.cc:657
void DEG_id_tag_update(ID *id, unsigned int flags)
float BKE_scene_frame_get(const Scene *scene)
Definition scene.cc:2595
static Vector< SnapTarget > action_get_snap_targets(bContext *C, FrameChangeModalData &op_data, const float timeline_frame)
Definition anim_ops.cc:439
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
bool convert_rotation_keys(const ed::AnimTransformable &transformable, ChannelbagFCurveMap &channelbag_fcurve_map, const eRotationModes to_mode)
static Vector< ID * > replace_action(Main &bmain, const animrig::Action &old_action, animrig::Action &new_action)
Definition anim_ops.cc:1425
wmWindowManager * CTX_wm_manager(const bContext *C)
static float frame_from_event(bContext *C, const wmEvent *event)
Definition anim_ops.cc:621
static wmOperatorStatus anim_set_sfra_exec(bContext *C, wmOperator *op)
Definition anim_ops.cc:951
void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
void ANIM_OT_keying_set_path_add(wmOperatorType *ot)
void WM_operator_properties_border_to_rcti(wmOperator *op, rcti *r_rect)
static wmOperatorStatus change_frame_exec(bContext *C, wmOperator *op)
Definition anim_ops.cc:611
void ANIM_OT_keyframe_delete_vse(wmOperatorType *ot)
static wmOperatorStatus scene_range_frame_exec(bContext *C, wmOperator *)
Definition anim_ops.cc:1229
void ED_keylist_prepare_for_direct_access(AnimKeylist *keylist)
static bool sequencer_is_mouse_over_handle(const bContext *C, const wmEvent *event)
Definition anim_ops.cc:678
static wmOperatorStatus change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition anim_ops.cc:696
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition wm_keymap.cc:935
static void change_frame_cancel(bContext *C, wmOperator *op)
Definition anim_ops.cc:761
AnimKeylist * ED_keylist_create()
static void change_frame_restore_initial(bContext *C, wmOperator *op)
Definition anim_ops.cc:782
static void ANIM_OT_start_frame_set(wmOperatorType *ot)
Definition anim_ops.cc:991
wmOperatorStatus WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message, const bool show_icon)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static float apply_frame_snap(bContext *C, FrameChangeModalData &op_data, const float frame)
Definition anim_ops.cc:499
static wmOperatorStatus replace_action_duplicate_exec(bContext *C, wmOperator *op)
Definition anim_ops.cc:1544
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
static wmOperatorStatus change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
Definition anim_ops.cc:790
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
@ SCER_LOCK_FRAME_SELECTION
static void change_frame_seq_preview_end(SpaceSeq *sseq)
Definition anim_ops.cc:648
void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot)
void ANIM_OT_copy_driver_button(wmOperatorType *ot)
Definition drivers.cc:1165
static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event, SpaceSeq *sseq)
Definition anim_ops.cc:639
static Vector< SnapTarget > nla_get_snap_targets(bContext *C, const float timeline_frame)
Definition anim_ops.cc:413
static void ANIM_OT_previewrange_clear(wmOperatorType *ot)
Definition anim_ops.cc:1157
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
wmOperatorStatus WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
Map< animrig::Channelbag *, RNAFCurveMap > ChannelbagFCurveMap
void bake_rotation_fcurves(const ChannelbagFCurveMap &channelbag_fcurve_map, const ed::AnimTransformable &transformable)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
Main * CTX_data_main(const bContext *C)
static Vector< SnapTarget > seq_get_snap_targets(bContext *C, FrameChangeModalData &op_data, const float timeline_frame)
Definition anim_ops.cc:372
void ANIM_channel_debug_print_info(bAnimContext &ac, bAnimListElem *ale, short indent_level)
static void ANIM_OT_previewrange_set(wmOperatorType *ot)
Definition anim_ops.cc:1102
static void ANIM_OT_replace_action(wmOperatorType *ot)
Definition anim_ops.cc:1506
static wmOperatorStatus anim_set_efra_exec(bContext *C, wmOperator *op)
Definition anim_ops.cc:1006
int ED_markers_find_nearest_marker_time(ListBaseT< TimeMarker > *markers, float x)
void ANIM_OT_keyframe_clear_vse(wmOperatorType *ot)
void ANIM_animdata_freelist(ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:472
void ANIM_OT_keying_set_remove(wmOperatorType *ot)
@ ANIMPLAY_FLAG_REVERSE
@ ID_RECALC_ALL
Definition DNA_ID.h:1190
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
@ ID_RECALC_ANIMATION_NO_FLUSH
Definition DNA_ID.h:1178
@ ID_RECALC_FRAME_CHANGE
Definition DNA_ID.h:1125
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
float BKE_scene_frame_snap_by_seconds(const Scene *scene, double interval_in_seconds, float frame)
Definition scene.cc:2532
void WM_gesture_box_cancel(bContext *C, wmOperator *op)
static void seq_frame_snap_update_best(const float position, const float timeline_frame, float *r_best_frame, float *r_best_distance)
Definition anim_ops.cc:297
void ANIM_OT_keying_set_add(wmOperatorType *ot)
static void append_frame_snap_target(const Scene *scene, const float timeline_frame, const int step, Vector< SnapTarget > &r_targets)
Definition anim_ops.cc:286
@ KM_RELEASE
Definition WM_types.hh:325
static void ANIM_OT_merge_animation(wmOperatorType *ot)
Definition anim_ops.cc:1357
static void ANIM_OT_end_frame_set(wmOperatorType *ot)
Definition anim_ops.cc:1046
void ANIM_OT_keyframe_insert(wmOperatorType *ot)
void ED_keylist_free(AnimKeylist *keylist)
void DEG_relations_tag_update(Main *bmain)
static std::string visited_slot_users_to_message(const Map< SlotTransformableID, int > &num_slot_users_to_visit)
Definition anim_ops.cc:1687
static void append_keyframe_snap_target(bContext *C, FrameChangeModalData &op_data, const float timeline_frame, Vector< SnapTarget > &r_targets)
Definition anim_ops.cc:247
Scene * CTX_data_scene(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
const ActKeyColumn * ED_keylist_find_closest(const AnimKeylist *keylist, const float cfra)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_UNDO_GROUPED
Definition WM_types.hh:215
@ OPTYPE_BLOCKING
Definition WM_types.hh:192
@ OPTYPE_GRAB_CURSOR_X
Definition WM_types.hh:198
void ED_screen_scrubbing_disable(bContext &C, bScreen &screen, const std::optional< PreScrubbingState > &resume)
bool CTX_data_selected_objects(const bContext *C, Vector< PointerRNA > *list)
void ANIM_OT_keyframe_insert_button(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 append_sequencer_strip_snap_target(const Scene *scene, const float timeline_frame, Vector< SnapTarget > &r_targets)
Definition anim_ops.cc:308
void ANIM_OT_keyframe_delete(wmOperatorType *ot)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
Definition lib_id.cc:2782
void ANIM_OT_driver_button_edit(wmOperatorType *ot)
Definition drivers.cc:1125
ID * BKE_id_copy(Main *bmain, const ID *id)
Definition lib_id.cc:856
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)
Object * CTX_data_active_object(const bContext *C)
void ANIM_OT_driver_button_add(wmOperatorType *ot)
Definition drivers.cc:1040
void id_us_min(ID *id)
Definition lib_id.cc:441
static wmOperatorStatus replace_action_duplicate_invoke(bContext *C, wmOperator *op, const blender::wmEvent *)
Definition anim_ops.cc:1569
void ANIM_OT_paste_driver_button(wmOperatorType *ot)
Definition drivers.cc:1210
ARegion * CTX_wm_region(const bContext *C)
static void ANIM_OT_debug_channel_list(wmOperatorType *ot)
Definition anim_ops.cc:1208
void ED_workspace_status_text(bContext *C, const char *str)
Definition area.cc:1153
static bool change_frame_poll(bContext *C)
Definition anim_ops.cc:116
float RNA_float_get(PointerRNA *ptr, const char *name)
static bool anim_set_end_frames_poll(bContext *C)
Definition anim_ops.cc:929
void ANIM_OT_keyframe_clear_button(wmOperatorType *ot)
static void change_frame_apply(bContext *C, wmOperator *op, const bool always_update)
Definition anim_ops.cc:560
static wmOperatorStatus replace_action_exec(bContext *C, wmOperator *op)
Definition anim_ops.cc:1446
bScreen * ED_screen_animation_playing(const wmWindowManager *wm)
static bool rotation_mode_convert_poll(bContext *C)
Definition anim_ops.cc:1821
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:784
static Vector< SnapTarget > graph_get_snap_targets(bContext *C, FrameChangeModalData &op_data, const float timeline_frame)
Definition anim_ops.cc:467
eRegion_Type regiontype
char name[258]
Definition DNA_ID.h:433
unsigned int session_uid
Definition DNA_ID.h:463
ListBaseT< NlaStrip > strips
struct AnimData * adt
ListBaseT< TimeMarker > markers
struct RenderData r
struct SceneEEVEE eevee
struct ToolSettings * toolsettings
ListBaseT< SpaceLink > spacedata
eGraphEdit_Mode mode
eAnimCont_Types datatype
void use_property_split_set(bool is_sep)
wmEventType type
Definition WM_types.hh:817
const char * undo_group
Definition WM_types.hh:1117
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
void(*) ui(bContext *C, wmOperator *op)
Definition WM_types.hh:1176
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
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
std::string(*) get_name(wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1191
struct ReportList * reports