Blender V4.3
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
11#include "BLI_bit_vector.hh"
12#include "BLI_span.hh"
13#include "BLI_sys_types.h" /* for bool */
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19struct AnimData;
20struct BlendDataReader;
21struct BlendWriter;
22struct Depsgraph;
23struct FCurve;
24struct ID;
25struct KS_Path;
26struct KeyingSet;
28struct ListBase;
29struct Main;
31struct PathResolvedRNA;
32struct PointerRNA;
33struct PropertyRNA;
34struct bAction;
35struct bActionGroup;
36
38typedef struct AnimationEvalContext {
39 /* For drivers, so that they have access to the dependency graph and the current view layer. See
40 * #77086. */
41 struct Depsgraph *depsgraph;
42
43 /* FCurves and Drivers can be evaluated at a different time than the current scene time, for
44 * example when evaluating NLA strips. This means that, even though the current time is stored in
45 * the dependency graph, we need an explicit evaluation time. */
46 float eval_time;
48
50 float eval_time) ATTR_WARN_UNUSED_RESULT;
52 const AnimationEvalContext *anim_eval_context, float eval_time) ATTR_WARN_UNUSED_RESULT;
53
54/* ************************************* */
55/* KeyingSets API */
56
62 struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag);
63
69 struct ID *id,
70 const char group_name[],
71 const char rna_path[],
72 int array_index,
73 short flag,
74 short groupmode);
75
81 struct ID *id,
82 const char group_name[],
83 const char rna_path[],
84 int array_index,
85 int group_mode);
86
87/* Copy all KeyingSets in the given list */
88void BKE_keyingsets_copy(struct ListBase *newlist, const struct ListBase *list);
89
92 const struct ListBase *keyingsets);
93
94/* Free the given Keying Set path */
95void BKE_keyingset_free_path(struct KeyingSet *ks, struct KS_Path *ksp);
96
97/* Free data for KeyingSet but not set itself */
98void BKE_keyingset_free_paths(struct KeyingSet *ks);
99
100/* Free all the KeyingSets in the given list */
101void BKE_keyingsets_free(struct ListBase *list);
102
103void BKE_keyingsets_blend_write(struct BlendWriter *writer, struct ListBase *list);
104void BKE_keyingsets_blend_read_data(struct BlendDataReader *reader, struct ListBase *list);
105
106/* ************************************* */
107/* Path Fixing API */
108
118char *BKE_animsys_fix_rna_path_rename(struct ID *owner_id,
119 char *old_path,
120 const char *prefix,
121 const char *oldName,
122 const char *newName,
123 int oldSubscript,
124 int newSubscript,
125 bool verify_paths);
126
136void BKE_action_fix_paths_rename(struct ID *owner_id,
137 struct bAction *act,
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
190/* -------------------------------------- */
191
197
206void BKE_animdata_transfer_by_basepath(struct Main *bmain,
207 struct ID *srcID,
208 struct ID *dstID,
209 struct ListBase *basepaths);
210
211/* ------------ NLA Keyframing --------------- */
212
214
225 struct ListBase *cache,
226 struct PointerRNA *ptr,
227 struct AnimData *adt,
228 const struct AnimationEvalContext *anim_eval_context);
245 struct PointerRNA *prop_ptr,
246 struct PropertyRNA *prop,
247 const blender::MutableSpan<float> values,
248 int index,
249 const struct AnimationEvalContext *anim_eval_context,
250 bool *r_force_all,
251 blender::BitVector<> &r_values_mask);
252
257
258/* ************************************* */
259/* Evaluation API */
260
261/* ------------- Main API -------------------- */
262/* In general, these ones should be called to do all animation evaluation */
263
264/* Flags for recalc parameter, indicating which part to recalculate. */
270
272 const char *rna_path,
273 int array_index,
274 struct PathResolvedRNA *r_result);
275bool BKE_animsys_read_from_rna_path(struct PathResolvedRNA *anim_rna, float *r_value);
279bool BKE_animsys_write_to_rna_path(struct PathResolvedRNA *anim_rna, float value);
280
289 struct AnimData *adt,
290 const struct AnimationEvalContext *anim_eval_context,
291 eAnimData_Recalc recalc,
292 bool flush_to_original);
293
303 struct Depsgraph *depsgraph,
304 float ctime);
305
306/* ------------ Specialized API --------------- */
307/* There are a few special tools which require these following functions. They are NOT to be used
308 * for standard animation evaluation UNDER ANY CIRCUMSTANCES!
309 *
310 * i.e. Pose Library (PoseLib) uses some of these for selectively applying poses, but
311 * Particles/Sequencer performing funky time manipulation is not ok.
312 */
313
320 struct bAction *act,
321 int32_t action_slot_handle,
322 const struct AnimationEvalContext *anim_eval_context,
323 bool flush_to_original);
324
325/* Evaluate action, and blend the result into the current values (instead of overwriting fully). */
327 struct bAction *act,
328 int32_t action_slot_handle,
329 const AnimationEvalContext *anim_eval_context,
330 float blend_factor);
331
332/* Evaluate Action Group */
334 struct bAction *act,
335 struct bActionGroup *agrp,
336 const struct AnimationEvalContext *anim_eval_context);
337
338/* ************************************* */
339
340/* ------------ Evaluation API --------------- */
341
342struct Depsgraph;
343
344void BKE_animsys_eval_animdata(struct Depsgraph *depsgraph, struct ID *id);
345void BKE_animsys_eval_driver(struct Depsgraph *depsgraph,
346 struct ID *id,
347 int driver_index,
348 struct FCurve *fcu_orig);
349
350void BKE_animsys_update_driver_array(struct ID *id);
351
352/* ************************************* */
353
354#ifdef __cplusplus
355}
356#endif
void BKE_animsys_free_nla_keyframing_context_cache(struct ListBase *cache)
Definition anim_sys.cc:3913
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:742
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:4039
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:916
AnimationEvalContext BKE_animsys_eval_context_construct(struct Depsgraph *depsgraph, float eval_time) ATTR_WARN_UNUSED_RESULT
Definition anim_sys.cc:734
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_keyingsets_blend_write(struct BlendWriter *writer, struct ListBase *list)
Definition anim_sys.cc:302
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)
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 AnimationBasePathChange AnimationBasePathChange
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:694
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:4187
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:981
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)
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:4201
void BKE_animsys_eval_driver(struct Depsgraph *depsgraph, struct ID *id, int driver_index, struct FCurve *fcu_orig)
Definition anim_sys.cc:4222
struct AnimationEvalContext AnimationEvalContext
bool BKE_animsys_write_to_rna_path(struct PathResolvedRNA *anim_rna, float value)
Definition anim_sys.cc:460
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)
#define ATTR_WARN_UNUSED_RESULT
const Depsgraph * depsgraph
int main()
signed int int32_t
Definition stdint.h:77
const char * dst_basepath
const char * src_basepath
struct AnimationBasePathChange * next
struct AnimationBasePathChange * prev
struct Depsgraph * depsgraph
Definition BKE_animsys.h:41
Definition DNA_ID.h:413
short groupmode
char * rna_path
char idname[64]
struct AnimData * adt
PointerRNA * ptr
Definition wm_files.cc:4126
uint8_t flag
Definition wm_window.cc:138