Blender  V3.3
BKE_animsys.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation, Joshua Leung. All rights reserved. */
3 
4 #pragma once
5 
10 #include "BLI_bitmap.h"
11 #include "BLI_sys_types.h" /* for bool */
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 struct AnimData;
18 struct BlendDataReader;
19 struct BlendExpander;
20 struct BlendLibReader;
21 struct BlendWriter;
22 struct Depsgraph;
23 struct FCurve;
24 struct ID;
25 struct KS_Path;
26 struct KeyingSet;
28 struct ListBase;
29 struct Main;
31 struct PathResolvedRNA;
32 struct PointerRNA;
33 struct PropertyRNA;
34 struct bAction;
35 struct bActionGroup;
36 struct bContext;
37 
38 /* Container for data required to do FCurve and Driver evaluation. */
39 typedef struct AnimationEvalContext {
40  /* For drivers, so that they have access to the dependency graph and the current view layer. See
41  * T77086. */
43 
44  /* FCurves and Drivers can be evaluated at a different time than the current scene time, for
45  * example when evaluating NLA strips. This means that, even though the current time is stored in
46  * the dependency graph, we need an explicit evaluation time. */
47  float eval_time;
49 
51  float eval_time);
53  const AnimationEvalContext *anim_eval_context, float eval_time);
54 
55 /* ************************************* */
56 /* KeyingSets API */
57 
63  struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag);
64 
69 struct KS_Path *BKE_keyingset_add_path(struct KeyingSet *ks,
70  struct ID *id,
71  const char group_name[],
72  const char rna_path[],
73  int array_index,
74  short flag,
75  short groupmode);
76 
82  struct ID *id,
83  const char group_name[],
84  const char rna_path[],
85  int array_index,
86  int group_mode);
87 
88 /* Copy all KeyingSets in the given list */
89 void BKE_keyingsets_copy(struct ListBase *newlist, const struct ListBase *list);
90 
93  const struct ListBase *keyingsets);
94 
95 /* Free the given Keying Set path */
96 void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp);
97 
98 /* Free data for KeyingSet but not set itself */
99 void BKE_keyingset_free(struct KeyingSet *ks);
100 
101 /* Free all the KeyingSets in the given list */
102 void BKE_keyingsets_free(struct ListBase *list);
103 
104 void BKE_keyingsets_blend_write(struct BlendWriter *writer, struct ListBase *list);
105 void BKE_keyingsets_blend_read_data(struct BlendDataReader *reader, struct ListBase *list);
107  struct ID *id,
108  struct ListBase *list);
109 void BKE_keyingsets_blend_read_expand(struct BlendExpander *expander, struct ListBase *list);
110 
111 /* ************************************* */
112 /* Path Fixing API */
113 
123 char *BKE_animsys_fix_rna_path_rename(struct ID *owner_id,
124  char *old_path,
125  const char *prefix,
126  const char *oldName,
127  const char *newName,
128  int oldSubscript,
129  int newSubscript,
130  bool verify_paths);
131 
141 void BKE_action_fix_paths_rename(struct ID *owner_id,
142  struct bAction *act,
143  const char *prefix,
144  const char *oldName,
145  const char *newName,
146  int oldSubscript,
147  int newSubscript,
148  bool verify_paths);
149 
156 void BKE_animdata_fix_paths_rename(struct ID *owner_id,
157  struct AnimData *adt,
158  struct ID *ref_id,
159  const char *prefix,
160  const char *oldName,
161  const char *newName,
162  int oldSubscript,
163  int newSubscript,
164  bool verify_paths);
165 
172 void BKE_animdata_fix_paths_rename_all_ex(struct Main *bmain,
173  struct ID *ref_id,
174  const char *prefix,
175  const char *oldName,
176  const char *newName,
177  int oldSubscript,
178  int newSubscript,
179  bool verify_paths);
180 
182 void BKE_animdata_fix_paths_rename_all(struct ID *ref_id,
183  const char *prefix,
184  const char *oldName,
185  const char *newName);
186 
191 bool BKE_animdata_fix_paths_remove(struct ID *id, const char *path);
192 
193 /* -------------------------------------- */
194 
195 typedef struct AnimationBasePathChange {
197  const char *src_basepath;
198  const char *dst_basepath;
200 
209 void BKE_animdata_transfer_by_basepath(struct Main *bmain,
210  struct ID *srcID,
211  struct ID *dstID,
212  struct ListBase *basepaths);
213 
214 /* ************************************* */
215 /* Batch AnimData API */
216 
217 /* Define for callback looper used in BKE_animdata_main_cb */
218 typedef void (*ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data);
219 
220 /* Define for callback looper used in BKE_fcurves_main_cb */
221 typedef void (*ID_FCurve_Edit_Callback)(struct ID *id, struct FCurve *fcu, void *user_data);
222 
223 /* Loop over all datablocks applying callback */
224 void BKE_animdata_main_cb(struct Main *bmain, ID_AnimData_Edit_Callback func, void *user_data);
225 
227 void BKE_fcurves_main_cb(struct Main *bmain, ID_FCurve_Edit_Callback func, void *user_data);
228 
229 /* Look over all f-curves of a given ID. */
231 
232 /* ************************************* */
233 // TODO: overrides, remapping, and path-finding api's
234 
235 /* ------------ NLA Keyframing --------------- */
236 
238 
249  struct ListBase *cache,
250  struct PointerRNA *ptr,
251  struct AnimData *adt,
252  const struct AnimationEvalContext *anim_eval_context);
267  struct PointerRNA *prop_ptr,
268  struct PropertyRNA *prop,
269  float *values,
270  int count,
271  int index,
272  const struct AnimationEvalContext *anim_eval_context,
273  bool *r_force_all,
274  BLI_bitmap *r_successful_remaps);
275 
280 
281 /* ************************************* */
282 /* Evaluation API */
283 
284 /* ------------- Main API -------------------- */
285 /* In general, these ones should be called to do all animation evaluation */
286 
287 /* Flags for recalc parameter, indicating which part to recalculate. */
288 typedef enum eAnimData_Recalc {
289  ADT_RECALC_DRIVERS = (1 << 0),
290  ADT_RECALC_ANIM = (1 << 1),
293 
295  const char *rna_path,
296  int array_index,
297  struct PathResolvedRNA *r_result);
298 bool BKE_animsys_read_from_rna_path(struct PathResolvedRNA *anim_rna, float *r_value);
302 bool BKE_animsys_write_to_rna_path(struct PathResolvedRNA *anim_rna, float value);
303 
312  struct AnimData *adt,
313  const struct AnimationEvalContext *anim_eval_context,
314  eAnimData_Recalc recalc,
315  bool flush_to_original);
316 
326  struct Depsgraph *depsgraph,
327  float ctime);
328 
329 /* ------------ Specialized API --------------- */
330 /* There are a few special tools which require these following functions. They are NOT to be used
331  * for standard animation evaluation UNDER ANY CIRCUMSTANCES!
332  *
333  * i.e. Pose Library (PoseLib) uses some of these for selectively applying poses, but
334  * Particles/Sequencer performing funky time manipulation is not ok.
335  */
336 
337 /* Evaluate Action (F-Curve Bag) */
339  struct bAction *act,
340  const struct AnimationEvalContext *anim_eval_context,
341  bool flush_to_original);
342 
343 /* Evaluate action, and blend the result into the current values (instead of overwriting fully). */
345  struct bAction *act,
346  const AnimationEvalContext *anim_eval_context,
347  float blend_factor);
348 
349 /* Evaluate Action Group */
351  struct bAction *act,
352  struct bActionGroup *agrp,
353  const struct AnimationEvalContext *anim_eval_context);
354 
355 /* ************************************* */
356 
357 /* ------------ Evaluation API --------------- */
358 
359 struct Depsgraph;
360 
361 void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id);
363  struct ID *id,
364  int driver_index,
365  struct FCurve *fcu_orig);
366 
367 void BKE_animsys_update_driver_array(struct ID *id);
368 
369 /* ************************************* */
370 
371 #ifdef __cplusplus
372 }
373 #endif
void BKE_animsys_free_nla_keyframing_context_cache(struct ListBase *cache)
Definition: anim_sys.c:3866
struct KS_Path * BKE_keyingset_add_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode)
Definition: anim_sys.c:160
void BKE_keyingsets_free(struct ListBase *list)
Definition: anim_sys.c:282
void(* ID_AnimData_Edit_Callback)(struct ID *id, struct AnimData *adt, void *user_data)
Definition: BKE_animsys.h:218
void BKE_keyingsets_copy(struct ListBase *newlist, const struct ListBase *list)
void BKE_fcurves_main_cb(struct Main *bmain, ID_FCurve_Edit_Callback func, void *user_data)
Definition: anim_data.c:1166
char * BKE_animsys_fix_rna_path_rename(struct ID *owner_id, char *old_path, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
Definition: anim_data.c:860
void BKE_animdata_fix_paths_rename_all(struct ID *ref_id, const char *prefix, const char *oldName, const char *newName)
Definition: anim_data.c:1287
void BKE_animsys_evaluate_all_animation(struct Main *main, struct Depsgraph *depsgraph, float ctime)
Definition: anim_sys.c:3985
struct KeyingSet * BKE_keyingset_add(struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag)
Definition: anim_sys.c:126
void animsys_evaluate_action(struct PointerRNA *ptr, struct bAction *act, const struct AnimationEvalContext *anim_eval_context, bool flush_to_original)
AnimationEvalContext BKE_animsys_eval_context_construct(struct Depsgraph *depsgraph, float eval_time)
Definition: anim_sys.c:761
void BKE_keyingsets_blend_read_lib(struct BlendLibReader *reader, struct ID *id, struct ListBase *list)
Definition: anim_sys.c:332
void BKE_keyingsets_blend_read_data(struct BlendDataReader *reader, struct ListBase *list)
Definition: anim_sys.c:319
void BKE_keyingsets_blend_write(struct BlendWriter *writer, struct ListBase *list)
Definition: anim_sys.c:301
void BKE_action_fix_paths_rename(struct ID *owner_id, struct bAction *act, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
Definition: anim_data.c:915
void BKE_keyingsets_foreach_id(struct LibraryForeachIDData *data, const struct ListBase *keyingsets)
struct AnimationBasePathChange AnimationBasePathChange
void BKE_fcurves_id_cb(struct ID *id, ID_FCurve_Edit_Callback func, void *user_data)
Definition: anim_data.c:1157
void BKE_animdata_transfer_by_basepath(struct Main *bmain, struct ID *srcID, struct ID *dstID, struct ListBase *basepaths)
Definition: anim_data.c:601
bool BKE_animdata_fix_paths_remove(struct ID *id, const char *path)
Definition: anim_data.c:1067
eAnimData_Recalc
Definition: BKE_animsys.h:288
@ ADT_RECALC_ANIM
Definition: BKE_animsys.h:290
@ ADT_RECALC_ALL
Definition: BKE_animsys.h:291
@ ADT_RECALC_DRIVERS
Definition: BKE_animsys.h:289
struct KS_Path * BKE_keyingset_find_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode)
void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id)
Definition: anim_sys.c:4136
void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, struct ID *ref_id, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
Definition: anim_data.c:958
void BKE_animsys_nla_remap_keyframe_values(struct NlaKeyframingContext *context, struct PointerRNA *prop_ptr, struct PropertyRNA *prop, float *values, int count, int index, const struct AnimationEvalContext *anim_eval_context, bool *r_force_all, BLI_bitmap *r_successful_remaps)
Definition: anim_sys.c:3740
bool BKE_animsys_rna_path_resolve(struct PointerRNA *ptr, const char *rna_path, int array_index, struct PathResolvedRNA *r_result)
Definition: anim_sys.c:367
void BKE_keyingsets_blend_read_expand(struct BlendExpander *expander, struct ListBase *list)
Definition: anim_sys.c:341
bool BKE_animsys_read_from_rna_path(struct PathResolvedRNA *anim_rna, float *r_value)
Definition: anim_sys.c:416
void(* ID_FCurve_Edit_Callback)(struct ID *id, struct FCurve *fcu, void *user_data)
Definition: BKE_animsys.h:221
void BKE_animsys_evaluate_animdata(struct ID *id, struct AnimData *adt, const struct AnimationEvalContext *anim_eval_context, eAnimData_Recalc recalc, bool flush_to_original)
void BKE_keyingset_free(struct KeyingSet *ks)
Definition: anim_sys.c:266
void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp)
Definition: anim_sys.c:223
void animsys_evaluate_action_group(struct PointerRNA *ptr, struct bAction *act, struct bActionGroup *agrp, const struct AnimationEvalContext *anim_eval_context)
void BKE_animsys_update_driver_array(struct ID *id)
Definition: anim_sys.c:4150
void BKE_animsys_eval_driver(struct Depsgraph *depsgraph, struct ID *id, int driver_index, struct FCurve *fcu_orig)
Definition: anim_sys.c:4170
struct AnimationEvalContext AnimationEvalContext
void animsys_blend_in_action(struct PointerRNA *ptr, struct bAction *act, const AnimationEvalContext *anim_eval_context, float blend_factor)
Definition: anim_sys.c:904
void BKE_animdata_main_cb(struct Main *bmain, ID_AnimData_Edit_Callback func, void *user_data)
Definition: anim_data.c:1177
struct NlaKeyframingContext * BKE_animsys_get_nla_keyframing_context(struct ListBase *cache, struct PointerRNA *ptr, struct AnimData *adt, const struct AnimationEvalContext *anim_eval_context)
bool BKE_animsys_write_to_rna_path(struct PathResolvedRNA *anim_rna, float value)
Definition: anim_sys.c:478
void BKE_animdata_fix_paths_rename_all_ex(struct Main *bmain, struct ID *ref_id, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
Definition: anim_data.c:1296
AnimationEvalContext BKE_animsys_eval_context_construct_at(const AnimationEvalContext *anim_eval_context, float eval_time)
Definition: anim_sys.c:771
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:16
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
int main(int argc, char *argv[])
const Depsgraph * depsgraph
void * user_data
SyclQueue void void size_t num_bytes void
int count
const char * dst_basepath
Definition: BKE_animsys.h:198
const char * src_basepath
Definition: BKE_animsys.h:197
struct AnimationBasePathChange * next
Definition: BKE_animsys.h:196
struct AnimationBasePathChange * prev
Definition: BKE_animsys.h:196
struct Depsgraph * depsgraph
Definition: BKE_animsys.h:42
Definition: DNA_ID.h:368
short flag
int array_index
short groupmode
char * rna_path
char name[64]
char idname[64]
short keyingflag
Definition: BKE_main.h:121
struct AnimData * adt
Definition: nla_private.h:140
PointerRNA * ptr
Definition: wm_files.c:3480