Blender V5.3
ED_keyframes_edit.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_array.hh"
12#include "BLI_enum_flags.hh"
14
15#include "ED_anim_api.hh" /* for enum eAnimFilter_Flags */
16
17#include "DNA_curve_types.h"
18#include "DNA_listBase.h"
19
20namespace blender {
21
22struct BezTriple;
24struct FCurve;
25struct Scene;
26struct bAnimContext;
27struct bAnimListElem;
28struct bDopeSheet;
29
30/* -------------------------------------------------------------------- */
35
38 /* Frame range */
41 /* Selection status (any of f1, f2, f3) */
43 /* Selection status (f2 is enough) */
45 /* Values (y-val) only */
48 /* For graph editor keyframes (2D tests) */
52 /* Only for keyframes a certain Dope-sheet channel. */
55};
56
58
59/* -------------------------------------------------------------------- */
62
63/* select modes */
65 /* SELECT_SUBTRACT for all, followed by SELECT_ADD for some */
66 SELECT_REPLACE = (1 << 0),
67 /* add ok keyframes to selection */
68 SELECT_ADD = (1 << 1),
69 /* remove ok keyframes from selection */
70 SELECT_SUBTRACT = (1 << 2),
71 /* flip ok status of keyframes based on key status */
72 SELECT_INVERT = (1 << 3),
74};
75
76/* "selection map" building modes. */
81
82/* snapping tools */
92
93/* equalizing tools */
99
100/* mirroring tools */
109
110/* use with BEZT_OK_REGION_LASSO */
116
117/* use with BEZT_OK_REGION_CIRCLE */
124
126
127/* -------------------------------------------------------------------- */
132
133/* which verts of a keyframe is active (after polling) */
136 /* 'key' itself is ok */
137 KEYFRAME_OK_KEY = (1 << 0),
138 /* 'handle 1' is ok */
139 KEYFRAME_OK_H1 = (1 << 1),
140 /* 'handle 2' is ok */
141 KEYFRAME_OK_H2 = (1 << 2),
142 /* all flags */
144};
145
146/* Flags for use during iteration */
148 /* Consider handles in addition to key itself. Used in #keyframe_ok_checks, #select_bezier_add,
149 * #select_bezier_subtract. If set, treat key and handles separately (e.g (de)select them
150 * individually, and do additional visibility checks on the handles if necessary), otherwise
151 * always treat key and handles the same (e.g. (de)select all of them).
152 */
154
155 /* Perform NLA time remapping (global -> strip) for the "f1" parameter
156 * (e.g. used for selection tools on summary tracks)
157 */
159
160 /* Perform NLA time remapping (global -> strip) for the "f2" parameter */
162
163 /* Set this when handles aren't visible by default and you want to perform additional checks to
164 * get the actual visibility state. E.g. in some cases handles are only drawn if either a handle
165 * or their control point is selected. The selection state will have to be checked in the
166 * iterator callbacks then. */
167 /* Represents "Only Selected Keyframes" option (SIPO_SELVHANDLESONLY). */
169
170 /* Represents "Show Handles" option (SIPO_NOHANDLES). */
172};
174
175
176
177/* -------------------------------------------------------------------- */
180
181
185struct CfraElem {
187 /* Expected to be in global scene time (e.g. not NLA unmapped). */
188 float cfra;
189 int sel;
190};
191
193 /* generic properties/data access */
195 ListBaseT<CfraElem> cfra_elem_list;
196 ListBaseT<TimeMarker> time_marker_list;
200 void *data;
202 float f1, f2;
204 int i1, i2;
205
206 /* current iteration data */
213
214 /* flags */
219};
220
222
223/* -------------------------------------------------------------------- */
226
228using FcuEditFunc = void (*)(FCurve &fcu);
230using KeyframeEditFunc = short (*)(KeyframeEditData *ked, BezTriple *bezt);
231
233
234/* -------------------------------------------------------------------- */
237
240 float oldMin, oldMax; /* old range */
241 float newMin, newMax; /* new range */
242};
243
255
268
279
289
291
292/* -------------------------------------------------------------------- */
297
305short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
306 FCurve *fcu,
307 KeyframeEditFunc key_ok,
308 KeyframeEditFunc key_cb,
309 FcuEditFunc fcu_cb);
319 float handle_length,
320 bool flatten);
321
325short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked,
326 bDopeSheet *ads,
327 bAnimListElem *ale,
328 KeyframeEditFunc key_ok,
329 KeyframeEditFunc key_cb,
330 FcuEditFunc fcu_cb);
331
336void ANIM_animdata_keyframe_callback(bAnimContext *ac,
337 eAnimFilter_Flags filter,
338 KeyframeEditFunc callback_fn);
339
343void ANIM_editkeyframes_refresh(bAnimContext *ac);
344
346
347/* -------------------------------------------------------------------- */
350
351/* accessories */
353
354/* edit */
371
373
374/* -------------------------------------------------------------------- */
377
383
388short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt);
389
391
392/* -------------------------------------------------------------------- */
395
399short bezt_calc_average(KeyframeEditData *ked, BezTriple *bezt);
400
404short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt);
405
410void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt);
411
413
414/* -------------------------------------------------------------------- */
417
418/* XXX: These are temporary,
419 * until we can unify GP/Mask Keyframe handling and standard FCurve Keyframe handling */
420
421bool keyframe_region_lasso_test(const KeyframeEdit_LassoData *data_lasso, const float xy[2]);
422
423bool keyframe_region_circle_test(const KeyframeEdit_CircleData *data_circle, const float xy[2]);
424
426
427/* -------------------------------------------------------------------- */
432
433bool duplicate_fcurve_keys(FCurve *fcu);
434float get_default_rna_value(const FCurve *fcu, PropertyRNA *prop, PointerRNA *ptr);
435
440
447ListBaseT<FCurveSegment> find_fcurve_segments(FCurve *fcu);
448void clean_fcurve(bAnimListElem *ale, float thresh, bool cleardefault, bool only_selected_keys);
449void blend_to_neighbor_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
450void breakdown_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
451void scale_average_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
452void push_pull_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
454enum class FCurveSegmentAnchor { LEFT, RIGHT };
456 FCurveSegment *segment,
457 float factor,
458 FCurveSegmentAnchor anchor);
464void ED_ANIM_get_1d_gauss_kernel(const float sigma, int kernel_size, double *r_kernel);
465
466ButterworthCoefficients *ED_anim_allocate_butterworth_coefficients(const int filter_order);
467void ED_anim_free_butterworth_coefficients(ButterworthCoefficients *bw_coeff);
468void ED_anim_calculate_butterworth_coefficients(float cutoff_frequency,
469 float sampling_frequency,
470 ButterworthCoefficients *bw_coeff);
475void butterworth_smooth_fcurve_segment(FCurve *fcu,
476 FCurveSegment *segment,
477 float *samples,
478 int sample_count,
479 float factor,
480 int blend_in_out,
481 int sample_rate,
482 ButterworthCoefficients *bw_coeff);
483void smooth_fcurve_segment(FCurve *fcu,
484 FCurveSegment *segment,
485 const float *original_values,
486 float *samples,
487 const int sample_count,
488 float factor,
489 int kernel_size,
490 const double *kernel);
495void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor, float width);
496
501void shear_fcurve_segment(FCurve *fcu,
502 FCurveSegment *segment,
503 float factor,
504 tShearDirection direction);
512void blend_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
513void blend_to_ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
514void time_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float frame_offset);
515bool decimate_fcurve(bAnimListElem *ale, float remove_ratio, float error_sq_max);
516bool match_slope_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
517
521void blend_to_default_fcurve(PointerRNA *id_ptr, FCurve *fcu, float factor);
525void smooth_fcurve(FCurve *fcu);
526
527/* ----------- */
528
536
541
547bool copy_animedit_keys(bAnimContext *ac, ListBaseT<bAnimListElem> *anim_data);
548
553 bool flip;
554
555 int num_slots_selected; /* Number of selected Action Slots to paste into. */
556 int num_fcurves_selected; /* Number of selected F-Curves to paste into. */
557};
558
560 ListBaseT<bAnimListElem> *anim_data,
561 const KeyframePasteContext &paste_context);
562
564
565} // namespace blender
#define ENUM_OPERATORS(_enum_type)
These structs are the foundation for all linked lists in the library system.
BMesh Iterators.
ButterworthCoefficients * ED_anim_allocate_butterworth_coefficients(const int filter_order)
void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor, const float width)
@ KEYFRAME_PASTE_NOTHING_TO_PASTE
@ KEYFRAME_PASTE_NOWHERE_TO_PASTE
void ANIM_fcurves_copybuf_reset()
KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
void ANIM_fcurves_copybuf_free()
void scale_from_fcurve_segment_neighbor(FCurve *fcu, FCurveSegment *segment, const float factor, const FCurveSegmentAnchor anchor)
KeyframeEditFunc ANIM_editkeyframes_ipo(short mode)
short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt)
KeyframeEditFunc ANIM_editkeyframes_handles(short mode)
void ED_anim_calculate_butterworth_coefficients(const float cutoff_frequency, const float sampling_frequency, ButterworthCoefficients *bw_coeff)
void smooth_fcurve(FCurve *fcu)
void clean_fcurve(bAnimListElem *ale, float thresh, bool cleardefault, const bool only_selected_keys)
void butterworth_smooth_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float *samples, const int sample_count, const float factor, const int blend_in_out, const int sample_rate, ButterworthCoefficients *bw_coeff)
void blend_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
bool duplicate_fcurve_keys(FCurve *fcu)
@ KEYFRAME_PASTE_MERGE_OVER_RANGE_ALL
@ KEYFRAME_PASTE_MERGE_OVER_RANGE
@ KEYFRAME_PASTE_OFFSET_CFRA_START
@ KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE
@ KEYFRAME_PASTE_OFFSET_CFRA_END
short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
void time_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float frame_offset)
void push_pull_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
ListBaseT< FCurveSegment > find_fcurve_segments(FCurve *fcu)
bool keyframe_region_lasso_test(const KeyframeEdit_LassoData *data_lasso, const float xy[2])
bool copy_animedit_keys(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data)
void blend_to_neighbor_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
void ANIM_fcurve_equalize_keyframes_loop(FCurve *fcu, const eEditKeyframes_Equalize mode, const float handle_length, const bool flatten)
void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt)
void breakdown_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
void scale_average_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
void ANIM_editkeyframes_refresh(bAnimContext *ac)
KeyframeEditFunc ANIM_editkeyframes_select(const eEditKeyframes_Select selectmode)
bool match_slope_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode)
short(*)(KeyframeEditData *ked, BezTriple *bezt) KeyframeEditFunc
@ KEYFRAME_PASTE_VALUE_OFFSET_NONE
@ KEYFRAME_PASTE_VALUE_OFFSET_LEFT_KEY
@ KEYFRAME_PASTE_VALUE_OFFSET_CURSOR
@ KEYFRAME_PASTE_VALUE_OFFSET_RIGHT_KEY
@ KEYFRAME_PASTE_VALUE_OFFSET_CFRA
void(*)(FCurve &fcu) FcuEditFunc
void blend_to_default_fcurve(PointerRNA *id_ptr, FCurve *fcu, const float factor)
void smooth_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float *original_values, float *samples, const int sample_count, const float factor, const int kernel_size, const double *kernel)
void shear_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor, tShearDirection direction)
void ED_anim_free_butterworth_coefficients(ButterworthCoefficients *bw_coeff)
bool keyframe_region_circle_test(const KeyframeEdit_CircleData *data_circle, const float xy[2])
float get_default_rna_value(const FCurve *fcu, PropertyRNA *prop, PointerRNA *ptr)
void ED_ANIM_get_1d_gauss_kernel(const float sigma, const int kernel_size, double *r_kernel)
KeyframeEditFunc ANIM_editkeyframes_snap(short mode)
KeyframeEditFunc ANIM_editkeyframes_keytype(const eBezTriple_KeyframeType keyframe_type)
eKeyPasteError paste_animedit_keys(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const KeyframePasteContext &paste_context)
short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt)
KeyframeEditFunc ANIM_editkeyframes_easing(short mode)
short bezt_calc_average(KeyframeEditData *ked, BezTriple *bezt)
void ANIM_animdata_keyframe_callback(bAnimContext *ac, eAnimFilter_Flags filter, KeyframeEditFunc callback_fn)
@ KEYFRAME_ITER_HANDLES_INVISIBLE
@ KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE
bool decimate_fcurve(bAnimListElem *ale, float remove_ratio, float error_sq_max)
short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, bAnimListElem *ale, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
void blend_to_ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
KeyframeEditFunc ANIM_editkeyframes_mirror(short mode)
ListBaseT< TimeMarker > time_marker_list
ListBaseT< CfraElem > cfra_elem_list
eKeyPasteValueOffset value_offset_mode