40 for (
const FCurve *fcurve : fcurves) {
42 if (fcurve->array_index == fcurve_descriptor.
array_index &&
43 fcurve->rna_path() == fcurve_descriptor.
rna_path)
53 return const_cast<FCurve *
>(fcurve);
59 fcu->rna_path_set(fcurve_descriptor.
rna_path);
64 if (fcurve_descriptor.
prop_type.has_value()) {
151 float dy = bezt->
vec[1][1] - dst->
vec[1][1];
154 dst->
vec[0][1] += dy;
155 dst->
vec[1][1] += dy;
156 dst->
vec[2][1] += dy;
177 if ((i >= 0) && (i < fcu->totvert)) {
179 fcu->
bezt[i] = *bezt;
210 if (i < fcu->totvert) {
215 MEM_delete(fcu->
bezt);
233 *(fcu->
bezt) = *bezt;
271 if (bezt_auto && prev_auto && next_auto) {
286 const float hx = bezt->
vec[1][0] - bezt->
vec[0][0];
287 const float dx = bezt->
vec[1][0] - prev->vec[1][0];
290 const bool auto_works_well =
fabsf(hx - dx / 3.0f) < 0.001f;
291 if (auto_works_well) {
339 beztr->
back = 1.70158f;
374 return fcu.
bezt[bezt_index].
vec[1][1] != value;
377 const int diff_ulp = 32;
404 const float start = first->
vec[1][0], end = last->vec[1][0];
411 const float period = end - start;
418 short mode = (
step >= 0) ?
data->after_mode :
data->before_mode;
480 bezt->
ipo = (bezt - 1)->ipo;
482 else if (a < fcu->totvert - 1) {
483 bezt->
ipo = (bezt + 1)->ipo;
505 const float start_frame,
506 const float sample_rate,
508 const int sample_count)
510 for (
int i = 0; i < sample_count; i++) {
511 const float evaluation_time = start_frame + (
float(i) / sample_rate);
524 switch (removal_mode) {
537 if (before_index > 0) {
547 if (after_index < fcu->totvert) {
563 if (range_end_index > range_start_index) {
580 const int sample_count = (range[1] - range[0]) /
step + 1;
582 const float sample_rate = 1.0f /
step;
593 for (
int i = 0; i < sample_count; i++) {
595 float2 key_position = {range[0] + i *
step, samples[i]};
601 baked_keys, sample_count, fcu->
bezt, fcu->
totvert, &merged_size);
603 if (fcu->
bezt !=
nullptr) {
605 MEM_delete(fcu->
bezt);
607 MEM_delete(baked_keys);
608 fcu->
bezt = merged_bezt;
621 const BezTriple *bezt, *start =
nullptr, *end =
nullptr;
626 if (fcu->
bezt ==
nullptr) {
634 for (i = 0, bezt = fcu->
bezt; i < fcu->totvert; i++, bezt++) {
643 if (i < fcu->totvert - 1) {
656 range = int(
ceil(end->vec[1][0] - start->
vec[1][0]));
657 sfra = int(
floor(start->
vec[1][0]));
663 for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
664 fp->frame =
float(sfra + n);
669 for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
673 MEM_delete(value_cache);
676 bezt = fcu->
bezt + i + range - 1;
697 if (
ELEM(
nullptr, fcu, fcu->
bezt)) {
710 if ((i >= 0) && (i < fcu->totvert)) {
Functions to work with AnimData.
Functions to modify FCurves.
#define BEZT_IS_AUTOH(bezt)
#define BEZT_ISSEL_ANY(bezt)
#define BEZKEYTYPE_LVALUE(bezt)
Read Blender memory allocation and freeing.
Span< NewT > constexpr cast() const
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
static float2 remap_cyclic_keyframe_location(const FCurve &fcu, const eFCU_Cycle_Type type, float2 position)
void animdata_fcurve_delete(AnimData *adt, FCurve *fcu)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
bool fcurve_frame_has_keyframe(const FCurve *fcu, float frame)
static bool new_key_needed(const FCurve &fcu, const float frame, const float value)
eFCurve_Flags fcurve_flags_for_property_type(PropertyType prop_type)
FCurve * create_fcurve_for_channel(const FCurveDescriptor &fcurve_descriptor)
static void remove_fcurve_key_range(FCurve *fcu, const int2 range, const BakeCurveRemove removal_mode)
void initialize_bezt(BezTriple *beztr, float2 position, const KeyframeSettings &settings, eFCurve_Flags fcu_flags)
void sample_fcurve_segment(const FCurve *fcu, float start_frame, float sample_rate, float *samples, int sample_count)
bool fcurve_delete_keyframe_at_time(FCurve *fcurve, float time)
void bake_fcurve(FCurve *fcu, int2 range, float step, BakeCurveRemove remove_existing)
SingleKeyingResult insert_vert_fcurve(FCurve *fcu, const float2 position, const KeyframeSettings &settings, eInsertKeyFlags flag)
Main Key-framing API call.
static void subdivide_nonauto_handles(const FCurve *fcu, BezTriple *bezt, BezTriple *prev, BezTriple *next)
const FCurve * fcurve_find(Span< const FCurve * > fcurves, const FCurveDescriptor &fcurve_descriptor)
int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
Lesser Key-framing API call.
bool delete_keyframe_fcurve_legacy(AnimData *adt, FCurve *fcu, float cfra)
static void replace_bezt_keyframe_ypos(BezTriple *dst, const BezTriple *bezt)
void bake_fcurve_segments(FCurve *fcu)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE int compare_ff_relative(float a, float b, float max_diff, int max_ulps)
BezTriple * BKE_bezier_array_merge(const BezTriple *a, int size_a, const BezTriple *b, int size_b, int *r_merged_size)
void BKE_fcurve_delete_keys(FCurve &fcu, uint2 index_range)
bool BKE_fcurve_bezt_subdivide_handles(BezTriple *bezt, BezTriple *prev, BezTriple *next, float *r_pdelta)
void BKE_fcurve_delete_key(FCurve *fcu, int index)
@ INSERTKEY_OVERWRITE_FULL
@ FCM_EXTRAPOLATE_CYCLIC_OFFSET
bool BKE_fcurve_is_protected(const FCurve &fcu)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void BKE_fcurve_handles_recalc(FCurve &fcu)
BMesh const char void * data
eFCU_Cycle_Type BKE_fcurve_get_cycle_type(const FCurve &fcu)
void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
void BKE_fcurve_delete_keys_all(FCurve &fcu)
@ FCURVE_SMOOTH_CONT_ACCEL
int BKE_fcurve_bezt_binarysearch_index(const BezTriple array[], float frame, int arraylen, bool *r_replace)
bool BKE_fcurve_is_empty(const FCurve *fcu)
FCurve * BKE_fcurve_create()
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
float evaluate_fcurve(const FCurve *fcu, float evaltime)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBezTriple_Interpolation ipo
eFCurve_Smoothing auto_smoothing
ListBaseT< FModifier > modifiers
eFCurve_Coloring color_mode
std::optional< PropertySubType > prop_subtype
std::optional< PropertyType > prop_type
eBezTriple_Interpolation interpolation
eBezTriple_KeyframeType keyframe_type