Blender V5.0
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
84void BKE_keyingsets_copy(struct ListBase *newlist, const struct ListBase *list);
85
91 const struct ListBase *keyingsets);
92
94void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp);
95
97void BKE_keyingset_free_paths(struct KeyingSet *ks);
98
100void BKE_keyingsets_free(struct ListBase *list);
101
102void BKE_keyingsets_blend_write(struct BlendWriter *writer, struct ListBase *list);
103void BKE_keyingsets_blend_read_data(struct BlendDataReader *reader, struct ListBase *list);
104
105/* ************************************* */
106/* Path Fixing API */
107
117char *BKE_animsys_fix_rna_path_rename(struct ID *owner_id,
118 char *old_path,
119 const char *prefix,
120 const char *oldName,
121 const char *newName,
122 int oldSubscript,
123 int newSubscript,
124 bool verify_paths);
125
135void BKE_action_fix_paths_rename(struct ID *owner_id,
136 struct bAction *act,
137 int32_t /*slot_handle_t*/ slot_handle,
138 const char *prefix,
139 const char *oldName,
140 const char *newName,
141 int oldSubscript,
142 int newSubscript,
143 bool verify_paths);
144
151void BKE_animdata_fix_paths_rename(struct ID *owner_id,
152 struct AnimData *adt,
153 struct ID *ref_id,
154 const char *prefix,
155 const char *oldName,
156 const char *newName,
157 int oldSubscript,
158 int newSubscript,
159 bool verify_paths);
160
168 struct ID *ref_id,
169 const char *prefix,
170 const char *oldName,
171 const char *newName,
172 int oldSubscript,
173 int newSubscript,
174 bool verify_paths);
175
177void BKE_animdata_fix_paths_rename_all(struct ID *ref_id,
178 const char *prefix,
179 const char *oldName,
180 const char *newName);
181
188bool BKE_animdata_fix_paths_remove(struct ID *id, const char *prefix);
189
195bool BKE_animdata_driver_path_remove(struct ID *id, const char *prefix);
196
206 struct StructRNA &type,
207 void *data);
208
209/* -------------------------------------- */
210
216
225void BKE_animdata_transfer_by_basepath(struct Main *bmain,
226 struct ID *srcID,
227 struct ID *dstID,
228 struct ListBase *basepaths);
229
230/* ------------ NLA Keyframing --------------- */
231
233
244 struct ListBase *cache,
245 struct PointerRNA *ptr,
246 struct AnimData *adt,
247 const struct AnimationEvalContext *anim_eval_context);
264 struct PointerRNA *prop_ptr,
265 struct PropertyRNA *prop,
266 const blender::MutableSpan<float> values,
267 int index,
268 const struct AnimationEvalContext *anim_eval_context,
269 bool *r_force_all,
270 blender::BitVector<> &r_values_mask);
271
276
277/* ************************************* */
278/* Evaluation API */
279
280/* ------------- Main API -------------------- */
281/* In general, these ones should be called to do all animation evaluation */
282
283/* Flags for recalc parameter, indicating which part to recalculate. */
289
291 const char *rna_path,
292 int array_index,
293 struct PathResolvedRNA *r_result);
294bool BKE_animsys_read_from_rna_path(struct PathResolvedRNA *anim_rna, float *r_value);
303 float value,
304 bool force_write = false);
305
314 struct AnimData *adt,
315 const struct AnimationEvalContext *anim_eval_context,
316 eAnimData_Recalc recalc,
317 bool flush_to_original);
318
328 struct Depsgraph *depsgraph,
329 float ctime);
330
331/* ------------ Specialized API --------------- */
332/* There are a few special tools which require these following functions. They are NOT to be used
333 * for standard animation evaluation UNDER ANY CIRCUMSTANCES!
334 *
335 * i.e. Pose Library (PoseLib) uses some of these for selectively applying poses, but
336 * Particles/Sequencer performing funky time manipulation is not ok.
337 */
338
343 struct bAction *act,
344 int32_t action_slot_handle,
345 const struct AnimationEvalContext *anim_eval_context,
346 bool flush_to_original);
347
352 struct bAction *act,
353 int32_t action_slot_handle,
354 const AnimationEvalContext *anim_eval_context,
355 float blend_factor);
356
359 struct bAction *act,
360 struct bActionGroup *agrp,
361 const struct AnimationEvalContext *anim_eval_context);
362
363/* ************************************* */
364
365/* ------------ Evaluation API --------------- */
366
367struct Depsgraph;
368
369void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id);
370void BKE_animsys_eval_driver_unshare(Depsgraph *depsgraph, ID *id);
371void BKE_animsys_eval_driver(struct Depsgraph *depsgraph,
372 struct ID *id,
373 int driver_index,
374 struct FCurve *fcu_orig);
375
376void BKE_animsys_update_driver_array(struct ID *id);
377
378/* ************************************* */
379
380void BKE_time_markers_blend_write(BlendWriter *writer, ListBase /* TimeMarker */ &markers);
381void BKE_time_markers_blend_read(BlendDataReader *reader, ListBase /* TimeMarker */ &markers);
382
390void BKE_copy_time_markers(ListBase /* TimeMarker */ &markers_dst,
391 const ListBase /* TimeMarker */ &markers_src,
392 int flag);
void BKE_animsys_free_nla_keyframing_context_cache(struct ListBase *cache)
Definition anim_sys.cc:3887
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:84
void BKE_keyingsets_free(struct ListBase *list)
Definition anim_sys.cc:283
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:746
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:4013
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:914
AnimationEvalContext BKE_animsys_eval_context_construct(struct Depsgraph *depsgraph, float eval_time) ATTR_WARN_UNUSED_RESULT
Definition anim_sys.cc:738
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:320
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:302
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:460
void BKE_keyingsets_foreach_id(struct LibraryForeachIDData *data, const struct ListBase *keyingsets)
void BKE_keyingset_free_paths(struct KeyingSet *ks)
Definition anim_sys.cc:267
struct KeyingSet * BKE_keyingset_add(struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag)
Definition anim_sys.cc:134
void BKE_animdata_transfer_by_basepath(struct Main *bmain, struct ID *srcID, struct ID *dstID, struct ListBase *basepaths)
Definition anim_data.cc:611
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:890
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:350
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:164
bool BKE_animsys_read_from_rna_path(struct PathResolvedRNA *anim_rna, float *r_value)
Definition anim_sys.cc:399
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:227
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 * name
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:414
short groupmode
char * rna_path
char idname[64]
struct AnimData * adt
PointerRNA * ptr
Definition wm_files.cc:4238
uint8_t flag
Definition wm_window.cc:145