Blender V4.5
BKE_animsys.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors, Joshua Leung. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
10
11#include "BLI_bit_vector.hh"
12#include "BLI_span.hh"
13#include "BLI_sys_types.h" /* for bool */
14
15struct AnimData;
16struct BlendDataReader;
17struct BlendWriter;
18struct Depsgraph;
19struct FCurve;
20struct ID;
21struct KS_Path;
22struct KeyingSet;
24struct ListBase;
25struct Main;
27struct PathResolvedRNA;
28struct PointerRNA;
29struct PropertyRNA;
30struct bAction;
31struct bActionGroup;
32
34typedef struct AnimationEvalContext {
35 /* For drivers, so that they have access to the dependency graph and the current view layer. See
36 * #77086. */
37 struct Depsgraph *depsgraph;
38
39 /* FCurves and Drivers can be evaluated at a different time than the current scene time, for
40 * example when evaluating NLA strips. This means that, even though the current time is stored in
41 * the dependency graph, we need an explicit evaluation time. */
42 float eval_time;
44
46 float eval_time) ATTR_WARN_UNUSED_RESULT;
48 const AnimationEvalContext *anim_eval_context, float eval_time) ATTR_WARN_UNUSED_RESULT;
49
50/* ************************************* */
51/* KeyingSets API */
52
58 struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag);
59
65 struct ID *id,
66 const char group_name[],
67 const char rna_path[],
68 int array_index,
69 short flag,
70 short groupmode);
71
77 struct ID *id,
78 const char group_name[],
79 const char rna_path[],
80 int array_index,
81 int group_mode);
82
83/* Copy all KeyingSets in the given list */
84void BKE_keyingsets_copy(struct ListBase *newlist, const struct ListBase *list);
85
88 const struct ListBase *keyingsets);
89
90/* Free the given Keying Set path */
91void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp);
92
93/* Free data for KeyingSet but not set itself */
94void BKE_keyingset_free_paths(struct KeyingSet *ks);
95
96/* Free all the KeyingSets in the given list */
97void BKE_keyingsets_free(struct ListBase *list);
98
99void BKE_keyingsets_blend_write(struct BlendWriter *writer, struct ListBase *list);
100void BKE_keyingsets_blend_read_data(struct BlendDataReader *reader, struct ListBase *list);
101
102/* ************************************* */
103/* Path Fixing API */
104
114char *BKE_animsys_fix_rna_path_rename(struct ID *owner_id,
115 char *old_path,
116 const char *prefix,
117 const char *oldName,
118 const char *newName,
119 int oldSubscript,
120 int newSubscript,
121 bool verify_paths);
122
132void BKE_action_fix_paths_rename(struct ID *owner_id,
133 struct bAction *act,
134 const char *prefix,
135 const char *oldName,
136 const char *newName,
137 int oldSubscript,
138 int newSubscript,
139 bool verify_paths);
140
147void BKE_animdata_fix_paths_rename(struct ID *owner_id,
148 struct AnimData *adt,
149 struct ID *ref_id,
150 const char *prefix,
151 const char *oldName,
152 const char *newName,
153 int oldSubscript,
154 int newSubscript,
155 bool verify_paths);
156
164 struct ID *ref_id,
165 const char *prefix,
166 const char *oldName,
167 const char *newName,
168 int oldSubscript,
169 int newSubscript,
170 bool verify_paths);
171
173void BKE_animdata_fix_paths_rename_all(struct ID *ref_id,
174 const char *prefix,
175 const char *oldName,
176 const char *newName);
177
184bool BKE_animdata_fix_paths_remove(struct ID *id, const char *prefix);
185
191bool BKE_animdata_driver_path_remove(struct ID *id, const char *prefix);
192
202 struct StructRNA &type,
203 void *data);
204
205/* -------------------------------------- */
206
212
221void BKE_animdata_transfer_by_basepath(struct Main *bmain,
222 struct ID *srcID,
223 struct ID *dstID,
224 struct ListBase *basepaths);
225
226/* ------------ NLA Keyframing --------------- */
227
229
240 struct ListBase *cache,
241 struct PointerRNA *ptr,
242 struct AnimData *adt,
243 const struct AnimationEvalContext *anim_eval_context);
260 struct PointerRNA *prop_ptr,
261 struct PropertyRNA *prop,
262 const blender::MutableSpan<float> values,
263 int index,
264 const struct AnimationEvalContext *anim_eval_context,
265 bool *r_force_all,
266 blender::BitVector<> &r_values_mask);
267
272
273/* ************************************* */
274/* Evaluation API */
275
276/* ------------- Main API -------------------- */
277/* In general, these ones should be called to do all animation evaluation */
278
279/* Flags for recalc parameter, indicating which part to recalculate. */
285
287 const char *rna_path,
288 int array_index,
289 struct PathResolvedRNA *r_result);
290bool BKE_animsys_read_from_rna_path(struct PathResolvedRNA *anim_rna, float *r_value);
299 float value,
300 bool force_write = false);
301
310 struct AnimData *adt,
311 const struct AnimationEvalContext *anim_eval_context,
312 eAnimData_Recalc recalc,
313 bool flush_to_original);
314
324 struct Depsgraph *depsgraph,
325 float ctime);
326
327/* ------------ Specialized API --------------- */
328/* There are a few special tools which require these following functions. They are NOT to be used
329 * for standard animation evaluation UNDER ANY CIRCUMSTANCES!
330 *
331 * i.e. Pose Library (PoseLib) uses some of these for selectively applying poses, but
332 * Particles/Sequencer performing funky time manipulation is not ok.
333 */
334
339 struct bAction *act,
340 int32_t action_slot_handle,
341 const struct AnimationEvalContext *anim_eval_context,
342 bool flush_to_original);
343
344/* Evaluate action, and blend the result into the current values (instead of overwriting fully). */
346 struct bAction *act,
347 int32_t action_slot_handle,
348 const AnimationEvalContext *anim_eval_context,
349 float blend_factor);
350
351/* Evaluate Action Group */
353 struct bAction *act,
354 struct bActionGroup *agrp,
355 const struct AnimationEvalContext *anim_eval_context);
356
357/* ************************************* */
358
359/* ------------ Evaluation API --------------- */
360
361struct Depsgraph;
362
363void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id);
364void BKE_animsys_eval_driver_unshare(Depsgraph *depsgraph, ID *id);
365void BKE_animsys_eval_driver(struct Depsgraph *depsgraph,
366 struct ID *id,
367 int driver_index,
368 struct FCurve *fcu_orig);
369
370void BKE_animsys_update_driver_array(struct ID *id);
371
372/* ************************************* */
373
374void BKE_time_markers_blend_write(BlendWriter *writer, ListBase /* TimeMarker */ &markers);
375void BKE_time_markers_blend_read(BlendDataReader *reader, ListBase /* TimeMarker */ &markers);
376
384void BKE_copy_time_markers(ListBase /* TimeMarker */ &markers_dst,
385 const ListBase /* TimeMarker */ &markers_src,
386 int flag);
void BKE_animsys_free_nla_keyframing_context_cache(struct ListBase *cache)
Definition anim_sys.cc:3884
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)
Definition anim_sys.cc:81
void BKE_keyingsets_free(struct ListBase *list)
Definition anim_sys.cc:280
void BKE_keyingsets_copy(struct ListBase *newlist, const struct ListBase *list)
AnimationEvalContext BKE_animsys_eval_context_construct_at(const AnimationEvalContext *anim_eval_context, float eval_time) ATTR_WARN_UNUSED_RESULT
Definition anim_sys.cc:743
void BKE_animdata_fix_paths_rename_all(struct ID *ref_id, const char *prefix, const char *oldName, const char *newName)
void BKE_animsys_evaluate_all_animation(struct Main *main, struct Depsgraph *depsgraph, float ctime)
Definition anim_sys.cc:4010
void animsys_blend_in_action(struct PointerRNA *ptr, struct bAction *act, int32_t action_slot_handle, const AnimationEvalContext *anim_eval_context, float blend_factor)
Definition anim_sys.cc:911
AnimationEvalContext BKE_animsys_eval_context_construct(struct Depsgraph *depsgraph, float eval_time) ATTR_WARN_UNUSED_RESULT
Definition anim_sys.cc:735
void animsys_evaluate_action(struct PointerRNA *ptr, struct bAction *act, int32_t action_slot_handle, const struct AnimationEvalContext *anim_eval_context, bool flush_to_original)
void BKE_animsys_nla_remap_keyframe_values(struct NlaKeyframingContext *context, struct PointerRNA *prop_ptr, struct PropertyRNA *prop, const blender::MutableSpan< float > values, int index, const struct AnimationEvalContext *anim_eval_context, bool *r_force_all, blender::BitVector<> &r_values_mask)
void BKE_keyingsets_blend_read_data(struct BlendDataReader *reader, struct ListBase *list)
Definition anim_sys.cc:317
void BKE_time_markers_blend_read(BlendDataReader *reader, ListBase &markers)
Definition anim_sys.cc:4317
void BKE_keyingsets_blend_write(struct BlendWriter *writer, struct ListBase *list)
Definition anim_sys.cc:299
void BKE_animsys_eval_driver_unshare(Depsgraph *depsgraph, ID *id)
Definition anim_sys.cc:4192
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.cc:951
bool BKE_animsys_write_to_rna_path(struct PathResolvedRNA *anim_rna, float value, bool force_write=false)
Definition anim_sys.cc:457
void BKE_keyingsets_foreach_id(struct LibraryForeachIDData *data, const struct ListBase *keyingsets)
void BKE_keyingset_free_paths(struct KeyingSet *ks)
Definition anim_sys.cc:264
struct KeyingSet * BKE_keyingset_add(struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag)
Definition anim_sys.cc:131
void BKE_animdata_transfer_by_basepath(struct Main *bmain, struct ID *srcID, struct ID *dstID, struct ListBase *basepaths)
Definition anim_data.cc:610
eAnimData_Recalc
@ ADT_RECALC_ANIM
@ ADT_RECALC_ALL
@ ADT_RECALC_DRIVERS
void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id)
Definition anim_sys.cc:4158
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)
struct NlaKeyframingContext * BKE_animsys_get_nla_keyframing_context(struct ListBase *cache, struct PointerRNA *ptr, struct AnimData *adt, const struct AnimationEvalContext *anim_eval_context)
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.cc:894
void BKE_copy_time_markers(ListBase &markers_dst, const ListBase &markers_src, int flag)
Definition anim_sys.cc:4326
bool BKE_animsys_rna_path_resolve(struct PointerRNA *ptr, const char *rna_path, int array_index, struct PathResolvedRNA *r_result)
Definition anim_sys.cc:347
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.cc:161
bool BKE_animsys_read_from_rna_path(struct PathResolvedRNA *anim_rna, float *r_value)
Definition anim_sys.cc:396
void BKE_animsys_evaluate_animdata(struct ID *id, struct AnimData *adt, const struct AnimationEvalContext *anim_eval_context, eAnimData_Recalc recalc, bool flush_to_original)
bool BKE_animdata_driver_path_remove(struct ID *id, const char *prefix)
void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp)
Definition anim_sys.cc:224
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.cc:4172
void BKE_animsys_eval_driver(struct Depsgraph *depsgraph, struct ID *id, int driver_index, struct FCurve *fcu_orig)
Definition anim_sys.cc:4223
void BKE_time_markers_blend_write(BlendWriter *writer, ListBase &markers)
Definition anim_sys.cc:4306
bool BKE_animdata_fix_paths_remove(struct ID *id, const char *prefix)
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)
bool BKE_animdata_drivers_remove_for_rna_struct(struct ID &owner_id, struct StructRNA &type, void *data)
#define ATTR_WARN_UNUSED_RESULT
BMesh const char void * data
BPy_StructRNA * depsgraph
#define main()
const char * dst_basepath
const char * src_basepath
struct AnimationBasePathChange * next
struct AnimationBasePathChange * prev
struct Depsgraph * depsgraph
Definition BKE_animsys.h:37
Definition DNA_ID.h:404
short groupmode
char * rna_path
char name[64]
char idname[64]
struct AnimData * adt
PointerRNA * ptr
Definition wm_files.cc:4226
uint8_t flag
Definition wm_window.cc:139