Blender V5.3
nla_edit.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors, Joshua Leung. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cmath>
10#include <cstdio>
11#include <cstring>
12
13#include "DNA_anim_types.h"
14#include "DNA_object_types.h"
15#include "DNA_scene_types.h"
16#include "DNA_speaker_types.h"
17
18#include "MEM_guardedalloc.h"
19
20#include "BLI_listbase.hh"
21#include "BLI_math_base_c.hh"
22#include "BLI_utildefines.hh"
23
24#include "BLT_translation.hh"
25
26#include "BKE_context.hh"
27#include "BKE_fcurve.hh"
28#include "BKE_lib_id.hh"
29#include "BKE_library.hh"
30#include "BKE_main.hh"
31#include "BKE_nla.hh"
32#include "BKE_report.hh"
33
34#include "ED_anim_api.hh"
35#include "ED_keyframes_edit.hh"
36#include "ED_markers.hh"
37#include "ED_screen.hh"
38
39#include "RNA_access.hh"
40#include "RNA_define.hh"
41#include "RNA_enum_types.hh"
42#include "RNA_prototypes.hh"
43
44#include "UI_interface_icons.hh"
45
46#include "WM_api.hh"
47#include "WM_types.hh"
48
49#include "DEG_depsgraph.hh"
51
52#include "UI_view2d.hh"
53
54#include "ANIM_action.hh"
55#include "ANIM_action_legacy.hh"
56
57#include "nla_intern.hh"
58#include "nla_private.h"
59
60namespace blender {
61
62/* -------------------------------------------------------------------- */
65
67{
68 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
71
72 /* get blocks to work on */
73 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
74
75 for (bAnimListElem &ale : anim_data) {
76 if (!ale.adt) {
77 continue;
78 }
79 if (ale.type != ANIMTYPE_ANIMDATA) {
80 continue;
81 }
82 /* performing auto-blending, extend-mode validation, etc. */
83 BKE_nla_validate_state(static_cast<AnimData *>(ale.data));
84
85 ale.update |= ANIM_UPDATE_DEPS;
86 }
87
88 /* free temp memory */
89 ANIM_animdata_update(ac, &anim_data);
90 ANIM_animdata_freelist(&anim_data);
91}
92
94
95/* 'Special' Editing */
96
97/* 'Tweak mode' allows the action referenced by the active NLA-strip to be edited
98 * as if it were the normal Active-Action of its AnimData block.
99 */
100
101/* -------------------------------------------------------------------- */
104
106{
107 bAnimContext ac;
108
109 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
110
111 const bool do_solo = RNA_boolean_get(op->ptr, "isolate_action");
112 const bool use_upper_stack_evaluation = RNA_boolean_get(op->ptr, "use_upper_stack_evaluation");
113 bool ok = false;
114
115 /* get editor data */
116 if (ANIM_animdata_get_context(C, &ac) == 0) {
117 return OPERATOR_CANCELLED;
118 }
119
120 /* get a list of the AnimData blocks being shown in the NLA */
123 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
124
125 /* if no blocks, popup error? */
126 if (anim_data.is_empty()) {
127 BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweak mode for");
128 return OPERATOR_CANCELLED;
129 }
130
131 /* for each AnimData block with NLA-data, try setting it in tweak-mode */
132 for (bAnimListElem &ale : anim_data) {
133 if (ale.type != ANIMTYPE_ANIMDATA) {
134 continue;
135 }
136 AnimData *adt = static_cast<AnimData *>(ale.data);
137 BLI_assert(adt);
138
139 if (use_upper_stack_evaluation) {
141 }
142 else {
144 }
145
146 /* Try entering tweak-mode if valid. */
147 ok |= BKE_nla_tweakmode_enter({*ale.id, *adt});
148
149 /* mark the active track as being "solo"? */
150 if (do_solo && adt->actstrip) {
152
153 if (nlt && !(nlt->flag & NLATRACK_SOLO)) {
154 BKE_nlatrack_solo_toggle(adt, nlt);
155 }
156 }
157
158 ale.update |= ANIM_UPDATE_DEPS;
159 }
160
161 /* free temp data */
162 ANIM_animdata_update(&ac, &anim_data);
163 ANIM_animdata_freelist(&anim_data);
164
165 /* If we managed to enter tweak-mode on at least one AnimData block,
166 * set the flag for this in the active scene and send notifiers. */
167 if (ac.scene && ok) {
168 /* set editing flag */
170
171 /* set notifier that things have changed */
173 }
174 else {
175 BKE_report(op->reports, RPT_ERROR, "No active strip(s) to enter tweak mode on");
176 return OPERATOR_CANCELLED;
177 }
178
179 /* done */
180 return OPERATOR_FINISHED;
181}
182
184{
185 PropertyRNA *prop;
186
187 /* identifiers */
188 ot->name = "Enter Tweak Mode";
189 ot->idname = "NLA_OT_tweakmode_enter";
190 ot->description =
191 "Enter tweaking mode for the action referenced by the active strip to edit its keyframes";
192
193 /* API callbacks. */
196
197 /* flags */
199
200 /* properties */
201 prop = RNA_def_boolean(ot->srna,
202 "isolate_action",
203 false,
204 "Isolate Action",
205 "Enable 'solo' on the NLA Track containing the active strip, "
206 "to edit it without seeing the effects of the NLA stack");
208
209 prop = RNA_def_boolean(ot->srna,
210 "use_upper_stack_evaluation",
211 false,
212 "Evaluate Upper Stack",
213 "In tweak mode, display the effects of the tracks above the tweak strip");
215}
216
218
219/* -------------------------------------------------------------------- */
222
224{
225 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
226
227 /* get a list of the AnimData blocks being shown in the NLA */
230 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
231
232 /* if no blocks, popup error? */
233 if (anim_data.is_empty()) {
234 BKE_report(ac->reports, RPT_ERROR, "No AnimData blocks in tweak mode to exit from");
235 return false;
236 }
237
238 /* For each AnimData block with NLA-data, try exiting tweak-mode. */
239 for (bAnimListElem &ale : anim_data) {
240 AnimData *adt = static_cast<AnimData *>(ale.data);
241
242 /* clear solo flags */
243 if (do_solo && (adt->flag & ADT_NLA_SOLO_TRACK) && (adt->flag & ADT_NLA_EDIT_ON)) {
244 BKE_nlatrack_solo_toggle(adt, nullptr);
245 }
246
247 /* To be sure that we're doing everything right, just exit tweak-mode. */
248 BKE_nla_tweakmode_exit({*ale.id, *adt});
249
250 ale.update |= ANIM_UPDATE_DEPS;
251 }
252
253 /* free temp data */
254 ANIM_animdata_update(ac, &anim_data);
255 ANIM_animdata_freelist(&anim_data);
256
257 /* Clear the tweak-mode flag in the active scene and send notifiers. */
258 if (ac->scene) {
259 /* clear editing flag */
261
262 /* set notifier that things have changed */
264 }
265
266 /* done */
267 return true;
268}
269
270/* Exit tweak-mode operator callback. */
272{
273 bAnimContext ac;
274
275 const bool do_solo = RNA_boolean_get(op->ptr, "isolate_action");
276 bool ok = false;
277
278 /* get editor data */
279 if (ANIM_animdata_get_context(C, &ac) == 0) {
280 return OPERATOR_CANCELLED;
281 }
282
283 /* perform operation */
284 ok = nlaedit_disable_tweakmode(&ac, do_solo);
285
286 /* success? */
287 if (ok) {
288 return OPERATOR_FINISHED;
289 }
290 return OPERATOR_CANCELLED;
291}
292
294{
295 PropertyRNA *prop;
296
297 /* identifiers */
298 ot->name = "Exit Tweak Mode";
299 ot->idname = "NLA_OT_tweakmode_exit";
300 ot->description = "Exit tweaking mode for the action referenced by the active strip";
301
302 /* API callbacks. */
305
306 /* flags */
308
309 /* properties */
310 prop = RNA_def_boolean(ot->srna,
311 "isolate_action",
312 false,
313 "Isolate Action",
314 "Disable 'solo' on any of the NLA Tracks after exiting tweak mode "
315 "to get things back to normal");
317}
318
320
321/* NLA Strips Range Stuff */
322
323/* -------------------------------------------------------------------- */
326
327/* Get the min/max strip extents */
328static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const bool only_sel)
329{
330 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
331 bool found_bounds = false;
332
333 /* get data to filter */
336 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
337
338 /* set large values to try to override */
339 *min = 999999999.0f;
340 *max = -999999999.0f;
341
342 /* check if any tracks to set range with */
343 if (anim_data.first_) {
344 /* go through tracks, finding max extents */
345 for (bAnimListElem &ale : anim_data) {
346 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
347
348 for (NlaStrip &strip : nlt->strips) {
349 /* only consider selected strips? */
350 if ((only_sel == false) || (strip.flag & NLASTRIP_FLAG_SELECT)) {
351 /* extend range if appropriate */
352 *min = std::min(*min, strip.start);
353 *max = std::max(*max, strip.end);
354
355 found_bounds = true;
356 }
357 }
358 }
359
360 /* free memory */
361 ANIM_animdata_freelist(&anim_data);
362 }
363
364 /* set default range if nothing happened */
365 if (found_bounds == false) {
366 if (ac->scene) {
367 *min = float(ac->scene->r.sfra);
368 *max = float(ac->scene->r.efra);
369 }
370 else {
371 *min = -5;
372 *max = 100;
373 }
374 }
375}
376
378
379/* -------------------------------------------------------------------- */
382
384{
385 bAnimContext ac;
386 Scene *scene;
387 float min, max;
388
389 /* get editor data */
390 if (ANIM_animdata_get_context(C, &ac) == 0) {
391 return OPERATOR_CANCELLED;
392 }
393
394 if (ac.scene == nullptr) {
395 return OPERATOR_CANCELLED;
396 }
397
398 scene = ac.scene;
399
400 /* set the range directly */
401 get_nlastrip_extents(&ac, &min, &max, true);
402 scene->r.flag |= SCER_PRV_RANGE;
403 scene->r.psfra = round_fl_to_int(min);
404 scene->r.pefra = round_fl_to_int(max);
405
406 /* set notifier that things have changed */
407 /* XXX err... there's nothing for frame ranges yet, but this should do fine too */
409
410 return OPERATOR_FINISHED;
411}
412
414{
415 /* identifiers */
416 ot->name = "Set Preview Range to Selected";
417 ot->idname = "NLA_OT_previewrange_set";
418 ot->description = "Set Preview Range based on extents of selected strips";
419
420 /* API callbacks. */
423
424 /* flags */
426}
427
429
430/* -------------------------------------------------------------------- */
433
441static bool nla_tracks_get_selected_extents(bAnimContext *ac, float *r_min, float *r_max)
442{
443 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
444
445 SpaceNla *snla = reinterpret_cast<SpaceNla *>(ac->sl);
446 /* NOTE: not bool, since we want prioritize individual tracks over expanders. */
447 short found = 0;
448
449 /* get all items - we need to do it this way */
452 ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
453
454 /* loop through all tracks, finding the first one that's selected */
455 float ymax = NLATRACK_FIRST_TOP(ac);
456
457 for (bAnimListElem *ale = anim_data.first(); ale; ale = ale->next, ymax -= NLATRACK_STEP(snla)) {
459
460 /* must be selected... */
461 if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) &&
463 {
464 /* update best estimate */
465 *r_min = ymax - NLATRACK_HEIGHT(snla);
466 *r_max = ymax;
467
468 /* is this high enough priority yet? */
469 found = acf->channel_role;
470
471 /* only stop our search when we've found an actual track
472 * - data-block expanders get less priority so that we don't abort prematurely
473 */
474 if (found == ACHANNEL_ROLE_CHANNEL) {
475 break;
476 }
477 }
478 }
479
480 /* free all temp data */
481 ANIM_animdata_freelist(&anim_data);
482
483 return (found != 0);
484}
485
486static wmOperatorStatus nlaedit_viewall(bContext *C, const bool only_sel)
487{
488 bAnimContext ac;
489 View2D *v2d;
490 float extra;
491
492 /* get editor data */
493 if (ANIM_animdata_get_context(C, &ac) == 0) {
494 return OPERATOR_CANCELLED;
495 }
496 v2d = &ac.region->v2d;
497
498 /* set the horizontal range, with an extra offset so that the extreme keys will be in view */
499 get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, only_sel);
500
501 extra = 0.1f * BLI_rctf_size_x(&v2d->cur);
502 v2d->cur.xmin -= extra;
503 v2d->cur.xmax += extra;
504
505 /* set vertical range */
506 if (only_sel == false) {
507 /* view all -> the summary track is usually the shows everything,
508 * and resides right at the top... */
509 v2d->cur.ymax = 0.0f;
510 v2d->cur.ymin = float(-BLI_rcti_size_y(&v2d->mask));
511 }
512 else {
513 /* locate first selected track (or the active one), and frame those */
514 float ymin = v2d->cur.ymin;
515 float ymax = v2d->cur.ymax;
516
517 if (nla_tracks_get_selected_extents(&ac, &ymin, &ymax)) {
518 /* recenter the view so that this range is in the middle */
519 float ymid = (ymax - ymin) / 2.0f + ymin;
520 float x_center;
521
522 ui::view2d_center_get(v2d, &x_center, nullptr);
523 ui::view2d_center_set(v2d, x_center, ymid);
524 }
525 }
526
527 /* do View2D syncing */
529
530 /* just redraw this view */
532
533 return OPERATOR_FINISHED;
534}
535
536/* ......... */
537
539{
540 /* whole range */
541 return nlaedit_viewall(C, false);
542}
543
545{
546 /* only selected */
547 return nlaedit_viewall(C, true);
548}
549
551{
552 /* identifiers */
553 ot->name = "Frame All";
554 ot->idname = "NLA_OT_view_all";
555 ot->description = "Reset viewable area to show full strips range";
556
557 /* API callbacks. */
560
561 /* flags */
562 ot->flag = 0;
563}
564
566{
567 /* identifiers */
568 ot->name = "Frame Selected";
569 ot->idname = "NLA_OT_view_selected";
570 ot->description = "Reset viewable area to show selected strips range";
571
572 /* API callbacks. */
575
576 /* flags */
577 ot->flag = 0;
578}
579
581
582/* -------------------------------------------------------------------- */
585
587{
588 const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
589 ANIM_center_frame(C, smooth_viewtx);
590 return OPERATOR_FINISHED;
591}
592
594{
595 /* identifiers */
596 ot->name = "Go to Current Frame";
597 ot->idname = "NLA_OT_view_frame";
598 ot->description = "Move the view to the current frame";
599
600 /* API callbacks. */
603
604 /* flags */
605 ot->flag = 0;
606}
607
609
610/* NLA Editing Operations (Constructive/Destructive) */
611
612/* -------------------------------------------------------------------- */
618
619/* Get a list of the editable tracks being shown in the NLA. */
620static int nlaedit_get_editable_tracks(bAnimContext *ac, ListBaseT<bAnimListElem> *anim_data)
621{
624 return ANIM_animdata_filter(ac, anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
625}
626
628 wmOperator *op,
629 const wmEvent *event)
630{
631 /* Get editor data. */
632 bAnimContext ac;
633 if (ANIM_animdata_get_context(C, &ac) == 0) {
634 return OPERATOR_CANCELLED;
635 }
636
637 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
638 const size_t items = nlaedit_get_editable_tracks(&ac, &anim_data);
639
640 if (items == 0) {
642 RPT_ERROR,
643 "No active track(s) to add strip to, select an existing track or add one before "
644 "trying again");
645 return OPERATOR_CANCELLED;
646 }
647
648 return WM_enum_search_invoke(C, op, event);
649}
650
651/* add the specified action as new strip */
653{
654 Main *bmain = CTX_data_main(C);
655 bAnimContext ac;
656
657 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
658
659 /* get editor data */
660 if (ANIM_animdata_get_context(C, &ac) == 0) {
661 return OPERATOR_CANCELLED;
662 }
663
664 Scene *scene = ac.scene;
665 float cfra = float(scene->r.cfra);
666
667 /* get action to use */
668 bAction *act = static_cast<bAction *>(
669 BLI_findlink(&bmain->actions, RNA_enum_get(op->ptr, "action")));
670
671 if (act == nullptr) {
672 BKE_report(op->reports, RPT_ERROR, "No valid action to add");
673 // printf("Add strip - actname = '%s'\n", actname);
674 return OPERATOR_CANCELLED;
675 }
676
677 /* add tracks to empty but selected animdata blocks so that strips can be added to those directly
678 * without having to manually add tracks first
679 */
681
682 nlaedit_get_editable_tracks(&ac, &anim_data);
683
684 /* for every active track,
685 * try to add strip to free space in track or to the top of the stack if no space */
686
687 for (bAnimListElem &ale : anim_data) {
688 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
689 AnimData *adt = ale.adt;
690 NlaStrip *strip = nullptr;
691 const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale.id);
692
693 /* Sanity check: only apply actions of the right type for this ID.
694 * NOTE: in the case that this hasn't been set,
695 * we've already warned the user about this already
696 */
697 if ((act->idroot) && (act->idroot != GS(ale.id->name))) {
699 op->reports,
700 RPT_ERROR,
701 "Could not add action '%s' as it cannot be used relative to ID-blocks of type '%s'",
702 act->id.name + 2,
703 ale.id->name);
704 continue;
705 }
706
707 /* create a new strip, and offset it to start on the current frame */
708 BLI_assert(ale.id);
709 BLI_assert_msg(GS(ale.id->name) != ID_AC,
710 "Expecting the owner of an ALE to be the animated ID, not the Action");
711 ID &animated_id = *ale.id;
712 strip = BKE_nlastrip_new(act, animated_id);
713
714 strip->end += (cfra - strip->start);
715 strip->start = cfra;
716
717 /* firstly try adding strip to our current track, but if that fails, add to a new track */
718 if (BKE_nlatrack_add_strip(nlt, strip, is_liboverride) == 0) {
719 /* trying to add to the current failed (no space),
720 * so add a new track to the stack, and add to that...
721 */
722 nlt = BKE_nlatrack_new_tail(&adt->nla_tracks, is_liboverride);
724 BKE_nlatrack_add_strip(nlt, strip, is_liboverride);
725 }
726
727 /* auto-name it */
728 BKE_nlastrip_validate_name(adt, strip);
729 }
730
731 /* free temp data */
732 ANIM_animdata_freelist(&anim_data);
733
734 /* refresh auto strip properties */
736
738
739 /* set notifier that things have changed */
741
742 /* done */
743 return OPERATOR_FINISHED;
744}
745
747{
748 PropertyRNA *prop;
749
750 /* identifiers */
751 ot->name = "Add Action Strip";
752 ot->idname = "NLA_OT_actionclip_add";
753 ot->description =
754 "Add an Action-Clip strip (i.e. an NLA Strip referencing an Action) to the active track";
755
756 /* API callbacks. */
760
761 /* flags */
763
764 /* props */
765 /* TODO: this would be nicer as an ID-pointer. */
766 prop = RNA_def_enum(ot->srna, "action", rna_enum_dummy_NULL_items, 0, "Action", "");
769 ot->prop = prop;
770}
771
773
774/* -------------------------------------------------------------------- */
779
781{
782 bAnimContext ac;
783
784 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
785
786 bool done = false;
787
788 /* get editor data */
789 if (ANIM_animdata_get_context(C, &ac) == 0) {
790 return OPERATOR_CANCELLED;
791 }
792
793 /* get a list of the editable tracks being shown in the NLA */
796 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
797
798 /* for each track, find pairs of strips to add transitions to */
799 for (bAnimListElem &ale : anim_data) {
800 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
801 AnimData *adt = ale.adt;
802 NlaStrip *s1, *s2;
803
804 /* get initial pair of strips */
805 if (ELEM(nlt->strips.first(), nullptr, nlt->strips.last())) {
806 continue;
807 }
808 s1 = nlt->strips.first();
809 s2 = s1->next;
810
811 /* loop over strips */
812 for (; s1 && s2; s1 = s2, s2 = s2->next) {
813 NlaStrip *strip;
814
815 /* check if both are selected */
816 if (ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT))) {
817 continue;
818 }
819 /* check if there's space between the two */
820 if (IS_EQF(s1->end, s2->start)) {
821 continue;
822 }
823 /* make sure neither one is a transition
824 * - although this is impossible to create with the standard tools,
825 * the user may have altered the settings
826 */
827 if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) {
828 continue;
829 }
830 /* also make sure neither one is a soundclip */
831 if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type)) {
832 continue;
833 }
834
835 /* allocate new strip */
836 strip = MEM_new<NlaStrip>("NlaStrip");
837 BLI_insertlinkafter(&nlt->strips, s1, strip);
838
839 /* set the type */
841
842 /* generic settings
843 * - selected flag to highlight this to the user
844 * - auto-blends to ensure that blend in/out values are automatically
845 * determined by overlaps of strips
846 */
848
849 /* range is simply defined as the endpoints of the adjacent strips */
850 strip->start = s1->end;
851 strip->end = s2->start;
852
853 /* scale and repeat aren't of any use, but shouldn't ever be 0 */
854 strip->scale = 1.0f;
855 strip->repeat = 1.0f;
856
857 /* auto-name it */
858 BKE_nlastrip_validate_name(adt, strip);
859
860 /* make note of this */
861 done = true;
862 }
863 }
864
865 /* free temp data */
866 ANIM_animdata_freelist(&anim_data);
867
868 /* was anything added? */
869 if (done) {
870 /* refresh auto strip properties */
872
873 /* set notifier that things have changed */
875
876 /* done */
877 return OPERATOR_FINISHED;
878 }
879
881 RPT_ERROR,
882 "Needs at least a pair of adjacent selected strips with a gap between them");
883 return OPERATOR_CANCELLED;
884}
885
887{
888 /* identifiers */
889 ot->name = "Add Transition";
890 ot->idname = "NLA_OT_transition_add";
891 ot->description = "Add a transition strip between two adjacent selected strips";
892
893 /* API callbacks. */
896
897 /* flags */
899}
900
902
903/* -------------------------------------------------------------------- */
906
908{
909 Main *bmain = CTX_data_main(C);
910 bAnimContext ac;
911
912 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
913
914 /* get editor data */
915 if (ANIM_animdata_get_context(C, &ac) == 0) {
916 return OPERATOR_CANCELLED;
917 }
918
919 Scene *scene = ac.scene;
920 int cfra = scene->r.cfra;
921
922 /* get a list of the editable tracks being shown in the NLA */
925 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
926
927 /* for each track, add sound clips if it belongs to a speaker */
928 /* TODO: what happens if there aren't any tracks,
929 * well that's a more general problem for later. */
930 for (bAnimListElem &ale : anim_data) {
931 Object *ob = reinterpret_cast<Object *>(
932 ale.id); /* may not be object until we actually check! */
933
934 AnimData *adt = ale.adt;
935 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
936 const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale.id);
937
938 /* does this belong to speaker - assumed to live on Object level only */
939 if ((GS(ale.id->name) != ID_OB) || (ob->type != OB_SPEAKER)) {
940 continue;
941 }
942
943 /* create a new strip, and offset it to start on the current frame */
944 NlaStrip *strip = BKE_nla_add_soundstrip(bmain, ac.scene, id_cast<Speaker *>(ob->data));
945
946 strip->start += cfra;
947 strip->end += cfra;
948
949 /* firstly try adding strip to our current track, but if that fails, add to a new track */
950 if (BKE_nlatrack_add_strip(nlt, strip, is_liboverride) == 0) {
951 /* trying to add to the current failed (no space),
952 * so add a new track to the stack, and add to that...
953 */
954 nlt = BKE_nlatrack_new_tail(&adt->nla_tracks, is_liboverride);
956 BKE_nlatrack_add_strip(nlt, strip, is_liboverride);
957 }
958
959 /* auto-name it */
960 BKE_nlastrip_validate_name(adt, strip);
961 }
962
963 /* free temp data */
964 ANIM_animdata_freelist(&anim_data);
965
966 /* refresh auto strip properties */
968
969 /* set notifier that things have changed */
971
972 /* done */
973 return OPERATOR_FINISHED;
974}
975
977{
978 /* identifiers */
979 ot->name = "Add Sound Clip";
980 ot->idname = "NLA_OT_soundclip_add";
981 ot->description = "Add a strip for controlling when speaker plays its sound clip";
982
983 /* API callbacks. */
986
987 /* flags */
989}
990
992
993/* -------------------------------------------------------------------- */
998
999/* add the specified action as new strip */
1001{
1002 bAnimContext ac;
1003
1004 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1005
1006 /* get editor data */
1007 if (ANIM_animdata_get_context(C, &ac) == 0) {
1008 return OPERATOR_CANCELLED;
1009 }
1010
1011 /* get a list of the editable tracks being shown in the NLA */
1014 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1015
1016 /* for each track, find pairs of strips to add transitions to */
1017 for (bAnimListElem &ale : anim_data) {
1018 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
1019 AnimData *adt = ale.adt;
1020
1021 if (BKE_nlatrack_is_nonlocal_in_liboverride(ale.id, nlt)) {
1022 /* No making meta-strips in non-local tracks of override data. */
1023 continue;
1024 }
1025
1026 /* create meta-strips from the continuous chains of selected strips */
1027 BKE_nlastrips_make_metas(&nlt->strips, false);
1028
1029 /* name the metas */
1030 for (NlaStrip &strip : nlt->strips) {
1031 /* auto-name this strip if selected (that means it is a meta) */
1032 if (strip.flag & NLASTRIP_FLAG_SELECT) {
1033 BKE_nlastrip_validate_name(adt, &strip);
1034 }
1035 }
1036
1037 ale.update |= ANIM_UPDATE_DEPS;
1038 }
1039
1040 /* free temp data */
1041 ANIM_animdata_update(&ac, &anim_data);
1042 ANIM_animdata_freelist(&anim_data);
1043
1044 /* set notifier that things have changed */
1046
1047 /* done */
1048 return OPERATOR_FINISHED;
1049}
1050
1052{
1053 /* identifiers */
1054 ot->name = "Add Meta-Strips";
1055 ot->idname = "NLA_OT_meta_add";
1056 ot->description = "Add new meta-strips incorporating the selected strips";
1057
1058 /* API callbacks. */
1061
1062 /* flags */
1064}
1065
1067
1068/* -------------------------------------------------------------------- */
1073
1075{
1076 bAnimContext ac;
1077
1078 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1079
1080 /* get editor data */
1081 if (ANIM_animdata_get_context(C, &ac) == 0) {
1082 return OPERATOR_CANCELLED;
1083 }
1084
1085 /* get a list of the editable tracks being shown in the NLA */
1088 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1089
1090 /* for each track, find pairs of strips to add transitions to */
1091 for (bAnimListElem &ale : anim_data) {
1092 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
1093
1094 if (BKE_nlatrack_is_nonlocal_in_liboverride(ale.id, nlt)) {
1095 /* No removing meta-strips from non-local tracks of override data. */
1096 continue;
1097 }
1098
1099 /* clear all selected meta-strips, regardless of whether they are temporary or not */
1100 BKE_nlastrips_clear_metas(&nlt->strips, true, false);
1101
1102 ale.update |= ANIM_UPDATE_DEPS;
1103 }
1104
1105 /* free temp data */
1106 ANIM_animdata_update(&ac, &anim_data);
1107 ANIM_animdata_freelist(&anim_data);
1108
1109 /* set notifier that things have changed */
1111
1112 /* done */
1113 return OPERATOR_FINISHED;
1114}
1115
1117{
1118 /* identifiers */
1119 ot->name = "Remove Meta-Strips";
1120 ot->idname = "NLA_OT_meta_remove";
1121 ot->description = "Separate out the strips held by the selected meta-strips";
1122
1123 /* API callbacks. */
1126
1127 /* flags */
1129}
1130
1132
1133/* -------------------------------------------------------------------- */
1139
1141{
1142 bAnimContext ac;
1143
1144 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1145
1146 bool linked = RNA_boolean_get(op->ptr, "linked");
1147 bool done = false;
1148
1149 /* get editor data */
1150 if (ANIM_animdata_get_context(C, &ac) == 0) {
1151 return OPERATOR_CANCELLED;
1152 }
1153
1154 /* get a list of editable tracks being shown in the NLA */
1157 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1158
1159 /* duplicate strips in tracks starting from the last one so that we're
1160 * less likely to duplicate strips we just duplicated...
1161 */
1162 for (bAnimListElem &ale : anim_data.items_reversed()) {
1163 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
1164 AnimData *adt = ale.adt;
1165 NlaStrip *strip, *nstrip, *next;
1166 NlaTrack *track;
1167
1168 /* NOTE: We allow this operator in override context because it is almost always (from possible
1169 * default user interactions) paired with the transform one, which will ensure that the new
1170 * strip ends up in a valid (local) track. */
1171
1172 const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale.id);
1173 for (strip = nlt->strips.first(); strip; strip = next) {
1174 next = strip->next;
1175
1176 /* if selected, split the strip at its midpoint */
1177 if (strip->flag & NLASTRIP_FLAG_SELECT) {
1178 /* make a copy (assume that this is possible) */
1179 nstrip = BKE_nlastrip_copy(ac.bmain, strip, linked, 0);
1180
1181 /* in case there's no space in the track above,
1182 * or we haven't got a reference to it yet, try adding */
1183 if (BKE_nlatrack_add_strip(nlt->next, nstrip, is_liboverride) == 0) {
1184 track = BKE_nlatrack_new_after(&adt->nla_tracks, nlt->next, is_liboverride);
1185 BKE_nlatrack_set_active(&adt->nla_tracks, track);
1186 BKE_nlatrack_add_strip(track, nstrip, is_liboverride);
1187 }
1188
1189 /* deselect the original and the active flag */
1191
1192 /* auto-name newly created strip */
1193 BKE_nlastrip_validate_name(adt, nstrip);
1194
1195 done = true;
1196 }
1197 }
1198 }
1199
1200 /* free temp data */
1201 ANIM_animdata_freelist(&anim_data);
1202
1203 if (done) {
1204 /* refresh auto strip properties */
1206
1207 if (!linked) {
1209 }
1210
1211 /* set notifier that things have changed */
1213
1214 /* done */
1215 return OPERATOR_FINISHED;
1216 }
1217
1218 return OPERATOR_CANCELLED;
1219}
1220
1222 wmOperator *op,
1223 const wmEvent * /*event*/)
1224{
1226
1227 return OPERATOR_FINISHED;
1228}
1229
1231{
1232 /* identifiers */
1233 ot->name = "Duplicate Strips";
1234 ot->idname = "NLA_OT_duplicate";
1235 ot->description = "Duplicate selected NLA-Strips, adding the new strips to new track(s)";
1236
1237 /* API callbacks. */
1241
1242 /* flags */
1244
1245 /* own properties */
1246 ot->prop = RNA_def_boolean(ot->srna,
1247 "linked",
1248 false,
1249 "Linked",
1250 "When duplicating strips, assign new copies of the actions they use");
1251}
1252
1254
1255/* -------------------------------------------------------------------- */
1260
1262{
1263 bAnimContext ac;
1264
1265 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1266
1267 /* get editor data */
1268 if (ANIM_animdata_get_context(C, &ac) == 0) {
1269 return OPERATOR_CANCELLED;
1270 }
1271
1272 /* get a list of the editable tracks being shown in the NLA */
1275 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1276
1277 /* for each NLA-Track, delete all selected strips */
1278 for (bAnimListElem &ale : anim_data) {
1279 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
1280 NlaStrip *strip, *nstrip;
1281
1282 if (BKE_nlatrack_is_nonlocal_in_liboverride(ale.id, nlt)) {
1283 /* No deletion of strips in non-local tracks of override data. */
1284 continue;
1285 }
1286
1287 for (strip = nlt->strips.first(); strip; strip = nstrip) {
1288 nstrip = strip->next;
1289
1290 /* if selected, delete */
1291 if (strip->flag & NLASTRIP_FLAG_SELECT) {
1292 /* Fix for #109430. Defensively exit tweak mode before deleting
1293 * the active strip. */
1294 if (ale.adt && ale.adt->actstrip == strip) {
1295 BKE_nla_tweakmode_exit({*ale.id, *ale.adt});
1296 }
1297
1298 /* if a strip either side of this was a transition, delete those too */
1299 if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) {
1300 BKE_nlastrip_remove_and_free(&nlt->strips, strip->prev, true);
1301 }
1302 if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) {
1303 nstrip = nstrip->next;
1304 BKE_nlastrip_remove_and_free(&nlt->strips, strip->next, true);
1305 }
1306
1307 /* finally, delete this strip */
1308 BKE_nlastrip_remove_and_free(&nlt->strips, strip, true);
1309 }
1310 }
1311 }
1312
1313 /* free temp data */
1314 ANIM_animdata_freelist(&anim_data);
1315
1316 /* refresh auto strip properties */
1318
1320
1321 /* set notifier that things have changed */
1323
1324 /* done */
1325 return OPERATOR_FINISHED;
1326}
1327
1329{
1330 /* identifiers */
1331 ot->name = "Delete Strips";
1332 ot->idname = "NLA_OT_delete";
1333 ot->description = "Delete selected strips";
1334
1335 /* API callbacks. */
1338
1339 /* flags */
1341}
1342
1344
1345/* -------------------------------------------------------------------- */
1354
1355/* split a given Action-Clip strip */
1357 Main *bmain, AnimData *adt, NlaTrack *nlt, NlaStrip *strip, float cfra)
1358{
1359 NlaStrip *nstrip;
1360 float splitframe, splitaframe;
1361
1362 /* calculate the frames to do the splitting at
1363 * - use current frame if within extents of strip
1364 */
1365 if ((cfra > strip->start) && (cfra < strip->end)) {
1366 /* use the current frame */
1367 splitframe = cfra;
1368 splitaframe = nlastrip_get_frame(strip, cfra, NLATIME_CONVERT_UNMAP);
1369 }
1370 else {
1371 /* split in the middle */
1372 float len;
1373
1374 /* strip extents */
1375 len = strip->end - strip->start;
1376 if (IS_EQF(len, 0.0f)) {
1377 return;
1378 }
1379
1380 splitframe = strip->start + (len / 2.0f);
1381
1382 /* action range */
1383 len = strip->actend - strip->actstart;
1384 if (IS_EQF(len, 0.0f)) {
1385 splitaframe = strip->actend;
1386 }
1387 else {
1388 splitaframe = strip->actstart + (len / 2.0f);
1389 }
1390 }
1391
1392 /* make a copy (assume that this is possible) and append
1393 * it immediately after the current strip
1394 */
1395 nstrip = BKE_nlastrip_copy(bmain, strip, true, 0);
1396 BLI_insertlinkafter(&nlt->strips, strip, nstrip);
1397
1398 /* Set the endpoint of the first strip and the start of the new strip
1399 * to the split-frame values calculated above.
1400 */
1401 strip->end = splitframe;
1402 nstrip->start = splitframe;
1403
1404 if ((splitaframe > strip->actstart) && (splitaframe < strip->actend)) {
1405 /* only do this if we're splitting down the middle... */
1406 strip->actend = splitaframe;
1407 nstrip->actstart = splitaframe;
1408 }
1409
1410 /* Make sure Sync Length is off. With that setting on, entering and exiting tweak mode would
1411 * effectively undo the split, because both the old and the new strip will be at the length of
1412 * the Action again. */
1415
1416 /* auto-name the new strip */
1417 BKE_nlastrip_validate_name(adt, nstrip);
1418}
1419
1420/* split a given Meta strip */
1422{
1423 /* simply ungroup it for now... */
1425}
1426
1427/* ----- */
1428
1430{
1431 bAnimContext ac;
1432
1433 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1434
1435 /* get editor data */
1436 if (ANIM_animdata_get_context(C, &ac) == 0) {
1437 return OPERATOR_CANCELLED;
1438 }
1439
1440 /* get a list of editable tracks being shown in the NLA */
1443 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1444
1445 /* for each NLA-Track, split all selected strips into two strips */
1446 for (bAnimListElem &ale : anim_data) {
1447 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
1448 AnimData *adt = ale.adt;
1449 NlaStrip *strip, *next;
1450
1451 if (BKE_nlatrack_is_nonlocal_in_liboverride(ale.id, nlt)) {
1452 /* No splitting of strips in non-local tracks of override data. */
1453 continue;
1454 }
1455
1456 for (strip = nlt->strips.first(); strip; strip = next) {
1457 next = strip->next;
1458
1459 /* if selected, split the strip at its midpoint */
1460 if (strip->flag & NLASTRIP_FLAG_SELECT) {
1461 /* splitting method depends on the type of strip */
1462 switch (strip->type) {
1463 case NLASTRIP_TYPE_CLIP: /* action-clip */
1464 nlaedit_split_strip_actclip(ac.bmain, adt, nlt, strip, float(ac.scene->r.cfra));
1465 break;
1466
1467 case NLASTRIP_TYPE_META: /* meta-strips need special handling */
1468 nlaedit_split_strip_meta(nlt, strip);
1469 break;
1470
1471 default: /* for things like Transitions, do not split! */
1472 break;
1473 }
1474 }
1475 }
1476 }
1477
1478 /* free temp data */
1479 ANIM_animdata_freelist(&anim_data);
1480
1481 /* refresh auto strip properties */
1483
1484 /* set notifier that things have changed */
1486
1487 /* done */
1488 return OPERATOR_FINISHED;
1489}
1490
1492{
1493 /* identifiers */
1494 ot->name = "Split Strips";
1495 ot->idname = "NLA_OT_split";
1496 ot->description = "Split selected strips at their midpoints";
1497
1498 /* API callbacks. */
1501
1502 /* flags */
1504}
1505
1507
1508/* NLA Editing Operations (Modifying) */
1509
1510/* -------------------------------------------------------------------- */
1515
1517{
1518 bAnimContext ac;
1519
1520 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1521
1522 /* get editor data */
1523 if (ANIM_animdata_get_context(C, &ac) == 0) {
1524 return OPERATOR_CANCELLED;
1525 }
1526
1527 /* get a list of the editable tracks being shown in the NLA */
1530 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1531
1532 /* go over all selected strips */
1533 for (bAnimListElem &ale : anim_data) {
1534 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
1535
1536 /* For every selected strip, toggle muting. */
1537 for (NlaStrip &strip : nlt->strips) {
1538 if (strip.flag & NLASTRIP_FLAG_SELECT) {
1539 /* just flip the mute flag for now */
1540 /* TODO: have a pre-pass to check if mute all or unmute all? */
1541 strip.flag ^= NLASTRIP_FLAG_MUTED;
1542
1543 /* tag AnimData to get recalculated */
1544 ale.update |= ANIM_UPDATE_DEPS;
1545 }
1546 }
1547 }
1548
1549 /* cleanup */
1550 ANIM_animdata_update(&ac, &anim_data);
1551 ANIM_animdata_freelist(&anim_data);
1552
1553 /* set notifier that things have changed */
1555
1556 /* done */
1557 return OPERATOR_FINISHED;
1558}
1559
1561{
1562 /* identifiers */
1563 ot->name = "Toggle Muting";
1564 ot->idname = "NLA_OT_mute_toggle";
1565 ot->description = "Mute or un-mute selected strips";
1566
1567 /* API callbacks. */
1570
1571 /* flags */
1573}
1574
1576
1577/* -------------------------------------------------------------------- */
1582
1584{
1585 bAnimContext ac;
1586
1587 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1588
1589 /* get editor data */
1590 if (ANIM_animdata_get_context(C, &ac) == 0) {
1591 return OPERATOR_CANCELLED;
1592 }
1593
1594 /* get a list of the editable tracks being shown in the NLA */
1597 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1598
1599 /* consider each track in turn */
1600 for (bAnimListElem &ale : anim_data) {
1601 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
1602
1603 NlaStrip *strip, *stripN = nullptr;
1604 NlaStrip *area = nullptr, *sb = nullptr;
1605 const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale.id);
1606
1607 if (BKE_nlatrack_is_nonlocal_in_liboverride(ale.id, nlt)) {
1608 /* No re-ordering of strips within non-local tracks of override data. */
1609 continue;
1610 }
1611
1612 /* Make temporary meta-strips so that entire islands of selections can be moved around. */
1613 BKE_nlastrips_make_metas(&nlt->strips, true);
1614
1615 /* special case: if there is only 1 island
1616 * (i.e. temp meta BUT NOT unselected/normal/normal-meta strips) left after this,
1617 * and this island has two strips inside it, then we should be able to just swap these still...
1618 */
1619 if (nlt->strips.is_empty() == false) {
1620 NlaStrip *mstrip = nlt->strips.first();
1621
1622 if ((mstrip->flag & NLASTRIP_FLAG_TEMP_META) &&
1624 {
1625 /* remove this temp meta, so that we can see the strips inside */
1626 BKE_nlastrips_clear_metas(&nlt->strips, false, true);
1627 }
1628 }
1629
1630 /* get two selected strips only (these will be metas due to prev step) to operate on
1631 * - only allow swapping 2, as with more the context becomes unclear
1632 */
1633 for (strip = nlt->strips.first(); strip; strip = stripN) {
1634 stripN = strip->next;
1635
1636 if (strip->flag & NLASTRIP_FLAG_SELECT) {
1637 /* first or second strip? */
1638 if (area == nullptr) {
1639 /* store as first */
1640 area = strip;
1641 }
1642 else if (sb == nullptr) {
1643 /* store as second */
1644 sb = strip;
1645 }
1646 else {
1647 /* too many selected */
1648 break;
1649 }
1650 }
1651 }
1652
1653 if (strip) {
1654 /* too many selected warning */
1656 op->reports,
1658 "Too many clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected",
1659 nlt->name);
1660 }
1661 else if (area == nullptr) {
1662 /* no warning as this is just a common case,
1663 * and it may get annoying when doing multiple tracks */
1664 }
1665 else if (sb == nullptr) {
1666 /* too few selected warning */
1668 op->reports,
1670 "Too few clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected",
1671 nlt->name);
1672 }
1673 else {
1674 float nsa[2], nsb[2];
1675
1676 /* remove these strips from the track,
1677 * so that we can test if they can fit in the proposed places */
1678 BLI_remlink(&nlt->strips, area);
1679 BLI_remlink(&nlt->strips, sb);
1680
1681 /* calculate new extents for strips */
1682 /* a --> b */
1683 nsa[0] = sb->start;
1684 nsa[1] = sb->start + (area->end - area->start);
1685 /* b --> a */
1686 nsb[0] = area->start;
1687 nsb[1] = area->start + (sb->end - sb->start);
1688
1689 /* check if the track has room for the strips to be swapped */
1690 if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) &&
1691 BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1]) && (nsb[1] <= nsa[0]))
1692 {
1693 /* set new extents for strips then */
1694 area->start = nsa[0];
1695 area->end = nsa[1];
1697
1698 sb->start = nsb[0];
1699 sb->end = nsb[1];
1701 }
1702 else {
1703 /* not enough room to swap, so show message */
1704 if (nsb[1] > nsa[0]) {
1705 BKE_report(op->reports,
1707 "Cannot swap selected strips because they will overlap each other in their "
1708 "new places");
1709 }
1710 else if ((area->flag & NLASTRIP_FLAG_TEMP_META) || (sb->flag & NLASTRIP_FLAG_TEMP_META)) {
1711 BKE_report(
1712 op->reports,
1714 "Cannot swap selected strips as they will not be able to fit in their new places");
1715 }
1716 else {
1717 BKE_reportf(op->reports,
1719 "Cannot swap '%s' and '%s' as one or both will not be able to fit in their "
1720 "new places",
1721 area->name,
1722 sb->name);
1723 }
1724 }
1725
1726 /* add strips back to track now */
1727 BKE_nlatrack_add_strip(nlt, area, is_liboverride);
1728 BKE_nlatrack_add_strip(nlt, sb, is_liboverride);
1729 }
1730
1731 /* Clear (temp) meta-strips. */
1732 BKE_nlastrips_clear_metas(&nlt->strips, false, true);
1733 }
1734
1735 /* free temp data */
1736 ANIM_animdata_freelist(&anim_data);
1737
1738 /* refresh auto strip properties */
1740
1741 /* set notifier that things have changed */
1744
1745 /* done */
1746 return OPERATOR_FINISHED;
1747}
1748
1750{
1751 /* identifiers */
1752 ot->name = "Swap Strips";
1753 ot->idname = "NLA_OT_swap";
1754 ot->description = "Swap order of selected strips within tracks";
1755
1756 /* API callbacks. */
1757 ot->exec = nlaedit_swap_exec;
1759
1760 /* flags */
1762}
1763
1765
1766/* -------------------------------------------------------------------- */
1771
1773{
1774 bAnimContext ac;
1775
1776 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1777
1778 /* get editor data */
1779 if (ANIM_animdata_get_context(C, &ac) == 0) {
1780 return OPERATOR_CANCELLED;
1781 }
1782
1783 /* get a list of the editable tracks being shown in the NLA */
1786 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1787
1788 /* since we're potentially moving strips from lower tracks to higher tracks, we should
1789 * loop over the tracks in reverse order to avoid moving earlier strips up multiple tracks
1790 */
1791 for (bAnimListElem &ale : anim_data.items_reversed()) {
1792 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
1793 NlaTrack *nltn = nlt->next;
1794 NlaStrip *stripn;
1795
1796 const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale.id);
1797
1798 /* if this track has no tracks after it, skip for now... */
1799 if (nltn == nullptr) {
1800 continue;
1801 }
1802
1803 if (BKE_nlatrack_is_nonlocal_in_liboverride(ale.id, nlt) ||
1805 {
1806 /* No moving of strips in non-local tracks of override data. */
1807 continue;
1808 }
1809
1810 /* for every selected strip, try to move */
1811 for (NlaStrip *strip = nlt->strips.first(); strip; strip = stripn) {
1812 stripn = strip->next;
1813
1814 if (strip->flag & NLASTRIP_FLAG_SELECT) {
1815 /* check if the track above has room for this strip */
1816 if (BKE_nlatrack_has_space(nltn, strip->start, strip->end)) {
1817 /* remove from its current track, and add to the one above
1818 * (it 'should' work, so no need to worry) */
1819 BKE_nlatrack_remove_strip(nlt, strip);
1820 BKE_nlatrack_add_strip(nltn, strip, is_liboverride);
1821 }
1822 }
1823 }
1824 }
1825
1826 /* free temp data */
1827 ANIM_animdata_freelist(&anim_data);
1828
1829 /* refresh auto strip properties */
1831
1832 /* set notifier that things have changed */
1835
1836 /* done */
1837 return OPERATOR_FINISHED;
1838}
1839
1841{
1842 /* identifiers */
1843 ot->name = "Move Strips Up";
1844 ot->idname = "NLA_OT_move_up";
1845 ot->description = "Move selected strips up a track if there's room";
1846
1847 /* API callbacks. */
1850
1851 /* flags */
1853}
1854
1856
1857/* -------------------------------------------------------------------- */
1862
1864{
1865 bAnimContext ac;
1866
1867 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1868
1869 /* get editor data */
1870 if (ANIM_animdata_get_context(C, &ac) == 0) {
1871 return OPERATOR_CANCELLED;
1872 }
1873
1874 /* get a list of the editable tracks being shown in the NLA */
1877 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1878
1879 /* loop through the tracks in normal order, since we're pushing strips down,
1880 * strips won't get operated on twice
1881 */
1882 for (bAnimListElem &ale : anim_data) {
1883 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
1884 NlaTrack *nltp = nlt->prev;
1885 NlaStrip *stripn;
1886
1887 const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale.id);
1888
1889 /* if this track has no tracks before it, skip for now... */
1890 if (nltp == nullptr) {
1891 continue;
1892 }
1893
1894 if (BKE_nlatrack_is_nonlocal_in_liboverride(ale.id, nlt) ||
1896 {
1897 /* No moving of strips in non-local tracks of override data. */
1898 continue;
1899 }
1900
1901 /* for every selected strip, try to move */
1902 for (NlaStrip *strip = nlt->strips.first(); strip; strip = stripn) {
1903 stripn = strip->next;
1904
1905 if (strip->flag & NLASTRIP_FLAG_SELECT) {
1906 /* check if the track below has room for this strip */
1907 if (BKE_nlatrack_has_space(nltp, strip->start, strip->end)) {
1908 /* remove from its current track, and add to the one above
1909 * (it 'should' work, so no need to worry) */
1910 BKE_nlatrack_remove_strip(nlt, strip);
1911 BKE_nlatrack_add_strip(nltp, strip, is_liboverride);
1912 }
1913 }
1914 }
1915 }
1916
1917 /* free temp data */
1918 ANIM_animdata_freelist(&anim_data);
1919
1920 /* refresh auto strip properties */
1922
1923 /* set notifier that things have changed */
1926
1927 /* done */
1928 return OPERATOR_FINISHED;
1929}
1930
1932{
1933 /* identifiers */
1934 ot->name = "Move Strips Down";
1935 ot->idname = "NLA_OT_move_down";
1936 ot->description = "Move selected strips down a track if there's room";
1937
1938 /* API callbacks. */
1941
1942 /* flags */
1944}
1945
1947
1948/* -------------------------------------------------------------------- */
1953
1955{
1956 bAnimContext ac;
1957
1958 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1959 const bool active_only = RNA_boolean_get(op->ptr, "active");
1960
1961 /* get editor data */
1962 if (ANIM_animdata_get_context(C, &ac) == 0) {
1963 return OPERATOR_CANCELLED;
1964 }
1965
1966 /* get a list of the editable tracks being shown in the NLA */
1969 if (active_only) {
1971 }
1972 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
1973
1974 /* for each NLA-Track, apply scale of all selected strips */
1975 for (bAnimListElem &ale : anim_data) {
1976 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
1977
1978 for (NlaStrip &strip : nlt->strips) {
1979 /* strip selection/active status check */
1980 if (active_only) {
1981 if ((strip.flag & NLASTRIP_FLAG_ACTIVE) == 0) {
1982 continue;
1983 }
1984 }
1985 else {
1986 if ((strip.flag & NLASTRIP_FLAG_SELECT) == 0) {
1987 continue;
1988 }
1989 }
1990
1991 /* must be action-clip only (transitions don't have scale) */
1992 if (strip.type == NLASTRIP_TYPE_CLIP) {
1993 if (strip.act == nullptr) {
1994 continue;
1995 }
1996
1998
1999 ale.update |= ANIM_UPDATE_DEPS;
2000 }
2001 }
2002 }
2003
2004 /* free temp data */
2005 ANIM_animdata_update(&ac, &anim_data);
2006 ANIM_animdata_freelist(&anim_data);
2007
2008 /* set notifier that things have changed */
2010
2011 /* done */
2012 return OPERATOR_FINISHED;
2013}
2014
2016{
2017 /* identifiers */
2018 ot->name = "Sync Action Length";
2019 ot->idname = "NLA_OT_action_sync_length";
2020 ot->description =
2021 "Synchronize the length of the referenced Action with the length used in the strip";
2022
2023 /* API callbacks. */
2026
2027 /* flags */
2029
2030 /* properties */
2031 ot->prop = RNA_def_boolean(ot->srna,
2032 "active",
2033 true,
2034 "Active Strip Only",
2035 "Only sync the active length for the active strip");
2036}
2037
2039
2040/* -------------------------------------------------------------------- */
2045
2047{
2048 Main *bmain = CTX_data_main(C);
2049 bAnimContext ac;
2050
2051 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2052 bool copied = false;
2053
2054 /* get editor data */
2055 if (ANIM_animdata_get_context(C, &ac) == 0) {
2056 return OPERATOR_CANCELLED;
2057 }
2058
2059 /* get a list of the editable tracks being shown in the NLA */
2062 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
2063
2064 /* Ensure that each action used only has a single user
2065 * - This is done in reverse order so that the original strips are
2066 * likely to still get to keep their action
2067 */
2068 for (bAnimListElem &ale : anim_data.items_reversed()) {
2069 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
2070
2071 for (NlaStrip &strip : nlt->strips.items_reversed()) {
2072 /* must be action-clip only (as only these have actions) */
2073 if ((strip.flag & NLASTRIP_FLAG_SELECT) && (strip.type == NLASTRIP_TYPE_CLIP)) {
2074 if (strip.act == nullptr) {
2075 continue;
2076 }
2077
2078 /* multi-user? */
2079 if (ID_REAL_USERS(strip.act) > 1) {
2080 /* make a new copy of the action for us to use (it will have 1 user already) */
2081 bAction *new_action = reinterpret_cast<bAction *>(BKE_id_copy(bmain, &strip.act->id));
2082
2083 /* decrement user count of our existing action */
2084 id_us_min(&strip.act->id);
2085
2086 /* switch to the new copy */
2087 strip.act = new_action;
2088
2089 ale.update |= ANIM_UPDATE_DEPS;
2090 copied = true;
2091 }
2092 }
2093 }
2094 }
2095
2096 /* free temp data */
2097 ANIM_animdata_update(&ac, &anim_data);
2098 ANIM_animdata_freelist(&anim_data);
2099
2100 if (copied) {
2102 }
2103
2104 /* set notifier that things have changed */
2106
2107 /* done */
2108 return OPERATOR_FINISHED;
2109}
2110
2112 wmOperator *op,
2113 const wmEvent * /*event*/)
2114{
2115 if (RNA_boolean_get(op->ptr, "confirm")) {
2117 C,
2118 op,
2119 IFACE_("Make Selected Strips Single-User"),
2120 IFACE_("Linked actions will be duplicated for each selected strip."),
2121 IFACE_("Make Single"),
2123 false);
2124 }
2125 return nlaedit_make_single_user_exec(C, op);
2126}
2127
2129{
2130 /* identifiers */
2131 ot->name = "Make Single User";
2132 ot->idname = "NLA_OT_make_single_user";
2133 ot->description = "Make linked action local to each strip";
2134
2135 /* API callbacks. */
2139
2140 /* flags */
2143}
2144
2146
2147/* -------------------------------------------------------------------- */
2152
2153/* apply scaling to keyframe */
2155{
2156 /* NLA-strip which has this scaling is stored in ked->data */
2157 NlaStrip *strip = static_cast<NlaStrip *>(ked->data);
2158
2159 /* adjust all the times */
2160 bezt->vec[0][0] = nlastrip_get_frame(strip, bezt->vec[0][0], NLATIME_CONVERT_MAP);
2161 bezt->vec[1][0] = nlastrip_get_frame(strip, bezt->vec[1][0], NLATIME_CONVERT_MAP);
2162 bezt->vec[2][0] = nlastrip_get_frame(strip, bezt->vec[2][0], NLATIME_CONVERT_MAP);
2163
2164 /* nothing to return or else we exit */
2165 return 0;
2166}
2167
2169{
2170 Main *bmain = CTX_data_main(C);
2171 bAnimContext ac;
2172
2173 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2174 bool copied = false;
2175
2176 KeyframeEditData ked = {{nullptr}};
2177
2178 /* get editor data */
2179 if (ANIM_animdata_get_context(C, &ac) == 0) {
2180 return OPERATOR_CANCELLED;
2181 }
2182
2183 /* get a list of the editable tracks being shown in the NLA */
2186 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
2187
2188 /* for each NLA-Track, apply scale of all selected strips */
2189 for (bAnimListElem &ale : anim_data) {
2190 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
2191
2192 for (NlaStrip &strip : nlt->strips) {
2193 /* strip must be selected, and must be action-clip only
2194 * (transitions don't have scale) */
2195 if ((strip.flag & NLASTRIP_FLAG_SELECT) && (strip.type == NLASTRIP_TYPE_CLIP)) {
2196 if (strip.act == nullptr || ID_IS_OVERRIDE_LIBRARY(strip.act) ||
2197 !ID_IS_EDITABLE(strip.act))
2198 {
2199 continue;
2200 }
2201 /* if the referenced action is used by other strips,
2202 * make this strip use its own copy */
2203 if (strip.act->id.us > 1) {
2204 /* make a copy of the Action to work on */
2205 bAction *act = reinterpret_cast<bAction *>(BKE_id_copy(bmain, &strip.act->id));
2206
2207 /* set this as the new referenced action,
2208 * decrementing the users of the old one */
2209 id_us_min(&strip.act->id);
2210 strip.act = act;
2211
2212 copied = true;
2213 }
2214
2215 /* setup iterator, and iterate over all the keyframes in the action,
2216 * applying this scaling */
2217 animrig::Action &action = strip.act->wrap();
2219 strip.action_slot_handle);
2220 ked.data = &strip;
2221 for (FCurve *fcurve : fcurves) {
2223 &ked, fcurve, nullptr, bezt_apply_nlamapping, BKE_fcurve_handles_recalc);
2224 }
2225
2226 /* clear scale of strip now that it has been applied,
2227 * and recalculate the extents of the action now that it has been scaled
2228 * but leave everything else alone
2229 */
2230 const float start = nlastrip_get_frame(&strip, strip.actstart, NLATIME_CONVERT_MAP);
2231 const float end = nlastrip_get_frame(&strip, strip.actend, NLATIME_CONVERT_MAP);
2232
2233 if (strip.act->flag & ACT_FRAME_RANGE) {
2235 &strip, strip.act->frame_start, NLATIME_CONVERT_MAP);
2237 &strip, strip.act->frame_end, NLATIME_CONVERT_MAP);
2238 }
2239
2240 strip.scale = 1.0f;
2241 strip.actstart = start;
2242 strip.actend = end;
2243
2244 /* We have to update the action itself. Tagging the bAnimListElem will just update the ID
2245 * owning the NLA, not the action itself. This may be a bug of ANIM_animdata_update but so
2246 * far no other operator had issues with this so for this 5.0 fix I (Christoph) kept the
2247 * scope of the change small. */
2249 ale.update |= ANIM_UPDATE_DEPS;
2250 }
2251 }
2252 }
2253
2254 /* free temp data */
2255 ANIM_animdata_update(&ac, &anim_data);
2256 ANIM_animdata_freelist(&anim_data);
2257
2258 if (copied) {
2260 }
2261
2262 /* set notifier that things have changed */
2264
2265 /* done */
2266 return OPERATOR_FINISHED;
2267}
2268
2270{
2271 /* identifiers */
2272 ot->name = "Apply Scale";
2273 ot->idname = "NLA_OT_apply_scale";
2274 ot->description = "Apply scaling of selected strips to their referenced Actions";
2275
2276 /* API callbacks. */
2279
2280 /* flags */
2282}
2283
2285
2286/* -------------------------------------------------------------------- */
2291
2293{
2294 bAnimContext ac;
2295
2296 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2297
2298 /* get editor data */
2299 if (ANIM_animdata_get_context(C, &ac) == 0) {
2300 return OPERATOR_CANCELLED;
2301 }
2302
2303 /* get a list of the editable tracks being shown in the NLA */
2306 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
2307
2308 /* for each NLA-Track, reset scale of all selected strips */
2309 for (bAnimListElem &ale : anim_data) {
2310 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
2311
2312 for (NlaStrip &strip : nlt->strips) {
2313 /* strip must be selected, and must be action-clip only
2314 * (transitions don't have scale) */
2315 if ((strip.flag & NLASTRIP_FLAG_SELECT) && (strip.type == NLASTRIP_TYPE_CLIP)) {
2316 PointerRNA strip_ptr = RNA_pointer_create_discrete(nullptr, RNA_NlaStrip, &strip);
2317 RNA_float_set(&strip_ptr, "scale", 1.0f);
2318 }
2319 }
2320 }
2321
2322 /* free temp data */
2323 ANIM_animdata_freelist(&anim_data);
2324
2325 /* refresh auto strip properties */
2327
2328 /* set notifier that things have changed */
2330
2331 /* done */
2332 return OPERATOR_FINISHED;
2333}
2334
2336{
2337 /* identifiers */
2338 ot->name = "Clear Scale";
2339 ot->idname = "NLA_OT_clear_scale";
2340 ot->description = "Reset scaling of selected strips";
2341
2342 /* API callbacks. */
2345
2346 /* flags */
2348}
2349
2351
2352/* -------------------------------------------------------------------- */
2357
2358/* defines for snap keyframes tool */
2360 {NLAEDIT_SNAP_CFRA, "CFRA", 0, "Selection to Current Frame", ""},
2361 /* XXX as single entry? */
2362 {NLAEDIT_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Selection to Nearest Frame", ""},
2363 /* XXX as single entry? */
2364 {NLAEDIT_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Selection to Nearest Second", ""},
2365 {NLAEDIT_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Selection to Nearest Marker", ""},
2366 {0, nullptr, 0, nullptr, nullptr},
2367};
2368
2370{
2371 bAnimContext ac;
2372
2373 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2374
2375 Scene *scene;
2376 int mode = RNA_enum_get(op->ptr, "type");
2377 float secf;
2378
2379 /* get editor data */
2380 if (ANIM_animdata_get_context(C, &ac) == 0) {
2381 return OPERATOR_CANCELLED;
2382 }
2383
2384 /* get a list of the editable tracks being shown in the NLA */
2387 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
2388
2389 /* get some necessary vars */
2390 scene = ac.scene;
2391 secf = float(scene->frames_per_second());
2392
2393 bool any_added = false;
2394
2395 /* since we may add tracks, perform this in reverse order */
2396 for (bAnimListElem &ale : anim_data.items_reversed()) {
2397 ListBaseT<NlaStrip> tmp_strips = {nullptr, nullptr};
2398 AnimData *adt = ale.adt;
2399 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
2400 NlaStrip *stripn;
2401 NlaTrack *track;
2402
2403 const bool is_liboverride = ID_IS_OVERRIDE_LIBRARY(ale.id);
2404
2405 /* create meta-strips from the continuous chains of selected strips */
2406 BKE_nlastrips_make_metas(&nlt->strips, true);
2407
2408 /* apply the snapping to all the temp meta-strips, then put them in a separate list to be added
2409 * back to the original only if they still fit
2410 */
2411 for (NlaStrip *strip = nlt->strips.first(); strip; strip = stripn) {
2412 stripn = strip->next;
2413
2414 if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
2415 float start, end;
2416
2417 /* get the existing end-points */
2418 start = strip->start;
2419 end = strip->end;
2420
2421 /* calculate new start position based on snapping mode */
2422 switch (mode) {
2423 case NLAEDIT_SNAP_CFRA: /* to current frame */
2424 strip->start = float(scene->r.cfra);
2425 break;
2426 case NLAEDIT_SNAP_NEAREST_FRAME: /* to nearest frame */
2427 strip->start = floorf(start + 0.5f);
2428 break;
2429 case NLAEDIT_SNAP_NEAREST_SECOND: /* to nearest second */
2430 strip->start = floorf(start / secf + 0.5f) * secf;
2431 break;
2432 case NLAEDIT_SNAP_NEAREST_MARKER: /* to nearest marker */
2433 strip->start = float(ED_markers_find_nearest_marker_time(ac.markers, start));
2434 break;
2435 default: /* just in case... no snapping */
2436 strip->start = start;
2437 break;
2438 }
2439
2440 /* get new endpoint based on start-point (and old length) */
2441 strip->end = strip->start + (end - start);
2442
2443 /* apply transforms to meta-strip to its children */
2445
2446 /* remove strip from track, and add to the temp buffer */
2447 BLI_remlink(&nlt->strips, strip);
2448 BLI_addtail(&tmp_strips, strip);
2449 }
2450 }
2451
2452 /* try adding each meta-strip back to the track one at a time, to make sure they'll fit */
2453 for (NlaStrip *strip = tmp_strips.first(); strip; strip = stripn) {
2454 stripn = strip->next;
2455
2456 /* remove from temp-strips list */
2457 BLI_remlink(&tmp_strips, strip);
2458
2459 /* in case there's no space in the current track, try adding */
2460 if (BKE_nlatrack_add_strip(nlt, strip, is_liboverride) == 0) {
2461 /* need to add a new track above the current one */
2462 track = BKE_nlatrack_new_after(&adt->nla_tracks, nlt, is_liboverride);
2463 BKE_nlatrack_set_active(&adt->nla_tracks, track);
2464 BKE_nlatrack_add_strip(track, strip, is_liboverride);
2465
2466 /* clear temp meta-strips on this new track,
2467 * as we may not be able to get back to it */
2468 BKE_nlastrips_clear_metas(&track->strips, false, true);
2469
2470 any_added = true;
2471 }
2472 }
2473
2474 /* remove the meta-strips now that we're done */
2475 BKE_nlastrips_clear_metas(&nlt->strips, false, true);
2476
2477 /* tag for recalculating the animation */
2478 ale.update |= ANIM_UPDATE_DEPS;
2479 }
2480
2481 /* cleanup */
2482 ANIM_animdata_update(&ac, &anim_data);
2483 ANIM_animdata_freelist(&anim_data);
2484
2485 /* refresh auto strip properties */
2487
2488 /* set notifier that things have changed */
2490 if (any_added) {
2492 }
2493
2494 /* done */
2495 return OPERATOR_FINISHED;
2496}
2497
2499{
2500 /* identifiers */
2501 ot->name = "Snap Strips";
2502 ot->idname = "NLA_OT_snap";
2503 ot->description = "Move start of strips to specified time";
2504
2505 /* API callbacks. */
2506 ot->invoke = WM_menu_invoke;
2507 ot->exec = nlaedit_snap_exec;
2509
2510 /* flags */
2512
2513 /* properties */
2514 ot->prop = RNA_def_enum(ot->srna, "type", prop_nlaedit_snap_types, 0, "Type", "");
2515}
2516
2518
2519/* NLA Modifiers */
2520
2521/* -------------------------------------------------------------------- */
2524
2526 PointerRNA * /*ptr*/,
2527 PropertyRNA * /*prop*/,
2528 bool *r_free)
2529{
2530 EnumPropertyItem *item = nullptr;
2531 int totitem = 0;
2532 int i = 0;
2533
2534 if (C == nullptr) {
2536 }
2537
2538 /* start from 1 to skip the 'Invalid' modifier type */
2539 for (i = 1; i < FMODIFIER_NUM_TYPES; i++) {
2541 int index;
2542
2543 /* check if modifier is valid for this context */
2544 if (fmi == nullptr) {
2545 continue;
2546 }
2547 if (i == FMODIFIER_TYPE_CYCLES) { /* we already have repeat... */
2548 continue;
2549 }
2550
2552 if (index != -1) { /* Not all types are implemented yet... */
2554 }
2555 }
2556
2557 RNA_enum_item_end(&item, &totitem);
2558 *r_free = true;
2559
2560 return item;
2561}
2562
2564{
2565 bAnimContext ac;
2566
2567 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2568
2569 FModifier *fcm;
2570 int type = RNA_enum_get(op->ptr, "type");
2571 const bool active_only = RNA_boolean_get(op->ptr, "only_active");
2572
2573 /* get editor data */
2574 if (ANIM_animdata_get_context(C, &ac) == 0) {
2575 return OPERATOR_CANCELLED;
2576 }
2577
2578 /* get a list of the editable tracks being shown in the NLA */
2581 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
2582
2583 /* for each NLA-Track, add the specified modifier to all selected strips */
2584 for (bAnimListElem &ale : anim_data) {
2585 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
2586
2587 if (BKE_nlatrack_is_nonlocal_in_liboverride(ale.id, nlt)) {
2588 /* No adding f-modifiers to strips in non-local tracks of override data. */
2589 continue;
2590 }
2591
2592 for (NlaStrip &strip : nlt->strips) {
2593 /* can F-Modifier be added to the current strip? */
2594 if (active_only) {
2595 /* if not active, cannot add since we're only adding to active strip */
2596 if ((strip.flag & NLASTRIP_FLAG_ACTIVE) == 0) {
2597 continue;
2598 }
2599 }
2600 else {
2601 /* strip must be selected, since we're not just doing active */
2602 if ((strip.flag & NLASTRIP_FLAG_SELECT) == 0) {
2603 continue;
2604 }
2605 }
2606
2607 /* sound clips are not affected by FModifiers */
2608 if (strip.type == NLASTRIP_TYPE_SOUND) {
2609 continue;
2610 }
2611
2612 /* add F-Modifier of specified type to selected, and make it the active one */
2613 fcm = add_fmodifier(&strip.modifiers, type, nullptr);
2614
2615 if (fcm) {
2616 set_active_fmodifier(&strip.modifiers, fcm);
2617 ale.update |= ANIM_UPDATE_DEPS;
2618 }
2619 else {
2620 BKE_reportf(op->reports,
2621 RPT_ERROR,
2622 "Modifier could not be added to (%s : %s) (see console for details)",
2623 nlt->name,
2624 strip.name);
2625 }
2626 }
2627 }
2628
2629 /* free temp data */
2630 ANIM_animdata_update(&ac, &anim_data);
2631 ANIM_animdata_freelist(&anim_data);
2632
2633 /* set notifier that things have changed */
2635
2636 /* done */
2637 return OPERATOR_FINISHED;
2638}
2639
2641{
2642 PropertyRNA *prop;
2643
2644 /* identifiers */
2645 ot->name = "Add F-Modifier";
2646 ot->idname = "NLA_OT_fmodifier_add";
2647 ot->description = "Add F-Modifier to the active/selected NLA-Strips";
2648
2649 /* API callbacks. */
2650 ot->invoke = WM_menu_invoke;
2653
2654 /* flags */
2656
2657 /* id-props */
2658 ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_fmodifier_type_items, 0, "Type", "");
2661
2662 prop = RNA_def_boolean(ot->srna,
2663 "only_active",
2664 true,
2665 "Only Active",
2666 "Only add a F-Modifier of the specified type to the active strip");
2668}
2669
2671
2672/* -------------------------------------------------------------------- */
2675
2677{
2678 bAnimContext ac;
2679 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2680 bool ok = false;
2681
2682 /* get editor data */
2683 if (ANIM_animdata_get_context(C, &ac) == 0) {
2684 return OPERATOR_CANCELLED;
2685 }
2686
2687 /* clear buffer first */
2689
2690 /* get a list of the editable tracks being shown in the NLA */
2693 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
2694
2695 /* for each NLA-Track, add the specified modifier to all selected strips */
2696 for (bAnimListElem &ale : anim_data) {
2697 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
2698
2699 for (NlaStrip &strip : nlt->strips) {
2700 /* only add F-Modifier if on active strip? */
2701 if ((strip.flag & NLASTRIP_FLAG_ACTIVE) == 0) {
2702 continue;
2703 }
2704
2705 /* TODO: when 'active' vs 'all' boolean is added, change last param! */
2706 ok |= ANIM_fmodifiers_copy_to_buf(&strip.modifiers, false);
2707 }
2708 }
2709
2710 /* free temp data */
2711 ANIM_animdata_freelist(&anim_data);
2712
2713 /* successful or not? */
2714 if (ok == 0) {
2715 BKE_report(op->reports, RPT_ERROR, "No F-Modifiers available to be copied");
2716 return OPERATOR_CANCELLED;
2717 }
2718
2719 /* no updates needed - copy is non-destructive operation */
2720 return OPERATOR_FINISHED;
2721}
2722
2724{
2725 /* identifiers */
2726 ot->name = "Copy F-Modifiers";
2727 ot->idname = "NLA_OT_fmodifier_copy";
2728 ot->description = "Copy the F-Modifier(s) of the active NLA-Strip";
2729
2730 /* API callbacks. */
2733
2734 /* flags */
2736
2737 /* id-props */
2738#if 0
2739 ot->prop = RNA_def_boolean(ot->srna,
2740 "all",
2741 1,
2742 "All F-Modifiers",
2743 "Copy all the F-Modifiers, instead of just the active one");
2744#endif
2745}
2746
2748
2749/* -------------------------------------------------------------------- */
2752
2754{
2755 bAnimContext ac;
2756 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
2757 int ok = 0;
2758
2759 const bool active_only = RNA_boolean_get(op->ptr, "only_active");
2760 const bool replace = RNA_boolean_get(op->ptr, "replace");
2761
2762 /* get editor data */
2763 if (ANIM_animdata_get_context(C, &ac) == 0) {
2764 return OPERATOR_CANCELLED;
2765 }
2766
2767 /* get a list of the editable tracks being shown in the NLA */
2770 ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
2771
2772 /* for each NLA-Track, add the specified modifier to all selected strips */
2773 for (bAnimListElem &ale : anim_data) {
2774 NlaTrack *nlt = static_cast<NlaTrack *>(ale.data);
2775
2776 if (BKE_nlatrack_is_nonlocal_in_liboverride(ale.id, nlt)) {
2777 /* No pasting in non-local tracks of override data. */
2778 continue;
2779 }
2780
2781 for (NlaStrip &strip : nlt->strips) {
2782 /* can F-Modifier be added to the current strip? */
2783 if (active_only) {
2784 /* if not active, cannot add since we're only adding to active strip */
2785 if ((strip.flag & NLASTRIP_FLAG_ACTIVE) == 0) {
2786 continue;
2787 }
2788 }
2789 else {
2790 /* strip must be selected, since we're not just doing active */
2791 if ((strip.flag & NLASTRIP_FLAG_SELECT) == 0) {
2792 continue;
2793 }
2794 }
2795
2796 /* paste FModifiers from buffer */
2797 ok += ANIM_fmodifiers_paste_from_buf(&strip.modifiers, replace, nullptr);
2798 ale.update |= ANIM_UPDATE_DEPS;
2799 }
2800 }
2801
2802 /* clean up */
2803 ANIM_animdata_update(&ac, &anim_data);
2804 ANIM_animdata_freelist(&anim_data);
2805
2806 /* successful or not? */
2807 if (ok) {
2809 return OPERATOR_FINISHED;
2810 }
2811
2812 BKE_report(op->reports, RPT_ERROR, "No F-Modifiers to paste");
2813 return OPERATOR_CANCELLED;
2814}
2815
2817{
2818 /* identifiers */
2819 ot->name = "Paste F-Modifiers";
2820 ot->idname = "NLA_OT_fmodifier_paste";
2821 ot->description = "Add copied F-Modifiers to the selected NLA-Strips";
2822
2823 /* API callbacks. */
2826
2827 /* flags */
2829
2830 /* properties */
2831 ot->prop = RNA_def_boolean(
2832 ot->srna, "only_active", true, "Only Active", "Only paste F-Modifiers on active strip");
2834
2836 ot->srna,
2837 "replace",
2838 false,
2839 "Replace Existing",
2840 "Replace existing F-Modifiers, instead of just appending to the end of the existing list");
2841}
2842
2844
2845} // namespace blender
Functions and classes to work with Actions.
Functions for backward compatibility with the legacy Action API.
#define BLT_I18NCONTEXT_ID_ACTION
#define IFACE_(msgid)
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_REAL_USERS(id)
Definition DNA_ID.h:679
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
Object is a sort of wrapper for general info.
#define NLATRACK_FIRST_TOP(ac)
#define NLATRACK_STEP(snla)
#define NLATRACK_HEIGHT(snla)
Read Blender memory allocation and freeing.
#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 NA_EDITED
Definition WM_types.hh:634
#define ND_FRAME
Definition WM_types.hh:453
#define NA_REMOVED
Definition WM_types.hh:637
#define ND_NLA_ORDER
Definition WM_types.hh:543
#define ND_NLA
Definition WM_types.hh:540
#define ELEM(...)
#define IS_EQF(a, b)
#define BLI_assert_msg(a, msg)
btScalar max
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
Span< FCurve * > fcurves_for_action_slot(Action &action, slot_handle_t slot_handle)
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.
float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode)
void WM_main_add_notifier(uint type, void *reference)
static wmOperatorStatus nlaedit_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *)
Definition nla_edit.cc:1221
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus nlaedit_toggle_mute_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:1516
void NLA_OT_delete(wmOperatorType *ot)
Definition nla_edit.cc:1328
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
ScrArea * CTX_wm_area(const bContext *C)
short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
static void nlaedit_split_strip_actclip(Main *bmain, AnimData *adt, NlaTrack *nlt, NlaStrip *strip, float cfra)
Definition nla_edit.cc:1356
int RNA_enum_get(PointerRNA *ptr, const char *name)
const EnumPropertyItem rna_enum_fmodifier_type_items[]
Definition rna_fcurve.cc:31
void NLA_OT_transition_add(wmOperatorType *ot)
Definition nla_edit.cc:886
@ RPT_WARNING
Definition BKE_report.hh:40
void NLA_OT_previewrange_set(wmOperatorType *ot)
Definition nla_edit.cc:413
const bAnimChannelType * ANIM_channel_get_typeinfo(const bAnimListElem *ale)
bool ED_operator_region_nla_active(bContext *C)
bool ED_operator_nla_active(bContext *C)
static wmOperatorStatus nlaedit_move_up_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:1772
static wmOperatorStatus nlaedit_make_single_user_invoke(bContext *C, wmOperator *op, const wmEvent *)
Definition nla_edit.cc:2111
static wmOperatorStatus nlaedit_viewsel_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:544
void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
void ED_nla_postop_refresh(bAnimContext *ac)
Definition nla_edit.cc:66
MINLINE int round_fl_to_int(float a)
void NLA_OT_fmodifier_paste(wmOperatorType *ot)
Definition nla_edit.cc:2816
NlaStrip * BKE_nla_add_soundstrip(Main *bmain, Scene *scene, Speaker *speaker)
@ NLASTRIP_FLAG_SELECT
@ NLASTRIP_FLAG_ACTIVE
@ NLASTRIP_FLAG_MUTED
@ NLASTRIP_FLAG_SYNC_LENGTH
@ NLASTRIP_FLAG_AUTO_BLENDS
@ NLASTRIP_FLAG_TEMP_META
void BKE_nlatrack_set_active(ListBaseT< NlaTrack > *tracks, NlaTrack *nlt)
void NLA_OT_move_down(wmOperatorType *ot)
Definition nla_edit.cc:1931
bool BKE_nlatrack_add_strip(NlaTrack *nlt, NlaStrip *strip, bool is_liboverride)
@ 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)
int WM_operator_smooth_viewtx_get(const wmOperator *op)
static wmOperatorStatus nlaedit_add_meta_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:1000
@ ADT_NLA_EVAL_UPPER_TRACKS
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
NlaTrack * BKE_nlatrack_find_tweaked(AnimData *adt)
static wmOperatorStatus nlaedit_duplicate_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:1140
void NLA_OT_mute_toggle(wmOperatorType *ot)
Definition nla_edit.cc:1560
FModifier * add_fmodifier(ListBaseT< FModifier > *modifiers, int type, FCurve *owner_fcu)
static int nlaedit_get_editable_tracks(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data)
Definition nla_edit.cc:620
void NLA_OT_split(wmOperatorType *ot)
Definition nla_edit.cc:1491
void NLA_OT_view_all(wmOperatorType *ot)
Definition nla_edit.cc:550
@ ANIMTYPE_ANIMDATA
static const EnumPropertyItem prop_nlaedit_snap_types[]
Definition nla_edit.cc:2359
void NLA_OT_actionclip_add(wmOperatorType *ot)
Definition nla_edit.cc:746
static wmOperatorStatus nlaedit_add_transition_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:780
void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
int RNA_enum_from_value(const EnumPropertyItem *item, const int value)
void NLA_OT_meta_add(wmOperatorType *ot)
Definition nla_edit.cc:1051
short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
void ANIM_animdata_update(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:365
void NLA_OT_tweakmode_exit(wmOperatorType *ot)
Definition nla_edit.cc:293
@ ACHANNEL_ROLE_CHANNEL
const EnumPropertyItem * RNA_action_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
static wmOperatorStatus nlaedit_move_down_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:1863
void BKE_nla_tweakmode_exit(OwnedAnimData owned_adt)
void NLA_OT_fmodifier_copy(wmOperatorType *ot)
Definition nla_edit.cc:2723
static wmOperatorStatus nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:105
@ FMODIFIER_TYPE_CYCLES
@ FMODIFIER_NUM_TYPES
static void nlaedit_split_strip_meta(NlaTrack *nlt, NlaStrip *strip)
Definition nla_edit.cc:1421
bool nlaop_poll_tweakmode_on(bContext *C)
Definition nla_ops.cc:59
@ NLAEDIT_SNAP_NEAREST_FRAME
Definition nla_intern.hh:73
@ NLAEDIT_SNAP_NEAREST_SECOND
Definition nla_intern.hh:74
@ NLAEDIT_SNAP_NEAREST_MARKER
Definition nla_intern.hh:75
@ NLAEDIT_SNAP_CFRA
Definition nla_intern.hh:72
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
NlaStrip * BKE_nlastrip_new(bAction *act, ID &animated_id)
bool BKE_nlatrack_is_nonlocal_in_liboverride(const ID *id, const NlaTrack *nlt)
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const bool only_sel)
Definition nla_edit.cc:328
void NLA_OT_snap(wmOperatorType *ot)
Definition nla_edit.cc:2498
@ ACHANNEL_SETTING_SELECT
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
static wmOperatorStatus nlaedit_viewall(bContext *C, const bool only_sel)
Definition nla_edit.cc:486
void ANIM_center_frame(bContext *C, int smooth_viewtx)
Definition anim_draw.cc:801
void BKE_nla_validate_state(AnimData *adt)
size_t ANIM_animdata_filter(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode, void *data, const eAnimCont_Types datatype)
static wmOperatorStatus nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:1954
void NLA_OT_move_up(wmOperatorType *ot)
Definition nla_edit.cc:1840
static wmOperatorStatus nlaedit_split_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:1429
@ ANIMFILTER_FCURVESONLY
@ ANIMFILTER_ANIMDATA
@ ANIMFILTER_FOREDIT
@ ANIMFILTER_LIST_VISIBLE
@ ANIMFILTER_DATA_VISIBLE
@ ANIMFILTER_ACTIVE
@ ANIMFILTER_NODUPLIS
@ ANIMFILTER_LIST_CHANNELS
bool nlaedit_disable_tweakmode(bAnimContext *ac, bool do_solo)
Definition nla_edit.cc:223
void BKE_fcurve_handles_recalc(FCurve &fcu)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
void DEG_id_tag_update(ID *id, unsigned int flags)
bool nlaedit_add_tracks_empty(bAnimContext *ac)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:339
NlaStrip * BKE_nlastrip_copy(Main *bmain, NlaStrip *strip, bool use_same_action, int flag)
bool BKE_nlastrips_has_space(ListBaseT< NlaStrip > *strips, float start, float end)
static wmOperatorStatus nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:2753
static wmOperatorStatus nlaedit_apply_scale_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:2168
@ NLASTRIP_TYPE_SOUND
@ NLASTRIP_TYPE_TRANSITION
static wmOperatorStatus nlaedit_viewall_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:538
NlaTrack * BKE_nlatrack_new_tail(ListBaseT< NlaTrack > *nla_tracks, const bool is_liboverride)
void NLA_OT_tweakmode_enter(wmOperatorType *ot)
Definition nla_edit.cc:183
void NLA_OT_fmodifier_add(wmOperatorType *ot)
Definition nla_edit.cc:2640
BLI_INLINE bool BLI_listbase_count_is_equal_to(const ListBase *listbase, const int count_cmp)
void NLA_OT_soundclip_add(wmOperatorType *ot)
Definition nla_edit.cc:976
void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
bool ANIM_fmodifiers_paste_from_buf(ListBaseT< FModifier > *modifiers, bool replace, FCurve *curve)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
static wmOperatorStatus nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:271
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)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:28
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
void BKE_nlastrip_recalculate_bounds_sync_action(NlaStrip *strip)
void NLA_OT_swap(wmOperatorType *ot)
Definition nla_edit.cc:1749
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void BKE_nlastrips_clear_metas(ListBaseT< NlaStrip > *strips, bool only_sel, bool only_temp)
static wmOperatorStatus nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:2676
static wmOperatorStatus nlaedit_previewrange_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:383
void NLA_OT_apply_scale(wmOperatorType *ot)
Definition nla_edit.cc:2269
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
NlaTrack * BKE_nlatrack_new_after(ListBaseT< NlaTrack > *nla_tracks, NlaTrack *prev, bool is_liboverride)
void NLA_OT_make_single_user(wmOperatorType *ot)
Definition nla_edit.cc:2128
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
Main * CTX_data_main(const bContext *C)
void ANIM_fmodifiers_copybuf_free()
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
static wmOperatorStatus nlaedit_make_single_user_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:2046
void NLA_OT_duplicate(wmOperatorType *ot)
Definition nla_edit.cc:1230
int ED_markers_find_nearest_marker_time(ListBaseT< TimeMarker > *markers, float x)
void ANIM_animdata_freelist(ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:472
static wmOperatorStatus nlaedit_add_actionclip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Definition nla_edit.cc:627
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_ENUM_NO_TRANSLATE
Definition RNA_types.hh:502
void NLA_OT_view_frame(wmOperatorType *ot)
Definition nla_edit.cc:593
void NLA_OT_meta_remove(wmOperatorType *ot)
Definition nla_edit.cc:1116
void BKE_nlatrack_remove_strip(NlaTrack *track, NlaStrip *strip)
static const EnumPropertyItem * nla_fmodifier_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
Definition nla_edit.cc:2525
void NLA_OT_action_sync_length(wmOperatorType *ot)
Definition nla_edit.cc:2015
static wmOperatorStatus nla_fmodifier_add_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:2563
wmOperatorStatus WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus nlaedit_clear_scale_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:2292
void DEG_relations_tag_update(Main *bmain)
bool ANIM_fmodifiers_copy_to_buf(ListBaseT< FModifier > *modifiers, bool active)
bool nlaop_poll_tweakmode_off(bContext *C)
Definition nla_ops.cc:29
bScreen * CTX_wm_screen(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
static wmOperatorStatus nlaedit_viewframe_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:586
void BKE_nlastrips_make_metas(ListBaseT< NlaStrip > *strips, bool is_temp)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
bool BKE_nlatrack_has_space(NlaTrack *nlt, float start, float end)
static wmOperatorStatus nlaedit_add_sound_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:907
static bool nla_tracks_get_selected_extents(bAnimContext *ac, float *r_min, float *r_max)
Definition nla_edit.cc:441
static short bezt_apply_nlamapping(KeyframeEditData *ked, BezTriple *bezt)
Definition nla_edit.cc:2154
static wmOperatorStatus nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:652
ID * BKE_id_copy(Main *bmain, const ID *id)
Definition lib_id.cc:856
static wmOperatorStatus nlaedit_delete_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:1261
void id_us_min(ID *id)
Definition lib_id.cc:441
void NLA_OT_clear_scale(wmOperatorType *ot)
Definition nla_edit.cc:2335
void NLA_OT_view_selected(wmOperatorType *ot)
Definition nla_edit.cc:565
static wmOperatorStatus nlaedit_remove_meta_exec(bContext *C, wmOperator *)
Definition nla_edit.cc:1074
void set_active_fmodifier(ListBaseT< FModifier > *modifiers, FModifier *fcm)
void BKE_nlastrips_clear_metastrip(ListBaseT< NlaStrip > *strips, NlaStrip *strip)
void BKE_nlastrip_remove_and_free(ListBaseT< NlaStrip > *strips, NlaStrip *strip, const bool do_id_user)
@ ANIM_UPDATE_DEPS
const FModifierTypeInfo * get_fmodifier_typeinfo(int type)
bool BKE_nla_tweakmode_enter(OwnedAnimData owned_adt)
static wmOperatorStatus nlaedit_swap_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:1583
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:784
static wmOperatorStatus nlaedit_snap_exec(bContext *C, wmOperator *op)
Definition nla_edit.cc:2369
#define floorf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
eAnimData_Flag flag
ListBaseT< NlaTrack > nla_tracks
char name[258]
Definition DNA_ID.h:433
ListBaseT< bAction > actions
Definition BKE_main.hh:408
struct NlaStrip * next
ListBaseT< FModifier > modifiers
eNlaStrip_Flag flag
ListBaseT< NlaStrip > strips
eNlaStrip_Type type
struct NlaStrip * prev
struct NlaTrack * prev
eNlaTrack_Flag flag
ListBaseT< NlaStrip > strips
struct NlaTrack * next
struct RenderData r
bool(*) has_setting(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting)
eAnimChannel_Role channel_role
ListBaseT< TimeMarker > * markers
eAnimCont_Types datatype
bAnimListElem * next
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
struct ReportList * reports