Blender V5.0
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"
13
14#include "ED_anim_api.hh" /* for enum eAnimFilter_Flags */
15
16#include "DNA_curve_types.h"
17
18struct BezTriple;
20struct FCurve;
21struct Scene;
22struct bAnimContext;
23struct bAnimListElem;
24struct bDopeSheet;
25
26/* ************************************************ */
27/* Common Macros and Defines */
28
29/* -------------------------------------------------------------------- */
32
35 /* Frame range */
38 /* Selection status (any of f1, f2, f3) */
40 /* Selection status (f2 is enough) */
42 /* Values (y-val) only */
45 /* For graph editor keyframes (2D tests) */
49 /* Only for keyframes a certain Dope-sheet channel. */
52};
53
55
56/* select modes */
58 /* SELECT_SUBTRACT for all, followed by SELECT_ADD for some */
59 SELECT_REPLACE = (1 << 0),
60 /* add ok keyframes to selection */
61 SELECT_ADD = (1 << 1),
62 /* remove ok keyframes from selection */
63 SELECT_SUBTRACT = (1 << 2),
64 /* flip ok status of keyframes based on key status */
65 SELECT_INVERT = (1 << 3),
67};
68
69/* "selection map" building modes. */
74
75/* snapping tools */
85
86/* equalizing tools */
92
93/* mirroring tools */
102
103/* use with BEZT_OK_REGION_LASSO */
109
110/* use with BEZT_OK_REGION_CIRCLE */
117
118/* ************************************************ */
119/* Non-Destructive Editing API (keyframes_edit.cc) */
120
121/* -------------------------------------------------------------------- */
124
125/* which verts of a keyframe is active (after polling) */
128 /* 'key' itself is ok */
129 KEYFRAME_OK_KEY = (1 << 0),
130 /* 'handle 1' is ok */
131 KEYFRAME_OK_H1 = (1 << 1),
132 /* 'handle 2' is ok */
133 KEYFRAME_OK_H2 = (1 << 2),
134 /* all flags */
136};
137
138/* Flags for use during iteration */
140 /* Consider handles in addition to key itself. Used in #keyframe_ok_checks, #select_bezier_add,
141 * #select_bezier_subtract. If set, treat key and handles separately (e.g (de)select them
142 * individually, and do additional visibility checks on the handles if necessary), otherwise
143 * always treat key and handles the same (e.g. (de)select all of them).
144 */
146
147 /* Perform NLA time remapping (global -> strip) for the "f1" parameter
148 * (e.g. used for selection tools on summary tracks)
149 */
151
152 /* Perform NLA time remapping (global -> strip) for the "f2" parameter */
154
155 /* Set this when handles aren't visible by default and you want to perform additional checks to
156 * get the actual visibility state. E.g. in some cases handles are only drawn if either a handle
157 * or their control point is selected. The selection state will have to be checked in the
158 * iterator callbacks then. */
159 /* Represents "Only Selected Keyframes" option (SIPO_SELVHANDLESONLY). */
161
162 /* Represents "Show Handles" option (SIPO_NOHANDLES). */
164};
166
167
168
169/* -------------------------------------------------------------------- */
172
173
177struct CfraElem {
179 /* Expected to be in global scene time (e.g. not NLA unmapped). */
180 float cfra;
181 int sel;
182};
183
185 /* generic properties/data access */
191 void *data;
193 float f1, f2;
195 int i1, i2;
196
197 /* current iteration data */
204
205 /* flags */
210};
211
213
214/* -------------------------------------------------------------------- */
217
219using FcuEditFunc = void (*)(FCurve *fcu);
221using KeyframeEditFunc = short (*)(KeyframeEditData *ked, BezTriple *bezt);
222
224
225/* -------------------------------------------------------------------- */
228
231 float oldMin, oldMax; /* old range */
232 float newMin, newMax; /* new range */
233};
234
246
259
270
280
282
283/* -------------------------------------------------------------------- */
288
297 FCurve *fcu,
298 KeyframeEditFunc key_ok,
299 KeyframeEditFunc key_cb,
300 FcuEditFunc fcu_cb);
310 float handle_length,
311 bool flatten);
312
317 bDopeSheet *ads,
318 bAnimListElem *ale,
319 KeyframeEditFunc key_ok,
320 KeyframeEditFunc key_cb,
321 FcuEditFunc fcu_cb);
322
329 KeyframeEditFunc callback_fn);
330
335
337
338/* -------------------------------------------------------------------- */
341
342/* accessories */
344
345/* edit */
362
364
365/* -------------------------------------------------------------------- */
368
374
380
382
383/* -------------------------------------------------------------------- */
386
391
396
402
404
405/* -------------------------------------------------------------------- */
408
409/* XXX: These are temporary,
410 * until we can unify GP/Mask Keyframe handling and standard FCurve Keyframe handling */
411
412bool keyframe_region_lasso_test(const KeyframeEdit_LassoData *data_lasso, const float xy[2]);
413
414bool keyframe_region_circle_test(const KeyframeEdit_CircleData *data_circle, const float xy[2]);
415
416/* ************************************************ */
417/* Destructive Editing API `keyframes_general.cc`. */
418
420float get_default_rna_value(const FCurve *fcu, PropertyRNA *prop, PointerRNA *ptr);
421
426
434void clean_fcurve(bAnimListElem *ale, float thresh, bool cleardefault, bool only_selected_keys);
435void blend_to_neighbor_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
436void breakdown_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
437void scale_average_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
438void push_pull_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
442 FCurveSegment *segment,
443 float factor,
444 FCurveSegmentAnchor anchor);
450void ED_ANIM_get_1d_gauss_kernel(const float sigma, int kernel_size, double *r_kernel);
451
454void ED_anim_calculate_butterworth_coefficients(float cutoff_frequency,
455 float sampling_frequency,
456 ButterworthCoefficients *bw_coeff);
462 FCurveSegment *segment,
463 float *samples,
464 int sample_count,
465 float factor,
466 int blend_in_out,
467 int sample_rate,
468 ButterworthCoefficients *bw_coeff);
470 FCurveSegment *segment,
471 const float *original_values,
472 float *samples,
473 const int sample_count,
474 float factor,
475 int kernel_size,
476 const double *kernel);
481void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor, float width);
482
488 FCurveSegment *segment,
489 float factor,
490 tShearDirection direction);
498void blend_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
499void blend_to_ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
500void time_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float frame_offset);
501bool decimate_fcurve(bAnimListElem *ale, float remove_ratio, float error_sq_max);
502bool match_slope_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor);
503
507void blend_to_default_fcurve(PointerRNA *id_ptr, FCurve *fcu, float factor);
511void smooth_fcurve(FCurve *fcu);
512
513/* ----------- */
514
522
527
533bool copy_animedit_keys(bAnimContext *ac, ListBase *anim_data);
534
539 bool flip;
540
541 int num_slots_selected; /* Number of selected Action Slots to paste into. */
542 int num_fcurves_selected; /* Number of selected F-Curves to paste into. */
543};
544
546 ListBase *anim_data,
547 const KeyframePasteContext &paste_context);
548
549/* ************************************************ */
550
#define ENUM_OPERATORS(_type, _max)
eBezTriple_KeyframeType
eAnimFilter_Flags
void scale_average_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor)
tShearDirection
@ SHEAR_FROM_RIGHT
@ SHEAR_FROM_LEFT
eEditKeyframes_Mirror
@ MIRROR_KEYS_VALUE
@ MIRROR_KEYS_YAXIS
@ MIRROR_KEYS_MARKER
@ MIRROR_KEYS_CURFRAME
@ MIRROR_KEYS_XAXIS
@ MIRROR_KEYS_TIME
void shear_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor, tShearDirection direction)
KeyframeEditFunc ANIM_editkeyframes_mirror(short mode)
short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt)
void time_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float frame_offset)
void smooth_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float *original_values, float *samples, const int sample_count, float factor, int kernel_size, const double *kernel)
float get_default_rna_value(const FCurve *fcu, PropertyRNA *prop, PointerRNA *ptr)
eEditKeyframes_Equalize
@ EQUALIZE_HANDLES_LEFT
@ EQUALIZE_HANDLES_RIGHT
@ EQUALIZE_HANDLES_BOTH
void ANIM_editkeyframes_refresh(bAnimContext *ac)
bool decimate_fcurve(bAnimListElem *ale, float remove_ratio, float error_sq_max)
KeyframeEditFunc ANIM_editkeyframes_easing(short mode)
void ANIM_fcurves_copybuf_reset()
void clean_fcurve(bAnimListElem *ale, float thresh, bool cleardefault, bool only_selected_keys)
KeyframeEditFunc ANIM_editkeyframes_select(eEditKeyframes_Select selectmode)
KeyframeEditFunc ANIM_editkeyframes_ipo(short mode)
bool keyframe_region_lasso_test(const KeyframeEdit_LassoData *data_lasso, const float xy[2])
@ KEYFRAME_PASTE_MERGE_OVER_RANGE_ALL
@ KEYFRAME_PASTE_MERGE_OVER_RANGE
@ KEYFRAME_PASTE_MERGE_OVER
@ KEYFRAME_PASTE_MERGE_MIX
bool copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
ButterworthCoefficients * ED_anim_allocate_butterworth_coefficients(const int filter_order)
void butterworth_smooth_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float *samples, int sample_count, float factor, int blend_in_out, int sample_rate, ButterworthCoefficients *bw_coeff)
void ANIM_fcurve_equalize_keyframes_loop(FCurve *fcu, eEditKeyframes_Equalize mode, float handle_length, bool flatten)
eKeyframeVertOk
@ KEYFRAME_NONE
@ KEYFRAME_OK_KEY
@ KEYFRAME_OK_H1
@ KEYFRAME_OK_H2
@ KEYFRAME_OK_ALL
void blend_to_ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor)
eKeyPasteValueOffset
@ KEYFRAME_PASTE_VALUE_OFFSET_RIGHT_KEY
@ KEYFRAME_PASTE_VALUE_OFFSET_NONE
@ KEYFRAME_PASTE_VALUE_OFFSET_CURSOR
@ KEYFRAME_PASTE_VALUE_OFFSET_CFRA
@ KEYFRAME_PASTE_VALUE_OFFSET_LEFT_KEY
eKeyPasteOffset
@ KEYFRAME_PASTE_OFFSET_NONE
@ KEYFRAME_PASTE_OFFSET_CFRA_END
@ KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE
@ KEYFRAME_PASTE_OFFSET_CFRA_START
eKeyPasteError paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, const KeyframePasteContext &paste_context)
void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor, float width)
void ANIM_fcurves_copybuf_free()
eEditKeyframes_Validate
@ BEZT_OK_CHANNEL_CIRCLE
@ BEZT_OK_FRAMERANGE
@ BEZT_OK_FRAME
@ BEZT_OK_SELECTED_KEY
@ BEZT_OK_VALUERANGE
@ BEZT_OK_SELECTED
@ BEZT_OK_REGION_LASSO
@ BEZT_OK_VALUE
@ BEZT_OK_REGION_CIRCLE
@ BEZT_OK_CHANNEL_LASSO
@ BEZT_OK_REGION
KeyframeEditFunc ANIM_editkeyframes_keytype(eBezTriple_KeyframeType keyframe_type)
eKeyframeIterFlags
@ KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE
@ KED_F1_NLA_UNMAP
@ KEYFRAME_ITER_INCL_HANDLES
@ KEYFRAME_ITER_HANDLES_INVISIBLE
@ KED_F2_NLA_UNMAP
void blend_to_neighbor_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor)
short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt)
KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode)
eEditKeyframes_Snap
@ SNAP_KEYS_CURFRAME
@ SNAP_KEYS_NEARFRAME
@ SNAP_KEYS_NEARMARKER
@ SNAP_KEYS_TIME
@ SNAP_KEYS_NEARSEC
@ SNAP_KEYS_HORIZONTAL
@ SNAP_KEYS_VALUE
void smooth_fcurve(FCurve *fcu)
void ED_ANIM_get_1d_gauss_kernel(const float sigma, int kernel_size, double *r_kernel)
short(*)(KeyframeEditData *ked, BezTriple *bezt) KeyframeEditFunc
short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, bAnimListElem *ale, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
bool keyframe_region_circle_test(const KeyframeEdit_CircleData *data_circle, const float xy[2])
void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt)
short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
void blend_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor)
eEditKeyframes_SelMap
@ SELMAP_MORE
@ SELMAP_LESS
eEditKeyframes_Select
@ SELECT_INVERT
@ SELECT_EXTEND_RANGE
@ SELECT_SUBTRACT
@ SELECT_REPLACE
@ SELECT_ADD
KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
void(*)(FCurve *fcu) FcuEditFunc
@ KEYFRAME_PASTE_NOTHING_TO_PASTE
@ KEYFRAME_PASTE_OK
@ KEYFRAME_PASTE_NOWHERE_TO_PASTE
ListBase find_fcurve_segments(FCurve *fcu)
bool duplicate_fcurve_keys(FCurve *fcu)
KeyframeEditFunc ANIM_editkeyframes_snap(short mode)
void blend_to_default_fcurve(PointerRNA *id_ptr, FCurve *fcu, float factor)
void scale_from_fcurve_segment_neighbor(FCurve *fcu, FCurveSegment *segment, float factor, FCurveSegmentAnchor anchor)
void breakdown_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor)
void push_pull_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor)
void ANIM_animdata_keyframe_callback(bAnimContext *ac, eAnimFilter_Flags filter, KeyframeEditFunc callback_fn)
void ED_anim_calculate_butterworth_coefficients(float cutoff_frequency, float sampling_frequency, ButterworthCoefficients *bw_coeff)
short bezt_calc_average(KeyframeEditData *ked, BezTriple *bezt)
FCurveSegmentAnchor
void ED_anim_free_butterworth_coefficients(ButterworthCoefficients *bw_coeff)
bool match_slope_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float factor)
KeyframeEditFunc ANIM_editkeyframes_handles(short mode)
#define filter
@ LEFT
@ RIGHT
CfraElem * next
CfraElem * prev
FCurveSegment * next
FCurveSegment * prev
eKeyframeIterFlags iterflags
eKeyframeVertOk curflags
blender::Array< blender::int2 > mcoords
eKeyPasteValueOffset value_offset_mode
eKeyPasteOffset offset_mode
int xy[2]
Definition wm_draw.cc:178
PointerRNA * ptr
Definition wm_files.cc:4238