Blender  V3.3
ED_keyframes_edit.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2008 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 #include "ED_anim_api.h" /* for enum eAnimFilter_Flags */
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 struct BezTriple;
17 struct FCurve;
18 struct Scene;
19 struct bAnimContext;
20 struct bAnimListElem;
21 struct bDopeSheet;
22 
23 /* ************************************************ */
24 /* Common Macros and Defines */
25 
26 /* -------------------------------------------------------------------- */
30 /* bezt validation */
32  /* Frame range */
35  /* Selection status */
37  /* Values (y-val) only */
40  /* For graph editor keyframes (2D tests) */
44  /* Only for keyframes a certain Dopesheet channel */
48 
51 /* select modes */
52 typedef enum eEditKeyframes_Select {
53  /* SELECT_SUBTRACT for all, followed by SELECT_ADD for some */
54  SELECT_REPLACE = (1 << 0),
55  /* add ok keyframes to selection */
56  SELECT_ADD = (1 << 1),
57  /* remove ok keyframes from selection */
58  SELECT_SUBTRACT = (1 << 2),
59  /* flip ok status of keyframes based on key status */
60  SELECT_INVERT = (1 << 3),
62 
63 /* "selection map" building modes */
64 typedef enum eEditKeyframes_SelMap {
68 
69 /* snapping tools */
70 typedef enum eEditKeyframes_Snap {
79 
80 /* equalizing tools */
86 
87 /* mirroring tools */
88 typedef enum eEditKeyframes_Mirror {
96 
97 /* use with BEZT_OK_REGION_LASSO */
98 typedef struct KeyframeEdit_LassoData {
100  const rctf *rectf_view;
101  const int (*mcoords)[2];
104 
105 /* use with BEZT_OK_REGION_CIRCLE */
106 typedef struct KeyframeEdit_CircleData {
108  const rctf *rectf_view;
109  float mval[2];
112 
113 /* ************************************************ */
114 /* Non-Destructive Editing API (keyframes_edit.c) */
115 
116 /* -------------------------------------------------------------------- */
120 /* which verts of a keyframe is active (after polling) */
121 typedef enum eKeyframeVertOk {
122  /* 'key' itself is ok */
123  KEYFRAME_OK_KEY = (1 << 0),
124  /* 'handle 1' is ok */
125  KEYFRAME_OK_H1 = (1 << 1),
126  /* 'handle 2' is ok */
127  KEYFRAME_OK_H2 = (1 << 2),
128  /* all flags */
131 
132 /* Flags for use during iteration */
133 typedef enum eKeyframeIterFlags {
134  /* consider handles in addition to key itself */
136 
137  /* Perform NLA time remapping (global -> strip) for the "f1" parameter
138  * (e.g. used for selection tools on summary tracks)
139  */
140  KED_F1_NLA_UNMAP = (1 << 1),
141 
142  /* Perform NLA time remapping (global -> strip) for the "f2" parameter */
143  KED_F2_NLA_UNMAP = (1 << 2),
144 
145  /* Set this when handles aren't visible by default and you want to perform additional checks to
146  * get the actual visibility state. E.g. in some cases handles are only drawn if either a handle
147  * or their control point is selected. The selection state will have to be checked in the
148  * iterator callbacks then. */
151 
154 /* -------------------------------------------------------------------- */
158 typedef struct KeyframeEditData {
159  /* generic properties/data access */
163  struct Scene *scene;
165  void *data;
167  float f1, f2;
169  int i1, i2;
170 
171  /* current iteration data */
173  struct FCurve *fcu;
175  int curIndex;
177  float channel_y;
178 
179  /* flags */
185 
188 /* -------------------------------------------------------------------- */
192 /* callback function that refreshes the F-Curve after use */
193 typedef void (*FcuEditFunc)(struct FCurve *fcu);
194 /* callback function that operates on the given BezTriple */
195 typedef short (*KeyframeEditFunc)(KeyframeEditData *ked, struct BezTriple *bezt);
196 
199 /* -------------------------------------------------------------------- */
203 /* Custom data for remapping one range to another in a fixed way */
204 typedef struct KeyframeEditCD_Remap {
205  float oldMin, oldMax; /* old range */
206  float newMin, newMax; /* new range */
208 
209 /* Paste options */
210 typedef enum eKeyPasteOffset {
211  /* paste keys starting at current frame */
213  /* paste keys ending at current frame */
215  /* paste keys relative to the current frame when copying */
217  /* paste keys from original time */
220 
221 typedef enum eKeyMergeMode {
222  /* overlay existing with new keys */
224  /* replace entire fcurve */
226  /* overwrite keys in pasted range */
228  /* overwrite keys in pasted range (use all keyframe start & end for range) */
231 
232 /* Possible errors occurring while pasting keys. */
233 typedef enum eKeyPasteError {
234  /* No errors occurred */
236  /* Nothing was copied */
238  /* No F-curves was selected to paste into*/
241 
244 /* -------------------------------------------------------------------- */
258  struct FCurve *fcu,
259  KeyframeEditFunc key_ok,
260  KeyframeEditFunc key_cb,
261  FcuEditFunc fcu_cb);
271  float handle_length,
272  bool flatten);
273 
278  struct bDopeSheet *ads,
279  struct bAnimListElem *ale,
280  KeyframeEditFunc key_ok,
281  KeyframeEditFunc key_cb,
282  FcuEditFunc fcu_cb);
288  struct bDopeSheet *ads,
289  void *data,
290  int keytype,
291  KeyframeEditFunc key_ok,
292  KeyframeEditFunc key_cb,
293  FcuEditFunc fcu_cb);
294 
301  KeyframeEditFunc callback_fn);
302 
307 
310 /* -------------------------------------------------------------------- */
314 /* accessories */
316 
317 /* edit */
334 
337 /* -------------------------------------------------------------------- */
346 
351 short bezt_selmap_flush(KeyframeEditData *ked, struct BezTriple *bezt);
352 
355 /* -------------------------------------------------------------------- */
362 short bezt_calc_average(KeyframeEditData *ked, struct BezTriple *bezt);
363 
367 short bezt_to_cfraelem(KeyframeEditData *ked, struct BezTriple *bezt);
368 
373 void bezt_remap_times(KeyframeEditData *ked, struct BezTriple *bezt);
374 
377 /* -------------------------------------------------------------------- */
381 /* XXX: These are temporary,
382  * until we can unify GP/Mask Keyframe handling and standard FCurve Keyframe handling */
383 
384 bool keyframe_region_lasso_test(const KeyframeEdit_LassoData *data_lasso, const float xy[2]);
385 
386 bool keyframe_region_circle_test(const KeyframeEdit_CircleData *data_circle, const float xy[2]);
387 
388 /* ************************************************ */
389 /* Destructive Editing API (keyframes_general.c) */
390 
391 bool duplicate_fcurve_keys(struct FCurve *fcu);
392 float get_default_rna_value(struct FCurve *fcu, struct PropertyRNA *prop, struct PointerRNA *ptr);
393 
394 typedef struct FCurveSegment {
398 
406 void clean_fcurve(struct bAnimContext *ac,
407  struct bAnimListElem *ale,
408  float thresh,
409  bool cleardefault);
411  struct FCurveSegment *segment,
412  float factor);
413 void breakdown_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor);
414 bool decimate_fcurve(struct bAnimListElem *ale, float remove_ratio, float error_sq_max);
415 void blend_to_default_fcurve(struct PointerRNA *id_ptr, struct FCurve *fcu, float factor);
419 void smooth_fcurve(struct FCurve *fcu);
420 void sample_fcurve(struct FCurve *fcu);
421 
422 /* ----------- */
423 
424 void ANIM_fcurves_copybuf_free(void);
425 short copy_animedit_keys(struct bAnimContext *ac, ListBase *anim_data);
427  ListBase *anim_data,
428  eKeyPasteOffset offset_mode,
429  eKeyMergeMode merge_mode,
430  bool flip);
431 
432 /* ************************************************ */
433 
436 #ifdef __cplusplus
437 }
438 #endif
eAnimFilter_Flags
Definition: ED_anim_api.h:284
eEditKeyframes_Mirror
@ MIRROR_KEYS_VALUE
@ MIRROR_KEYS_YAXIS
@ MIRROR_KEYS_MARKER
@ MIRROR_KEYS_CURFRAME
@ MIRROR_KEYS_XAXIS
@ MIRROR_KEYS_TIME
bool duplicate_fcurve_keys(struct FCurve *fcu)
KeyframeEditFunc ANIM_editkeyframes_select(short mode)
void bezt_remap_times(KeyframeEditData *ked, struct BezTriple *bezt)
float get_default_rna_value(struct FCurve *fcu, struct PropertyRNA *prop, struct PointerRNA *ptr)
struct KeyframeEdit_LassoData KeyframeEdit_LassoData
KeyframeEditFunc ANIM_editkeyframes_mirror(short mode)
void ANIM_editkeyframes_refresh(struct bAnimContext *ac)
void clean_fcurve(struct bAnimContext *ac, struct bAnimListElem *ale, float thresh, bool cleardefault)
void ANIM_fcurve_equalize_keyframes_loop(struct FCurve *fcu, eEditKeyframes_Equalize mode, float handle_length, bool flatten)
KeyframeEditFunc ANIM_editkeyframes_keytype(short mode)
void breakdown_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor)
eEditKeyframes_Equalize
@ EQUALIZE_HANDLES_LEFT
@ EQUALIZE_HANDLES_RIGHT
@ EQUALIZE_HANDLES_BOTH
short bezt_to_cfraelem(KeyframeEditData *ked, struct BezTriple *bezt)
KeyframeEditFunc ANIM_editkeyframes_easing(short mode)
void(* FcuEditFunc)(struct FCurve *fcu)
struct FCurveSegment FCurveSegment
KeyframeEditFunc ANIM_editkeyframes_ipo(short mode)
bool keyframe_region_lasso_test(const KeyframeEdit_LassoData *data_lasso, const float xy[2])
eKeyMergeMode
@ KEYFRAME_PASTE_MERGE_OVER_RANGE_ALL
@ KEYFRAME_PASTE_MERGE_OVER_RANGE
@ KEYFRAME_PASTE_MERGE_OVER
@ KEYFRAME_PASTE_MERGE_MIX
eKeyframeVertOk
@ KEYFRAME_OK_KEY
@ KEYFRAME_OK_H1
@ KEYFRAME_OK_H2
@ KEYFRAME_OK_ALL
void sample_fcurve(struct FCurve *fcu)
struct KeyframeEditData KeyframeEditData
eKeyPasteOffset
@ KEYFRAME_PASTE_OFFSET_NONE
@ KEYFRAME_PASTE_OFFSET_CFRA_END
@ KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE
@ KEYFRAME_PASTE_OFFSET_CFRA_START
void blend_to_neighbor_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor)
eEditKeyframes_Validate
@ BEZT_OK_CHANNEL_CIRCLE
@ BEZT_OK_FRAMERANGE
@ BEZT_OK_FRAME
@ BEZT_OK_VALUERANGE
@ BEZT_OK_SELECTED
@ BEZT_OK_REGION_LASSO
@ BEZT_OK_VALUE
@ BEZT_OK_REGION_CIRCLE
@ BEZT_OK_CHANNEL_LASSO
@ BEZT_OK_REGION
eKeyPasteError paste_animedit_keys(struct bAnimContext *ac, ListBase *anim_data, eKeyPasteOffset offset_mode, eKeyMergeMode merge_mode, bool flip)
short bezt_calc_average(KeyframeEditData *ked, struct BezTriple *bezt)
short copy_animedit_keys(struct bAnimContext *ac, ListBase *anim_data)
void ANIM_animdata_keyframe_callback(struct bAnimContext *ac, eAnimFilter_Flags filter, KeyframeEditFunc callback_fn)
eKeyframeIterFlags
@ KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE
@ KED_F1_NLA_UNMAP
@ KEYFRAME_ITER_INCL_HANDLES
@ KED_F2_NLA_UNMAP
ListBase find_fcurve_segments(struct FCurve *fcu)
KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode)
short bezt_selmap_flush(KeyframeEditData *ked, struct BezTriple *bezt)
short(* KeyframeEditFunc)(KeyframeEditData *ked, struct BezTriple *bezt)
eEditKeyframes_Snap
@ SNAP_KEYS_CURFRAME
@ SNAP_KEYS_NEARFRAME
@ SNAP_KEYS_NEARMARKER
@ SNAP_KEYS_TIME
@ SNAP_KEYS_NEARSEC
@ SNAP_KEYS_HORIZONTAL
@ SNAP_KEYS_VALUE
void blend_to_default_fcurve(struct PointerRNA *id_ptr, struct FCurve *fcu, float factor)
void smooth_fcurve(struct FCurve *fcu)
struct KeyframeEditCD_Remap KeyframeEditCD_Remap
bool keyframe_region_circle_test(const KeyframeEdit_CircleData *data_circle, const float xy[2])
void ANIM_fcurves_copybuf_free(void)
struct KeyframeEdit_CircleData KeyframeEdit_CircleData
eEditKeyframes_SelMap
@ SELMAP_MORE
@ SELMAP_LESS
eEditKeyframes_Select
@ SELECT_INVERT
@ SELECT_SUBTRACT
@ SELECT_REPLACE
@ SELECT_ADD
KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
eKeyPasteError
@ KEYFRAME_PASTE_NOTHING_TO_PASTE
@ KEYFRAME_PASTE_OK
@ KEYFRAME_PASTE_NOWHERE_TO_PASTE
short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, struct bDopeSheet *ads, struct bAnimListElem *ale, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
KeyframeEditFunc ANIM_editkeyframes_snap(short mode)
short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, struct FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked, struct bDopeSheet *ads, void *data, int keytype, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
bool decimate_fcurve(struct bAnimListElem *ale, float remove_ratio, float error_sq_max)
KeyframeEditFunc ANIM_editkeyframes_handles(short mode)
SyclQueue void void size_t num_bytes void
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
Segment< FEdge *, Vec3r > segment
struct FCurveSegment * next
struct FCurveSegment * prev
struct FCurve * fcu
eKeyframeIterFlags iterflags
struct Scene * scene
eKeyframeVertOk curflags
int xy[2]
Definition: wm_draw.c:135
PointerRNA * ptr
Definition: wm_files.c:3480