40 for (
const FCurve *fcurve : fcurves) {
42 if (fcurve->array_index == fcurve_descriptor.
array_index && fcurve->rna_path &&
53 return const_cast<FCurve *
>(fcurve);
65 if (fcurve_descriptor.
prop_type.has_value()) {
152 float dy = bezt->
vec[1][1] - dst->
vec[1][1];
155 dst->
vec[0][1] += dy;
156 dst->
vec[1][1] += dy;
157 dst->
vec[2][1] += dy;
180 fcu->
bezt[
i] = *bezt;
234 *(fcu->
bezt) = *bezt;
272 if (bezt_auto && prev_auto && next_auto) {
287 const float hx = bezt->
vec[1][0] - bezt->
vec[0][0];
288 const float dx = bezt->
vec[1][0] - prev->vec[1][0];
291 const bool auto_works_well =
fabsf(hx - dx / 3.0f) < 0.001f;
292 if (auto_works_well) {
309 beztr->
vec[0][0] = position.x - 1.0f;
310 beztr->
vec[0][1] = position.y;
311 beztr->
vec[1][0] = position.x;
312 beztr->
vec[1][1] = position.y;
313 beztr->
vec[2][0] = position.x + 1.0f;
314 beztr->
vec[2][1] = position.y;
340 beztr->
back = 1.70158f;
375 return fcu.
bezt[bezt_index].
vec[1][1] != value;
378 const int diff_ulp = 32;
405 const float start = first->
vec[1][0], end = last->vec[1][0];
411 if (position.x < start || position.x > end) {
412 const float period = end - start;
413 const float step =
floorf((position.x - start) / period);
414 position.x -=
step * period;
420 short mode = (
step >= 0) ?
data->after_mode :
data->before_mode;
423 position.y -=
step * (last->vec[1][1] - first->
vec[1][1]);
438 float2 remapped_position = position;
482 bezt->
ipo = (bezt - 1)->ipo;
484 else if (a < fcu->totvert - 1) {
485 bezt->
ipo = (bezt + 1)->ipo;
507 const float start_frame,
508 const float sample_rate,
510 const int sample_count)
512 for (
int i = 0;
i < sample_count;
i++) {
513 const float evaluation_time = start_frame + (
float(
i) / sample_rate);
522 switch (removal_mode) {
535 if (before_index > 0) {
545 if (after_index < fcu->totvert) {
561 if (range_end_index > range_start_index) {
578 const int sample_count = (range[1] - range[0]) /
step + 1;
580 const float sample_rate = 1.0f /
step;
591 for (
int i = 0;
i < sample_count;
i++) {
593 float2 key_position = {range[0] +
i *
step, samples[
i]};
599 baked_keys, sample_count, fcu->
bezt, fcu->
totvert, &merged_size);
601 if (fcu->
bezt !=
nullptr) {
606 fcu->
bezt = merged_bezt;
619 const BezTriple *bezt, *start =
nullptr, *end =
nullptr;
624 if (fcu->
bezt ==
nullptr) {
654 range = int(
ceil(end->vec[1][0] - start->
vec[1][0]));
655 sfra = int(
floor(start->
vec[1][0]));
661 for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
662 fp->frame =
float(sfra + n);
667 for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
675 bezt = fcu->
bezt +
i + range - 1;
696 if (
ELEM(
nullptr, fcu, fcu->
bezt)) {
Functions to work with AnimData.
Functions to modify FCurves.
FCurve * BKE_fcurve_create()
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)
void BKE_fcurve_handles_recalc(FCurve *fcu)
bool BKE_fcurve_is_empty(const FCurve *fcu)
eFCU_Cycle_Type BKE_fcurve_get_cycle_type(const FCurve *fcu)
void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
bool BKE_fcurve_is_protected(const FCurve *fcu)
bool BKE_fcurve_bezt_subdivide_handles(BezTriple *bezt, BezTriple *prev, BezTriple *next, float *r_pdelta)
float evaluate_fcurve(const FCurve *fcu, float evaltime)
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_key(FCurve *fcu, int index)
void BKE_fcurve_delete_keys_all(FCurve *fcu)
MINLINE int compare_ff_relative(float a, float b, float max_diff, int max_ulps)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
@ FCM_EXTRAPOLATE_CYCLIC_OFFSET
@ INSERTKEY_OVERWRITE_FULL
@ FCURVE_SMOOTH_CONT_ACCEL
#define BEZT_IS_AUTOH(bezt)
#define BEZT_ISSEL_ANY(bezt)
#define BEZKEYTYPE_LVALUE(bezt)
Read Guarded memory(de)allocation.
BMesh const char void * data
Span< NewT > constexpr cast() const
constexpr int64_t size() const
constexpr const char * data() const
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
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)
SingleKeyingResult insert_vert_fcurve(FCurve *fcu, const float2 position, const KeyframeSettings &settings, eInsertKeyFlags flag)
Main Key-framing API call.
void bake_fcurve(FCurve *fcu, blender::int2 range, float step, BakeCurveRemove remove_existing)
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)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
std::optional< PropertySubType > prop_subtype
std::optional< PropertyType > prop_type
eBezTriple_Interpolation interpolation
eBezTriple_KeyframeType keyframe_type