40 for (
const FCurve *fcurve : fcurves) {
42 if (fcurve->array_index == fcurve_descriptor.
array_index && fcurve->rna_path &&
53 return const_cast<FCurve *
>(fcurve);
131 float dy = bezt->
vec[1][1] - dst->
vec[1][1];
134 dst->
vec[0][1] += dy;
135 dst->
vec[1][1] += dy;
136 dst->
vec[2][1] += dy;
157 if ((i >= 0) && (i < fcu->totvert)) {
159 fcu->
bezt[i] = *bezt;
191 if (i < fcu->totvert) {
214 *(fcu->
bezt) = *bezt;
252 if (bezt_auto && prev_auto && next_auto) {
267 const float hx = bezt->
vec[1][0] - bezt->
vec[0][0];
268 const float dx = bezt->
vec[1][0] - prev->vec[1][0];
271 const bool auto_works_well =
fabsf(hx - dx / 3.0f) < 0.001f;
272 if (auto_works_well) {
289 beztr->
vec[0][0] = position.x - 1.0f;
290 beztr->
vec[0][1] = position.y;
291 beztr->
vec[1][0] = position.x;
292 beztr->
vec[1][1] = position.y;
293 beztr->
vec[2][0] = position.x + 1.0f;
294 beztr->
vec[2][1] = position.y;
297 beztr->
h1 = beztr->
h2 = settings.handle;
298 beztr->
ipo = settings.interpolation;
320 beztr->
back = 1.70158f;
355 return fcu.
bezt[bezt_index].
vec[1][1] != value;
358 const int diff_ulp = 32;
385 const float start = first->
vec[1][0], end = last->vec[1][0];
391 if (position.x < start || position.x > end) {
392 const float period = end - start;
393 const float step =
floorf((position.x - start) / period);
394 position.x -= step * period;
399 short mode = (step >= 0) ? data->
after_mode : data->before_mode;
402 position.y -= step * (last->vec[1][1] - first->
vec[1][1]);
417 float2 remapped_position = position;
424 flag &= ~INSERTKEY_CYCLE_AWARE;
461 bezt->
ipo = (bezt - 1)->ipo;
463 else if (a < fcu->totvert - 1) {
464 bezt->
ipo = (bezt + 1)->ipo;
486 const float start_frame,
487 const float sample_rate,
489 const int sample_count)
491 for (
int i = 0; i < sample_count; i++) {
492 const float evaluation_time = start_frame + (
float(i) / sample_rate);
501 switch (removal_mode) {
514 if (before_index > 0) {
524 if (after_index < fcu->totvert) {
540 if (range_end_index > range_start_index) {
557 const int sample_count = (range[1] - range[0]) / step + 1;
558 float *samples =
static_cast<float *
>(
559 MEM_callocN(sample_count *
sizeof(
float),
"Channel Bake Samples"));
560 const float sample_rate = 1.0f / step;
572 for (
int i = 0; i < sample_count; i++) {
574 float2 key_position = {range[0] + i * step, samples[i]};
580 baked_keys, sample_count, fcu->
bezt, fcu->
totvert, &merged_size);
582 if (fcu->
bezt !=
nullptr) {
587 fcu->
bezt = merged_bezt;
600 const BezTriple *bezt, *start =
nullptr, *end =
nullptr;
605 if (fcu->
bezt ==
nullptr) {
613 for (i = 0, bezt = fcu->
bezt; i < fcu->
totvert; i++, bezt++) {
622 if (i < fcu->totvert - 1) {
635 range =
int(
ceil(end->vec[1][0] - start->vec[1][0]));
636 sfra =
int(
floor(start->vec[1][0]));
643 for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
649 for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
657 bezt = fcu->
bezt + i + range - 1;
Functions to work with AnimData.
Functions to modify FCurves.
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)
FCurve * BKE_fcurve_create(void)
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.
Span< NewT > constexpr cast() const
constexpr int64_t size() const
constexpr const char * data() const
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float2 floor(const float2 a)
ccl_device_inline float3 ceil(const float3 a)
static float2 remap_cyclic_keyframe_location(const FCurve &fcu, const eFCU_Cycle_Type type, float2 position)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
static bool new_key_needed(const FCurve &fcu, const float frame, const float value)
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)
const FCurve * fcurve_find(Span< const FCurve * > fcurves, FCurveDescriptor fcurve_descriptor)
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)
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)
void animdata_fcurve_delete(bAnimContext *ac, AnimData *adt, FCurve *fcu)
FCurve * create_fcurve_for_channel(FCurveDescriptor fcurve_descriptor)
std::optional< PropertySubType > prop_subtype
eBezTriple_KeyframeType keyframe_type