68 FCurve *fcu = MEM_new<FCurve>(__func__);
69 fcu->
runtime = MEM_new<FCurveRuntime>(__func__);
86 MEM_SAFE_DELETE(fcu->
bezt);
87 MEM_SAFE_DELETE(fcu->
fpt);
104 if (
list ==
nullptr) {
111 for (
FCurve *fcu =
list->first(); fcu; fcu = fcn) {
117 list->clear_no_delete();
129 if (fcu ==
nullptr) {
134 FCurve *fcu_d = MEM_dupalloc(fcu);
135 fcu_d->
runtime = MEM_new<bke::FCurveRuntime>(__func__, *fcu->
runtime);
137 fcu_d->
next = fcu_d->
prev =
nullptr;
138 fcu_d->
grp =
nullptr;
141 fcu_d->
bezt = MEM_dupalloc(fcu_d->
bezt);
142 fcu_d->
fpt = MEM_dupalloc(fcu_d->
fpt);
160 if (
ELEM(
nullptr, dst, src)) {
165 dst->clear_no_delete();
168 for (
FCurve &sfcu : *src) {
174void FCurve::rna_path_set(
const StringRef path)
182void FCurve::rna_path_set_move(
char *path)
233 if (driver !=
nullptr) {
266 if (prop ==
nullptr) {
277 bool is_driven =
false;
279 adt, path->c_str(),
index,
nullptr, &is_driven);
281 if (r_driven !=
nullptr) {
282 *r_driven = is_driven;
301 if (fcu.array_index == array_index && fcu.rna_path_ptr && fcu.rna_path_ptr[0] ==
rna_path[0] &&
325 for (
FCurve *fcu = fcu_iter; fcu; fcu = fcu->
next) {
327 if (fcu->rna_path_ptr &&
STREQ(fcu->rna_path_ptr,
rna_path)) {
338 if (r_driven !=
nullptr) {
341 if (r_action !=
nullptr) {
356 const bool has_drivers = !
animdata->drivers.is_empty();
360 if (fcu !=
nullptr) {
361 if (r_driven !=
nullptr) {
380 nullptr, ptr, prop, rnaindex, r_adt, r_action, r_driven, r_special);
392 if (r_animdata !=
nullptr) {
393 *r_animdata =
nullptr;
395 if (r_action !=
nullptr) {
398 if (r_driven !=
nullptr) {
419 *r_animdata =
nullptr;
435 if (adt ==
nullptr) {
447 adt,
rna_path->c_str(), rnaindex, r_action, r_driven);
449 if (fcu !=
nullptr && r_animdata !=
nullptr) {
469 const float threshold,
472 int start = 0, end = arraylen;
481 if (arraylen <= 0 ||
array ==
nullptr) {
488 float framenum =
array[0].vec[1][0];
489 if (
IS_EQT(frame, framenum, threshold)) {
493 if (frame < framenum) {
498 framenum =
array[(arraylen - 1)].vec[1][0];
499 if (
IS_EQT(frame, framenum, threshold)) {
501 return (arraylen - 1);
503 if (frame > framenum) {
507 while (start <= end) {
511 const int mid = start + ((end - start) / 2);
513 const float midfra =
array[mid].vec[1][0];
516 if (
IS_EQT(frame, midfra, threshold)) {
522 if (frame > midfra) {
554 const bool selected_keys_only,
555 const float frame_range[2],
560 if (fcu->
bezt ==
nullptr) {
568 if (frame_range !=
nullptr) {
570 bool replace =
false;
572 fcu->
bezt, frame_range[0], fcu->
totvert, &replace);
574 fcu->
bezt, frame_range[1], fcu->
totvert, &replace);
577 if (*r_first == *r_last) {
588 if (selected_keys_only) {
590 for (
int i = *r_first; i <= *r_last; i++) {
600 for (
int i = *r_last; i >= *r_first; i--) {
617 const int index_range[2],
618 const bool include_handles,
622 *r_min = bezt_array[index_range[0]].
vec[1][0];
623 *r_max = bezt_array[index_range[1]].
vec[1][0];
625 if (include_handles) {
627 for (
int i = index_range[0]; i <= index_range[1]; i++) {
629 *r_min = std::min({*r_min, bezt->
vec[0][0], bezt->
vec[1][0]});
630 *r_max = std::max({*r_max, bezt->
vec[1][0], bezt->
vec[2][0]});
636 const int index_range[2],
637 const bool selected_keys_only,
638 const bool include_handles,
642 *r_min = bezt_array[index_range[0]].
vec[1][1];
643 *r_max = bezt_array[index_range[0]].
vec[1][1];
645 for (
int i = index_range[0]; i <= index_range[1]; i++) {
652 *r_min =
min_ff(*r_min, bezt->
vec[1][1]);
653 *r_max =
max_ff(*r_max, bezt->
vec[1][1]);
655 if (include_handles) {
656 *r_min = std::min({*r_min, bezt->
vec[0][1], bezt->
vec[2][1]});
657 *r_max = std::max({*r_max, bezt->
vec[0][1], bezt->
vec[2][1]});
663 const bool selected_keys_only,
664 const bool include_handles,
665 const float frame_range[2],
670 fcu, selected_keys_only, frame_range, &index_range[0], &index_range[1]);
671 if (!found_indices) {
675 fcu->
bezt, index_range, include_handles, &r_bounds->
xmin, &r_bounds->
xmax);
687 r_bounds->
xmin = INFINITY;
688 r_bounds->
xmax = -INFINITY;
689 r_bounds->
ymin = INFINITY;
690 r_bounds->
ymax = -INFINITY;
692 const int first_index = 0;
693 const int last_index = fcu->
totvert - 1;
694 int start_index = first_index;
695 int end_index = last_index;
697 if (frame_range !=
nullptr) {
699 const float start_index_f = frame_range[0] - fcu->
fpt[0].
vec[0];
700 const float end_index_f = start_index_f + frame_range[1] - frame_range[0];
702 if (start_index_f > fcu->
totvert - 1 || end_index_f < 0) {
713 r_bounds->
xmin = fcu->
fpt[start_index].
vec[0];
716 for (
int i = start_index; i <= end_index; i++) {
725 const bool selected_keys_only,
726 const bool include_handles,
727 const float frame_range[2],
736 fcu, selected_keys_only, include_handles, frame_range, r_bounds);
742 return founds_bounds;
751 const bool selected_keys_only)
755 bool foundvert =
false;
764 fcu, selected_keys_only,
nullptr, &index_range[0], &index_range[1]);
768 const bool include_handles =
false;
785 const float interval)
789 const double interval_db =
max_ff(interval, 1e-3f);
791 for (
FCurve *fcu : fcurve_array) {
792 for (
int i = 0; i < fcu->totvert; i++) {
794 const double value =
round(
double(bezt->
vec[1][0]) / interval_db);
796 frames_unique.
add(
int(value));
800 const size_t frames_len = frames_unique.
size();
804 const int value = frames_unique[i];
805 frames[i] = double(value) * interval_db;
825 if (active_bezt ==
nullptr) {
832 const ptrdiff_t offset = active_bezt - fcu->
bezt;
833 if (offset < 0 || offset >= fcu->
totvert) {
849 if (fcu->
bezt ==
nullptr || active_keyframe_index >= fcu->
totvert || active_keyframe_index < 0) {
853 const BezTriple *active_bezt = &fcu->
bezt[active_keyframe_index];
854 if (((active_bezt->
f1 | active_bezt->
f2 | active_bezt->
f3) &
SELECT) == 0) {
859 return active_keyframe_index;
866 const float time_delta = new_time - keyframe->
vec[1][0];
867 keyframe->
vec[0][0] += time_delta;
868 keyframe->
vec[1][0] = new_time;
869 keyframe->
vec[2][0] += time_delta;
874 const float value_delta = new_value - keyframe->
vec[1][1];
875 keyframe->
vec[0][1] += value_delta;
876 keyframe->
vec[1][1] = new_value;
877 keyframe->
vec[2][1] += value_delta;
946 for (bezt = fcu.
bezt, i = 0; i < fcu.
totvert; ++i, ++bezt) {
959 for (
int i = 0; i < fcu.
totvert; i++) {
1000 if (
ELEM(
nullptr, fcu, sample_cb)) {
1001 CLOG_ERROR(&
LOG,
"No F-Curve with F-Curve Modifiers to Bake");
1005 CLOG_ERROR(&
LOG,
"Error: Frame range for Sampled F-Curve creation is inappropriate");
1014 for (
int cfra = start; cfra <= end; cfra++, fpt++) {
1016 fpt->
vec[1] = sample_cb(fcu,
data,
float(cfra));
1021 MEM_delete(fcu->
bezt);
1024 MEM_delete(fcu->
fpt);
1028 fcu->
bezt =
nullptr;
1030 fcu->
totvert = end - start + 1;
1046 if (fcu ==
nullptr) {
1047 CLOG_ERROR(&
LOG,
"No F-Curve with F-Curve Modifiers to Un-Bake");
1052 CLOG_ERROR(&
LOG,
"Error: Frame range to unbake F-Curve is inappropriate");
1056 if (fcu->
fpt ==
nullptr) {
1058 CLOG_ERROR(&
LOG,
"Error: Curve contains no baked keyframes");
1064 MEM_delete(fcu->
bezt);
1068 int keyframes_to_insert = end - start;
1069 int sample_points = fcu->
totvert;
1072 fcu->
totvert = keyframes_to_insert;
1075 for (; sample_points && (fpt->
vec[0] < start); fpt++, sample_points--) {
1080 int cur_pos = start;
1083 for (; keyframes_to_insert && (fpt->
vec[0] > start); cur_pos++, bezt++, keyframes_to_insert--) {
1086 bezt->
vec[1][1] = fpt->
vec[1];
1090 for (; keyframes_to_insert && sample_points;
1091 cur_pos++, bezt++, keyframes_to_insert--, fpt++, sample_points--)
1098 for (fpt--; keyframes_to_insert; cur_pos++, bezt++, keyframes_to_insert--) {
1101 bezt->
vec[1][1] = fpt->
vec[1];
1104 MEM_SAFE_DELETE(fcu->
fpt);
1134 if (
data &&
data->after_cycles == 0 &&
data->before_cycles == 0) {
1171 for (
int i = 0; i < 3; i++) {
1185 if (fcu.
bezt ==
nullptr ||
1198 for (const int i : range) {
1199 BezTriple *bezt = &fcu.bezt[i];
1200 BezTriple *prev = nullptr;
1201 BezTriple *next = nullptr;
1206 prev = cycle_offset_triple(cycle, &tmp, &fcu.bezt[fcu.totvert - 2], last, first);
1208 if (i < fcu.totvert - 1) {
1212 next = cycle_offset_triple(cycle, &tmp, &fcu.bezt[1], first, last);
1220 const float threshold = 0.001;
1221 CLAMP_MAX(bezt->vec[0][0], decrement_ulp(bezt->vec[1][0] - threshold));
1222 CLAMP_MIN(bezt->vec[2][0], increment_ulp(bezt->vec[1][0] + threshold));
1225 BKE_nurb_handle_calc_ex(bezt, prev, next, handle_sel_flag, true, fcu.auto_smoothing);
1228 if (BEZT_IS_AUTOH(bezt) && !cycle) {
1230 if (ELEM(i, 0, fcu.totvert - 1)) {
1232 if (fcu.extend == FCURVE_EXTRAPOLATE_CONSTANT) {
1233 bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1];
1235 bezt->auto_handle_type = HD_AUTOTYPE_LOCKED_FINAL;
1241 if (prev && prev->vec[1][0] >= bezt->vec[1][0]) {
1242 prev->auto_handle_type = bezt->auto_handle_type = HD_AUTOTYPE_LOCKED_FINAL;
1251 first->vec[0][1] = first->vec[2][1] = first->vec[1][1];
1252 last->vec[0][1] = last->vec[2][1] = last->vec[1][1];
1266 switch (source_side) {
1324 if (
ELEM(
nullptr, fcu, fcu->
bezt)) {
1331 for (a = 0, bezt = fcu->
bezt; a < fcu->totvert; a++, bezt++) {
1342 if (fcu.
bezt ==
nullptr) {
1356 for (a = 0, bezt = fcu.
bezt; a < fcu.
totvert; a++, bezt++) {
1360 if (bezt->
vec[1][0] > (bezt + 1)->vec[1][0]) {
1361 std::swap(*bezt, *(bezt + 1));
1374 for (a = 0, bezt = fcu.
bezt; a < fcu.
totvert; a++, bezt++) {
1376 if ((bezt->
vec[0][0] > bezt->
vec[1][0]) && (bezt->
vec[2][0] < bezt->
vec[1][0])) {
1397 for (a = 0, bezt = fcu.
bezt; a < (fcu.
totvert - 1); a++, bezt++) {
1398 if (bezt->
vec[1][0] > (bezt + 1)->vec[1][0]) {
1407 for (a = 0, fpt = fcu.
fpt; a < (fcu.
totvert - 1); a++, fpt++) {
1408 if (fpt->
vec[0] > (fpt + 1)->vec[0]) {
1426 float h1[2], h2[2], len1, len2,
len, fac;
1429 h1[0] = v1[0] -
v2[0];
1430 h1[1] = v1[1] -
v2[1];
1432 h2[0] = v4[0] - v3[0];
1433 h2[1] = v4[1] - v3[1];
1440 len = v4[0] - v1[0];
1441 len1 =
fabsf(h1[0]);
1442 len2 =
fabsf(h2[0]);
1445 if ((len1 + len2) == 0.0f) {
1453 v2[0] = (v1[0] - fac * h1[0]);
1454 v2[1] = (v1[1] - fac * h1[1]);
1459 v3[0] = (v4[0] - fac * h2[0]);
1460 v3[1] = (v4[1] - fac * h2[1]);
1470static int solve_cubic(
double c0,
double c1,
double c2,
double c3,
float *o)
1472 double a,
b, c, p, q, d, t, phi;
1482 q = (2 * a * a * a - a *
b + c) / 2;
1483 d = q * q + p * p * p;
1489 if ((o[0] >=
float(
SMALL)) && (o[0] <= 1.000001f)) {
1497 o[0] =
float(2 * t - a);
1499 if ((o[0] >=
float(
SMALL)) && (o[0] <= 1.000001f)) {
1502 o[nr] =
float(-t - a);
1504 if ((o[nr] >=
float(
SMALL)) && (o[nr] <= 1.000001f)) {
1510 phi =
acos(-q /
sqrt(-(p * p * p)));
1513 q =
sqrt(3 - 3 * p * p);
1514 o[0] =
float(2 * t * p - a);
1516 if ((o[0] >=
float(
SMALL)) && (o[0] <= 1.000001f)) {
1519 o[nr] =
float(-t * (p + q) - a);
1521 if ((o[nr] >=
float(
SMALL)) && (o[nr] <= 1.000001f)) {
1524 o[nr] =
float(-t * (p - q) - a);
1526 if ((o[nr] >=
float(
SMALL)) && (o[nr] <= 1.000001f)) {
1537 p =
b *
b - 4 * a * c;
1541 o[0] =
float((-
b - p) / (2 * a));
1543 if ((o[0] >=
float(
SMALL)) && (o[0] <= 1.000001f)) {
1546 o[nr] =
float((-
b + p) / (2 * a));
1548 if ((o[nr] >=
float(
SMALL)) && (o[nr] <= 1.000001f)) {
1555 o[0] =
float(-
b / (2 * a));
1556 if ((o[0] >=
float(
SMALL)) && (o[0] <= 1.000001f)) {
1567 if ((o[0] >=
float(
SMALL)) && (o[0] <= 1.000001f)) {
1582static int findzero(
float x,
float q0,
float q1,
float q2,
float q3,
float *o)
1584 const double c0 = q0 -
x;
1585 const double c1 = 3.0f * (q1 - q0);
1586 const double c2 = 3.0f * (q0 - 2.0f * q1 + q2);
1587 const double c3 = q3 - q0 + 3.0f * (q1 - q2);
1592static void berekeny(
float f1,
float f2,
float f3,
float f4,
float *o,
int b)
1594 float t, c0, c1, c2, c3;
1598 c1 = 3.0f * (f2 - f1);
1599 c2 = 3.0f * (f1 - 2.0f * f2 + f3);
1600 c3 = f4 - f1 + 3.0f * (f2 - f3);
1602 for (a = 0; a <
b; a++) {
1604 o[a] = c0 + t * c1 + t * t * c2 + t * t * t * c3;
1610 MEM_SAFE_DELETE(fcu.
bezt);
1620 const float *prev_coords = prev->vec[1];
1621 float *prev_handle_right = prev->vec[2];
1622 float *next_handle_left = next->
vec[0];
1623 const float *next_coords = next->
vec[1];
1625 float *new_handle_left = bezt->
vec[0];
1626 const float *new_coords = bezt->
vec[1];
1627 float *new_handle_right = bezt->
vec[2];
1629 if (new_coords[0] <= prev_coords[0] || new_coords[0] >= next_coords[0]) {
1639 prev_handle_right[0],
1640 next_handle_left[0],
1647 const float t = roots[0];
1648 if (t <= 0.0f || t >= 1.0f) {
1655 float split1[3][2], split2[2][2], split3[2];
1657 interp_v2_v2v2(split1[1], prev_handle_right, next_handle_left, t);
1667 float diff_coords[2];
1669 add_v2_v2v2(new_handle_left, split2[0], diff_coords);
1670 add_v2_v2v2(new_handle_right, split2[1], diff_coords);
1672 *r_pdelta = diff_coords[1];
1684 if (new_totvert == 0) {
1694 const int old_totvert = fcu.
totvert;
1695 if (new_totvert > old_totvert) {
1696 std::fill_n(fcu.
bezt + old_totvert, new_totvert - old_totvert,
BezTriple{});
1705 if (fcu ==
nullptr) {
1737 const int removed_index_count = index_range[1] - index_range[0];
1738 memmove(&fcu.
bezt[index_range[0]],
1739 &fcu.
bezt[index_range[1]],
1741 fcu.
totvert -= removed_index_count;
1749 const BezTriple *a,
const int size_a,
const BezTriple *
b,
const int size_b,
int *r_merged_size)
1758 const int max_ulps = 32;
1760 while (iterator_a < size_a || iterator_b < size_b) {
1761 if (iterator_a >= size_a) {
1762 const int remaining_keys = size_b - iterator_b;
1763 memcpy(&large_array[*r_merged_size], &
b[iterator_b],
sizeof(
BezTriple) * remaining_keys);
1764 (*r_merged_size) += remaining_keys;
1767 if (iterator_b >= size_b) {
1768 const int remaining_keys = size_a - iterator_a;
1769 memcpy(&large_array[*r_merged_size], &a[iterator_a],
sizeof(
BezTriple) * remaining_keys);
1770 (*r_merged_size) += remaining_keys;
1777 memcpy(&large_array[*r_merged_size], &a[iterator_a],
sizeof(
BezTriple));
1781 else if (a[iterator_a].vec[1][0] <
b[iterator_b].vec[1][0]) {
1782 memcpy(&large_array[*r_merged_size], &a[iterator_a],
sizeof(
BezTriple));
1786 memcpy(&large_array[*r_merged_size], &
b[iterator_b],
sizeof(
BezTriple));
1793 if (*r_merged_size < size_a + size_b) {
1794 minimal_array =
static_cast<BezTriple *
>(
1798 minimal_array = large_array;
1801 return minimal_array;
1806 if (fcu.
bezt ==
nullptr) {
1810 bool changed =
false;
1813 for (
int i = 0; i < fcu.
totvert; i++) {
1851 ListBaseT<tRetainedKeyframe> retained_keys = {
nullptr,
nullptr};
1856 if ((fcu->
totvert == 0) || (fcu->
bezt ==
nullptr)) {
1864 for (
int i = 0; i < fcu->
totvert; i++) {
1873 rk.val += bezt->
vec[1][1];
1879 if (rk.frame < bezt->
vec[1][0]) {
1886 if (found ==
false) {
1890 rk->
val = bezt->
vec[1][1];
1898 if (retained_keys.is_empty()) {
1901 printf(
"%s: nothing to do for FCurve %p (rna_path = '%s')\n",
1904 fcu->rna_path().c_str());
1911 rk.val = rk.val /
float(rk.tot_count);
1919 for (
int i = fcu->
totvert - 1; i >= 0; i--) {
1933 if (rk.del_count == rk.tot_count - 1) {
1935 if (can_average_points) {
1937 bezt->
vec[1][1] = rk.val;
1965 retained_keys.free_no_destruct();
1974 BLI_assert_msg(fcu->
bezt,
"this function only works with regular (non-sampled) FCurves");
1975 if (fcu->
bezt ==
nullptr) {
1979 int prev_bezt_index = 0;
1980 for (
int i = 1; i < fcu->
totvert; i++) {
1984 const float bezt_x = bezt->
vec[1][0];
1985 const float prev_x = prev_bezt->
vec[1][0];
1991 if (
floor(bezt_x) == bezt_x) {
2009 if (prev_bezt_index != i) {
2011 fcu->
bezt[prev_bezt_index] = *bezt;
2027 int endpoint_offset,
2028 int direction_to_neighbor)
2031 const BezTriple *endpoint_bezt = bezts + endpoint_offset;
2033 const BezTriple *neighbor_bezt = endpoint_bezt + direction_to_neighbor;
2040 return endpoint_bezt->
vec[1][1];
2046 return endpoint_bezt->
vec[1][1];
2049 const float dx = endpoint_bezt->
vec[1][0] - evaltime;
2050 float fac = neighbor_bezt->
vec[1][0] - endpoint_bezt->
vec[1][0];
2054 return endpoint_bezt->
vec[1][1];
2057 fac = (neighbor_bezt->
vec[1][1] - endpoint_bezt->
vec[1][1]) / fac;
2058 return endpoint_bezt->
vec[1][1] - (fac * dx);
2063 const int handle = direction_to_neighbor > 0 ? 0 : 2;
2064 const float dx = endpoint_bezt->
vec[1][0] - evaltime;
2065 float fac = endpoint_bezt->
vec[1][0] - endpoint_bezt->
vec[handle][0];
2069 return endpoint_bezt->
vec[1][1];
2072 fac = (endpoint_bezt->
vec[1][1] - endpoint_bezt->
vec[handle][1]) / fac;
2073 return endpoint_bezt->
vec[1][1] - (fac * dx);
2080 const float eps = 1.e-8f;
2103 return bezt->
vec[1][1];
2109 const BezTriple *prevbezt = (a > 0) ? (bezt - 1) : bezt;
2114 return bezt->
vec[1][1];
2117 if (evaltime < prevbezt->vec[1][0] || bezt->
vec[1][0] < evaltime) {
2119 printf(
" ERROR: failed eval - p=%f b=%f, t=%f (%f)\n",
2120 prevbezt->
vec[1][0],
2123 fabsf(bezt->
vec[1][0] - evaltime));
2129 const float begin = prevbezt->
vec[1][1];
2130 const float change = bezt->
vec[1][1] - prevbezt->
vec[1][1];
2131 const float duration = bezt->
vec[1][0] - prevbezt->
vec[1][0];
2132 const float time = evaltime - prevbezt->
vec[1][0];
2133 const float amplitude = prevbezt->
amplitude;
2134 const float period = prevbezt->
period;
2140 return prevbezt->
vec[1][1];
2143 switch (prevbezt->
ipo) {
2146 float v1[2],
v2[2], v3[2], v4[2], opl[32];
2150 v1[0] = prevbezt->
vec[1][0];
2151 v1[1] = prevbezt->
vec[1][1];
2152 v2[0] = prevbezt->
vec[2][0];
2153 v2[1] = prevbezt->
vec[2][1];
2155 v3[0] = bezt->
vec[0][0];
2156 v3[1] = bezt->
vec[0][1];
2157 v4[0] = bezt->
vec[1][0];
2158 v4[1] = bezt->
vec[1][1];
2172 if (!
findzero(evaltime, v1[0],
v2[0], v3[0], v4[0], opl)) {
2174 printf(
" ERROR: findzero() failed at %f with %f %f %f %f\n",
2184 berekeny(v1[1],
v2[1], v3[1], v4[1], opl, 1);
2193 switch (prevbezt->
easing) {
2207 switch (prevbezt->
easing) {
2221 switch (prevbezt->
easing) {
2235 switch (prevbezt->
easing) {
2249 switch (prevbezt->
easing) {
2263 switch (prevbezt->
easing) {
2277 switch (prevbezt->
easing) {
2291 switch (prevbezt->
easing) {
2305 switch (prevbezt->
easing) {
2319 switch (prevbezt->
easing) {
2333 return prevbezt->
vec[1][1];
2342 if (evaltime <= bezts->vec[1][0]) {
2347 if (lastbezt->
vec[1][0] <= evaltime) {
2357 float cvalue = 0.0f;
2360 const FPoint *prevfpt = fpts;
2364 if (prevfpt->
vec[0] >= evaltime) {
2366 cvalue = prevfpt->
vec[1];
2368 else if (lastfpt->
vec[0] <= evaltime) {
2370 cvalue = lastfpt->
vec[1];
2376 const FPoint *fpt = prevfpt + (int(evaltime) - int(prevfpt->
vec[0]));
2379 if (t != 0.0f && t < 1.0f) {
2380 cvalue =
interpf(fpt->
vec[1], (fpt + 1)->vec[1], 1.0f - t);
2383 cvalue = fpt->
vec[1];
2417 else if (fcu->
fpt) {
2428 cvalue =
floorf(cvalue + 0.5f);
2468 float cvalue = 0.0f;
2469 float evaltime = anim_eval_context->
eval_time;
2480 bool do_linear =
true;
2488 (fcm.
sfra <= evaltime && fcm.
efra >= evaltime))
2555 if (fmi && fcm.data) {
2565 if (
data->coefficients) {
2589 ListBaseT<FModifier> *fmodifiers,
2604 RPT_(
"F-Curve modifier lost on '%s[%d]' because it has an unknown type"),
2605 curve->rna_path().c_str(),
2655 if (dtar->rna_path) {
2672 for (
FCurve &fcu : *fcurves) {
2681 fcu->
runtime = MEM_new<bke::FCurveRuntime>(__func__);
2726 dtar->rna_path =
nullptr;
2742 for (
FCurve &fcu : *fcurves) {
Functions and classes to work with Actions.
#define BEZT_BINARYSEARCH_THRESH
#define DRIVER_TARGETS_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_USED_LOOPER_BEGIN(dvar)
#define DRIVER_TARGETS_LOOPER_END
#define BKE_LIB_FOREACHID_PROCESS_ID(data_, id_, cb_flag_)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct(reader, struct_name, ptr_p)
#define BLT_I18NCONTEXT_ID_ACTION
#define CTX_DATA_(context, msgid)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define FCURVE_ACTIVE_KEYFRAME_NONE
#define BEZT_IS_AUTOH(bezt)
#define BEZT_ISSEL_ANY(bezt)
#define BEZT_DESEL_ALL(bezt)
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
#define BLI_assert_msg(a, msg)
#define MEM_realloc_uninitialized(vmemh, len)
constexpr IndexRange()=default
static std::optional< ParsedRNAPath > from_string(StringRefNull path)
constexpr StringRefNull()
IndexRange index_range() const
#define storage(slot, qualifiers)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
FCurve * fcurve_find_in_action_slot(bAction *act, slot_handle_t slot_handle, const FCurveDescriptor &fcurve_descriptor)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
MINLINE float min_ff(float a, float b)
VecBase< uint32_t, 2 > uint2
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
float BLI_easing_elastic_ease_in(float time, float begin, float change, float duration, float amplitude, float period)
float BLI_easing_quint_ease_out(float time, float begin, float change, float duration)
static BezTriple * cycle_offset_triple(bool cycle, BezTriple *out, const BezTriple *in, const BezTriple *from, const BezTriple *to)
bool BKE_fcurve_calc_range(const FCurve *fcu, float *r_min, float *r_max, bool selected_keys_only)
char * STRNCPY(char(&dst)[N], const char *src)
@ DRIVER_FLAG_PYTHON_BLOCKED
MINLINE int compare_ff_relative(float a, float b, float max_diff, int max_ulps)
void BKE_fcurve_keyframe_move_value_with_handles(BezTriple *keyframe, float new_value)
@ HD_AUTOTYPE_LOCKED_FINAL
@ FMI_TYPE_GENERATE_CURVE
bool BKE_fcurve_delete_keys_selected(FCurve &fcu)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void testhandles_fcurve(FCurve *fcu, eBezTriple_Flag sel_flag, bool use_handle)
BezTriple * BKE_bezier_array_merge(const BezTriple *a, int size_a, const BezTriple *b, int size_b, int *r_merged_size)
float BLI_easing_sine_ease_in(float time, float begin, float change, float duration)
float BLI_easing_back_ease_in_out(float time, float begin, float change, float duration, float overshoot)
float BLI_easing_expo_ease_in_out(float time, float begin, float change, float duration)
BlendFileReadReport * BLO_read_data_reports(BlendDataReader *reader)
float(*) FcuSampleFunc(FCurve *fcu, void *data, float evaltime)
void * BLO_read_struct_by_name_array(BlendDataReader *reader, StringRef struct_name, int64_t items_num, const void *old_address)
static int BKE_fcurve_bezt_binarysearch_index_ex(const BezTriple array[], const float frame, const int arraylen, const float threshold, bool *r_replace)
float calculate_fcurve(PathResolvedRNA *anim_rna, FCurve *fcu, const AnimationEvalContext *anim_eval_context)
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
FCurve * BKE_fcurve_iter_step(FCurve *fcu_iter, const char rna_path[])
bool BKE_fcurve_is_keyframable(const FCurve &fcu)
void BKE_nurb_bezt_handle_test(BezTriple *bezt, eBezTriple_Flag__Alias sel_flag, const eNurbHandleTest_Mode handle_mode, bool use_around_local)
float BLI_easing_quad_ease_out(float time, float begin, float change, float duration)
std::optional< std::string > RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop)
float evaluate_driver(struct PathResolvedRNA *anim_rna, struct ChannelDriver *driver, struct ChannelDriver *driver_orig, const struct AnimationEvalContext *anim_eval_context)
void BKE_fcurves_free(ListBaseT< FCurve > *list)
static bool get_bounding_bezt_indices(const FCurve *fcu, const bool selected_keys_only, const float frame_range[2], int *r_first, int *r_last)
uint evaluate_fmodifiers_storage_size_per_modifier(const ListBaseT< FModifier > *modifiers)
const char * RNA_property_identifier(const PropertyRNA *prop)
void BKE_fcurve_delete_keys(FCurve &fcu, uint2 index_range)
void BKE_fcurve_update_handle_flag_from_opposite(BezTriple &key, HandleSide source_side)
MINLINE void copy_v2_v2(float r[2], const float a[2])
void BKE_fmodifier_ensure_flag(ListBaseT< FModifier > *modifiers)
void BKE_fmodifier_name_set(FModifier *fcm, const char *name)
void copy_fmodifiers(ListBaseT< FModifier > *dst, const ListBaseT< FModifier > *src)
struct ChannelDriver * fcurve_copy_driver(const struct ChannelDriver *driver)
bool BKE_fcurve_bezt_subdivide_handles(BezTriple *bezt, BezTriple *prev, BezTriple *next, float *r_pdelta)
void BKE_fcurve_delete_key(FCurve *fcu, int index)
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_fcurve_handles_recalc_ex(FCurve &fcu, eBezTriple_Flag handle_sel_flag)
void BKE_fcurve_blend_read_data_listbase(BlendDataReader *reader, ListBaseT< FCurve > *fcurves)
void BKE_fcurve_foreach_id(FCurve *fcu, LibraryForeachIDData *data)
const FModifierTypeInfo * fmodifier_get_typeinfo(const FModifier *fcm)
MINLINE void swap_v2_v2(float a[2], float b[2])
float BLI_easing_cubic_ease_in_out(float time, float begin, float change, float duration)
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
float evaluate_fcurve_unmodified(const FCurve *fcu, float evaltime)
@ NURB_HANDLE_TEST_KNOT_ONLY
bool RNA_property_animateable(const PointerRNA *ptr, PropertyRNA *prop_orig)
Span< rna_path::Item > ParsedRNAPathRef
float BLI_easing_quart_ease_out(float time, float begin, float change, float duration)
float BLI_easing_cubic_ease_out(float time, float begin, float change, float duration)
void BKE_fcurve_blend_write_data(BlendWriter *writer, FCurve *fcu)
float BLI_easing_sine_ease_out(float time, float begin, float change, float duration)
static void calculate_bezt_bounds_y(BezTriple *bezt_array, const int index_range[2], const bool selected_keys_only, const bool include_handles, float *r_min, float *r_max)
float BLI_easing_back_ease_out(float time, float begin, float change, float duration, float overshoot)
void BKE_fcurve_blend_read_data(BlendDataReader *reader, FCurve *fcu)
void BKE_fcurve_blend_write_listbase(BlendWriter *writer, ListBaseT< FCurve > *fcurves)
bool list_has_suitable_fmodifier(const ListBaseT< FModifier > *modifiers, int mtype, short acttype)
float BLI_easing_linear_ease(float time, float begin, float change, float duration)
void BKE_fmodifiers_blend_write(BlendWriter *writer, ListBaseT< FModifier > *fmodifiers)
float BLI_easing_expo_ease_in(float time, float begin, float change, float duration)
static void init_unbaked_bezt_data(BezTriple *bezt)
float BLI_easing_bounce_ease_out(float time, float begin, float change, float duration)
static void calculate_bezt_bounds_x(BezTriple *bezt_array, const int index_range[2], const bool include_handles, float *r_min, float *r_max)
void BKE_fcurve_merge_duplicate_keys(FCurve *fcu, const int sel_flag, const bool use_handle)
float BLI_easing_circ_ease_out(float time, float begin, float change, float duration)
float BLI_easing_circ_ease_in_out(float time, float begin, float change, float duration)
@ FMODIFIER_TYPE_ENVELOPE
@ FMODIFIER_TYPE_FN_GENERATOR
@ FMODIFIER_TYPE_GENERATOR
static void fcurve_bezt_free(FCurve &fcu)
bool BLI_rctf_is_valid(const struct rctf *rect)
float BLI_easing_quint_ease_in(float time, float begin, float change, float duration)
AnimData * BKE_animdata_from_id(const ID *id)
int BLI_sortutil_cmp_float(const void *a_, const void *b_)
void BKE_fcurve_keyframe_move_time_with_handles(BezTriple *keyframe, const float new_time)
void BLI_uniquename(const ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_maxncpy) ATTR_NONNULL(1
bool BKE_nlastrip_has_curves_for_property(const PointerRNA *ptr, const PropertyRNA *prop)
@ FCM_EXTRAPOLATE_CYCLIC_OFFSET
bool BKE_fcurve_is_protected(const FCurve &fcu)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void BKE_fcurves_copy(ListBaseT< FCurve > *dst, ListBaseT< FCurve > *src)
void evaluate_value_fmodifiers(FModifiersStackStorage *storage, const ListBaseT< FModifier > *modifiers, const FCurve *fcu, float *cvalue, float evaltime)
void BKE_fcurve_handles_recalc(FCurve &fcu)
bool BKE_fcurve_calc_bounds(const FCurve *fcu, bool selected_keys_only, bool include_handles, const float frame_range[2], rctf *r_bounds)
BMesh const char void * data
void BKE_fcurve_deselect_all_keys(FCurve &fcu)
float BLI_easing_quad_ease_in_out(float time, float begin, float change, float duration)
FCurve * BKE_animadata_fcurve_find_by_rna_path(AnimData *animdata, const char *rna_path, const int rna_index, bAction **r_action, bool *r_driven)
FCurve * BKE_fcurve_copy(const FCurve *fcu)
static float fcurve_eval_keyframes_extrapolate(const FCurve *fcu, const BezTriple *bezts, float evaltime, int endpoint_offset, int direction_to_neighbor)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
eFCU_Cycle_Type BKE_fcurve_get_cycle_type(const FCurve &fcu)
float evaluate_fcurve_driver(PathResolvedRNA *anim_rna, FCurve *fcu, ChannelDriver *driver_orig, const AnimationEvalContext *anim_eval_context)
float BLI_easing_back_ease_in(float time, float begin, float change, float duration, float overshoot)
static bool calculate_fpt_bounds(const FCurve *fcu, const float frame_range[2], rctf *r_bounds)
void BLO_reportf_wrap(BlendFileReadReport *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void free_fmodifiers(ListBaseT< FModifier > *modifiers)
bool BKE_fcurve_is_cyclic(const FCurve &fcu)
float BLI_easing_quart_ease_in_out(float time, float begin, float change, float duration)
float BLI_easing_bounce_ease_in(float time, float begin, float change, float duration)
MINLINE double sqrt3d(double d)
void BKE_nurb_handle_smooth_fcurve(BezTriple *bezt, int total, bool cyclic)
void BLO_read_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size, const int elems=1)
float BLI_easing_expo_ease_out(float time, float begin, float change, float duration)
MINLINE void add_v3_v3(float r[3], const float a[3])
static float fcurve_eval_keyframes_interpolate(const FCurve *fcu, const BezTriple *bezts, float evaltime)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
static void berekeny(float f1, float f2, float f3, float f4, float *o, int b)
static float evaluate_fcurve_ex(const FCurve *fcu, float evaltime, float cvalue)
void BKE_fcurve_free(FCurve *fcu)
void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2])
Array< float > BKE_fcurves_calc_keyed_frames_ex(Span< FCurve * > fcurve_array, float interval)
float evaluate_fcurve_only_curve(const FCurve *fcu, float evaltime)
float BLI_easing_bounce_ease_in_out(float time, float begin, float change, float duration)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BKE_fcurve_active_keyframe_set(FCurve *fcu, const BezTriple *active_bezt)
int BKE_fcurve_active_keyframe_index(const FCurve *fcu)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
float BLI_easing_quint_ease_in_out(float time, float begin, float change, float duration)
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], float t)
MINLINE float max_ff(float a, float b)
Array< float > BKE_fcurves_calc_keyed_frames(Span< FCurve * > fcurve_array)
float BLI_easing_circ_ease_in(float time, float begin, float change, float duration)
bool BKE_fcurve_are_keyframes_usable(const FCurve &fcu)
FCurve * id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *prop_name, int index, bool *r_driven)
void BKE_fmodifiers_blend_read_data(BlendDataReader *reader, ListBaseT< FModifier > *fmodifiers, FCurve *curve)
void BKE_fcurve_delete_keys_all(FCurve &fcu)
MINLINE float interpf(float target, float origin, float t)
float BLI_easing_elastic_ease_in_out(float time, float begin, float change, float duration, float amplitude, float period)
bool test_time_fcurve(FCurve &fcu)
int BKE_fcurve_bezt_binarysearch_index(const BezTriple array[], float frame, int arraylen, bool *r_replace)
void fcurve_free_driver(struct FCurve *fcu)
void BKE_fcurve_bezt_resize(FCurve &fcu, int new_totvert)
bool BKE_fcurve_is_empty(const FCurve *fcu)
void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSampleFunc sample_cb)
void BKE_fcurve_deduplicate_keys(FCurve *fcu)
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)
float BLI_easing_quad_ease_in(float time, float begin, float change, float duration)
FCurve * BKE_fcurve_find(ListBaseT< FCurve > *list, const char rna_path[], int array_index)
float fcurve_samplingcb_evalcurve(FCurve *fcu, void *data, float evaltime)
static int solve_cubic(double c0, double c1, double c2, double c3, float *o)
static float fcurve_eval_samples(const FCurve *fcu, const FPoint *fpts, float evaltime)
float BLI_easing_quart_ease_in(float time, float begin, float change, float duration)
ListBase BLI_listbase_from_link(Link *some_link)
bool BKE_fcurve_has_selected_control_points(const FCurve &fcu)
MINLINE int clamp_i(int value, int min, int max)
@ FCURVE_EXTRAPOLATE_CONSTANT
static float fcurve_eval_keyframes(const FCurve *fcu, const BezTriple *bezts, float evaltime)
static int findzero(float x, float q0, float q1, float q2, float q3, float *o)
@ FMI_REQUIRES_ORIGINAL_DATA
float BLI_easing_sine_ease_in_out(float time, float begin, float change, float duration)
const FModifierTypeInfo * get_fmodifier_typeinfo(int type)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
float BLI_easing_cubic_ease_in(float time, float begin, float change, float duration)
float evaluate_time_fmodifiers(FModifiersStackStorage *storage, const ListBaseT< FModifier > *modifiers, const FCurve *fcu, float cvalue, float evaltime)
void fcurve_samples_to_keyframes(FCurve *fcu, int start, int end)
float BLI_easing_elastic_ease_out(float time, float begin, float change, float duration, float amplitude, float period)
FCurve * BKE_fcurve_create()
void sort_time_fcurve(FCurve &fcu)
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)
static bool calculate_bezt_bounds(const FCurve *fcu, const bool selected_keys_only, const bool include_handles, const float frame_range[2], rctf *r_bounds)
@ FMODIFIER_FLAG_DISABLED
@ FMODIFIER_FLAG_RANGERESTRICT
@ FMODIFIER_FLAG_USEINFLUENCE
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBezTriple_Interpolation ipo
void write_string(const char *data)
void write_struct_by_name(const char *struct_name, const void *data, BlendStructWriterFn fn=nullptr)
void write_float_array(int64_t num, const float *data)
void write_struct_list(const ListBaseT< T > *list, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct_array(const int64_t array_size, const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
ListBaseT< DriverVar > variables
struct ExprPyLike_Parsed * expr_simple
int active_keyframe_index
ListBaseT< FModifier > modifiers
bke::FCurveRuntime * runtime
ListBaseT< FCurve > fcurves
std::optional< ParsedRNAPath<> > parsed_rna_path