Blender V5.0
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
10
12#include "BLI_span.hh"
13#include "BLI_string_ref.hh"
14
15#include "DNA_curve_types.h"
16
17struct ChannelDriver;
18struct FCM_EnvelopeData;
19struct FCurve;
20struct FModifier;
21struct FCurvePathCache;
22
23struct AnimData;
25struct BezTriple;
26struct BlendDataReader;
27struct BlendWriter;
29struct PathResolvedRNA;
30struct PointerRNA;
31struct PropertyRNA;
32struct StructRNA;
33struct bAction;
34struct bContext;
35
36/* ************** F-Curve Modifiers *************** */
37
50 /* Admin/identity. */
52 short type;
54 short size;
56 short acttype;
60 char name[64];
62 char struct_name[64];
65
66 /* data management function pointers - special handling */
68 void (*free_data)(FModifier *fcm);
70 void (*copy_data)(FModifier *fcm, const FModifier *src);
74 void (*new_data)(void *mdata);
76 void (*verify_data)(FModifier *fcm);
77
78 /* evaluation */
81 const FCurve *fcu, const FModifier *fcm, float cvalue, float evaltime, void *storage);
84 const FCurve *fcu, const FModifier *fcm, float *cvalue, float evaltime, void *storage);
85};
86
87/* Values which describe the behavior of a FModifier Type */
89 /* modifier only modifies values outside of data range */
91 /* modifier leaves data-points alone, but adjusts the interpolation between and around them */
93 /* modifier only modifies the values of points (but times stay the same) */
95 /* modifier generates a curve regardless of what came before */
97};
98
99/* Flags for the requirements of a FModifier Type */
101 /* modifier requires original data-points (kind of beats the purpose of a modifier stack?) */
103 /* modifier doesn't require on any preceding data (i.e. it will generate a curve).
104 * Use in conjunction with FMI_TYPE_GENRATE_CURVE
105 */
107 /* refer to modifier instance */
109};
110
111/* Function Prototypes for FModifierTypeInfo's */
112
123
124/* ---------------------- */
125
129FModifier *add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu);
137void copy_fmodifiers(ListBase *dst, const ListBase *src);
141bool remove_fmodifier(ListBase *modifiers, FModifier *fcm);
145void free_fmodifiers(ListBase *modifiers);
146
154void set_active_fmodifier(ListBase *modifiers, FModifier *fcm);
155
162bool list_has_suitable_fmodifier(const ListBase *modifiers, int mtype, short acttype);
163
169
185 const ListBase *modifiers,
186 const FCurve *fcu,
187 float cvalue,
188 float evaltime);
194 const ListBase *modifiers,
195 const FCurve *fcu,
196 float *cvalue,
197 float evaltime);
198
203void fcurve_bake_modifiers(FCurve *fcu, int start, int end);
204
206 float frame,
207 int arraylen,
208 bool *r_exists);
209
210/* ************** F-Curves API ******************** */
211
212/* threshold for binary-searching keyframes - threshold here should be good enough for now,
213 * but should become userpref */
214#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */
215
216/* -------- Data Management -------- */
221void BKE_fcurve_free(FCurve *fcu);
225FCurve *BKE_fcurve_copy(const FCurve *fcu);
229void BKE_fcurves_free(ListBase *list);
233void BKE_fcurves_copy(ListBase *dst, ListBase *src);
234
239
240/* Set fcurve modifier name and ensure uniqueness.
241 * Pass new name string when it's been edited otherwise pass empty string. */
242void BKE_fmodifier_name_set(FModifier *fcm, const char *name);
243
252
263FCurve *BKE_fcurve_find(ListBase *list, const char rna_path[], int array_index);
264
268FCurve *BKE_fcurve_iter_step(FCurve *fcu_iter, const char rna_path[]);
269
286 ID *id, void *data, StructRNA *type, const char *prop_name, int index, bool *r_driven);
287
307 const char *rna_path,
308 const int rna_index,
309 bAction **r_action,
310 bool *r_driven);
311
316 PropertyRNA *prop,
317 int rnaindex,
318 AnimData **r_adt,
319 bAction **r_action,
320 bool *r_driven,
321 bool *r_special);
330 const PointerRNA *ptr,
331 PropertyRNA *prop,
332 int rnaindex,
333 AnimData **r_animdata,
334 bAction **r_action,
335 bool *r_driven,
336 bool *r_special);
337
343 float frame,
344 int arraylen,
345 bool *r_replace);
346
347/* `fcurve_cache.cc` */
348
355 const char rna_path[],
356 int array_index);
363 const char *rna_path,
364 FCurve **fcurve_result,
365 int fcurve_result_len);
366
371bool BKE_fcurve_calc_range(const FCurve *fcu, float *r_min, float *r_max, bool selected_keys_only);
372
379bool BKE_fcurve_calc_bounds(const FCurve *fcu,
380 bool selected_keys_only,
381 bool include_handles,
382 const float frame_range[2],
383 rctf *r_bounds);
384
393float *BKE_fcurves_calc_keyed_frames_ex(FCurve **fcurve_array,
394 int fcurve_array_len,
395 float interval,
396 int *r_frames_len);
397float *BKE_fcurves_calc_keyed_frames(FCurve **fcurve_array,
398 int fcurve_array_len,
399 int *r_frames_len);
400
405void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt);
410
415void BKE_fcurve_keyframe_move_time_with_handles(BezTriple *keyframe, const float new_time);
416void BKE_fcurve_keyframe_move_value_with_handles(BezTriple *keyframe, float new_value);
417
418/* .............. */
419
426
431bool BKE_fcurve_is_keyframable(const FCurve *fcu);
432bool BKE_fcurve_is_protected(const FCurve *fcu);
433
438
443
448bool BKE_fcurve_is_cyclic(const FCurve *fcu);
449
450/* Type of infinite cycle for a curve. */
453 /* The cycle repeats identically to the base range. */
455 /* The cycle accumulates the change between start and end keys. */
457};
458
463
473 BezTriple *prev,
475 float *r_pdelta);
476
488void BKE_fcurve_bezt_resize(FCurve *fcu, int new_totvert);
489
500 const BezTriple *a, int size_a, const BezTriple *b, int size_b, int *r_merged_size);
501
505void BKE_fcurve_delete_key(FCurve *fcu, int index);
506
514void BKE_fcurve_delete_keys(FCurve *fcu, blender::uint2 index_range);
515
520
525
534void BKE_fcurve_merge_duplicate_keys(FCurve *fcu, const int sel_flag, const bool use_handle);
535
550
551/* -------- Curve Sanity -------- */
552
568void BKE_fcurve_handles_recalc_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag);
579void testhandles_fcurve(FCurve *fcu, eBezTriple_Flag sel_flag, bool use_handle);
584void sort_time_fcurve(FCurve *fcu);
588bool test_time_fcurve(FCurve *fcu);
589
598void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]);
599
600/* -------- Evaluation -------- */
601
602/* evaluate fcurve */
603float evaluate_fcurve(const FCurve *fcu, float evaltime);
604float evaluate_fcurve_only_curve(const FCurve *fcu, float evaltime);
606 FCurve *fcu,
607 ChannelDriver *driver_orig,
608 const AnimationEvalContext *anim_eval_context);
612bool BKE_fcurve_is_empty(const FCurve *fcu);
617float calculate_fcurve(PathResolvedRNA *anim_rna,
618 FCurve *fcu,
619 const AnimationEvalContext *anim_eval_context);
620
621/* ************* F-Curve Samples API ******************** */
622
623/* -------- Defines -------- */
624
631typedef float (*FcuSampleFunc)(FCurve *fcu, void *data, float evaltime);
632
633/* ----- Sampling Callbacks ------ */
634
639float fcurve_samplingcb_evalcurve(FCurve *fcu, void *data, float evaltime);
640
641/* -------- Main Methods -------- */
642
647void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb);
648
652void fcurve_samples_to_keyframes(FCurve *fcu, int start, int end);
653
654/* ************* F-Curve .blend file API ******************** */
655
656void BKE_fmodifiers_blend_write(BlendWriter *writer, ListBase *fmodifiers);
657void BKE_fmodifiers_blend_read_data(BlendDataReader *reader, ListBase *fmodifiers, FCurve *curve);
658
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:88
@ FMI_TYPE_EXTRAPOLATION
Definition BKE_fcurve.hh:90
@ FMI_TYPE_REPLACE_VALUES
Definition BKE_fcurve.hh:94
@ FMI_TYPE_INTERPOLATION
Definition BKE_fcurve.hh:92
@ FMI_TYPE_GENERATE_CURVE
Definition BKE_fcurve.hh:96
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)
FCurve * BKE_fcurve_create()
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)
FCurvePathCache * BKE_fcurve_pathcache_create(blender::Span< FCurve * > fcurves)
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)
FCurve * BKE_fcurve_pathcache_find(const FCurvePathCache *fcache, 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)
eFMI_Requirement_Flags
@ 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_bezt_resize(FCurve *fcu, int new_totvert)
void BKE_fcurve_deselect_all_keys(FCurve &fcu)
void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
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)
int BKE_fcurve_pathcache_find_array(const FCurvePathCache *fcache, const char *rna_path, FCurve **fcurve_result, int fcurve_result_len)
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)
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
#define C
Definition RandGen.cpp:29
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v2
float evaltime
nullptr float
static ulong * next
VecBase< uint32_t, 2 > uint2
const char * name
void(* copy_data)(FModifier *fcm, const FModifier *src)
Definition BKE_fcurve.hh:70
void(* verify_data)(FModifier *fcm)
Definition BKE_fcurve.hh:76
char struct_name[64]
Definition BKE_fcurve.hh:62
void(* new_data)(void *mdata)
Definition BKE_fcurve.hh:74
void(* free_data)(FModifier *fcm)
Definition BKE_fcurve.hh:68
void(* evaluate_modifier)(const FCurve *fcu, const FModifier *fcm, float *cvalue, float evaltime, void *storage)
Definition BKE_fcurve.hh:83
float(* evaluate_modifier_time)(const FCurve *fcu, const FModifier *fcm, float cvalue, float evaltime, void *storage)
Definition BKE_fcurve.hh:80
Definition DNA_ID.h:414
PointerRNA * ptr
Definition wm_files.cc:4238