Blender  V3.3
ED_keyframing.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2008 Blender Foundation. */
3 
8 #pragma once
9 
10 #include "DNA_anim_types.h"
11 #include "RNA_types.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 struct ID;
18 struct ListBase;
19 struct Main;
20 struct Scene;
21 
22 struct KeyingSet;
23 
25 struct BezTriple;
26 struct FCurve;
27 struct bAction;
28 
29 struct bPoseChannel;
30 
31 struct ReportList;
32 struct bContext;
33 
34 struct EnumPropertyItem;
35 struct PointerRNA;
36 struct PropertyRNA;
37 
39 
40 /* -------------------------------------------------------------------- */
49 eInsertKeyFlags ANIM_get_keyframing_flags(struct Scene *scene, bool use_autokey_mode);
50 
51 /* -------- */
52 
57 struct bAction *ED_id_action_ensure(struct Main *bmain, struct ID *id);
58 
63 struct FCurve *ED_action_fcurve_ensure(struct Main *bmain,
64  struct bAction *act,
65  const char group[],
66  struct PointerRNA *ptr,
67  const char rna_path[],
68  int array_index);
69 
74 struct FCurve *ED_action_fcurve_find(struct bAction *act, const char rna_path[], int array_index);
75 
76 /* -------- */
77 
84 void update_autoflags_fcurve(struct FCurve *fcu,
85  struct bContext *C,
86  struct ReportList *reports,
87  struct PointerRNA *ptr);
88 
89 /* -------- */
90 
103 int insert_bezt_fcurve(struct FCurve *fcu, const struct BezTriple *bezt, eInsertKeyFlags flag);
104 
120 int insert_vert_fcurve(struct FCurve *fcu,
121  float x,
122  float y,
123  eBezTriple_KeyframeType keyframe_type,
125 
126 /* -------- */
127 
144 bool insert_keyframe_direct(struct ReportList *reports,
145  struct PointerRNA ptr,
146  struct PropertyRNA *prop,
147  struct FCurve *fcu,
148  const struct AnimationEvalContext *anim_eval_context,
149  eBezTriple_KeyframeType keytype,
150  struct NlaKeyframingContext *nla,
152 
153 /* -------- */
154 
167 int insert_keyframe(struct Main *bmain,
168  struct ReportList *reports,
169  struct ID *id,
170  struct bAction *act,
171  const char group[],
172  const char rna_path[],
173  int array_index,
174  const struct AnimationEvalContext *anim_eval_context,
175  eBezTriple_KeyframeType keytype,
176  struct ListBase *nla_cache,
178 
186 int delete_keyframe(struct Main *bmain,
187  struct ReportList *reports,
188  struct ID *id,
189  struct bAction *act,
190  const char rna_path[],
191  int array_index,
192  float cfra);
193 
196 /* -------------------------------------------------------------------- */
200 /* forward decl. for this struct which is declared a bit later... */
201 struct ExtensionRNA;
202 struct KeyingSetInfo;
203 
204 /* Polling Callback for KeyingSets */
205 typedef bool (*cbKeyingSet_Poll)(struct KeyingSetInfo *ksi, struct bContext *C);
206 /* Context Iterator Callback for KeyingSets */
207 typedef void (*cbKeyingSet_Iterator)(struct KeyingSetInfo *ksi,
208  struct bContext *C,
209  struct KeyingSet *ks);
210 /* Property Specifier Callback for KeyingSets (called from iterators) */
211 typedef void (*cbKeyingSet_Generate)(struct KeyingSetInfo *ksi,
212  struct bContext *C,
213  struct KeyingSet *ks,
214  struct PointerRNA *ptr);
215 
216 /* Callback info for 'Procedural' KeyingSets to use */
217 typedef struct KeyingSetInfo {
219 
220  /* info */
221  /* identifier used for class name, which KeyingSet instances reference as "Typeinfo Name" */
222  char idname[64];
223  /* identifier so that user can hook this up to a KeyingSet (used as label). */
224  char name[64];
225  /* short help/description. */
226  char description[240]; /* RNA_DYN_DESCR_MAX */
227  /* keying settings */
228  short keyingflag;
229 
230  /* polling callbacks */
231  /* callback for polling the context for whether the right data is available */
233 
234  /* generate callbacks */
235  /* iterator to use to go through collections of data in context
236  * - this callback is separate from the 'adding' stage, allowing
237  * BuiltIn KeyingSets to be manually specified to use
238  */
240  /* generator to use to add properties based on the data found by iterator */
242 
243  /* RNA integration */
244  struct ExtensionRNA rna_ext;
246 
247 /* -------- */
248 
253  struct ID *id,
254  struct StructRNA *srna,
255  void *data);
256 
257 /* mode for modify_keyframes */
258 typedef enum eModifyKey_Modes {
262 
263 /* return codes for errors (with Relative KeyingSets) */
264 typedef enum eModifyKey_Returns {
265  /* context info was invalid for using the Keying Set */
267  /* there isn't any typeinfo for generating paths from context */
270 
280  ListBase *dsources,
281  struct KeyingSet *ks);
282 
293 int ANIM_apply_keyingset(struct bContext *C,
294  ListBase *dsources,
295  struct bAction *act,
296  struct KeyingSet *ks,
297  short mode,
298  float cfra);
299 
300 /* -------- */
301 
308 struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, const char name[]);
309 
314 
318 bool ANIM_keyingset_find_id(struct KeyingSet *ks, ID *id);
319 
329 void ANIM_keyingset_info_unregister(struct Main *bmain, KeyingSetInfo *ksi);
330 
331 /* cleanup on exit */
332 /* --------------- */
333 
334 void ANIM_keyingset_infos_exit(void);
335 
336 /* -------- */
337 
342 
346 int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks);
347 
352  const char *transformKSName);
353 
355  struct PointerRNA *ptr,
356  struct PropertyRNA *prop,
357  const char *edit_text,
359  void *visit_user_data);
360 
362  struct PointerRNA *ptr,
363  struct PropertyRNA *prop,
364  const char *edit_text,
366  void *visit_user_data);
371  struct PointerRNA *ptr,
372  struct PropertyRNA *prop,
373  bool *r_free);
374 
385 KeyingSet *ANIM_keyingset_get_from_idname(struct Scene *scene, const char *idname);
386 
390 bool ANIM_keyingset_context_ok_poll(struct bContext *C, struct KeyingSet *ks);
391 
394 /* -------------------------------------------------------------------- */
398 /* Flags for use by driver creation calls */
399 typedef enum eCreateDriverFlags {
405 
406 /* Heuristic to use for connecting target properties to driven ones */
414 
422 
428 
429 /* -------- */
430 
432  DRIVER_FCURVE_LOOKUP_ONLY = 0, /* Don't add anything if not found. */
433  DRIVER_FCURVE_KEYFRAMES = 1, /* Add with keyframes, for visual tweaking. */
434  DRIVER_FCURVE_GENERATOR = 2, /* Add with generator, for script backwards compatibility. */
435  DRIVER_FCURVE_EMPTY = 3 /* Add without data, for pasting. */
437 
445 struct FCurve *verify_driver_fcurve(struct ID *id,
446  const char rna_path[],
447  int array_index,
448  eDriverFCurveCreationMode creation_mode);
449 
450 struct FCurve *alloc_driver_fcurve(const char rna_path[],
451  int array_index,
452  eDriverFCurveCreationMode creation_mode);
453 
454 /* -------- */
455 
469 int ANIM_add_driver_with_target(struct ReportList *reports,
470  struct ID *dst_id,
471  const char dst_path[],
472  int dst_index,
473  struct ID *src_id,
474  const char src_path[],
475  int src_index,
476  short flag,
477  int driver_type,
478  short mapping_type);
479 
480 /* -------- */
481 
487 int ANIM_add_driver(struct ReportList *reports,
488  struct ID *id,
489  const char rna_path[],
490  int array_index,
491  short flag,
492  int type);
493 
500  struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag);
501 
502 /* -------- */
503 
508 void ANIM_drivers_copybuf_free(void);
509 
515 
516 /* -------- */
517 
521 bool ANIM_driver_can_paste(void);
522 
529  struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag);
530 
538  struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag);
539 
540 /* -------- */
541 
545 bool ANIM_driver_vars_can_paste(void);
546 
550 bool ANIM_driver_vars_copy(struct ReportList *reports, struct FCurve *fcu);
551 
555 bool ANIM_driver_vars_paste(struct ReportList *reports, struct FCurve *fcu, bool replace);
556 
557 /* -------- */
558 
563 void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name);
564 
567 /* -------------------------------------------------------------------- */
578 /* Auto-Keying macros for use by various tools. */
579 
582 #define IS_AUTOKEY_ON(scene) \
583  ((scene) ? ((scene)->toolsettings->autokey_mode & AUTOKEY_ON) : (U.autokey_mode & AUTOKEY_ON))
585 #define IS_AUTOKEY_MODE(scene, mode) \
586  ((scene) ? ((scene)->toolsettings->autokey_mode == AUTOKEY_MODE_##mode) : \
587  (U.autokey_mode == AUTOKEY_MODE_##mode))
589 #define IS_AUTOKEY_FLAG(scene, flag) \
590  ((scene) ? (((scene)->toolsettings->autokey_flag & AUTOKEY_FLAG_##flag) || \
591  (U.autokey_flag & AUTOKEY_FLAG_##flag)) : \
592  (U.autokey_flag & AUTOKEY_FLAG_##flag))
593 
597 bool autokeyframe_cfra_can_key(const struct Scene *scene, struct ID *id);
598 
601 /* -------------------------------------------------------------------- */
611 bool fcurve_frame_has_keyframe(const struct FCurve *fcu, float frame, short filter);
612 
620  struct PropertyRNA *prop,
621  struct FCurve *fcu,
622  const struct AnimationEvalContext *anim_eval_context);
623 
632 bool id_frame_has_keyframe(struct ID *id, float frame, short filter);
633 
639 typedef enum eAnimFilterFlags {
640  /* general */
641  ANIMFILTER_KEYS_LOCAL = (1 << 0), /* only include locally available anim data */
642  ANIMFILTER_KEYS_MUTED = (1 << 1), /* include muted elements */
643  ANIMFILTER_KEYS_ACTIVE = (1 << 2), /* only include active-subelements */
644 
645  /* object specific */
646  ANIMFILTER_KEYS_NOMAT = (1 << 9), /* don't include material keyframes */
647  ANIMFILTER_KEYS_NOSKEY = (1 << 10), /* don't include shape keys (for geometry) */
649 
650 /* Utility functions for auto key-frame. */
651 
652 bool ED_autokeyframe_object(struct bContext *C,
653  struct Scene *scene,
654  struct Object *ob,
655  struct KeyingSet *ks);
656 bool ED_autokeyframe_pchan(struct bContext *C,
657  struct Scene *scene,
658  struct Object *ob,
659  struct bPoseChannel *pchan,
660  struct KeyingSet *ks);
661 
668 bool ED_autokeyframe_property(struct bContext *C,
669  struct Scene *scene,
670  PointerRNA *ptr,
671  PropertyRNA *prop,
672  int rnaindex,
673  float cfra,
674  bool only_if_property_keyed);
675 
676 /* Names for builtin keying sets so we don't confuse these with labels/text,
677  * defined in python script: `keyingsets_builtins.py`. */
678 
679 #define ANIM_KS_LOCATION_ID "Location"
680 #define ANIM_KS_ROTATION_ID "Rotation"
681 #define ANIM_KS_SCALING_ID "Scaling"
682 #define ANIM_KS_LOC_ROT_SCALE_ID "LocRotScale"
683 #define ANIM_KS_LOC_ROT_SCALE_CPROP_ID "LocRotScaleCProp"
684 #define ANIM_KS_AVAILABLE_ID "Available"
685 #define ANIM_KS_WHOLE_CHARACTER_ID "WholeCharacter"
686 #define ANIM_KS_WHOLE_CHARACTER_SELECTED_ID "WholeCharacterSelected"
687 
690 #ifdef __cplusplus
691 }
692 #endif
eInsertKeyFlags
eBezTriple_KeyframeType
KeyingSet * ANIM_keyingset_get_from_idname(struct Scene *scene, const char *idname)
Definition: keyingsets.c:864
bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, const struct AnimationEvalContext *anim_eval_context, eBezTriple_KeyframeType keytype, struct NlaKeyframingContext *nla, eInsertKeyFlags flag)
Secondary Insert Key-framing API call.
eInsertKeyFlags ANIM_get_keyframing_flags(struct Scene *scene, bool use_autokey_mode)
Definition: keyframing.c:82
eAnimFilterFlags
@ ANIMFILTER_KEYS_NOSKEY
@ ANIMFILTER_KEYS_MUTED
@ ANIMFILTER_KEYS_LOCAL
@ ANIMFILTER_KEYS_ACTIVE
@ ANIMFILTER_KEYS_NOMAT
void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const char *var_name)
Definition: drivers.c:792
bool ED_autokeyframe_property(struct bContext *C, struct Scene *scene, PointerRNA *ptr, PropertyRNA *prop, int rnaindex, float cfra, bool only_if_property_keyed)
Definition: keyframing.c:3111
bool ED_autokeyframe_object(struct bContext *C, struct Scene *scene, struct Object *ob, struct KeyingSet *ks)
Definition: keyframing.c:3070
bool fcurve_is_changed(struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, const struct AnimationEvalContext *anim_eval_context)
Lesser Keyframe Checking API call.
struct FCurve * alloc_driver_fcurve(const char rna_path[], int array_index, eDriverFCurveCreationMode creation_mode)
Definition: drivers.c:91
void ANIM_driver_vars_copybuf_free(void)
Definition: drivers.c:692
int ANIM_add_driver_with_target(struct ReportList *reports, struct ID *dst_id, const char dst_path[], int dst_index, struct ID *src_id, const char src_path[], int src_index, short flag, int driver_type, short mapping_type)
Main Driver Management API calls.
Definition: drivers.c:281
eModifyKey_Modes
@ MODIFYKEY_MODE_INSERT
@ MODIFYKEY_MODE_DELETE
bool ANIM_remove_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag)
Main Driver Management API calls.
bool ANIM_copy_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag)
Main Driver Management API calls.
void ANIM_relative_keyingset_add_source(ListBase *dsources, struct ID *id, struct StructRNA *srna, void *data)
Definition: keyingsets.c:924
int insert_keyframe(struct Main *bmain, struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, const struct AnimationEvalContext *anim_eval_context, eBezTriple_KeyframeType keytype, struct ListBase *nla_cache, eInsertKeyFlags flag)
Main Insert Key-framing API call.
void update_autoflags_fcurve(struct FCurve *fcu, struct bContext *C, struct ReportList *reports, struct PointerRNA *ptr)
Lesser Key-framing API call.
Definition: keyframing.c:274
void ANIM_keyingset_visit_for_search_no_poll(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, const char *edit_text, StringPropertySearchVisitFunc visit_fn, void *visit_user_data)
bool(* cbKeyingSet_Poll)(struct KeyingSetInfo *ksi, struct bContext *C)
int ANIM_add_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag, int type)
Main Driver Management API calls.
Definition: drivers.c:395
void ANIM_keyingset_visit_for_search(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, const char *edit_text, StringPropertySearchVisitFunc visit_fn, void *visit_user_data)
void(* cbKeyingSet_Iterator)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks)
int ANIM_apply_keyingset(struct bContext *C, ListBase *dsources, struct bAction *act, struct KeyingSet *ks, short mode, float cfra)
Definition: keyingsets.c:1038
bool ANIM_keyingset_find_id(struct KeyingSet *ks, ID *id)
Definition: keyingsets.c:632
bool autokeyframe_cfra_can_key(const struct Scene *scene, struct ID *id)
int insert_vert_fcurve(struct FCurve *fcu, float x, float y, eBezTriple_KeyframeType keyframe_type, eInsertKeyFlags flag)
Main Key-framing API call.
Definition: keyframing.c:545
struct FCurve * verify_driver_fcurve(struct ID *id, const char rna_path[], int array_index, eDriverFCurveCreationMode creation_mode)
Definition: drivers.c:50
KeyingSetInfo * ANIM_keyingset_info_find_name(const char name[])
Definition: keyingsets.c:520
KeyingSet * ANIM_keyingset_get_from_enum_type(struct Scene *scene, int type)
Definition: keyingsets.c:847
bool ANIM_driver_can_paste(void)
Definition: drivers.c:580
EnumPropertyItem prop_driver_create_mapping_types[]
Definition: drivers.c:835
bool ANIM_driver_vars_paste(struct ReportList *reports, struct FCurve *fcu, bool replace)
Definition: drivers.c:737
struct KeyingSetInfo KeyingSetInfo
bool ANIM_keyingset_context_ok_poll(struct bContext *C, struct KeyingSet *ks)
Definition: keyingsets.c:878
bool fcurve_frame_has_keyframe(const struct FCurve *fcu, float frame, short filter)
Lesser Keyframe Checking API call.
bool ED_autokeyframe_pchan(struct bContext *C, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, struct KeyingSet *ks)
Definition: keyframing.c:3090
int delete_keyframe(struct Main *bmain, struct ReportList *reports, struct ID *id, struct bAction *act, const char rna_path[], int array_index, float cfra)
Main Delete Key-Framing API call.
Definition: keyframing.c:1723
void ANIM_keyingset_infos_exit(void)
Definition: keyingsets.c:613
bool ANIM_paste_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag)
Main Driver Management API calls.
void ANIM_keyingset_info_register(KeyingSetInfo *ksi)
Definition: keyingsets.c:566
eModifyKey_Returns ANIM_validate_keyingset(struct bContext *C, ListBase *dsources, struct KeyingSet *ks)
Definition: keyingsets.c:954
bool ANIM_driver_vars_can_paste(void)
Definition: drivers.c:708
bool ANIM_driver_vars_copy(struct ReportList *reports, struct FCurve *fcu)
Definition: drivers.c:715
eModifyKey_Returns
@ MODIFYKEY_MISSING_TYPEINFO
@ MODIFYKEY_INVALID_CONTEXT
eCreateDriverFlags
@ CREATEDRIVER_WITH_FMODIFIER
@ CREATEDRIVER_WITH_DEFAULT_DVAR
eCreateDriver_MappingTypes
@ CREATEDRIVER_MAPPING_NONE_ALL
@ CREATEDRIVER_MAPPING_1_N
@ CREATEDRIVER_MAPPING_NONE
@ CREATEDRIVER_MAPPING_N_N
@ CREATEDRIVER_MAPPING_1_1
struct KeyingSet * ANIM_get_keyingset_for_autokeying(const struct Scene *scene, const char *transformKSName)
bool id_frame_has_keyframe(struct ID *id, float frame, short filter)
Main Keyframe Checking API call.
Definition: keyframing.c:3036
struct FCurve * ED_action_fcurve_find(struct bAction *act, const char rna_path[], int array_index)
Definition: keyframing.c:164
int insert_bezt_fcurve(struct FCurve *fcu, const struct BezTriple *bezt, eInsertKeyFlags flag)
Lesser Key-framing API call.
void ANIM_drivers_copybuf_free(void)
Definition: drivers.c:571
eDriverFCurveCreationMode
@ DRIVER_FCURVE_LOOKUP_ONLY
@ DRIVER_FCURVE_KEYFRAMES
@ DRIVER_FCURVE_EMPTY
@ DRIVER_FCURVE_GENERATOR
struct KeyingSet * ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, const char name[])
Definition: keyingsets.c:531
struct KeyingSet * ANIM_scene_get_active_keyingset(const struct Scene *scene)
void(* cbKeyingSet_Generate)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks, struct PointerRNA *ptr)
struct bAction * ED_id_action_ensure(struct Main *bmain, struct ID *id)
Definition: keyframing.c:123
const struct EnumPropertyItem * ANIM_keying_sets_enum_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free)
struct FCurve * ED_action_fcurve_ensure(struct Main *bmain, struct bAction *act, const char group[], struct PointerRNA *ptr, const char rna_path[], int array_index)
Definition: keyframing.c:173
int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks)
Definition: keyingsets.c:665
void ANIM_keyingset_info_unregister(struct Main *bmain, KeyingSetInfo *ksi)
Definition: keyingsets.c:585
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
void(* StringPropertySearchVisitFunc)(void *visit_user_data, const StringPropertySearchVisitParams *params)
Definition: RNA_types.h:568
#define C
Definition: RandGen.cpp:25
Scene scene
SyclQueue void void size_t num_bytes void
DO_INLINE void filter(lfVector *V, fmatrix3x3 *S)
StructRNA * srna
Definition: RNA_types.h:766
char * rna_path
BezTriple * bezt
int array_index
short flag
Definition: DNA_ID.h:368
struct ExtensionRNA rna_ext
cbKeyingSet_Generate generate
struct KeyingSetInfo * prev
struct KeyingSetInfo * next
char description[240]
cbKeyingSet_Iterator iter
cbKeyingSet_Poll poll
char idname[64]
char name[64]
Definition: BKE_main.h:121
PointerRNA * ptr
Definition: wm_files.c:3480