45 return td2d->
loc2d_i && td2d->
h1 ==
nullptr;
89 const bool use_duplicates)
94 if (trans_data.
status != LayerTransformData::TRANS_CLEAR) {
110 for (
const int frame_number : frames_affected) {
111 const bool was_duplicated = use_duplicates &&
123 if (!was_duplicated) {
134 for (
const auto [frame_number, frame] : layer.frames().items()) {
135 if (frame.is_end()) {
140 trans_data.
frames_duration.
add(frame_number, layer.get_frame_duration_at(frame_number));
143 trans_data.
status = LayerTransformData::TRANS_INIT;
155 if (trans_data.
status == LayerTransformData::TRANS_CLEAR) {
158 trans_data.
status = LayerTransformData::TRANS_INIT;
163 const int src_frame_number,
164 const int dst_frame_number)
169 if (trans_data.
status == LayerTransformData::TRANS_CLEAR) {
173 if (trans_data.
status == LayerTransformData::TRANS_INIT) {
179 layer.tag_frames_map_keys_changed();
180 trans_data.
status = LayerTransformData::TRANS_RUNNING;
194 layer.remove_frame(dst_frame_number);
207 const bool duplicate)
212 if (trans_data.
status == LayerTransformData::TRANS_CLEAR) {
225 layer.tag_frames_map_keys_changed();
230 grease_pencil.move_duplicate_frames(
234 if (canceled && duplicate) {
246 grease_pencil.remove_drawings_with_no_users();
253 trans_data.
status = LayerTransformData::TRANS_CLEAR;
270 int i,
count = 0, count_all = 0;
272 if (
ELEM(
nullptr, fcu, fcu->
bezt)) {
277 for (i = 0, bezt = fcu->
bezt; i < fcu->
totvert; i++, bezt++) {
289 if (is_prop_edit &&
count > 0) {
300 int count = 0, count_all = 0;
302 if (gpl ==
nullptr) {
316 if (is_prop_edit &&
count > 0) {
325 const bool is_prop_edit,
326 const bool use_duplicated)
328 if (layer ==
nullptr) {
332 int count_selected = 0;
335 if (use_duplicated) {
337 count_selected += layer->runtime->trans_data_.duplicated_frames_buffer.size();
338 count_all += count_selected;
342 for (
const auto &[frame_number, frame] : layer->frames().items()) {
346 if (frame.is_selected()) {
353 if (is_prop_edit && count_selected > 0) {
356 return count_selected;
362 int count = 0, count_all = 0;
364 if (masklay ==
nullptr) {
378 if (is_prop_edit &&
count > 0) {
388 float *time = bezt->
vec[1];
393 td2d->
h1 = bezt->
vec[0];
394 td2d->
h2 = bezt->
vec[2];
411 td->center[0] = td->ival;
413 td->center[1] = ypos;
449 if (
ELEM(
nullptr, fcu, fcu->
bezt)) {
453 for (i = 0, bezt = fcu->
bezt; i < fcu->
totvert; i++, bezt++) {
455 if (is_prop_edit || (bezt->
f2 &
SELECT))
493 if (is_prop_edit || is_selected) {
495 td2d->
loc[0] =
float(gpf->framenum);
496 td2d->
loc2d_i = &gpf->framenum;
498 td->loc = td->val = td2d->
loc;
499 td->iloc[0] = td->ival = td2d->
loc[0];
501 td->center[0] = td->ival;
502 td->center[1] = ypos;
532 const bool is_prop_edit,
534 const bool duplicate)
537 using namespace bke::greasepencil;
539 int total_trans_frames = 0;
540 bool any_frame_affected =
false;
543 const auto grease_pencil_frame_to_trans_data = [&](
const int frame_number,
544 const bool frame_selected) {
548 if ((!is_prop_edit && !frame_selected) || !
FrameOnMouseSide(side, frame_number, cfra)) {
554 td->val = td->loc = &td2d->
loc[0];
555 td->ival = td->iloc[0] = td2d->
loc[0];
557 td->center[0] = td->ival;
558 td->center[1] = ypos;
560 if (frame_selected) {
574 total_trans_frames++;
576 frames_affected.
append(frame_number);
577 any_frame_affected =
true;
581 duplicate ? (layer->runtime->trans_data_.duplicated_frames_buffer) : layer->frames();
583 for (
const auto [frame_number, frame] : frame_map.
items()) {
584 grease_pencil_frame_to_trans_data(frame_number, frame.is_selected());
587 if (total_trans_frames == 0) {
588 return total_trans_frames;
593 if (any_frame_affected) {
595 *grease_pencil, *layer, frames_affected.
as_span(), duplicate);
598 return total_trans_frames;
618 td2d->
loc[0] =
float(masklay_shape->frame);
619 td2d->
loc2d_i = &masklay_shape->frame;
621 td->loc = td->val = td2d->
loc;
622 td->iloc[0] = td->ival = td2d->
loc[0];
624 td->center[0] = td->ival;
625 td->center[1] = ypos;
659 ListBase anim_data = {
nullptr,
nullptr};
697 cfra =
float(scene->r.cfra);
713 static_cast<Layer *
>(ale->data), t->
frame_side, cfra, is_prop_edit, use_duplicated);
768 gpf_count += adt_count;
776 if (
count == 0 && gpf_count == 0) {
797 if (is_prop_edit && !ale->tag) {
801 cfra =
float(scene->r.cfra);
822 Layer *layer =
static_cast<Layer *
>(ale->data);
826 td, td2d, grease_pencil, layer, t->
frame_side, cfra, is_prop_edit, ypos, use_duplicated);
863 cfra =
float(scene->r.cfra);
878 int val =
abs(gpf->framenum - gpf_iter->framenum);
892 Layer *layer =
static_cast<Layer *
>(ale->data);
894 const auto grease_pencil_closest_selected_frame = [&](
const int frame_number,
895 const bool frame_selected) {
896 if (frame_selected) {
902 int closest_selected = INT_MAX;
903 for (
const auto [neighbor_frame_number, neighbor_frame] : layer->frames().items()) {
904 if (!neighbor_frame.is_selected() ||
909 const int distance =
abs(neighbor_frame_number - frame_number);
910 closest_selected = std::min(closest_selected, distance);
917 for (
const auto [frame_number, frame] : layer->frames().items()) {
918 grease_pencil_closest_selected_frame(frame_number, frame.is_selected());
921 if (use_duplicated) {
923 for (
const auto [frame_number, frame] :
924 layer->runtime->trans_data_.duplicated_frames_buffer.items())
926 grease_pencil_closest_selected_frame(frame_number, frame.is_selected());
943 int val =
abs(masklay_shape->frame - masklay_iter->frame);
961 for (i = 0, bezt = fcu->
bezt; i < fcu->
totvert; i++, bezt++) {
970 for (j = 0, bezt_iter = fcu->
bezt; j < fcu->
totvert; j++, bezt_iter++) {
973 float val =
fabs(bezt->
vec[1][0] - bezt_iter->
vec[1][0]);
1004 snap_mode &= ~SCE_SNAP_TO_FRAME;
1008 snap_mode &= ~SCE_SNAP_TO_SECOND;
1019 ListBase anim_data = {
nullptr,
nullptr};
1054 td->loc[1] = td->iloc[1];
1124 *((
bool *)thunk) =
true;
1136 bool is_double =
false;
1141 for (masklay_shape =
static_cast<MaskLayerShape *
>(masklay->splines_shapes.first);
1143 masklay_shape = masklay_shape_next)
1145 masklay_shape_next = masklay_shape->
next;
1146 if (masklay_shape_next && masklay_shape->
frame == masklay_shape_next->
frame) {
1153 for (masklay_shape =
static_cast<MaskLayerShape *
>(masklay->splines_shapes.first);
1155 masklay_shape = masklay_shape->
next)
1174 bool is_double =
false;
1179 for (gpf =
static_cast<bGPDframe *
>(gpl->frames.first); gpf; gpf = gpfn) {
1188 for (gpf =
static_cast<bGPDframe *
>(gpl->frames.first); gpf; gpf = gpf->
next) {
1206 ListBase anim_data = {
nullptr,
nullptr};
1253 ListBase anim_data = {
nullptr,
nullptr};
1261 switch (ale->datatype) {
1263 ale->id->tag &= ~ID_TAG_DOIT;
1302 BLI_assert_msg(
false,
"Keys cannot be transformed into this animation type.");
1341 ListBase anim_data = {
nullptr,
nullptr};
1347 switch (ale->datatype) {
1351 ale->id->tag &= ~ID_TAG_DOIT;
1383 ListBase anim_data = {
nullptr,
nullptr};
1390 ale->id->tag &= ~ID_TAG_DOIT;
1427 saction->
flag &= ~SACTION_MOVING;
Main * CTX_data_main(const bContext *C)
void BKE_fcurve_merge_duplicate_keys(FCurve *fcu, const int sel_flag, const bool use_handle)
void BKE_gpencil_layer_frames_sort(struct bGPDlayer *gpl, bool *r_has_duplicate_frames)
bool BKE_gpencil_layer_frame_delete(struct bGPDlayer *gpl, struct bGPDframe *gpf)
Low-level operations for grease pencil.
Key * BKE_key_from_object(Object *ob)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
void BKE_mask_layer_shape_unlink(struct MaskLayer *masklay, struct MaskLayerShape *masklay_shape)
float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode)
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
#define LISTBASE_FOREACH(type, var, list)
void void void BLI_listbase_sort_r(ListBase *listbase, int(*cmp)(void *, const void *, const void *), void *thunk) ATTR_NONNULL(1
MINLINE int round_fl_to_int(float a)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ SACTION_NOREALTIMEUPDATES
@ ANIMTYPE_SPECIALDATA__UNUSED
@ ANIMTYPE_GREASE_PENCIL_DATABLOCK
@ ANIMTYPE_GREASE_PENCIL_LAYER
@ ANIMTYPE_FILLACT_LAYERED
@ ANIMTYPE_GREASE_PENCIL_LAYER_GROUP
@ ANIMFILTER_DATA_VISIBLE
Read Guarded memory(de)allocation.
void ANIM_animdata_freelist(ListBase *anim_data)
void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
AnimData * ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, bool only_keys)
bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
bool ANIM_animdata_context_getdata(bAnimContext *ac)
size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, const eAnimFilter_Flags filter_mode, void *data, const eAnimCont_Types datatype)
int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, float value, char side)
ListBase * ED_context_get_markers(const bContext *C)
bool remove_as(const ForwardKey &key)
bool add_overwrite(const Key &key, const Value &value)
bool add(const Key &key, const Value &value)
const Value & lookup(const Key &key) const
Value lookup_default(const Key &key, const Value &default_value) const
ValueIterator values() const
ItemIterator items() const
bool contains(const Key &key) const
void append(const T &value)
Span< T > as_span() const
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
void ANIM_editkeyframes_refresh(bAnimContext *ac)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float2 fabs(const float2 a)
float wrap(float value, float max, float min)
struct MaskLayerShape * next
ccl_device_inline int abs(int x)
void WM_main_add_notifier(uint type, void *reference)