Blender V5.3
transform_convert_action.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <algorithm>
10
11#include "DNA_anim_types.h"
13#include "DNA_mask_types.h"
14
15#include "MEM_guardedalloc.h"
16
17#include "BLI_listbase.hh"
18#include "BLI_math_vector_c.hh"
19#include "BLI_rect.hh"
20#include "BLI_set.hh"
21
22#include "BKE_annotations.h"
23#include "BKE_context.hh"
24#include "BKE_fcurve.hh"
25#include "BKE_grease_pencil.hh"
26#include "BKE_key.hh"
27#include "BKE_layer.hh"
28#include "BKE_mask.hh"
29#include "BKE_nla.hh"
30
31#include "ED_anim_api.hh"
32#include "ED_keyframes_edit.hh"
33#include "ED_markers.hh"
34
35#include "WM_api.hh"
36#include "WM_types.hh"
37
38#include "transform.hh"
39#include "transform_snap.hh"
40
41#include "transform_convert.hh"
42
43namespace blender::ed::transform {
44
45/* Weak way of identifying whether TransData was set by #GPLayerToTransData or
46 * #MaskLayerToTransData. This way we can identify whether the #td->loc2d_i is a pointer to an
47 * integer value and we can correctly flush in #recalcData_actedit. */
48static bool is_td2d_int(TransData2D *td2d)
49{
50 return td2d->loc2d_i && td2d->h1 == nullptr;
51}
52
53/* -------------------------------------------------------------------- */
56
57/* Add a fake user to ensure drawings are not deleted during transform when a frame is overwritten
58 * temporarily. The drawing_index of any existing frame will also remain valid. */
60{
61 using namespace bke::greasepencil;
62
63 for (const GreasePencilDrawingBase *drawing_base : grease_pencil.drawings()) {
64 /* Only actual drawings have a user count, ignore drawing references. */
65 if (drawing_base->type != GP_DRAWING) {
66 continue;
67 }
68
69 const Drawing &drawing = reinterpret_cast<const GreasePencilDrawing *>(drawing_base)->wrap();
70 drawing.runtime->fake_user = true;
71 }
72}
73
74/* Remove fake users from drawings after frame data has been restored. After this drawing data can
75 * be freed and drawing indices may become invalid. */
77{
78 using namespace bke::greasepencil;
79
80 for (const GreasePencilDrawingBase *drawing_base : grease_pencil.drawings()) {
81 /* Only actual drawings have a user count, ignore drawing references. */
82 if (drawing_base->type != GP_DRAWING) {
83 continue;
84 }
85
86 const Drawing &drawing = reinterpret_cast<const GreasePencilDrawing *>(drawing_base)->wrap();
87 drawing.runtime->fake_user = false;
88 }
89}
90
93 const Span<int> frames_affected,
94 const bool use_duplicates)
95{
96 using namespace bke::greasepencil;
97 LayerTransformData &trans_data = layer.runtime->trans_data_;
98
99 if (trans_data.status != LayerTransformData::TRANS_CLEAR) {
100 return false;
101 }
102
103 /* "Freeze" drawing indices by adding a fake user to each drawing. This ensures the drawing_index
104 * in frame data remains valid and no data is lost if the drawing is temporarily unused during
105 * transform. */
107
108 /* Initialize the transformation data structure, by storing in separate maps frames that will
109 * remain static during the transformation, and frames that are affected by the
110 * transformation.
111 */
112 trans_data.frames_static = layer.frames();
113 trans_data.frames_transformed.clear();
114
115 for (const int frame_number : frames_affected) {
116 const bool was_duplicated = use_duplicates &&
117 trans_data.duplicated_frames_buffer.contains(frame_number);
118
119 /* Get the frame that is going to be affected by the transformation :
120 * if the frame was duplicated, then its the duplicated frame which is being transformed,
121 * otherwise it is the original frame, stored in the layer. */
122 const Map<int, GreasePencilFrame> &frame_map = was_duplicated ?
123 trans_data.duplicated_frames_buffer :
124 layer.frames();
125
126 const GreasePencilFrame frame_transformed = frame_map.lookup(frame_number);
127 trans_data.frames_transformed.add_overwrite(frame_number, frame_transformed);
128
129 if (!was_duplicated) {
130 /* Remove from the static map each frame that is affected by the transformation and that was
131 * not duplicated. Note that if the frame was duplicated, then the original frame is not
132 * affected by the transformation. */
133 trans_data.frames_static.remove_as(frame_number);
134 }
135 }
136
137 trans_data.frames_duration.clear();
138 trans_data.frames_destination.clear();
139
140 for (const auto [frame_number, frame] : layer.frames().items()) {
141 if (frame.is_end()) {
142 continue;
143 }
144
145 /* Store frames' duration to keep them visually correct while moving the frames. */
146 trans_data.frames_duration.add(frame_number, layer.get_frame_duration_at(frame_number));
147 }
148
150 return true;
151}
152
154{
155 using namespace bke::greasepencil;
156 LayerTransformData &trans_data = layer.runtime->trans_data_;
157
158 /* If the layer frame map was affected by the transformation, set its status to initialized so
159 * that the frames map gets reset the next time this modal function is called.
160 */
161 if (trans_data.status == LayerTransformData::TRANS_CLEAR) {
162 return false;
163 }
165 return true;
166}
167
169 const int src_frame_number,
170 const int dst_frame_number)
171{
172 using namespace bke::greasepencil;
173 LayerTransformData &trans_data = layer.runtime->trans_data_;
174
175 if (trans_data.status == LayerTransformData::TRANS_CLEAR) {
176 return false;
177 }
178
179 if (trans_data.status == LayerTransformData::TRANS_INIT) {
180 /* The transdata was only initialized. No transformation was applied yet.
181 * The frame mapping is always defined relatively to the initial frame map, so we first need
182 * to initialize the frames in its static state, meaning containing only the frames not
183 * affected by the transformation. */
184 layer.frames_for_write() = trans_data.frames_static;
185 layer.tag_frames_map_keys_changed();
187 }
188
189 if (!trans_data.frames_transformed.contains(src_frame_number)) {
190 /* If the frame is not affected by the transformation, then do nothing. */
191 return false;
192 }
193
194 /* Apply the transformation directly in the layer frame map, so that we display the transformed
195 * frame numbers. We don't want to edit the frames or remove any drawing here. This will be
196 * done at once at the end of the transformation. */
197 const GreasePencilFrame src_frame = trans_data.frames_transformed.lookup(src_frame_number);
198 const int src_duration = 0 /* trans_data.frames_duration.lookup_default(src_frame_number, 0) */;
199
200 layer.remove_frame(dst_frame_number);
201
202 GreasePencilFrame *frame = layer.add_frame(dst_frame_number, src_duration);
203 *frame = src_frame;
204
205 trans_data.frames_destination.add_overwrite(src_frame_number, dst_frame_number);
206
207 return true;
208}
209
212 const bool canceled,
213 const bool duplicate)
214{
215 using namespace bke::greasepencil;
216 LayerTransformData &trans_data = layer.runtime->trans_data_;
217
218 if (trans_data.status == LayerTransformData::TRANS_CLEAR) {
219 /* The layer was not affected by the transformation, so do nothing. */
220 return false;
221 }
222
223 /* Reset the frames to their initial state. */
224 layer.frames_for_write() = trans_data.frames_static;
225 for (const auto [frame_number, frame] : trans_data.frames_transformed.items()) {
226 if (trans_data.duplicated_frames_buffer.contains(frame_number)) {
227 continue;
228 }
229 layer.frames_for_write().add_overwrite(frame_number, frame);
230 }
231 layer.tag_frames_map_keys_changed();
232
233 if (!canceled) {
234 /* Moves all the selected frames according to the transformation, and inserts the potential
235 * duplicate frames in the layer. */
236 grease_pencil.move_duplicate_frames(
237 layer, trans_data.frames_destination, trans_data.duplicated_frames_buffer);
238 }
239
240 if (canceled && duplicate) {
241 /* Duplicates were done, so we need to delete the corresponding duplicate drawings. Note that
242 * we just decrement the user-count here. The actual drawings are removed after all the layers
243 * have been processed. */
244 for (const GreasePencilFrame &duplicate_frame : trans_data.duplicated_frames_buffer.values()) {
245 GreasePencilDrawingBase *drawing_base = grease_pencil.drawing(duplicate_frame.drawing_index);
246 if (drawing_base->type == GP_DRAWING) {
247 reinterpret_cast<GreasePencilDrawing *>(drawing_base)->wrap().remove_user();
248 }
249 }
250 }
251
252 /* Clear the frames copy. */
253 trans_data.frames_static.clear();
254 trans_data.frames_transformed.clear();
255 trans_data.frames_destination.clear();
256 trans_data.duplicated_frames_buffer.clear();
258
259 return true;
260}
261
263
264/* -------------------------------------------------------------------- */
267
271static int count_fcurve_keys(FCurve *fcu, char side, float cfra, bool is_prop_edit)
272{
273 BezTriple *bezt;
274 int i, count = 0, count_all = 0;
275
276 if (ELEM(nullptr, fcu, fcu->bezt)) {
277 return count;
278 }
279
280 /* Only include points that occur on the right side of cfra. */
281 for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
282 if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
283 /* No need to adjust the handle selection since they are assumed
284 * selected (like graph editor with #SIPO_NOHANDLES). */
285 if (bezt->f2 & SELECT) {
286 count++;
287 }
288
289 count_all++;
290 }
291 }
292
293 if (is_prop_edit && count > 0) {
294 return count_all;
295 }
296 return count;
297}
298
302static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra, bool is_prop_edit)
303{
304 int count = 0, count_all = 0;
305
306 if (gpl == nullptr) {
307 return count;
308 }
309
310 /* Only include points that occur on the right side of cfra. */
311 for (bGPDframe &gpf : gpl->frames) {
312 if (FrameOnMouseSide(side, float(gpf.framenum), cfra)) {
313 if (gpf.flag & GP_FRAME_SELECT) {
314 count++;
315 }
316 count_all++;
317 }
318 }
319
320 if (is_prop_edit && count > 0) {
321 return count_all;
322 }
323 return count;
324}
325
327 const char side,
328 const float cfra,
329 const bool is_prop_edit,
330 const bool use_duplicated)
331{
332 if (layer == nullptr) {
333 return 0;
334 }
335
336 int count_selected = 0;
337 int count_all = 0;
338
339 if (use_duplicated) {
340 /* Only count the frames that were duplicated. */
341 count_selected += layer->runtime->trans_data_.duplicated_frames_buffer.size();
342 count_all += count_selected;
343 }
344 else {
345 /* Only include points that occur on the right side of cfra. */
346 for (const auto &[frame_number, frame] : layer->frames().items()) {
347 if (!FrameOnMouseSide(side, float(frame_number), cfra)) {
348 continue;
349 }
350 if (frame.is_selected()) {
351 count_selected++;
352 }
353 count_all++;
354 }
355 }
356
357 if (is_prop_edit && count_selected > 0) {
358 return count_all;
359 }
360 return count_selected;
361}
362
364static int count_masklayer_frames(MaskLayer *masklay, char side, float cfra, bool is_prop_edit)
365{
366 int count = 0, count_all = 0;
367
368 if (masklay == nullptr) {
369 return count;
370 }
371
372 /* Only include points that occur on the right side of cfra. */
373 for (MaskLayerShape &masklayer_shape : masklay->splines_shapes) {
374 if (FrameOnMouseSide(side, float(masklayer_shape.frame), cfra)) {
375 if (masklayer_shape.flag & MASK_SHAPE_SELECT) {
376 count++;
377 }
378 count_all++;
379 }
380 }
381
382 if (is_prop_edit && count > 0) {
383 return count_all;
384 }
385 return count;
386}
387
388/* This function assigns the information to transdata. */
389static void TimeToTransData(
390 TransData *td, TransData2D *td2d, BezTriple *bezt, bAnimListElem *ale, float ypos)
391{
392 float *time = bezt->vec[1];
393
394 /* Setup #TransData2D. */
395 td2d->loc[0] = *time;
396 td2d->loc2d = time;
397 td2d->h1 = bezt->vec[0];
398 td2d->h2 = bezt->vec[2];
399 copy_v2_v2(td2d->ih1, td2d->h1);
400 copy_v2_v2(td2d->ih2, td2d->h2);
401
402 /* Setup #TransData. */
403
404 /* Usually #td2d->loc is used here.
405 * But this is for when the original location is not float[3]. */
406 td->loc = time;
407
408 copy_v3_v3(td->iloc, td->loc);
409 td->val = time;
410 td->ival = *(time);
412 td->center[1] = ypos;
413
414 /* Store the AnimData where this keyframe exists as a keyframe of the
415 * active action as #td->extra.
416 *
417 * We do this conditionally as a hacky way of indicating whether NLA remapping
418 * should be done. This is left over from old code, most of which was changed
419 * in #130440 to avoid using `adt == nullptr` as an indicator for that. This
420 * was left that way because updating it cleanly was more involved than made
421 * sense for the bug fix in #130440. */
422 if (ANIM_nla_mapping_allowed(ale)) {
423 td->extra = ale->adt;
424 }
425
426 if (bezt->f2 & SELECT) {
427 td->flag |= TD_SELECTED;
428 }
429
430 /* Set flags to move handles as necessary. */
432
433 BLI_assert(!is_td2d_int(td2d));
434}
435
436/* This function advances the address to which td points to, so it must return
437 * the new address so that the next time new transform data is added, it doesn't
438 * overwrite the existing ones... i.e. td = IcuToTransData(td, icu, ob, side, cfra);
439 *
440 * The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
441 * on the named side are used.
442 */
444 TransData2D **td2dv,
445 FCurve *fcu,
446 bAnimListElem *ale,
447 char side,
448 float cfra,
449 bool is_prop_edit,
450 float ypos)
451{
452 BezTriple *bezt;
453 TransData2D *td2d = *td2dv;
454 int i;
455
456 if (ELEM(nullptr, fcu, fcu->bezt)) {
457 return td;
458 }
459
460 for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
461 /* Only add selected keyframes (for now, proportional edit is not enabled). */
462
463 /* Note this check MUST match #count_fcurve_keys(), so can't use #BEZT_ISSEL_ANY() macro. */
464 if (is_prop_edit || (bezt->f2 & SELECT)) {
465 /* Only add if on the right 'side' of the current frame. */
466 if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
467 TimeToTransData(td, td2d, bezt, ale, ypos);
468
469 td++;
470 td2d++;
471 }
472 }
473 }
474
475 *td2dv = td2d;
476
477 return td;
478}
479
489 TransData2D *td2d,
490 bGPDlayer *gpl,
491 char side,
492 float cfra,
493 bool is_prop_edit,
494 float ypos)
495{
496 int count = 0;
497
498 /* Check for select frames on right side of current frame. */
499 for (bGPDframe &gpf : gpl->frames) {
500 const bool is_selected = (gpf.flag & GP_FRAME_SELECT) != 0;
501 if (is_prop_edit || is_selected) {
502 if (FrameOnMouseSide(side, float(gpf.framenum), cfra)) {
503 td2d->loc[0] = float(gpf.framenum);
504 td2d->loc2d_i = &gpf.framenum;
505
506 td->loc = td->val = td2d->loc;
507 td->iloc[0] = td->ival = td2d->loc[0];
508
509 td->center[0] = td->ival;
510 td->center[1] = ypos;
511
512 if (is_selected) {
513 td->flag = TD_SELECTED;
514 }
515
516 BLI_assert(is_td2d_int(td2d));
517
518 /* Advance `td` now. */
519 td++;
520 td2d++;
521 count++;
522 }
523 }
524 }
525
526 return count;
527}
528
535 TransData2D *td2d,
538 const char side,
539 const float cfra,
540 const bool is_prop_edit,
541 const float ypos,
542 const bool duplicate)
543{
544 using namespace bke::greasepencil;
545
546 int total_trans_frames = 0;
547 bool any_frame_affected = false;
548 Vector<int> frames_affected;
549
550 const auto grease_pencil_frame_to_trans_data = [&](const int frame_number,
551 const bool frame_selected) {
552 /* We only add transform data for selected frames that are on the right side of current frame.
553 * If proportional edit is set, then we should also account for non selected frames.
554 */
555 if ((!is_prop_edit && !frame_selected) || !FrameOnMouseSide(side, frame_number, cfra)) {
556 return;
557 }
558
559 td2d->loc[0] = float(frame_number);
560
561 td->val = td->loc = &td2d->loc[0];
562 td->ival = td->iloc[0] = td2d->loc[0];
563
564 td->center[0] = td->ival;
565 td->center[1] = ypos;
566
567 if (frame_selected) {
568 td->flag |= TD_SELECTED;
569 }
570 /* Set a pointer to the layer in the transform data so that we can apply the transformation
571 * while the operator is running.
572 */
574 td->extra = layer;
575
576 BLI_assert(!is_td2d_int(td2d));
577
578 /* Advance `td` now. */
579 td++;
580 td2d++;
581 total_trans_frames++;
582
583 frames_affected.append(frame_number);
584 any_frame_affected = true;
585 };
586
587 const Map<int, GreasePencilFrame> &frame_map =
588 duplicate ? (layer->runtime->trans_data_.duplicated_frames_buffer) : layer->frames();
589
590 for (const auto [frame_number, frame] : frame_map.items()) {
591 grease_pencil_frame_to_trans_data(frame_number, frame.is_selected());
592 }
593
594 if (total_trans_frames == 0) {
595 return total_trans_frames;
596 }
597
598 /* If it was not previously done, initialize the transform data in the layer, and if some frames
599 * are actually concerned by the transform. */
600 if (any_frame_affected) {
602 *grease_pencil, *layer, frames_affected.as_span(), duplicate);
603 }
604
605 return total_trans_frames;
606}
607
612 TransData2D *td2d,
613 MaskLayer *masklay,
614 char side,
615 float cfra,
616 bool is_prop_edit,
617 float ypos)
618{
619 int count = 0;
620
621 /* Check for select frames on right side of current frame. */
622 for (MaskLayerShape &masklay_shape : masklay->splines_shapes) {
623 if (is_prop_edit || (masklay_shape.flag & MASK_SHAPE_SELECT)) {
624 if (FrameOnMouseSide(side, float(masklay_shape.frame), cfra)) {
625 td2d->loc[0] = float(masklay_shape.frame);
626 td2d->loc2d_i = &masklay_shape.frame;
627
628 td->loc = td->val = td2d->loc;
629 td->iloc[0] = td->ival = td2d->loc[0];
630
631 td->center[0] = td->ival;
632 td->center[1] = ypos;
633
634 BLI_assert(is_td2d_int(td2d));
635
636 /* Advance td now. */
637 td++;
638 td2d++;
639 count++;
640 }
641 }
642 }
643
644 return count;
645}
646
648{
649 Scene *scene = t->scene;
650 TransData *td = nullptr;
651 TransData2D *td2d = nullptr;
652
653 /* The T_DUPLICATED_KEYFRAMES flag is only set if we made some duplicates of the selected frames,
654 * and they are the ones that are being transformed. */
655 const bool use_duplicated = (t->flag & T_DUPLICATED_KEYFRAMES) != 0;
656
657 float xsize, ysize, xmask, ymask;
658 float view_center_y;
659
660 if (t->region) {
661 const rcti *mask = &t->region->v2d.mask;
662 const rctf *datamask = &t->region->v2d.cur;
663 xsize = BLI_rctf_size_x(datamask);
664 ysize = BLI_rctf_size_y(datamask);
665 xmask = BLI_rcti_size_x(mask);
666 ymask = BLI_rcti_size_y(mask);
667 view_center_y = BLI_rctf_cent_y(datamask);
668 }
669 else {
670 xsize = ysize = xmask = ymask = 1.0f;
671 view_center_y = 0.0f;
672 }
673
674 bAnimContext ac;
675 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
676 int filter;
677 const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
678
679 int count = 0;
680 int gpf_count = 0;
681 const float ypos = 1.0f / ((ysize / xsize) * (xmask / ymask)) * view_center_y;
682
683 /* Determine what type of data we are operating on. */
684 if (ANIM_animdata_get_context(C, &ac) == 0) {
685 return;
686 }
687
688 /* Filter data. */
691 &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
692
693 /* Which side of the current frame should be allowed. */
694 if (t->mode == TFM_TIME_EXTEND) {
696 }
697 else {
698 /* Normal transform - both sides of current frame are considered. */
699 t->frame_side = 'B';
700 }
701
702 /* Loop 1: fully select F-Curve keys and count how many BezTriples are selected. */
703 for (bAnimListElem &ale : anim_data) {
704 int ale_count = 0;
705 /* Convert current-frame to action-time (slightly less accurate, especially under
706 * higher scaling ratios, but is faster than converting all points). */
707 const float cfra = ANIM_nla_tweakedit_remap(&ale, float(scene->r.cfra), NLATIME_CONVERT_UNMAP);
708
709 switch (ale.type) {
710 case ANIMTYPE_FCURVE:
712 ale_count = count_fcurve_keys(
713 static_cast<FCurve *>(ale.key_data), t->frame_side, cfra, is_prop_edit);
714 break;
715 case ANIMTYPE_GPLAYER:
716 ale_count = count_gplayer_frames(
717 static_cast<bGPDlayer *>(ale.data), t->frame_side, cfra, is_prop_edit);
718 break;
720 using namespace bke::greasepencil;
721 ale_count = count_grease_pencil_frames(
722 static_cast<Layer *>(ale.data), t->frame_side, cfra, is_prop_edit, use_duplicated);
723 break;
724 }
726 ale_count = count_masklayer_frames(
727 static_cast<MaskLayer *>(ale.data), t->frame_side, cfra, is_prop_edit);
728 break;
729 case ANIMTYPE_NONE:
732 case ANIMTYPE_SUMMARY:
733 case ANIMTYPE_SCENE:
734 case ANIMTYPE_OBJECT:
735 case ANIMTYPE_GROUP:
741 case ANIMTYPE_DSMAT:
742 case ANIMTYPE_DSLAM:
743 case ANIMTYPE_DSCAM:
745 case ANIMTYPE_DSCUR:
746 case ANIMTYPE_DSSKEY:
747 case ANIMTYPE_DSWOR:
748 case ANIMTYPE_DSNTREE:
749 case ANIMTYPE_DSPART:
750 case ANIMTYPE_DSMBALL:
751 case ANIMTYPE_DSARM:
752 case ANIMTYPE_DSMESH:
753 case ANIMTYPE_DSTEX:
754 case ANIMTYPE_DSLAT:
756 case ANIMTYPE_DSSPK:
758 case ANIMTYPE_DSMCLIP:
759 case ANIMTYPE_DSHAIR:
769 case ANIMTYPE_PALETTE:
772 break;
773 }
774
775 if (ale_count > 0) {
776 if (ELEM(ale.type, ANIMTYPE_GPLAYER, ANIMTYPE_MASKLAYER)) {
777 gpf_count += ale_count;
778 }
779 count += ale_count;
780 ale.tag = true;
781 }
782 }
783
784 /* Stop if trying to build list if nothing selected. */
785 if (count == 0 && gpf_count == 0) {
786 /* Cleanup temp list. */
787 ANIM_animdata_freelist(&anim_data);
788 return;
789 }
790
792
793 /* Allocate memory for data. */
794 tc->data_len = count;
795
796 tc->data = MEM_new_array_zeroed<TransData>(tc->data_len, "TransData(Action Editor)");
797 tc->data_2d = MEM_new_array_zeroed<TransData2D>(tc->data_len, "transdata2d");
798 td = tc->data;
799 td2d = tc->data_2d;
800
801 /* Loop 2: build transdata array. */
802 for (bAnimListElem &ale : anim_data) {
803
804 if (is_prop_edit && !ale.tag) {
805 continue;
806 }
807
808 const float cfra = ANIM_nla_tweakedit_remap(&ale, float(scene->r.cfra), NLATIME_CONVERT_UNMAP);
809
810 if (ale.type == ANIMTYPE_GPLAYER) {
811 bGPDlayer *gpl = static_cast<bGPDlayer *>(ale.data);
812 int i;
813
814 i = GPLayerToTransData(td, td2d, gpl, t->frame_side, cfra, is_prop_edit, ypos);
815 td += i;
816 td2d += i;
817 }
818 else if (ale.type == ANIMTYPE_GREASE_PENCIL_LAYER) {
819 using namespace bke::greasepencil;
820 GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(ale.id);
821 Layer *layer = static_cast<Layer *>(ale.data);
822 int i;
823
825 td, td2d, grease_pencil, layer, t->frame_side, cfra, is_prop_edit, ypos, use_duplicated);
826 td += i;
827 td2d += i;
828 }
829 else if (ale.type == ANIMTYPE_MASKLAYER) {
830 MaskLayer *masklay = static_cast<MaskLayer *>(ale.data);
831 int i;
832
833 i = MaskLayerToTransData(td, td2d, masklay, t->frame_side, cfra, is_prop_edit, ypos);
834 td += i;
835 td2d += i;
836 }
837 else {
838 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
839 td = ActionFCurveToTransData(td, &td2d, fcu, &ale, t->frame_side, cfra, is_prop_edit, ypos);
840 }
841 }
842
843 /* Calculate distances for proportional editing. */
844 if (is_prop_edit) {
845 td = tc->data;
846
847 for (bAnimListElem &ale : anim_data) {
848 /* F-Curve may not have any keyframes. */
849 if (!ale.tag) {
850 continue;
851 }
852
853 const float cfra = ANIM_nla_tweakedit_remap(
854 &ale, float(scene->r.cfra), NLATIME_CONVERT_UNMAP);
855
856 if (ale.type == ANIMTYPE_GPLAYER) {
857 bGPDlayer *gpl = static_cast<bGPDlayer *>(ale.data);
858
859 for (bGPDframe &gpf : gpl->frames) {
860 if (gpf.flag & GP_FRAME_SELECT) {
861 td->dist = td->rdist = 0.0f;
862 }
863 else {
864 int min = INT_MAX;
865 for (bGPDframe &gpf_iter : gpl->frames) {
866 if (gpf_iter.flag & GP_FRAME_SELECT) {
867 if (FrameOnMouseSide(t->frame_side, float(gpf_iter.framenum), cfra)) {
868 int val = abs(gpf.framenum - gpf_iter.framenum);
869 min = std::min(val, min);
870 }
871 }
872 }
873 td->dist = td->rdist = min;
874 }
875 td++;
876 }
877 }
878 else if (ale.type == ANIMTYPE_GREASE_PENCIL_LAYER) {
879 using namespace bke::greasepencil;
880 Layer *layer = static_cast<Layer *>(ale.data);
881
882 const auto grease_pencil_closest_selected_frame = [&](const int frame_number,
883 const bool frame_selected) {
884 if (frame_selected) {
885 td->dist = td->rdist = 0.0f;
886 ++td;
887 return;
888 }
889
890 int closest_selected = INT_MAX;
891 for (const auto [neighbor_frame_number, neighbor_frame] : layer->frames().items()) {
892 if (!neighbor_frame.is_selected() ||
893 !FrameOnMouseSide(t->frame_side, float(neighbor_frame_number), cfra))
894 {
895 continue;
896 }
897 const int distance = abs(neighbor_frame_number - frame_number);
898 closest_selected = std::min(closest_selected, distance);
899 }
900
901 td->dist = td->rdist = closest_selected;
902 ++td;
903 };
904
905 for (const auto [frame_number, frame] : layer->frames().items()) {
906 grease_pencil_closest_selected_frame(frame_number, frame.is_selected());
907 }
908
909 if (use_duplicated) {
910 /* Also count for duplicated frames. */
911 for (const auto [frame_number, frame] :
912 layer->runtime->trans_data_.duplicated_frames_buffer.items())
913 {
914 grease_pencil_closest_selected_frame(frame_number, frame.is_selected());
915 }
916 }
917 }
918 else if (ale.type == ANIMTYPE_MASKLAYER) {
919 MaskLayer *masklay = static_cast<MaskLayer *>(ale.data);
920
921 for (MaskLayerShape &masklay_shape : masklay->splines_shapes) {
922 if (FrameOnMouseSide(t->frame_side, float(masklay_shape.frame), cfra)) {
923 if (masklay_shape.flag & MASK_SHAPE_SELECT) {
924 td->dist = td->rdist = 0.0f;
925 }
926 else {
927 int min = INT_MAX;
928 for (MaskLayerShape &masklay_iter : masklay->splines_shapes) {
929 if (masklay_iter.flag & MASK_SHAPE_SELECT) {
930 if (FrameOnMouseSide(t->frame_side, float(masklay_iter.frame), cfra)) {
931 int val = abs(masklay_shape.frame - masklay_iter.frame);
932 min = std::min(val, min);
933 }
934 }
935 }
936 td->dist = td->rdist = min;
937 }
938 td++;
939 }
940 }
941 }
942 else {
943 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
944 BezTriple *bezt;
945 int i;
946
947 for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
948 if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) {
949 if (bezt->f2 & SELECT) {
950 td->dist = td->rdist = 0.0f;
951 }
952 else {
953 BezTriple *bezt_iter;
954 int j;
955 float min = FLT_MAX;
956 for (j = 0, bezt_iter = fcu->bezt; j < fcu->totvert; j++, bezt_iter++) {
957 if (bezt_iter->f2 & SELECT) {
958 if (FrameOnMouseSide(t->frame_side, bezt_iter->vec[1][0], cfra)) {
959 float val = fabs(bezt->vec[1][0] - bezt_iter->vec[1][0]);
960 min = std::min(val, min);
961 }
962 }
963 }
964 td->dist = td->rdist = min;
965 }
966 td++;
967 }
968 }
969 }
970 }
971 }
972
973 /* Cleanup temp list. */
974 ANIM_animdata_freelist(&anim_data);
975}
976
978
979/* -------------------------------------------------------------------- */
982
983static void invert_snap(eSnapMode &snap_mode)
984{
985 /* Make snapping work like before 4.0 where pressing CTRL will switch between snapping to seconds
986 * and frames. */
987 if (snap_mode & SCE_SNAP_TO_FRAME) {
988 snap_mode &= ~SCE_SNAP_TO_FRAME;
989 snap_mode |= SCE_SNAP_TO_SECOND;
990 }
991 else if (snap_mode & SCE_SNAP_TO_SECOND) {
992 snap_mode &= ~SCE_SNAP_TO_SECOND;
993 snap_mode |= SCE_SNAP_TO_FRAME;
994 }
995}
996
998{
999 ViewLayer *view_layer = t->view_layer;
1000 SpaceAction *saction = t->area->spacedata.first_as<SpaceAction>();
1001
1002 bAnimContext ac = {nullptr};
1003 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1004 int filter;
1005
1007
1008 /* Initialize relevant anim-context `context` data from #TransInfo data. */
1009 /* NOTE: sync this with the code in #ANIM_animdata_get_context(). */
1010 ac.bmain = CTX_data_main(t->context);
1011 ac.scene = t->scene;
1012 ac.view_layer = t->view_layer;
1013 ac.obact = BKE_view_layer_active_object_get(view_layer);
1014 ac.area = t->area;
1015 ac.region = t->region;
1016 ac.sl = t->area ? t->area->spacedata.first_as<SpaceLink>() : nullptr;
1017 ac.spacetype = eSpace_Type((t->area) ? t->area->spacetype : 0);
1018 ac.regiontype = eRegion_Type((t->region) ? t->region->regiontype : 0);
1019
1021
1022 /* Flush 2d vector. */
1024 eSnapMode snap_mode = t->tsnap.mode;
1025 if (t->modifiers & MOD_SNAP_INVERT) {
1026 invert_snap(snap_mode);
1027 }
1028
1029 TransData *td;
1030 TransData2D *td2d;
1031 int i = 0;
1032 for (td = tc->data, td2d = tc->data_2d; i < tc->data_len; i++, td++, td2d++) {
1033 if ((t->tsnap.flag & SCE_SNAP) && (t->state != TRANS_CANCEL) && !(td->flag & TD_NOTIMESNAP)) {
1034 transform_snap_anim_flush_data(t, td, snap_mode, td->loc);
1035 }
1036
1037 /* Constrain Y. */
1038 td->loc[1] = td->iloc[1];
1039
1040 transform_convert_flush_handle2D(td, td2d, 0.0f);
1041
1042 if ((td->flag & TD_GREASE_PENCIL_FRAME) != 0) {
1044 round_fl_to_int(td->ival),
1045 round_fl_to_int(td2d->loc[0]));
1046 }
1047 else if (is_td2d_int(td2d)) {
1048 /* (Grease Pencil Legacy)
1049 * This helps flush transdata written to tempdata into the gp-frames. */
1050 *td2d->loc2d_i = round_fl_to_int(td2d->loc[0]);
1051 }
1052 }
1053
1054 if (ac.datatype != ANIMCONT_MASK) {
1055 /* Get animdata blocks visible in editor,
1056 * assuming that these will be the ones where things changed. */
1059 &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
1060
1061 /* Just tag these animdata-blocks to recalc, assuming that some data there changed
1062 * BUT only do this if realtime updates are enabled. */
1063 if ((saction->flag & SACTION_NOREALTIMEUPDATES) == 0) {
1064 for (bAnimListElem &ale : anim_data) {
1065 /* Set refresh tags for objects using this animation. */
1067 }
1068
1069 /* Now free temp channels. */
1070 ANIM_animdata_freelist(&anim_data);
1071 }
1072
1073 {
1076 &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
1077
1078 for (bAnimListElem &ale : anim_data) {
1079 if (ale.type != ANIMTYPE_GREASE_PENCIL_LAYER) {
1080 continue;
1081 }
1083 ANIM_id_update(ale.bmain, ale.id);
1084 }
1085 ANIM_animdata_freelist(&anim_data);
1086 }
1087 }
1088}
1089
1091
1092/* -------------------------------------------------------------------- */
1095
1096static int masklay_shape_cmp_frame(void *thunk, const void *a, const void *b)
1097{
1098 const MaskLayerShape *frame_a = static_cast<const MaskLayerShape *>(a);
1099 const MaskLayerShape *frame_b = static_cast<const MaskLayerShape *>(b);
1100
1101 if (frame_a->frame < frame_b->frame) {
1102 return -1;
1103 }
1104 if (frame_a->frame > frame_b->frame) {
1105 return 1;
1106 }
1107 *(static_cast<bool *>(thunk)) = true;
1108 /* Selected last. */
1109 if ((frame_a->flag & MASK_SHAPE_SELECT) && ((frame_b->flag & MASK_SHAPE_SELECT) == 0)) {
1110 return 1;
1111 }
1112 return 0;
1113}
1114
1116{
1117 for (MaskLayer &masklay : mask->masklayers) {
1118 MaskLayerShape *masklay_shape, *masklay_shape_next;
1119 bool is_double = false;
1120
1122
1123 if (is_double) {
1124 for (masklay_shape = masklay.splines_shapes.first(); masklay_shape;
1125 masklay_shape = masklay_shape_next)
1126 {
1127 masklay_shape_next = masklay_shape->next;
1128 if (masklay_shape_next && masklay_shape->frame == masklay_shape_next->frame) {
1129 BKE_mask_layer_shape_unlink(&masklay, masklay_shape);
1130 }
1131 }
1132 }
1133
1134#ifndef NDEBUG
1135 for (masklay_shape = masklay.splines_shapes.first(); masklay_shape;
1136 masklay_shape = masklay_shape->next)
1137 {
1138 BLI_assert(!masklay_shape->next || masklay_shape->frame < masklay_shape->next->frame);
1139 }
1140#endif
1141 }
1142
1144}
1145
1146/* Called by special_aftertrans_update to make sure selected gp-frames replace
1147 * any other gp-frames which may reside on that frame (that are not selected).
1148 * It also makes sure gp-frames are still stored in chronological order after
1149 * transform.
1150 */
1152{
1153 for (bGPDlayer &gpl : gpd->layers) {
1154 bGPDframe *gpf, *gpfn;
1155 bool is_double = false;
1156
1157 BKE_annotations_layer_frames_sort(&gpl, &is_double);
1158
1159 if (is_double) {
1160 for (gpf = gpl.frames.first(); gpf; gpf = gpfn) {
1161 gpfn = gpf->next;
1162 if (gpfn && gpf->framenum == gpfn->framenum) {
1164 }
1165 }
1166 }
1167
1168#ifndef NDEBUG
1169 for (gpf = gpl.frames.first(); gpf; gpf = gpf->next) {
1170 BLI_assert(!gpf->next || gpf->framenum < gpf->next->framenum);
1171 }
1172#endif
1173 }
1174 /* Set cache flag to dirty. */
1176
1178}
1179
1186{
1187 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1188 int filter;
1189
1190 /* Filter data. */
1193
1194 /* Loop through relevant data, removing keyframes as appropriate.
1195 * - all keyframes are converted in/out of global time.
1196 */
1197 for (bAnimListElem &ale : anim_data) {
1199 &ale, static_cast<FCurve *>(ale.key_data), false, false);
1200 BKE_fcurve_merge_duplicate_keys(static_cast<FCurve *>(ale.key_data),
1201 SELECT,
1202 false); /* Only use handles in graph editor. */
1204 &ale, static_cast<FCurve *>(ale.key_data), true, false);
1205 }
1206
1207 /* Free temp data. */
1208 ANIM_animdata_freelist(&anim_data);
1209}
1210
1212{
1213 SpaceAction *saction = t->area->spacedata.first_as<SpaceAction>();
1214 bAnimContext ac;
1215
1216 const bool canceled = (t->state == TRANS_CANCEL);
1217 const bool duplicate = (t->flag & T_DUPLICATED_KEYFRAMES) != 0;
1218
1219 /* Initialize relevant anim-context 'context' data. */
1220 if (ANIM_animdata_get_context(C, &ac) == 0) {
1221 return;
1222 }
1223
1224 Object *ob = ac.obact;
1225
1226 /* When keyframes are moved on top of other keyframes, the drawings in the GreasePencil data
1227 * might need to be updated/removed. This needs to happen after all the layers have been
1228 * processed. So keep track of the GreasePencils that need to be updated later. */
1229 Set<GreasePencil *> grease_pencils_to_update;
1230
1232 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1234
1235 /* Get channels to work on. */
1237 &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
1238
1239 for (bAnimListElem &ale : anim_data) {
1240 switch (ale.datatype) {
1241 case ALE_GPFRAME:
1242 ale.id->tag &= ~ID_TAG_DOIT;
1243 posttrans_gpd_clean(id_cast<bGPdata *>(ale.id));
1244 break;
1245
1246 case ALE_FCURVE: {
1247 FCurve *fcu = static_cast<FCurve *>(ale.key_data);
1248
1249 /* 3 cases here for curve cleanups:
1250 * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done.
1251 * 2) canceled == 0 -> user confirmed the transform,
1252 * so duplicates should be removed.
1253 * 3) canceled + duplicate -> user canceled the transform,
1254 * but we made duplicates, so get rid of these.
1255 */
1256 if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 && ((canceled == 0) || (duplicate))) {
1257 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcu, false, false);
1259 fcu, SELECT, false); /* Only use handles in graph editor. */
1260 ANIM_nla_mapping_apply_if_needed_fcurve(&ale, fcu, true, false);
1261 }
1262 break;
1263 }
1264 case ALE_GREASE_PENCIL_CEL: {
1265 GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(ale.id);
1267 *static_cast<bke::greasepencil::Layer *>(ale.data),
1268 canceled,
1269 duplicate);
1270 grease_pencils_to_update.add(grease_pencil);
1271 break;
1272 }
1273 default:
1274 BLI_assert_msg(false, "Keys cannot be transformed into this animation type.");
1275 }
1276 }
1277
1278 /* Free temp memory. */
1279 ANIM_animdata_freelist(&anim_data);
1280 }
1281 else if (ac.datatype == ANIMCONT_ACTION) { /* TODO: just integrate into the above. */
1282 /* Depending on the lock status, draw necessary views. */
1283 /* FIXME: some of this stuff is not good. */
1284 if (ob) {
1285 if (ob->pose || BKE_key_from_object(ob)) {
1287 }
1288 else {
1290 }
1291 }
1292
1293 /* 3 cases here for curve cleanups:
1294 * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
1295 * 2) canceled == 0 -> user confirmed the transform,
1296 * so duplicates should be removed.
1297 * 3) canceled + duplicate -> user canceled the transform,
1298 * but we made duplicates, so get rid of these.
1299 */
1300 if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 && ((canceled == 0) || (duplicate))) {
1301 posttrans_action_clean(&ac, static_cast<bAction *>(ac.data));
1302 }
1303 }
1304 else if (ac.datatype == ANIMCONT_GPENCIL) {
1305 /* Remove duplicate frames and also make sure points are in order! */
1306 /* 3 cases here for curve cleanups:
1307 * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done.
1308 * 2) canceled == 0 -> user confirmed the transform,
1309 * so duplicates should be removed.
1310 * 3) canceled + duplicate -> user canceled the transform,
1311 * but we made duplicates, so get rid of these.
1312 */
1313 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1314 const int filter = ANIMFILTER_DATA_VISIBLE;
1316 &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
1317
1318 for (bAnimListElem &ale : anim_data) {
1319 switch (ale.datatype) {
1320 case ALE_GPFRAME:
1321 /* Grease Pencil legacy. */
1322 if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 && ((canceled == 0) || (duplicate))) {
1323 ale.id->tag &= ~ID_TAG_DOIT;
1324 posttrans_gpd_clean(id_cast<bGPdata *>(ale.id));
1325 }
1326 break;
1327
1328 case ALE_GREASE_PENCIL_CEL: {
1329 GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(ale.id);
1331 *static_cast<bke::greasepencil::Layer *>(ale.data),
1332 canceled,
1333 duplicate);
1334 grease_pencils_to_update.add(grease_pencil);
1335 break;
1336 }
1337
1338 default:
1339 break;
1340 }
1341 }
1342 ANIM_animdata_freelist(&anim_data);
1343 }
1344 else if (ac.datatype == ANIMCONT_MASK) {
1345 /* Remove duplicate frames and also make sure points are in order! */
1346 /* 3 cases here for curve cleanups:
1347 * 1) NOTRANSKEYCULL on:
1348 * Cleanup of duplicates shouldn't be done.
1349 * 2) canceled == 0:
1350 * User confirmed the transform, so duplicates should be removed.
1351 * 3) Canceled + duplicate:
1352 * User canceled the transform, but we made duplicates, so get rid of these.
1353 */
1354 if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 && ((canceled == 0) || (duplicate))) {
1355 ListBaseT<bAnimListElem> anim_data = {nullptr, nullptr};
1356 const int filter = ANIMFILTER_DATA_VISIBLE;
1358 &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype));
1359
1360 for (bAnimListElem &ale : anim_data) {
1361 if (ale.datatype == ALE_MASKLAY) {
1362 ale.id->tag &= ~ID_TAG_DOIT;
1363 posttrans_mask_clean(id_cast<Mask *>(ale.id));
1364 }
1365 }
1366 ANIM_animdata_freelist(&anim_data);
1367 }
1368 }
1369
1370 if (!grease_pencils_to_update.is_empty()) {
1371 for (GreasePencil *grease_pencil : grease_pencils_to_update) {
1372 /* All frame data is updated, safe to remove the fake user and remove unused drawings. */
1374 grease_pencil->remove_drawings_with_no_users();
1375 }
1376 }
1377
1378 /* Marker transform, not especially nice but we may want to move markers
1379 * at the same time as keyframes in the dope sheet. */
1380 if ((saction->flag & SACTION_MARKERS_MOVE) && (canceled == 0)) {
1381 if (t->mode == TFM_TIME_TRANSLATE) {
1382#if 0
1383 if (ELEM(t->frame_side, 'L', 'R')) { /* #TFM_TIME_EXTEND. */
1384 /* Same as below. */
1387 }
1388 else /* #TFM_TIME_TRANSLATE. */
1389#endif
1390 {
1393 }
1394 }
1395 else if (t->mode == TFM_TIME_SCALE) {
1398 }
1399 }
1400
1401 /* Make sure all F-Curves are set correctly. */
1402 if (!ELEM(ac.datatype, ANIMCONT_GPENCIL)) {
1404 }
1405
1406 /* Clear flag that was set for time-slide drawing. */
1407 saction->flag &= ~SACTION_MOVING;
1408}
1409
1411
1413 /*flags*/ (T_POINTS | T_2D_EDIT),
1414 /*create_trans_data*/ createTransActionData,
1415 /*recalc_data*/ recalcData_actedit,
1416 /*special_aftertrans_update*/ special_aftertrans_update__actedit,
1417};
1418
1419} // namespace blender::ed::transform
Low-level operations for grease pencil.
#define SELECT
Definition BKE_mask.hh:19
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define NA_EDITED
Definition WM_types.hh:634
#define NC_GPENCIL
Definition WM_types.hh:412
#define NC_MASK
Definition WM_types.hh:411
#define BLI_assert_unreachable()
#define ELEM(...)
#define BLI_assert_msg(a, msg)
void clear()
Definition BLI_map.hh:1038
bool add_overwrite(const Key &key, const Value &value)
Definition BLI_map.hh:325
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
ItemIterator items() const &
Definition BLI_map.hh:902
bool add(const Key &key)
Definition BLI_set.hh:248
bool is_empty() const
Definition BLI_set.hh:614
void append(const T &value)
Span< T > as_span() const
#define FLT_MAX
#define INT_MAX
#define layer
#define abs
float distance(float, float) RET
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
Definition math_dual.h:241
static bool grease_pencil_layer_reset_trans_data(bke::greasepencil::Layer &layer)
static TransData * ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FCurve *fcu, bAnimListElem *ale, char side, float cfra, bool is_prop_edit, float ypos)
static void invert_snap(eSnapMode &snap_mode)
static int count_masklayer_frames(MaskLayer *masklay, char side, float cfra, bool is_prop_edit)
static bool is_td2d_int(TransData2D *td2d)
static void grease_pencil_transdata_add_fake_drawing_users(const GreasePencil &grease_pencil)
static void posttrans_action_clean(bAnimContext *ac, bAction *act)
static void posttrans_gpd_clean(bGPdata *gpd)
static void grease_pencil_transdata_remove_fake_drawing_users(const GreasePencil &grease_pencil)
static void TimeToTransData(TransData *td, TransData2D *td2d, BezTriple *bezt, bAnimListElem *ale, float ypos)
char transform_convert_frame_side_dir_get(TransInfo *t, float cframe)
static int count_grease_pencil_frames(const bke::greasepencil::Layer *layer, const char side, const float cfra, const bool is_prop_edit, const bool use_duplicated)
static bool grease_pencil_layer_initialize_trans_data(const GreasePencil &grease_pencil, bke::greasepencil::Layer &layer, const Span< int > frames_affected, const bool use_duplicates)
static bool grease_pencil_layer_update_trans_data(bke::greasepencil::Layer &layer, const int src_frame_number, const int dst_frame_number)
static int count_fcurve_keys(FCurve *fcu, char side, float cfra, bool is_prop_edit)
static void createTransActionData(bContext *C, TransInfo *t)
static bool grease_pencil_layer_apply_trans_data(GreasePencil &grease_pencil, bke::greasepencil::Layer &layer, const bool canceled, const bool duplicate)
static void posttrans_mask_clean(Mask *mask)
TransConvertTypeInfo TransConvertType_Action
bool FrameOnMouseSide(char side, float frame, float cframe)
static int GPLayerToTransData(TransData *td, TransData2D *td2d, bGPDlayer *gpl, char side, float cfra, bool is_prop_edit, float ypos)
void transform_snap_anim_flush_data(TransInfo *t, TransData *td, eSnapMode snap_mode, float *r_val_final)
static void special_aftertrans_update__actedit(bContext *C, TransInfo *t)
static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra, bool is_prop_edit)
static int masklay_shape_cmp_frame(void *thunk, const void *a, const void *b)
void transform_convert_flush_handle2D(TransData *td, TransData2D *td2d, const float y_fac)
static void recalcData_actedit(TransInfo *t)
static int MaskLayerToTransData(TransData *td, TransData2D *td2d, MaskLayer *masklay, char side, float cfra, bool is_prop_edit, float ypos)
static int GreasePencilLayerToTransData(TransData *td, TransData2D *td2d, GreasePencil *grease_pencil, bke::greasepencil::Layer *layer, const char side, const float cfra, const bool is_prop_edit, const float ypos, const bool duplicate)
BLI_INLINE Texture * wrap(MTLTexture *texture)
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
MINLINE void copy_v3_v3(float r[3], const float a[3])
@ ANIMCONT_SHAPEKEY
@ ANIMCONT_TIMELINE
@ ANIMCONT_ACTION
@ ANIMCONT_DOPESHEET
@ ANIMCONT_GPENCIL
ListBaseT< TimeMarker > * ED_context_get_markers(const bContext *C)
MINLINE int round_fl_to_int(float a)
MINLINE void copy_v2_v2(float r[2], const float a[2])
@ 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)
float ANIM_nla_tweakedit_remap(bAnimListElem *ale, const float cframe, const eNlaTime_ConvertModes mode)
Definition anim_draw.cc:329
bool ANIM_nla_mapping_allowed(const bAnimListElem *ale)
Definition anim_draw.cc:279
@ ANIMTYPE_MASKDATABLOCK
@ ANIMTYPE_NLAACTION
@ ANIMTYPE_NLACURVE
@ ANIMTYPE_GREASE_PENCIL_LAYER_GROUP
@ ANIMTYPE_DSPOINTCLOUD
@ ANIMTYPE_DSMCLIP
@ ANIMTYPE_DSLIGHTPROBE
@ ANIMTYPE_DSNTREE
@ ANIMTYPE_GREASE_PENCIL_DATABLOCK
@ ANIMTYPE_FCURVE
@ ANIMTYPE_ANIMDATA
@ ANIMTYPE_DSVOLUME
@ ANIMTYPE_NLATRACK
@ ANIMTYPE_OBJECT
@ ANIMTYPE_GPLAYER
@ ANIMTYPE_GREASE_PENCIL_LAYER
@ ANIMTYPE_DSMBALL
@ ANIMTYPE_DSMESH
@ ANIMTYPE_NUM_TYPES
@ ANIMTYPE_NLACONTROLS
@ ANIMTYPE_DSHAIR
@ ANIMTYPE_FILLDRIVERS
@ ANIMTYPE_SUMMARY
@ ANIMTYPE_FILLACT_LAYERED
@ ANIMTYPE_SHAPEKEY
@ ANIMTYPE_SPECIALDATA__UNUSED
@ ANIMTYPE_ACTION_SLOT
@ ANIMTYPE_DSCACHEFILE
@ ANIMTYPE_MASKLAYER
@ ANIMTYPE_DSGPENCIL
@ ANIMTYPE_DSPART
@ ANIMTYPE_FILLACTD
@ ANIMTYPE_DSSKEY
@ ANIMTYPE_DSLINESTYLE
@ ANIMTYPE_PALETTE
bool ANIM_animdata_context_getdata(bAnimContext *ac)
void ANIM_nla_mapping_apply_if_needed_fcurve(bAnimListElem *ale, FCurve *fcu, const bool restore, const bool only_keys)
Definition anim_draw.cc:406
void BKE_fcurve_merge_duplicate_keys(FCurve *fcu, const int sel_flag, const bool use_handle)
void ANIM_id_update(Main *bmain, ID *id)
Definition anim_deps.cc:105
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
@ ALE_GREASE_PENCIL_CEL
size_t ANIM_animdata_filter(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const eAnimFilter_Flags filter_mode, void *data, const eAnimCont_Types datatype)
void void void BLI_listbase_sort_r(ListBase *listbase, int(*cmp)(void *, const void *, const void *), void *thunk) ATTR_NONNULL(1
Definition listbase.cc:328
@ ANIMFILTER_FCURVESONLY
@ ANIMFILTER_ANIMDATA
@ ANIMFILTER_FOREDIT
@ ANIMFILTER_DATA_VISIBLE
void BKE_mask_layer_shape_unlink(MaskLayer *masklay, MaskLayerShape *masklay_shape)
void DEG_id_tag_update(ID *id, unsigned int flags)
void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
Definition anim_deps.cc:54
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.hh:215
void ANIM_editkeyframes_refresh(bAnimContext *ac)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
Main * CTX_data_main(const bContext *C)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
void ANIM_animdata_freelist(ListBaseT< bAnimListElem > *anim_data)
Definition anim_deps.cc:472
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition BLI_rect.hh:198
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1054
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
bool BKE_annotations_layer_frame_delete(struct bGPDlayer *gpl, struct bGPDframe *gpf)
@ ID_TAG_DOIT
Definition DNA_ID.h:1029
void BKE_annotations_layer_frames_sort(struct bGPDlayer *gpl, bool *r_has_duplicate_frames)
@ SACTION_NOREALTIMEUPDATES
Key * BKE_key_from_object(Object *ob)
Definition key.cc:1311
int ED_markers_post_apply_transform(ListBaseT< TimeMarker > *markers, Scene *scene, int mode, float value, char side)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
eRegion_Type regiontype
eBezTriple_Flag f2
bke::greasepencil::DrawingRuntime * runtime
MaskLayerShapeFlag flag
struct MaskLayerShape * next
ListBaseT< MaskLayerShape > splines_shapes
struct bPose * pose
struct RenderData r
ListBaseT< SpaceLink > spacedata
eAnimCont_Types datatype
ListBaseT< bGPDframe > frames
ListBaseT< bGPDlayer > layers
Map< int, GreasePencilFrame > duplicated_frames_buffer
#define TRANS_DATA_CONTAINER_FIRST_SINGLE(t)
Definition transform.hh:45
conversion and adaptation of different datablocks to a common struct.