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 int32_t /*slot_handle_t*/ slot_handle,
135 const char *prefix,
136 const char *oldName,
137 const char *newName,
138 int oldSubscript,
139 int newSubscript,
140 bool verify_paths);
141
148void BKE_animdata_fix_paths_rename(struct ID *owner_id,
149 struct AnimData *adt,
150 struct ID *ref_id,
151 const char *prefix,
152 const char *oldName,
153 const char *newName,
154 int oldSubscript,
155 int newSubscript,
156 bool verify_paths);
157
165 struct ID *ref_id,
166 const char *prefix,
167 const char *oldName,
168 const char *newName,
169 int oldSubscript,
170 int newSubscript,
171 bool verify_paths);
172
174void BKE_animdata_fix_paths_rename_all(struct ID *ref_id,
175 const char *prefix,
176 const char *oldName,
177 const char *newName);
178
185bool BKE_animdata_fix_paths_remove(struct ID *id, const char *prefix);
186
192bool BKE_animdata_driver_path_remove(struct ID *id, const char *prefix);
193
203 struct StructRNA &type,
204 void *data);
205
206/* -------------------------------------- */
207
213
222void BKE_animdata_transfer_by_basepath(struct Main *bmain,
223 struct ID *srcID,
224 struct ID *dstID,
225 struct ListBase *basepaths);
226
227/* ------------ NLA Keyframing --------------- */
228
230
241 struct ListBase *cache,
242 struct PointerRNA *ptr,
243 struct AnimData *adt,
244 const struct AnimationEvalContext *anim_eval_context);
261 struct PointerRNA *prop_ptr,
262 struct PropertyRNA *prop,
263 const blender::MutableSpan<float> values,
264 int index,
265 const struct AnimationEvalContext *anim_eval_context,
266 bool *r_force_all,
267 blender::BitVector<> &r_values_mask);
268
273
274/* ************************************* */
275/* Evaluation API */
276
277/* ------------- Main API -------------------- */
278/* In general, these ones should be called to do all animation evaluation */
279
280/* Flags for recalc parameter, indicating which part to recalculate. */
286
288 const char *rna_path,
289 int array_index,
290 struct PathResolvedRNA *r_result);
291bool BKE_animsys_read_from_rna_path(struct PathResolvedRNA *anim_rna, float *r_value);
300 float value,
301 bool force_write = false);
302
311 struct AnimData *adt,
312 const struct AnimationEvalContext *anim_eval_context,
313 eAnimData_Recalc recalc,
314 bool flush_to_original);
315
325 struct Depsgraph *depsgraph,
326 float ctime);
327
328/* ------------ Specialized API --------------- */
329/* There are a few special tools which require these following functions. They are NOT to be used
330 * for standard animation evaluation UNDER ANY CIRCUMSTANCES!
331 *
332 * i.e. Pose Library (PoseLib) uses some of these for selectively applying poses, but
333 * Particles/Sequencer performing funky time manipulation is not ok.
334 */
335
340 struct bAction *act,
341 int32_t action_slot_handle,
342 const struct AnimationEvalContext *anim_eval_context,
343 bool flush_to_original);
344
345/* Evaluate action, and blend the result into the current values (instead of overwriting fully). */
347 struct bAction *act,
348 int32_t action_slot_handle,
349 const AnimationEvalContext *anim_eval_context,
350 float blend_factor);
351
352/* Evaluate Action Group */
354 struct bAction *act,
355 struct bActionGroup *agrp,
356 const struct AnimationEvalContext *anim_eval_context);
357
358/* ************************************* */
359
360/* ------------ Evaluation API --------------- */
361
362struct Depsgraph;
363
364void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id);
365void BKE_animsys_eval_driver_unshare(Depsgraph *depsgraph, ID *id);
366void BKE_animsys_eval_driver(struct Depsgraph *depsgraph,
367 struct ID *id,
368 int driver_index,
369 struct FCurve *fcu_orig);
370
371void BKE_animsys_update_driver_array(struct ID *id);
372
373/* ************************************* */
374
375void BKE_time_markers_blend_write(BlendWriter *writer, ListBase /* TimeMarker */ &markers);
376void BKE_time_markers_blend_read(BlendDataReader *reader, ListBase /* TimeMarker */ &markers);
377
385void BKE_copy_time_markers(ListBase /* TimeMarker */ &markers_dst,
386 const ListBase /* TimeMarker */ &markers_src,
387 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
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:614
eAnimData_Recalc
@ ADT_RECALC_ANIM
@ ADT_RECALC_ALL
@ ADT_RECALC_DRIVERS
void BKE_action_fix_paths_rename(struct ID *owner_id, struct bAction *act, int32_t slot_handle, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
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:898
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:4227
uint8_t flag
Definition wm_window.cc:139