Blender V5.3
animrig/intern/fcurve.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cfloat>
10#include <cmath>
11#include <cstring>
12
13#include "ANIM_animdata.hh"
14#include "ANIM_fcurve.hh"
15#include "BKE_fcurve.hh"
16#include "BLI_math_base_c.hh"
18#include "BLI_string.hh"
19#include "DNA_anim_types.h"
20#include "MEM_guardedalloc.h"
21
22namespace blender::animrig {
23
24KeyframeSettings get_keyframe_settings(const bool from_userprefs)
25{
26 KeyframeSettings settings = {};
28 settings.handle = HD_AUTO_ANIM;
29 settings.interpolation = BEZT_IPO_BEZ;
30
31 if (from_userprefs) {
32 settings.interpolation = eBezTriple_Interpolation(U.ipo_new);
33 settings.handle = eBezTriple_Handle(U.keyhandles_new);
34 }
35 return settings;
36}
37
38const FCurve *fcurve_find(Span<const FCurve *> fcurves, const FCurveDescriptor &fcurve_descriptor)
39{
40 for (const FCurve *fcurve : fcurves) {
41 /* Check indices first, much cheaper than a string comparison. */
42 if (fcurve->array_index == fcurve_descriptor.array_index &&
43 fcurve->rna_path() == fcurve_descriptor.rna_path)
44 {
45 return fcurve;
46 }
47 }
48 return nullptr;
49}
50FCurve *fcurve_find(Span<FCurve *> fcurves, const FCurveDescriptor &fcurve_descriptor)
51{
52 const FCurve *fcurve = fcurve_find(fcurves.cast<const FCurve *>(), fcurve_descriptor);
53 return const_cast<FCurve *>(fcurve);
54}
55
57{
59 fcu->rna_path_set(fcurve_descriptor.rna_path);
60 fcu->array_index = fcurve_descriptor.array_index;
62 fcu->auto_smoothing = U.auto_smoothing_new;
63
64 if (fcurve_descriptor.prop_type.has_value()) {
65 fcu->flag |= fcurve_flags_for_property_type(*fcurve_descriptor.prop_type);
66 }
67
68 /* Set the fcurve's color mode if needed/able. */
69 if ((U.keying_flag & KEYING_FLAG_XYZ2RGB) != 0 && fcurve_descriptor.prop_subtype.has_value()) {
70 switch (*fcurve_descriptor.prop_subtype) {
72 case PROP_XYZ:
73 case PROP_EULER:
74 case PROP_COLOR:
75 case PROP_COORDS:
77 break;
78
79 case PROP_QUATERNION:
81 break;
82
83 default:
84 /* Leave the color mode as default. */
85 break;
86 }
87 }
88
89 return fcu;
90}
91
93{
94 switch (prop_type) {
95 case PROP_FLOAT:
96 return eFCurve_Flags{};
97 case PROP_INT:
98 /* Do integer (only 'whole' numbers) interpolation between all points. */
99 return FCURVE_INT_VALUES;
100 default:
101 /* Do 'discrete' (i.e. enum, boolean values which cannot take any intermediate
102 * values at all) interpolation between all points.
103 * - however, we must also ensure that evaluated values are only integers still.
104 */
106 }
107}
108
109bool fcurve_delete_keyframe_at_time(FCurve *fcurve, const float time)
110{
111 if (!fcurve || BKE_fcurve_is_protected(*fcurve)) {
112 return false;
113 }
114 bool found;
115
117 fcurve->bezt, time, fcurve->totvert, &found);
118 if (!found) {
119 return false;
120 }
121
124
125 return true;
126}
127
129{
130 if (!fcurve_delete_keyframe_at_time(fcu, cfra)) {
131 return false;
132 }
133
134 /* Empty curves get automatically deleted. */
135 if (BKE_fcurve_is_empty(fcu)) {
136 animdata_fcurve_delete(adt, fcu);
137 }
138
139 return true;
140}
141
142/* ************************************************** */
143/* KEYFRAME INSERTION */
144
145/* -------------- BezTriple Insertion -------------------- */
146
147/* Change the Y position of a keyframe to match the input, adjusting handles. */
148static void replace_bezt_keyframe_ypos(BezTriple *dst, const BezTriple *bezt)
149{
150 /* Just change the values when replacing, so as to not overwrite handles. */
151 float dy = bezt->vec[1][1] - dst->vec[1][1];
152
153 /* Just apply delta value change to the handle values. */
154 dst->vec[0][1] += dy;
155 dst->vec[1][1] += dy;
156 dst->vec[2][1] += dy;
157
158 dst->f1 = bezt->f1;
159 dst->f2 = bezt->f2;
160 dst->f3 = bezt->f3;
161
162 /* TODO: perform some other operations? */
163}
164
166{
167 int i = 0;
168
169 /* Are there already keyframes? */
170 if (fcu->bezt) {
171 bool replace;
172 i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, bezt->vec[1][0], fcu->totvert, &replace);
173
174 /* Replace an existing keyframe? */
175 if (replace) {
176 /* `i` may in rare cases exceed array bounds. */
177 if ((i >= 0) && (i < fcu->totvert)) {
178 if (flag & INSERTKEY_OVERWRITE_FULL) {
179 fcu->bezt[i] = *bezt;
180 }
181 else {
182 replace_bezt_keyframe_ypos(&fcu->bezt[i], bezt);
183 }
184
185 if (flag & INSERTKEY_CYCLE_AWARE) {
186 /* If replacing an end point of a cyclic curve without offset,
187 * modify the other end too. */
188 if (ELEM(i, 0, fcu->totvert - 1) && BKE_fcurve_get_cycle_type(*fcu) == FCU_CYCLE_PERFECT)
189 {
190 replace_bezt_keyframe_ypos(&fcu->bezt[i == 0 ? fcu->totvert - 1 : 0], bezt);
191 }
192 }
193 }
194 }
195 /* Keyframing modes allow not replacing the keyframe. */
196 else if ((flag & INSERTKEY_REPLACE) == 0) {
197 /* Insert new - if we're not restricted to replacing keyframes only. */
198 BezTriple *newb = MEM_new_array_zeroed<BezTriple>(fcu->totvert + 1, "beztriple");
199
200 /* Add the beztriples that should occur before the beztriple to be pasted
201 * (originally in fcu). */
202 if (i > 0) {
203 memcpy(newb, fcu->bezt, i * sizeof(BezTriple));
204 }
205
206 /* Add beztriple to paste at index i. */
207 *(newb + i) = *bezt;
208
209 /* Add the beztriples that occur after the beztriple to be pasted (originally in fcu). */
210 if (i < fcu->totvert) {
211 memcpy(newb + i + 1, fcu->bezt + i, (fcu->totvert - i) * sizeof(BezTriple));
212 }
213
214 /* Replace (+ free) old with new, only if necessary to do so. */
215 MEM_delete(fcu->bezt);
216 fcu->bezt = newb;
217
218 fcu->totvert++;
219 }
220 else {
221 return -1;
222 }
223 }
224 /* No keyframes yet, but can only add if...
225 * 1) keyframing modes say that keyframes can only be replaced, so adding new ones won't know
226 * 2) there are no samples on the curve
227 * NOTE: maybe we may want to allow this later when doing samples -> bezt conversions,
228 * but for now, having both is asking for trouble
229 */
230 else if ((flag & INSERTKEY_REPLACE) == 0 && (fcu->fpt == nullptr)) {
231 /* Create new keyframes array. */
232 fcu->bezt = MEM_new_zeroed<BezTriple>("beztriple");
233 *(fcu->bezt) = *bezt;
234 fcu->totvert = 1;
235 }
236 /* Cannot add anything. */
237 else {
238 /* Return error code -1 to prevent any misunderstandings. */
239 return -1;
240 }
241
242 /* We need to return the index, so that some tools which do post-processing can
243 * detect where we added the BezTriple in the array.
244 */
245 return i;
246}
247
258static void subdivide_nonauto_handles(const FCurve *fcu,
259 BezTriple *bezt,
260 BezTriple *prev,
261 BezTriple *next)
262{
263 if (prev->ipo != BEZT_IPO_BEZ || bezt->ipo != BEZT_IPO_BEZ) {
264 return;
265 }
266
267 /* Don't change Vector handles, or completely auto regions. */
268 const bool bezt_auto = BEZT_IS_AUTOH(bezt) || (bezt->h1 == HD_VECT && bezt->h2 == HD_VECT);
269 const bool prev_auto = BEZT_IS_AUTOH(prev) || (prev->h2 == HD_VECT);
270 const bool next_auto = BEZT_IS_AUTOH(next) || (next->h1 == HD_VECT);
271 if (bezt_auto && prev_auto && next_auto) {
272 return;
273 }
274
275 /* Subdivide the curve. */
276 float delta;
277 if (!BKE_fcurve_bezt_subdivide_handles(bezt, prev, next, &delta)) {
278 return;
279 }
280
281 /* Decide when to force auto to manual. */
282 if (!BEZT_IS_AUTOH(bezt)) {
283 return;
284 }
285 if ((prev_auto || next_auto) && fcu->auto_smoothing == FCURVE_SMOOTH_CONT_ACCEL) {
286 const float hx = bezt->vec[1][0] - bezt->vec[0][0];
287 const float dx = bezt->vec[1][0] - prev->vec[1][0];
288
289 /* This mode always uses 1/3 of key distance for handle x size. */
290 const bool auto_works_well = fabsf(hx - dx / 3.0f) < 0.001f;
291 if (auto_works_well) {
292 return;
293 }
294 }
295
296 /* Turn off auto mode. */
297 bezt->h1 = bezt->h2 = HD_ALIGN;
298}
299
301 const float2 position,
302 const KeyframeSettings &settings,
303 const eFCurve_Flags fcu_flags)
304{
305 /* Set all three points, for nicer start position.
306 * NOTE: +/- 1 on vec.x for left and right handles is so that 'free' handles work ok...
307 */
308 beztr->vec[0][0] = position.x - 1.0f;
309 beztr->vec[0][1] = position.y;
310 beztr->vec[1][0] = position.x;
311 beztr->vec[1][1] = position.y;
312 beztr->vec[2][0] = position.x + 1.0f;
313 beztr->vec[2][1] = position.y;
314 beztr->f1 = beztr->f2 = beztr->f3 = BEZT_FLAG_SELECT;
315
316 beztr->h1 = beztr->h2 = settings.handle;
317 beztr->ipo = settings.interpolation;
318
319 /* Interpolation type used is constrained by the type of values the curve can take. */
320 if (fcu_flags & FCURVE_DISCRETE_VALUES) {
321 beztr->ipo = BEZT_IPO_CONST;
322 }
323 else if ((beztr->ipo == BEZT_IPO_BEZ) && (fcu_flags & FCURVE_INT_VALUES)) {
324 beztr->ipo = BEZT_IPO_LIN;
325 }
326
327 /* Set keyframe type value (supplied),
328 * which should come from the scene settings in most cases. */
329 BEZKEYTYPE_LVALUE(beztr) = settings.keyframe_type;
330
331 /* Set default values for "easing" interpolation mode settings.
332 * NOTE: Even if these modes aren't currently used, if users switch
333 * to these later, we want these to work in a sane way out of
334 * the box.
335 */
336
337 /* "back" easing - This value used to be used when overshoot=0, but that
338 * introduced discontinuities in how the param worked. */
339 beztr->back = 1.70158f;
340
341 /* "elastic" easing - Values here were hand-optimized for a default duration of
342 * ~10 frames (typical motion-graph motion length). */
343 beztr->amplitude = 0.8f;
344 beztr->period = 4.1f;
345}
346
362static bool new_key_needed(const FCurve &fcu, const float frame, const float value)
363{
364 if (fcu.totvert == 0) {
365 return true;
366 }
367
368 bool replace;
369 const int bezt_index = BKE_fcurve_bezt_binarysearch_index(
370 fcu.bezt, frame, fcu.totvert, &replace);
371
372 if (replace) {
373 /* If there is already a key, we only need to modify it if the proposed value is different. */
374 return fcu.bezt[bezt_index].vec[1][1] != value;
375 }
376
377 const int diff_ulp = 32;
378 const float fcu_eval = evaluate_fcurve(&fcu, frame);
379 /* No need to insert a key if the same value is already the value of the FCurve at that point. */
380 if (compare_ff_relative(fcu_eval, value, FLT_EPSILON, diff_ulp)) {
381 return false;
382 }
383
384 return true;
385}
386
392 const eFCU_Cycle_Type type,
394{
395 if (fcu.totvert < 2 || !fcu.bezt) {
396 return position;
397 }
398
399 if (type == FCU_CYCLE_NONE) {
400 return position;
401 }
402
403 BezTriple *first = &fcu.bezt[0], *last = &fcu.bezt[fcu.totvert - 1];
404 const float start = first->vec[1][0], end = last->vec[1][0];
405
406 if (start >= end) {
407 return position;
408 }
409
410 if (position.x < start || position.x > end) {
411 const float period = end - start;
412 const float step = floorf((position.x - start) / period);
413 position.x -= step * period;
414
415 if (type == FCU_CYCLE_OFFSET) {
416 /* Nasty check to handle the case when the modes are different better. */
417 FMod_Cycles *data = static_cast<FMod_Cycles *>(fcu.modifiers.first()->data);
418 short mode = (step >= 0) ? data->after_mode : data->before_mode;
419
420 if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) {
421 position.y -= step * (last->vec[1][1] - first->vec[1][1]);
422 }
423 }
424 }
425
426 return position;
427}
428
430 const float2 position,
431 const KeyframeSettings &settings,
432 eInsertKeyFlags flag)
433{
434 BLI_assert(fcu != nullptr);
435
436 float2 remapped_position = position;
437 /* Adjust coordinates for cycle aware insertion. */
438 if (flag & INSERTKEY_CYCLE_AWARE) {
440 remapped_position = remap_cyclic_keyframe_location(*fcu, type, position);
441 if (type != FCU_CYCLE_PERFECT) {
442 /* Inhibit action from insert_bezt_fcurve unless it's a perfect cycle. */
444 }
445 }
446
447 if ((flag & INSERTKEY_NEEDED) && !new_key_needed(*fcu, remapped_position.x, remapped_position.y))
448 {
450 }
451
452 BezTriple beztr = {{{0}}};
453 initialize_bezt(&beztr, remapped_position, settings, eFCurve_Flags(fcu->flag));
454
455 uint oldTot = fcu->totvert;
456 int a;
457
458 /* Add temp beztriple to keyframes. */
459 a = insert_bezt_fcurve(fcu, &beztr, flag);
461
462 /* Key insertion failed. */
463 if (a < 0) {
464 /* TODO: we need more info from `insert_bezt_fcurve()` called above to
465 * return a more specific failure. */
467 }
468
469 /* Set handle-type and interpolation. */
470 if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE) == 0) {
471 BezTriple *bezt = (fcu->bezt + a);
472
473 /* Set interpolation from previous (if available),
474 * but only if we didn't just replace some keyframe:
475 * - Replacement is indicated by no-change in number of verts.
476 * - When replacing, the user may have specified some interpolation that should be kept.
477 */
478 if (fcu->totvert > oldTot) {
479 if (a > 0) {
480 bezt->ipo = (bezt - 1)->ipo;
481 }
482 else if (a < fcu->totvert - 1) {
483 bezt->ipo = (bezt + 1)->ipo;
484 }
485
486 if (0 < a && a < (fcu->totvert - 1) && (flag & INSERTKEY_OVERWRITE_FULL) == 0) {
487 subdivide_nonauto_handles(fcu, bezt, bezt - 1, bezt + 1);
488 }
489 }
490 }
491
492 /* Don't recalculate handles if fast is set.
493 * - this is a hack to make importers faster
494 * - we may calculate twice (due to auto-handle needing to be calculated twice)
495 */
496 if ((flag & INSERTKEY_FAST) == 0) {
498 }
499
500 /* Return the index at which the keyframe was added. */
502}
503
505 const float start_frame,
506 const float sample_rate,
507 float *samples,
508 const int sample_count)
509{
510 for (int i = 0; i < sample_count; i++) {
511 const float evaluation_time = start_frame + (float(i) / sample_rate);
512 samples[i] = evaluate_fcurve(fcu, evaluation_time);
513 }
514}
515
517 const int2 range,
518 const BakeCurveRemove removal_mode)
519{
520 if (fcu->totvert == 0) {
521 return;
522 }
523
524 switch (removal_mode) {
525
528 break;
529 }
530
532 bool replace;
533
534 int before_index = BKE_fcurve_bezt_binarysearch_index(
535 fcu->bezt, range[0], fcu->totvert, &replace);
536
537 if (before_index > 0) {
538 BKE_fcurve_delete_keys(*fcu, {0, uint(before_index)});
539 }
540
541 int after_index = BKE_fcurve_bezt_binarysearch_index(
542 fcu->bezt, range[1], fcu->totvert, &replace);
543 /* #OUT_RANGE is treated as exclusive on both ends. */
544 if (replace) {
545 after_index++;
546 }
547 if (after_index < fcu->totvert) {
548 BKE_fcurve_delete_keys(*fcu, {uint(after_index), fcu->totvert});
549 }
550 break;
551 }
552
554 bool replace;
555 const int range_start_index = BKE_fcurve_bezt_binarysearch_index(
556 fcu->bezt, range[0], fcu->totvert, &replace);
557 int range_end_index = BKE_fcurve_bezt_binarysearch_index(
558 fcu->bezt, range[1], fcu->totvert, &replace);
559 if (replace) {
560 range_end_index++;
561 }
562
563 if (range_end_index > range_start_index) {
564 BKE_fcurve_delete_keys(*fcu, {uint(range_start_index), uint(range_end_index)});
565 }
566 break;
567 }
568
569 default:
570 break;
571 }
572}
573
575 const int2 range,
576 const float step,
577 const BakeCurveRemove remove_existing)
578{
579 BLI_assert(step > 0);
580 const int sample_count = (range[1] - range[0]) / step + 1;
581 float *samples = MEM_new_array_zeroed<float>(sample_count, "Channel Bake Samples");
582 const float sample_rate = 1.0f / step;
583 sample_fcurve_segment(fcu, range[0], sample_rate, samples, sample_count);
584
585 if (remove_existing != BakeCurveRemove::NONE) {
586 remove_fcurve_key_range(fcu, range, remove_existing);
587 }
588
589 BezTriple *baked_keys = MEM_new_array_zeroed<BezTriple>(sample_count, "beztriple");
590
591 const KeyframeSettings settings = get_keyframe_settings(true);
592
593 for (int i = 0; i < sample_count; i++) {
594 BezTriple *key = &baked_keys[i];
595 float2 key_position = {range[0] + i * step, samples[i]};
596 initialize_bezt(key, key_position, settings, eFCurve_Flags(fcu->flag));
597 }
598
599 int merged_size;
600 BezTriple *merged_bezt = BKE_bezier_array_merge(
601 baked_keys, sample_count, fcu->bezt, fcu->totvert, &merged_size);
602
603 if (fcu->bezt != nullptr) {
604 /* Can happen if we removed all keys beforehand. */
605 MEM_delete(fcu->bezt);
606 }
607 MEM_delete(baked_keys);
608 fcu->bezt = merged_bezt;
609 fcu->totvert = merged_size;
610
611 MEM_delete(samples);
613}
614
616 float frame, val;
617};
618
620{
621 const BezTriple *bezt, *start = nullptr, *end = nullptr;
622 TempFrameValCache *value_cache, *fp;
623 int sfra, range;
624 int i, n;
625
626 if (fcu->bezt == nullptr) {
627 return;
628 }
629
632
633 /* Find selected keyframes... once pair has been found, add keyframes. */
634 for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
635 /* check if selected, and which end this is */
636 if (BEZT_ISSEL_ANY(bezt)) {
637 if (start) {
638 /* If next bezt is also selected, don't start sampling yet,
639 * but instead wait for that one to reconsider, to avoid
640 * changing the curve when sampling consecutive segments
641 * (#53229)
642 */
643 if (i < fcu->totvert - 1) {
644 BezTriple *next = &fcu->bezt[i + 1];
645 if (BEZT_ISSEL_ANY(next)) {
646 continue;
647 }
648 }
649
650 end = bezt;
651
652 /* Cache values then add keyframes using these values, as adding
653 * keyframes while sampling will affect the outcome...
654 * - Only start sampling+adding from index=1, so that we don't overwrite original keyframe.
655 */
656 range = int(ceil(end->vec[1][0] - start->vec[1][0]));
657 sfra = int(floor(start->vec[1][0]));
658
659 if (range) {
660 value_cache = MEM_new_array_zeroed<TempFrameValCache>(range, "IcuFrameValCache");
661
662 /* Sample values. */
663 for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
664 fp->frame = float(sfra + n);
665 fp->val = evaluate_fcurve(fcu, fp->frame);
666 }
667
668 /* Add keyframes with these, tagging as 'breakdowns'. */
669 for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
670 animrig::insert_vert_fcurve(fcu, {fp->frame, fp->val}, settings, INSERTKEY_NOFLAGS);
671 }
672
673 MEM_delete(value_cache);
674
675 /* As we added keyframes, we need to compensate so that bezt is at the right place. */
676 bezt = fcu->bezt + i + range - 1;
677 i += (range - 1);
678 }
679
680 /* The current selection island has ended, so start again from scratch. */
681 start = nullptr;
682 end = nullptr;
683 }
684 else {
685 /* Just set start keyframe. */
686 start = bezt;
687 end = nullptr;
688 }
689 }
690 }
691
693}
694
695bool fcurve_frame_has_keyframe(const FCurve *fcu, const float frame)
696{
697 if (ELEM(nullptr, fcu, fcu->bezt)) {
698 return false;
699 }
700
701 if ((fcu->flag & FCURVE_MUTED) == 0) {
702 bool replace;
703 const int i = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, frame, fcu->totvert, &replace);
704
705 /* #BKE_fcurve_bezt_binarysearch_index will set replace to be 0 or 1
706 * - obviously, 1 represents a match
707 */
708 if (replace) {
709 /* `i` may in rare cases exceed array bounds. */
710 if ((i >= 0) && (i < fcu->totvert)) {
711 return true;
712 }
713 }
714 }
715
716 return false;
717}
718
719} // namespace blender::animrig
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.
#define ELEM(...)
Span< NewT > constexpr cast() const
Definition BLI_span.hh:422
#define FLT_EPSILON
#define position
#define floor
#define ceil
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)
Definition animdata.cc:251
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)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ BEZT_KEYTYPE_KEYFRAME
@ BEZT_KEYTYPE_BREAKDOWN
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)
unsigned int uint
Definition BKE_text.h:55
void BKE_fcurve_delete_keys(FCurve &fcu, uint2 index_range)
@ FCU_CYCLE_OFFSET
@ FCU_CYCLE_NONE
@ FCU_CYCLE_PERFECT
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_CYCLE_AWARE
@ 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
@ FCURVE_DISCRETE_VALUES
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_COLOR_AUTO_YRGB
@ FCURVE_COLOR_AUTO_RGB
@ PROP_TRANSLATION
Definition RNA_types.hh:318
@ PROP_COORDS
Definition RNA_types.hh:331
@ PROP_QUATERNION
Definition RNA_types.hh:324
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)
#define floorf
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBezTriple_Flag f2
eBezTriple_Handle h2
eBezTriple_Flag f3
eBezTriple_Flag f1
eBezTriple_Interpolation ipo
eBezTriple_Handle h1
eFCurve_Flags flag
eFCurve_Smoothing auto_smoothing
ListBaseT< FModifier > modifiers
eFCurve_Coloring color_mode
unsigned int totvert
std::optional< PropertySubType > prop_subtype
std::optional< PropertyType > prop_type
eBezTriple_Interpolation interpolation
eBezTriple_KeyframeType keyframe_type