Blender V4.3
BKE_fcurve.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
12#include "BLI_string_ref.hh"
13#include "DNA_curve_types.h"
14
15struct ChannelDriver;
16struct FCM_EnvelopeData;
17struct FCurve;
18struct FModifier;
19struct FCurvePathCache;
20
21struct AnimData;
23struct BezTriple;
24struct BlendDataReader;
25struct BlendWriter;
27struct PathResolvedRNA;
28struct PointerRNA;
29struct PropertyRNA;
30struct StructRNA;
31struct bAction;
32struct bContext;
33
34/* ************** F-Curve Modifiers *************** */
35
48 /* Admin/identity. */
50 short type;
52 short size;
54 short acttype;
58 char name[64];
60 char struct_name[64];
63
64 /* data management function pointers - special handling */
66 void (*free_data)(FModifier *fcm);
68 void (*copy_data)(FModifier *fcm, const FModifier *src);
72 void (*new_data)(void *mdata);
74 void (*verify_data)(FModifier *fcm);
75
76 /* evaluation */
79 const FCurve *fcu, const FModifier *fcm, float cvalue, float evaltime, void *storage);
82 const FCurve *fcu, const FModifier *fcm, float *cvalue, float evaltime, void *storage);
83};
84
85/* Values which describe the behavior of a FModifier Type */
87 /* modifier only modifies values outside of data range */
89 /* modifier leaves data-points alone, but adjusts the interpolation between and around them */
91 /* modifier only modifies the values of points (but times stay the same) */
93 /* modifier generates a curve regardless of what came before */
95};
96
97/* Flags for the requirements of a FModifier Type */
99 /* modifier requires original data-points (kind of beats the purpose of a modifier stack?) */
101 /* modifier doesn't require on any preceding data (i.e. it will generate a curve).
102 * Use in conjunction with FMI_TYPE_GENRATE_CURVE
103 */
105 /* refer to modifier instance */
107};
108
109/* Function Prototypes for FModifierTypeInfo's */
110
121
122/* ---------------------- */
123
127FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu);
135void copy_fmodifiers(ListBase *dst, const ListBase *src);
139bool remove_fmodifier(ListBase *modifiers, FModifier *fcm);
143void free_fmodifiers(ListBase *modifiers);
144
152void set_active_fmodifier(ListBase *modifiers, FModifier *fcm);
153
160bool list_has_suitable_fmodifier(const ListBase *modifiers, int mtype, short acttype);
161
167
183 const ListBase *modifiers,
184 const FCurve *fcu,
185 float cvalue,
186 float evaltime);
192 const ListBase *modifiers,
193 const FCurve *fcu,
194 float *cvalue,
195 float evaltime);
196
201void fcurve_bake_modifiers(FCurve *fcu, int start, int end);
202
204 float frame,
205 int arraylen,
206 bool *r_exists);
207
208/* ************** F-Curves API ******************** */
209
210/* threshold for binary-searching keyframes - threshold here should be good enough for now,
211 * but should become userpref */
212#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */
213
214/* -------- Data Management -------- */
219void BKE_fcurve_free(FCurve *fcu);
223FCurve *BKE_fcurve_copy(const FCurve *fcu);
227void BKE_fcurves_free(ListBase *list);
231void BKE_fcurves_copy(ListBase *dst, ListBase *src);
232
237
238/* Set fcurve modifier name and ensure uniqueness.
239 * Pass new name string when it's been edited otherwise pass empty string. */
240void BKE_fmodifier_name_set(FModifier *fcm, const char *name);
241
250
261FCurve *BKE_fcurve_find(ListBase *list, const char rna_path[], int array_index);
262
266FCurve *BKE_fcurve_iter_step(FCurve *fcu_iter, const char rna_path[]);
267
284 ID *id, void *data, StructRNA *type, const char *prop_name, int index, bool *r_driven);
285
306 const char *rna_path,
307 const int rna_index,
308 bAction **r_action,
309 bool *r_driven);
310
315 PropertyRNA *prop,
316 int rnaindex,
317 AnimData **r_adt,
318 bAction **r_action,
319 bool *r_driven,
320 bool *r_special);
329 const PointerRNA *ptr,
330 PropertyRNA *prop,
331 int rnaindex,
332 AnimData **r_animdata,
333 bAction **r_action,
334 bool *r_driven,
335 bool *r_special);
336
342 float frame,
343 int arraylen,
344 bool *r_replace);
345
346/* `fcurve_cache.cc` */
347
353FCurve *BKE_fcurve_pathcache_find(FCurvePathCache *fcache, const char rna_path[], int array_index);
360 const char *rna_path,
361 FCurve **fcurve_result,
362 int fcurve_result_len);
363
368bool BKE_fcurve_calc_range(const FCurve *fcu, float *r_min, float *r_max, bool selected_keys_only);
369
376bool BKE_fcurve_calc_bounds(const FCurve *fcu,
377 bool selected_keys_only,
378 bool include_handles,
379 const float frame_range[2],
380 rctf *r_bounds);
381
390float *BKE_fcurves_calc_keyed_frames_ex(FCurve **fcurve_array,
391 int fcurve_array_len,
392 float interval,
393 int *r_frames_len);
394float *BKE_fcurves_calc_keyed_frames(FCurve **fcurve_array,
395 int fcurve_array_len,
396 int *r_frames_len);
397
402void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt);
407
412void BKE_fcurve_keyframe_move_time_with_handles(BezTriple *keyframe, const float new_time);
413void BKE_fcurve_keyframe_move_value_with_handles(BezTriple *keyframe, float new_value);
414
415/* .............. */
416
423
428bool BKE_fcurve_is_keyframable(const FCurve *fcu);
429bool BKE_fcurve_is_protected(const FCurve *fcu);
430
435
440
445bool BKE_fcurve_is_cyclic(const FCurve *fcu);
446
447/* Type of infinite cycle for a curve. */
448typedef enum eFCU_Cycle_Type {
450 /* The cycle repeats identically to the base range. */
452 /* The cycle accumulates the change between start and end keys. */
455
460
470 BezTriple *prev,
472 float *r_pdelta);
473
480void BKE_fcurve_bezt_shrink(FCurve *fcu, int new_totvert);
481
492 const BezTriple *a, int size_a, const BezTriple *b, int size_b, int *r_merged_size);
493
497void BKE_fcurve_delete_key(FCurve *fcu, int index);
498
505void BKE_fcurve_delete_keys(FCurve *fcu, blender::uint2 index_range);
506
511
516
525void BKE_fcurve_merge_duplicate_keys(FCurve *fcu, const int sel_flag, const bool use_handle);
526
541
542/* -------- Curve Sanity -------- */
543
559void BKE_fcurve_handles_recalc_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag);
570void testhandles_fcurve(FCurve *fcu, eBezTriple_Flag sel_flag, bool use_handle);
575void sort_time_fcurve(FCurve *fcu);
579bool test_time_fcurve(FCurve *fcu);
580
589void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]);
590
591/* -------- Evaluation -------- */
592
593/* evaluate fcurve */
594float evaluate_fcurve(const FCurve *fcu, float evaltime);
595float evaluate_fcurve_only_curve(const FCurve *fcu, float evaltime);
597 FCurve *fcu,
598 ChannelDriver *driver_orig,
599 const AnimationEvalContext *anim_eval_context);
603bool BKE_fcurve_is_empty(const FCurve *fcu);
608float calculate_fcurve(PathResolvedRNA *anim_rna,
609 FCurve *fcu,
610 const AnimationEvalContext *anim_eval_context);
611
612/* ************* F-Curve Samples API ******************** */
613
614/* -------- Defines -------- */
615
622typedef float (*FcuSampleFunc)(FCurve *fcu, void *data, float evaltime);
623
624/* ----- Sampling Callbacks ------ */
625
630float fcurve_samplingcb_evalcurve(FCurve *fcu, void *data, float evaltime);
631
632/* -------- Main Methods -------- */
633
638void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb);
639
643void fcurve_samples_to_keyframes(FCurve *fcu, int start, int end);
644
645/* ************* F-Curve .blend file API ******************** */
646
647void BKE_fmodifiers_blend_write(BlendWriter *writer, ListBase *fmodifiers);
648void BKE_fmodifiers_blend_read_data(BlendDataReader *reader, ListBase *fmodifiers, FCurve *curve);
649
int BKE_fcm_envelope_find_index(FCM_EnvelopeData *array, float frame, int arraylen, bool *r_exists)
void BKE_fcurve_deduplicate_keys(FCurve *fcu)
eFMI_Action_Types
Definition BKE_fcurve.hh:86
@ FMI_TYPE_EXTRAPOLATION
Definition BKE_fcurve.hh:88
@ FMI_TYPE_REPLACE_VALUES
Definition BKE_fcurve.hh:92
@ FMI_TYPE_INTERPOLATION
Definition BKE_fcurve.hh:90
@ FMI_TYPE_GENERATE_CURVE
Definition BKE_fcurve.hh:94
void fcurve_bake_modifiers(FCurve *fcu, int start, int end)
void testhandles_fcurve(FCurve *fcu, eBezTriple_Flag sel_flag, bool use_handle)
bool BKE_fcurve_is_cyclic(const FCurve *fcu)
void BKE_fcurve_keyframe_move_time_with_handles(BezTriple *keyframe, const float new_time)
float * BKE_fcurves_calc_keyed_frames(FCurve **fcurve_array, int fcurve_array_len, int *r_frames_len)
FCurve * BKE_fcurve_copy(const FCurve *fcu)
void BKE_fcurve_foreach_id(FCurve *fcu, LibraryForeachIDData *data)
void BKE_fcurve_blend_write_data(BlendWriter *writer, FCurve *fcu)
bool BKE_fcurve_is_keyframable(const FCurve *fcu)
FModifier * copy_fmodifier(const FModifier *src)
const FModifierTypeInfo * get_fmodifier_typeinfo(int type)
float evaluate_time_fmodifiers(FModifiersStackStorage *storage, const ListBase *modifiers, const FCurve *fcu, float cvalue, float evaltime)
void BKE_fmodifier_name_set(FModifier *fcm, const char *name)
void copy_fmodifiers(ListBase *dst, const ListBase *src)
float * BKE_fcurves_calc_keyed_frames_ex(FCurve **fcurve_array, int fcurve_array_len, float interval, int *r_frames_len)
void BKE_fcurve_delete_keys(FCurve *fcu, blender::uint2 index_range)
int BKE_fcurve_bezt_binarysearch_index(const BezTriple array[], float frame, int arraylen, bool *r_replace)
uint evaluate_fmodifiers_storage_size_per_modifier(const ListBase *modifiers)
int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
void BKE_fcurve_handles_recalc(FCurve *fcu)
eFCU_Cycle_Type
@ FCU_CYCLE_OFFSET
@ FCU_CYCLE_NONE
@ FCU_CYCLE_PERFECT
bool test_time_fcurve(FCurve *fcu)
void BKE_fcurve_pathcache_destroy(FCurvePathCache *fcache)
void evaluate_value_fmodifiers(FModifiersStackStorage *storage, const ListBase *modifiers, const FCurve *fcu, float *cvalue, float evaltime)
void fcurve_samples_to_keyframes(FCurve *fcu, int start, int end)
FModifier * add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
bool list_has_suitable_fmodifier(const ListBase *modifiers, int mtype, short acttype)
void BKE_fcurve_handles_recalc_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag)
FCurve * BKE_animadata_fcurve_find_by_rna_path(AnimData *animdata, const char *rna_path, const int rna_index, bAction **r_action, bool *r_driven)
float(* FcuSampleFunc)(FCurve *fcu, void *data, float evaltime)
FCurve * BKE_fcurve_find_by_rna_context_ui(bContext *C, const PointerRNA *ptr, PropertyRNA *prop, int rnaindex, AnimData **r_animdata, bAction **r_action, bool *r_driven, bool *r_special)
void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
FCurve * BKE_fcurve_iter_step(FCurve *fcu_iter, const char rna_path[])
void BKE_fcurve_blend_write_listbase(BlendWriter *writer, ListBase *fcurves)
FCurve * BKE_fcurve_find(ListBase *list, const char rna_path[], int array_index)
float evaluate_fcurve_only_curve(const FCurve *fcu, float evaltime)
bool BKE_fcurve_is_empty(const FCurve *fcu)
bool BKE_fcurve_delete_keys_selected(FCurve *fcu)
FCurve * BKE_fcurve_find_by_rna(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, AnimData **r_adt, bAction **r_action, bool *r_driven, bool *r_special)
void BKE_fmodifiers_blend_write(BlendWriter *writer, ListBase *fmodifiers)
void BKE_fcurve_blend_read_data_listbase(BlendDataReader *reader, ListBase *fcurves)
eFCU_Cycle_Type BKE_fcurve_get_cycle_type(const FCurve *fcu)
FCurve * BKE_fcurve_create(void)
int BKE_fcurve_pathcache_find_array(FCurvePathCache *fcache, const char *rna_path, FCurve **fcurve_result, int fcurve_result_len)
eFMI_Requirement_Flags
Definition BKE_fcurve.hh:98
@ FMI_REQUIRES_NOTHING
@ FMI_REQUIRES_RUNTIME_CHECK
@ FMI_REQUIRES_ORIGINAL_DATA
float evaluate_fcurve_driver(PathResolvedRNA *anim_rna, FCurve *fcu, ChannelDriver *driver_orig, const AnimationEvalContext *anim_eval_context)
void BKE_fcurve_deselect_all_keys(FCurve &fcu)
FCurve * BKE_fcurve_pathcache_find(FCurvePathCache *fcache, const char rna_path[], int array_index)
void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
FCurvePathCache * BKE_fcurve_pathcache_create(ListBase *list)
bool BKE_fcurve_is_protected(const FCurve *fcu)
void BKE_fmodifiers_blend_read_data(BlendDataReader *reader, ListBase *fmodifiers, FCurve *curve)
bool BKE_fcurve_bezt_subdivide_handles(BezTriple *bezt, BezTriple *prev, BezTriple *next, float *r_pdelta)
void BKE_fcurve_keyframe_move_value_with_handles(BezTriple *keyframe, float new_value)
bool BKE_fcurve_are_keyframes_usable(const FCurve *fcu)
void BKE_fcurves_free(ListBase *list)
void BKE_fcurves_copy(ListBase *dst, ListBase *src)
FModifier * find_active_fmodifier(ListBase *modifiers)
float evaluate_fcurve(const FCurve *fcu, float evaltime)
void BKE_fcurve_rnapath_set(FCurve &fcu, blender::StringRef rna_path)
BezTriple * BKE_bezier_array_merge(const BezTriple *a, int size_a, const BezTriple *b, int size_b, int *r_merged_size)
void BKE_fcurve_merge_duplicate_keys(FCurve *fcu, const int sel_flag, const bool use_handle)
void BKE_fcurve_bezt_shrink(FCurve *fcu, int new_totvert)
bool BKE_fcurve_has_selected_control_points(const FCurve *fcu)
float calculate_fcurve(PathResolvedRNA *anim_rna, FCurve *fcu, const AnimationEvalContext *anim_eval_context)
void free_fmodifiers(ListBase *modifiers)
void BKE_fcurve_free(FCurve *fcu)
bool BKE_fcurve_calc_range(const FCurve *fcu, float *r_min, float *r_max, bool selected_keys_only)
void sort_time_fcurve(FCurve *fcu)
FCurve * id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *prop_name, int index, bool *r_driven)
const FModifierTypeInfo * fmodifier_get_typeinfo(const FModifier *fcm)
void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb)
float fcurve_samplingcb_evalcurve(FCurve *fcu, void *data, float evaltime)
void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2])
void BKE_fcurve_blend_read_data(BlendDataReader *reader, FCurve *fcu)
void BKE_fcurve_delete_key(FCurve *fcu, int index)
bool BKE_fcurve_calc_bounds(const FCurve *fcu, bool selected_keys_only, bool include_handles, const float frame_range[2], rctf *r_bounds)
void BKE_fcurve_delete_keys_all(FCurve *fcu)
unsigned int uint
eBezTriple_Flag
ATTR_WARN_UNUSED_RESULT const BMVert * v2
float evaltime
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
static ulong * next
void(* copy_data)(FModifier *fcm, const FModifier *src)
Definition BKE_fcurve.hh:68
void(* verify_data)(FModifier *fcm)
Definition BKE_fcurve.hh:74
char struct_name[64]
Definition BKE_fcurve.hh:60
void(* new_data)(void *mdata)
Definition BKE_fcurve.hh:72
void(* free_data)(FModifier *fcm)
Definition BKE_fcurve.hh:66
void(* evaluate_modifier)(const FCurve *fcu, const FModifier *fcm, float *cvalue, float evaltime, void *storage)
Definition BKE_fcurve.hh:81
float(* evaluate_modifier_time)(const FCurve *fcu, const FModifier *fcm, float cvalue, float evaltime, void *storage)
Definition BKE_fcurve.hh:78
Definition DNA_ID.h:413
PointerRNA * ptr
Definition wm_files.cc:4126