74 for (
int i = 0; i < fcu->
totvert; i++) {
86 MEM_delete(fcu->
bezt);
109 const bool only_selected_keys)
117 if ((fcu ==
nullptr) || (fcu->
bezt ==
nullptr) || (fcu->
totvert == 0) ||
118 (!cleardefault && fcu->
totvert == 1))
124 old_bezts = fcu->
bezt;
140 for (i = 1; i < totCount; i++) {
141 float prev[2], cur[2], next[2];
144 if (i < (totCount - 1)) {
145 beztn = (old_bezts + (i + 1));
146 next[0] = beztn->
vec[1][0];
147 next[1] = beztn->
vec[1][1];
151 next[0] = next[1] = 0.0f;
154 bezt = (old_bezts + i);
157 prev[0] = lastb->
vec[1][0];
158 prev[1] = lastb->
vec[1][1];
159 cur[0] = bezt->
vec[1][0];
160 cur[1] = bezt->
vec[1][1];
162 if (only_selected_keys && !(bezt->
f2 &
SELECT)) {
170 if (
IS_EQT(cur[0], prev[0], thresh)) {
175 if (beztn &&
IS_EQT(cur[0], next[0], thresh) && (
IS_EQT(next[1], prev[1], thresh) == 0)) {
177 if (cur[1] > next[1]) {
178 if (
IS_EQT(cur[1], prev[1], thresh) == 0) {
186 if (
IS_EQT(cur[1], prev[1], thresh) == 0) {
196 if (
IS_EQT(cur[1], prev[1], thresh) == 0) {
200 else if (
IS_EQT(cur[1], next[1], thresh) == 0) {
207 if (
IS_EQT(cur[1], prev[1], thresh) == 0) {
217 MEM_delete(old_bezts);
222 if (cleardefault && fcu->
totvert == 1) {
223 float default_value = 0.0f;
235 if (fcu->
bezt->
vec[1][1] == default_value) {
256 const int start_index,
257 int *r_segment_start_idx,
260 *r_segment_start_idx = 0;
263 bool in_segment =
false;
265 for (
int i = start_index; i < fcu->
totvert; i++) {
266 const bool point_is_selected = fcu->
bezt[i].
f2 &
SELECT;
269 if (point_is_selected && !point_is_ignored) {
271 *r_segment_start_idx = i;
276 else if (in_segment) {
290 ListBaseT<FCurveSegment> segments = {
nullptr,
nullptr};
297 int segment_start_idx = 0;
299 int current_index = 0;
304 segment->start_index = segment_start_idx;
305 segment->length = segment_len;
307 current_index = segment_start_idx + segment_len;
336 const float lerp_factor =
fabs(factor);
338 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
339 const float key_y_value =
interpf(target_bezt->
vec[1][1], fcu->
bezt[i].
vec[1][1], lerp_factor);
350 float default_value = 0;
381 return default_value;
397 for (
int i = 0; i < fcu->
totvert; i++) {
401 const float key_y_value =
interpf(default_value, fcu->
bezt[i].
vec[1][1], factor);
413 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
417 const float y_average =
y / segment->length;
419 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
420 const float key_y_value =
interpf(y_average, fcu->
bezt[i].
vec[1][1], 1 - factor);
435 "Butterworth Coefficients");
445 MEM_delete(bw_coeff->
d1);
446 MEM_delete(bw_coeff->
d2);
447 MEM_delete(bw_coeff->
A);
448 MEM_delete(bw_coeff);
452 const float sampling_frequency,
455 double s = double(sampling_frequency);
456 const double a =
tan(
M_PI * cutoff_frequency / s);
457 const double a2 = a * a;
461 s = a2 + 2.0 * a * r + 1.0;
462 bw_coeff->
A[i] = a2 / s;
463 bw_coeff->
d1[i] = 2.0 * (1 - a2) / s;
464 bw_coeff->
d2[i] = -(a2 - 2.0 * a * r + 1.0) / s;
472 w0[i] = bw_coeff->
d1[i] * w1[i] + bw_coeff->
d2[i] * w2[i] +
x;
473 x = bw_coeff->
A[i] * (w0[i] + 2.0 * w1[i] + w2[i]);
481 const float *filtered_values,
482 const int start_index,
484 const int sample_index,
485 const int blend_in_out)
487 if (start_index == end_index || blend_in_out == 0) {
488 return samples[start_index];
491 const float blend_in_y_samples = samples[start_index];
492 const float blend_out_y_samples = samples[end_index];
494 const float blend_in_y_filtered = filtered_values[start_index + blend_in_out];
495 const float blend_out_y_filtered = filtered_values[end_index - blend_in_out];
497 const float slope_in_samples = samples[start_index] - samples[start_index - 1];
498 const float slope_out_samples = samples[end_index] - samples[end_index + 1];
499 const float slope_in_filtered = filtered_values[start_index + blend_in_out - 1] -
500 filtered_values[start_index + blend_in_out];
501 const float slope_out_filtered = filtered_values[end_index - blend_in_out] -
502 filtered_values[end_index - blend_in_out - 1];
504 if (sample_index - start_index <= blend_in_out) {
505 const int blend_index = sample_index - start_index;
506 const float blend_in_out_factor =
clamp_f(
float(blend_index) / blend_in_out, 0.0f, 1.0f);
507 const float blend_value =
interpf(blend_in_y_filtered +
508 slope_in_filtered * (blend_in_out - blend_index),
509 blend_in_y_samples + slope_in_samples * blend_index,
510 blend_in_out_factor);
513 if (end_index - sample_index <= blend_in_out) {
514 const int blend_index = end_index - sample_index;
515 const float blend_in_out_factor =
clamp_f(
float(blend_index) / blend_in_out, 0.0f, 1.0f);
516 const float blend_value =
interpf(blend_out_y_filtered +
517 slope_out_filtered * (blend_in_out - blend_index),
518 blend_out_y_samples + slope_out_samples * blend_index,
519 blend_in_out_factor);
528 const int sample_count,
530 const int blend_in_out,
531 const int sample_rate,
537 "Butterworth Filtered FCurve Values");
545 const float fwd_offset = samples[0];
547 for (
int i = 0; i < sample_count; i++) {
548 const double x = double(samples[i] - fwd_offset);
550 filtered_values[i] =
float(filtered_value) + fwd_offset;
553 for (
int i = 0; i < filter_order; i++) {
559 const float bwd_offset = filtered_values[sample_count - 1];
562 for (
int i = sample_count - 1; i >= 0; i--) {
563 const double x = double(filtered_values[i] - bwd_offset);
565 filtered_values[i] =
float(filtered_value) + bwd_offset;
568 const int segment_end_index = segment->start_index + segment->length;
572 const int samples_start_index = filter_order * sample_rate;
573 const int samples_end_index = int(right_bezt.
vec[1][0] - left_bezt.
vec[1][0] + filter_order) *
576 const int blend_in_out_clamped =
min_ii(blend_in_out,
577 (samples_end_index - samples_start_index) / 2);
579 for (
int i = segment->start_index; i < segment_end_index; i++) {
580 float blend_in_out_factor;
581 if (blend_in_out_clamped == 0) {
582 blend_in_out_factor = 1;
584 else if (i < segment->start_index + segment->length / 2) {
585 blend_in_out_factor =
min_ff(
float(i - segment->start_index) / blend_in_out_clamped, 1.0f);
588 blend_in_out_factor =
min_ff(
float(segment_end_index - i - 1) / blend_in_out_clamped, 1.0f);
591 const float x_delta = fcu->
bezt[i].
vec[1][0] - left_bezt.
vec[1][0] + filter_order;
594 const int filter_index =
round(x_delta * sample_rate);
600 blend_in_out_clamped);
602 const float blended_value =
interpf(
603 filtered_values[filter_index], blend_value, blend_in_out_factor);
604 const float key_y_value =
interpf(blended_value, samples[filter_index], factor);
609 MEM_delete(filtered_values);
621 const double sigma_sq = 2.0 * sigma * sigma;
624 for (
int i = 0; i < kernel_size; i++) {
625 const double normalized_index = double(i) / (kernel_size - 1);
626 r_kernel[i] =
exp(-normalized_index * normalized_index / sigma_sq);
633 sum += r_kernel[i] * 2;
638 for (
int i = 0; i < kernel_size; i++) {
645 const float *original_values,
647 const int sample_count,
649 const int kernel_size,
650 const double *kernel)
652 const int segment_end_index = segment->start_index + segment->length;
653 const float segment_start_x = fcu->
bezt[segment->start_index].
vec[1][0];
654 float *filtered_samples = MEM_dupalloc(samples);
655 for (
int i = kernel_size; i < sample_count - kernel_size; i++) {
657 double filter_result = samples[i] * kernel[0];
658 for (
int j = 1; j <= kernel_size; j++) {
659 const double kernel_value = kernel[j];
660 filter_result += samples[i + j] * kernel_value;
661 filter_result += samples[i - j] * kernel_value;
663 filtered_samples[i] = filter_result;
666 for (
int i = segment->start_index; i < segment_end_index; i++) {
667 const float sample_index_f = (fcu->
bezt[i].
vec[1][0] - segment_start_x) + kernel_size;
670 const int sample_index =
round(sample_index_f);
674 const int secondary_index =
clamp_i(
675 sample_index +
signum_i(sample_index_f - sample_index), 0, sample_count - 1);
677 const float filter_result =
interpf(filtered_samples[secondary_index],
678 filtered_samples[sample_index],
679 std::abs(sample_index_f - sample_index));
680 const float key_y_value =
interpf(
681 filter_result, original_values[i - segment->start_index], factor);
684 MEM_delete(filtered_samples);
690 const float x_shift = (
x - shift) * width;
691 const float y = x_shift /
sqrt(1 +
pow2f(x_shift));
693 return (
y + 1) * 0.5f;
704 const float key_x_range = right_key->
vec[1][0] - left_key->
vec[1][0];
705 const float key_y_range = right_key->
vec[1][1] - left_key->
vec[1][1];
709 if (
IS_EQF(key_x_range, 0.0f)) {
714 const float shift = -factor;
718 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
720 const float x = ((fcu->
bezt[i].
vec[1][0] - left_key->
vec[1][0]) / key_x_range) * 2 - 1;
724 const float blend = (
y - y_min) * (1 / (y_max - y_min));
726 const float key_y_value = left_key->
vec[1][1] + key_y_range * blend;
741 const BezTriple segment_last_key = fcu->
bezt[segment->start_index + segment->length - 1];
742 y_delta = right_key->
vec[1][1] - segment_last_key.
vec[1][1];
745 const BezTriple segment_first_key = fcu->
bezt[segment->start_index];
746 y_delta = left_key->
vec[1][1] - segment_first_key.
vec[1][1];
749 const float offset_value = y_delta *
fabs(factor);
750 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
751 const float key_y_value = fcu->
bezt[i].
vec[1][1] + offset_value;
758static float s_curve(
float x,
float slope,
float width,
float height,
float xshift,
float yshift)
765 float y = height *
pow((
x - xshift), slope) /
766 (
pow((
x - xshift), slope) +
pow((width - (
x - xshift)), slope)) +
770 if (
x > xshift + width) {
773 else if (
x < xshift) {
784 const float key_x_range = right_key->
vec[1][0] - left_key->
vec[1][0];
785 const float key_y_range = right_key->
vec[1][1] - left_key->
vec[1][1];
789 if (
IS_EQF(key_x_range, 0.0f)) {
793 const float slope = 3.0;
795 const float width = 2.0;
796 const float height = 2.0;
807 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
809 const float x = (fcu->
bezt[i].
vec[1][0] - left_key->
vec[1][0]) / key_x_range;
810 const float ease =
s_curve(
x, slope, width, height, xy_shift, xy_shift);
811 const float base = left_key->
vec[1][1] + key_y_range * ease;
815 y_delta = base - fcu->
bezt[i].
vec[1][1];
818 y_delta = fcu->
bezt[i].
vec[1][1] - base;
821 const float key_y_value = fcu->
bezt[i].
vec[1][1] + y_delta * factor;
838 if (segment->start_index + segment->length >= fcu->
totvert - 1) {
841 reference_key = right_key;
842 beyond_key = fcu->
bezt[segment->start_index + segment->length + 1];
846 if (segment->start_index <= 1) {
849 reference_key = left_key;
850 beyond_key = fcu->
bezt[segment->start_index - 2];
855 const float y_delta = beyond_key.
vec[1][1] - reference_key->
vec[1][1];
856 const float x_delta = beyond_key.
vec[1][0] - reference_key->
vec[1][0];
863 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
867 const float new_x_delta = fcu->
bezt[i].
vec[1][0] - reference_key->
vec[1][0];
868 const float new_y_delta = new_x_delta * y_delta / x_delta;
870 const float delta = reference_key->
vec[1][1] + new_y_delta - fcu->
bezt[i].
vec[1][1];
872 const float key_y_value = fcu->
bezt[i].
vec[1][1] + delta *
fabs(factor);
888 const float key_x_range = right_key->
vec[1][0] - left_key->
vec[1][0];
889 const float key_y_range = right_key->
vec[1][1] - left_key->
vec[1][1];
893 if (
IS_EQF(key_x_range, 0.0f)) {
897 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
901 normalized_x = (fcu->
bezt[i].
vec[1][0] - left_key->
vec[1][0]) / key_x_range;
904 normalized_x = (right_key->
vec[1][0] - fcu->
bezt[i].
vec[1][0]) / key_x_range;
907 const float y_delta = key_y_range * normalized_x;
909 const float key_y_value = fcu->
bezt[i].
vec[1][1] + y_delta * factor;
921 const float key_x_range = right_key->
vec[1][0] - left_key->
vec[1][0];
922 const float key_y_range = right_key->
vec[1][1] - left_key->
vec[1][1];
926 if (
IS_EQF(key_x_range, 0.0f)) {
930 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
932 const float normalized_x = (fcu->
bezt[i].
vec[1][0] - left_key->
vec[1][0]) / key_x_range;
934 const float linear = left_key->
vec[1][1] + key_y_range * normalized_x;
936 const float delta = fcu->
bezt[i].
vec[1][1] - linear;
938 const float key_y_value = linear + delta * factor;
951 const float fcu_x_range = last_key->
vec[1][0] - first_key->
vec[1][0];
952 const float fcu_y_range = last_key->
vec[1][1] - first_key->
vec[1][1];
954 const float first_key_x = first_key->
vec[1][0];
960 for (
int i = 0; i < segment->length; i++) {
962 const float time = fcu->
bezt[segment->start_index + i].
vec[1][0] + frame_offset;
964 const float wrapped_time =
floored_fmod(time - first_key_x, fcu_x_range) + first_key_x;
965 const float delta_y = fcu_y_range *
floorf((time - first_key_x) / fcu_x_range);
967 const float key_y_value =
evaluate_fcurve(fcu, wrapped_time) + delta_y;
968 y_values[i] = key_y_value;
971 for (
int i = 0; i < segment->length; i++) {
974 MEM_delete(y_values);
994 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
995 const float key_y_value =
interpf(fcu->
bezt[i].
vec[1][1], reference_key->
vec[1][1], factor);
1006 segment->start_index + segment->length);
1008 const float lerp_factor = (factor + 1) / 2;
1009 for (
int i = segment->start_index; i < segment->start_index + segment->length; i++) {
1010 const float key_y_value =
interpf(right_bezt->
vec[1][1], left_bezt->
vec[1][1], lerp_factor);
1059 int bezt_segment_start_idx,
1060 int bezt_segment_len,
1064 int selected_len = bezt_segment_len;
1070 if (bezt_segment_len + bezt_segment_start_idx != fcu->
totvert &&
1076 bezt_segment_start_idx--;
1080 const int target_fcurve_verts =
ceil(bezt_segment_len - selected_len * remove_ratio);
1090 target_fcurve_verts);
1097 if (fcu ==
nullptr || fcu->
bezt ==
nullptr || fcu->
totvert == 0) {
1103 bool can_decimate_all_selected =
true;
1105 for (
int i = 0; i < fcu->
totvert; i++) {
1108 can_decimate_all_selected =
false;
1119 segments.free_no_destruct();
1122 fcu->
bezt =
nullptr;
1125 for (
int i = 0; i < old_totvert; i++) {
1134 MEM_delete(old_bezts);
1137 return can_decimate_all_selected;
1156 if (fcu->
bezt ==
nullptr) {
1162 for (
int i = 0; i < fcu->
totvert; i++, bezt++) {
1177 for (
int i = 0,
x = 0; (i < fcu->
totvert) && (
x < totSel); i++, bezt++) {
1180 tsb->
h1 = &bezt->
vec[0][1];
1181 tsb->
h2 = &bezt->
vec[1][1];
1182 tsb->
h3 = &bezt->
vec[2][1];
1185 if (
x < totSel - 1) {
1203 for (
int i = 0; i < totSel; i++, tsb++) {
1206 if (
ELEM(i, 0, (totSel - 1)) == 0) {
1208 const tSmooth_Bezt *tP2 = (i - 2 > 0) ? (tsb - 2) : (
nullptr);
1210 const tSmooth_Bezt *tN2 = (i + 2 < totSel) ? (tsb + 2) : (
nullptr);
1212 const float p1 = *tP1->
h2;
1213 const float p2 = (tP2) ? (*tP2->
h2) : (*tP1->
h2);
1214 const float c1 = *tsb->
h2;
1215 const float n1 = *tN1->
h2;
1216 const float n2 = (tN2) ? (*tN2->
h2) : (*tN1->
h2);
1219 tsb->
y1 = (3 * p2 + 5 * p1 + 2 * c1 + n1 + n2) / 12;
1220 tsb->
y3 = (p2 + p1 + 2 * c1 + 5 * n1 + 3 * n2) / 12;
1222 tsb->
y2 = (tsb->
y1 + tsb->
y3) / 2;
1228 for (
int i = 0; i < totSel; i++, tsb++) {
1230 if (
ELEM(i, 0, (totSel - 1)) == 0) {
1235 *tsb->
h1 = ((*tsb->
h1) * 0.7f) + (tsb->
y1 * 0.3f);
1236 *tsb->
h3 = ((*tsb->
h3) * 0.7f) + (tsb->
y3 * 0.3f);
1261namespace ed::animation {
1279 return channelbag->
fcurves().size() == 1;
1306 if (identifier == slot_identifier) {
1317 std::cout <<
"KeyframeCopyBuffer contents:" << std::endl;
1319 std::cout <<
" scene frame: " << this->
current_frame << std::endl;
1322 std::cout <<
" buffer is empty" << std::endl;
1326 std::cout <<
" buffer has single F-Curve" << std::endl;
1335 std::cout <<
" - Channelbag for slotless F-Curves:" << std::endl;
1338 std::cout <<
" - Channelbag for slot \"" << slot_identifier <<
"\":" << std::endl;
1340 for (
const FCurve *fcurve : channelbag->fcurves()) {
1341 std::cout <<
" " << fcurve->rna_path() <<
"[" << fcurve->array_index <<
"]";
1343 std::cout <<
" (bone)";
1345 std::cout << std::endl;
1373 if (!ale->
id || ale->
id->id_type() !=
ID_OB) {
1394 return pchan !=
nullptr;
1440 const Action *map_key_action;
1447 map_key_action =
nullptr;
1448 map_key_handle = SLOTLESS_SLOT_HANDLE;
1451 const auto map_key = std::make_pair(map_key_action, map_key_handle);
1453 if (
const std::optional<slot_handle_t> opt_internal_slot_handle =
1454 this->orig_to_buffer_slots.
lookup_try(map_key))
1457 const slot_handle_t internal_slot_handle = *opt_internal_slot_handle;
1461 internal_slot_handle);
1462 BLI_assert_msg(channelbag,
"If the slot exists, so should the channelbag");
1470 internal_slot_handle);
1471 this->orig_to_buffer_slots.
add_new(map_key, internal_slot_handle);
1474 StringRef slot_identifier;
1475 if (map_key_action) {
1477 BLI_assert_msg(ale_slot,
"Slot for copied keyframes is expected to exist.");
1481 slot_identifier = KeyframeCopyBuffer::SLOTLESS_SLOT_IDENTIFIER;
1517 const_cast<FCurve *
>(fcu),
1525 Channelbag &channelbag = slot_mapper.channelbag_for_ale(&ale);
1529 fcurve_copy.rna_path_set(fcu->rna_path());
1547 for (; bezt_index < fcu->
totvert; bezt_index++, bezt++) {
1558 const float bezt_frame = bezt->
vec[1][0];
1578 int ofs_start, ofs_end;
1588 const std::string bone_name =
rna_path.substr(ofs_start, ofs_end - ofs_start);
1592 return rna_path.substr(0, ofs_start) + bname_new +
rna_path.substr(ofs_end);
1596 const FCurve &fcurve_to_match,
1597 const FCurve &fcurve_in_copy_buffer,
1607enum class SlotMatchMethod {
1615 SELECTION_AND_IDENTIFIER = 3,
1625 const bool to_single,
1629 "The from-single-to-single case is expected to be implemented as a special case "
1630 "in `paste_animedit_keys()`");
1640 return SlotMatchMethod::IDENTIFIER;
1646 return SlotMatchMethod::SELECTION;
1652 return SlotMatchMethod::SELECTION_AND_IDENTIFIER;
1663 return SlotMatchMethod::NONE;
1675 "If any keyframes were copied, they MUST have come from some slot.");
1676 if (num_slots_copied > 1) {
1678 return SlotMatchMethod::IDENTIFIER;
1681 return SlotMatchMethod::NONE;
1693 const bool from_single,
1694 const bool to_single,
1700 const FCurve &fcurve_to_match = *
static_cast<FCurve *
>(ale_to_paste_into.
data);
1703 "The from-single-to-single case is expected to be implemented as a special case "
1704 "in `paste_animedit_keys()`");
1708 const Channelbag *single_copy_buffer_channelbag;
1713 const Slot *ale_slot =
nullptr;
1714 const Action *ale_action =
nullptr;
1731 switch (slot_match) {
1732 case SlotMatchMethod::SELECTION:
1738 case SlotMatchMethod::NONE:
1743 case SlotMatchMethod::SELECTION_AND_IDENTIFIER:
1749 case SlotMatchMethod::IDENTIFIER: {
1751 const std::string target_slot_identifier = ale_slot ?
1756 target_slot_identifier);
1757 if (!single_copy_buffer_channelbag) {
1770 for (
const Channelbag *channelbag : channelbags_to_paste_from) {
1778 paste_context.
flip))
1789 const FCurve &fcurve_to_match,
1790 const FCurve &fcurve_in_copy_buffer,
1792 const bool from_single,
1793 const bool to_single,
1796 if (fcurve_to_match.rna_path().is_empty() || fcurve_in_copy_buffer.rna_path().is_empty()) {
1804 const bool is_source_ok = from_single ||
1806 if (!is_source_ok) {
1812 fcurve_in_copy_buffer.rna_path());
1813 return with_flipped_name && with_flipped_name == fcurve_to_match.rna_path();
1816 return to_single || fcurve_in_copy_buffer.rna_path() == fcurve_to_match.rna_path();
1821 const FCurve &fcurve_to_match,
1822 const FCurve &fcurve_in_copy_buffer,
1824 const bool from_single,
1825 const bool to_single,
1828 if (fcurve_to_match.rna_path_parsed().size() != fcurve_in_copy_buffer.rna_path_parsed().size()) {
1834 fcurve_in_copy_buffer,
1835 slot_handle_in_copy_buffer,
1842 const FCurve &fcurve_to_match,
1843 const FCurve &fcurve_in_copy_buffer,
1845 const bool from_single,
1849 if (fcurve_in_copy_buffer.rna_path().is_empty() || fcurve_to_match.rna_path().is_empty()) {
1856 const bool is_source_ok = from_single ||
1858 if (!is_source_ok) {
1863 const ParsedRNAPathRef rnapath_to_match = fcurve_to_match.rna_path_parsed();
1864 const ParsedRNAPathRef rnapath_in_copy_buffer = fcurve_in_copy_buffer.rna_path_parsed();
1874 if (last_item_to_match.index() != last_item_in_copy_buffer.index()) {
1881 if (last_item_to_match != last_item_in_copy_buffer) {
1884 if (!std::holds_alternative<rna_path::LookupIndex>(last_item_to_match)) {
1889 if (rnapath_to_match.
size() < 2 || rnapath_in_copy_buffer.
size() < 2) {
1896 return preceding_item_to_match == preceding_item_in_copy_buffer;
1900 const FCurve &fcurve_to_match,
1901 const FCurve &fcurve_in_copy_buffer,
1903 const bool from_single,
1922 const size_t slength =
rna_path.size();
1944 bezt.
vec[0][1] = -bezt.
vec[0][1];
1945 bezt.
vec[1][1] = -bezt.
vec[1][1];
1946 bezt.
vec[2][1] = -bezt.
vec[2][1];
1952 const FCurve &fcurve_in_copy_buffer,
1961 for (i = 0, bezt = fcu->
bezt; i < fcu->totvert; i++, bezt++) {
1966 switch (merge_mode) {
1982 f_min = fcurve_in_copy_buffer.
bezt[0].
vec[1][0] + offset[0];
1983 f_max = fcurve_in_copy_buffer.
bezt[fcurve_in_copy_buffer.
totvert - 1].
vec[1][0] +
1992 if (f_min < f_max) {
1994 for (i = 0, bezt = fcu->
bezt; i < fcu->totvert; i++, bezt++) {
1995 if ((f_min < bezt[0].vec[1][0]) && (bezt[0].vec[1][0] < f_max)) {
2008 for (i = 0, bezt = fcurve_in_copy_buffer.
bezt; i < fcurve_in_copy_buffer.
totvert; i++, bezt++) {
2040 "Paste keys starting at current frame"},
2046 "Paste keys relative to the current frame when copying"},
2048 {0,
nullptr, 0,
nullptr,
nullptr},
2056 "Paste keys with the first key matching the key left of the cursor"},
2061 "Paste keys with the last key matching the key right of the cursor"},
2065 "Current Frame Value",
2066 "Paste keys relative to the value of the curve under the cursor"},
2071 "Paste keys relative to the Y-Position of the cursor"},
2076 "Paste keys with the same value as they were copied"},
2077 {0,
nullptr, 0,
nullptr,
nullptr},
2087 "Overwrite keys in pasted range"},
2091 "Overwrite Entire Range",
2092 "Overwrite keys in pasted range, using the range of all copied keys"},
2093 {0,
nullptr, 0,
nullptr,
nullptr},
2097 const FCurve &fcurve_in_copy_buffer,
2105 switch (value_offset_mode) {
2108 const float offset = sipo->
cursorVal - fcurve_in_copy_buffer.
bezt[0].
vec[1][1];
2114 const float offset = cfra_y - fcurve_in_copy_buffer.
bezt[0].
vec[1][1];
2123 const float offset = left_key.
vec[1][1] - fcurve_in_copy_buffer.
bezt[0].
vec[1][1];
2132 const float offset = right_key.
vec[1][1] -
2133 fcurve_in_copy_buffer.
bezt[fcurve_in_copy_buffer.
totvert - 1].
vec[1][1];
2145 ListBaseT<bAnimListElem> *anim_data,
2153 if (anim_data->is_empty()) {
2159 const bool to_single = anim_data->is_single();
2160 float offset[2] = {0, 0};
2178 if (from_single && to_single) {
2182 const FCurve &fcurve_in_copy_buffer =
2190 fcu, fcurve_in_copy_buffer, offset, paste_context.
merge_mode,
false);
2209 bool found_match =
false;
2214 matcher, ac->
bmain, ale, from_single, to_single, paste_context);
2215 if (!fcurve_in_copy_buffer) {
2227 *fcurve_in_copy_buffer,
2230 paste_context.
flip);
Functions and classes to work with Actions.
Functions to work with AnimData.
Functions to modify FCurves.
Blender kernel action and pose functionality.
#define BEZT_ISSEL_IDX(bezt, i)
#define BEZT_SEL_ALL(bezt)
#define BEZT_ISSEL_ANY(bezt)
#define BEZT_DESEL_ALL(bezt)
Object is a sort of wrapper for general info.
#define ANIM_UPDATE_DEFAULT
Read Blender memory allocation and freeing.
#define UNUSED_VARS_NDEBUG(...)
#define BLI_assert_msg(a, msg)
std::optional< Value > lookup_try(const Key &key) const
bool add(const Key &key, const Value &value)
const Value & lookup(const Key &key) const
void add_new(const Key &key, const Value &value)
bool contains(const Key &key) const
ItemIterator items() const &
constexpr int64_t size() const
constexpr const T & last(const int64_t n=0) const
constexpr bool is_empty() const
Slot * slot_for_handle(slot_handle_t handle)
const FCurve * fcurve(int64_t index) const
bool fcurve_assign_to_channel_group(FCurve &fcurve, bActionGroup &to_group)
Span< const FCurve * > fcurves() const
void fcurve_append(FCurve &fcurve)
bActionGroup & channel_group_ensure(StringRefNull name)
const Channelbag * channelbag_for_slot(const Slot &slot) const
Channelbag & channelbag_for_slot_add(const Slot &slot)
Span< const Channelbag * > channelbags() const
const Channelbag * channelbag(int64_t index) const
float wrap(float a, float b, float c)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
decltype(blender::ActionSlot::handle) slot_handle_t
void animdata_fcurve_delete(AnimData *adt, FCurve *fcu)
int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
Lesser Key-framing API call.
std::optional< std::string > flip_names(const StringRefNull rna_path)
KeyframeCopyBuffer * keyframe_copy_buffer
static void paste_animedit_keys_fcurve(FCurve *fcu, const FCurve &fcurve_in_copy_buffer, float offset[2], const eKeyMergeMode merge_mode, bool flip)
static SlotMatchMethod get_slot_match_method(const bool from_single, const bool to_single, const KeyframePasteContext &paste_context)
bool pastebuf_match_index_only(Main *, const FCurve &fcurve_to_match, const FCurve &fcurve_in_copy_buffer, animrig::slot_handle_t, const bool from_single, const bool, const bool)
static const FCurve * pastebuf_find_matching_copybuf_item(const pastebuf_match_func strategy, Main *bmain, const bAnimListElem &ale_to_paste_into, const bool from_single, const bool to_single, const KeyframePasteContext &paste_context)
bool pastebuf_match_path_property_and_component_length(Main *bmain, const FCurve &fcurve_to_match, const FCurve &fcurve_in_copy_buffer, const animrig::slot_handle_t slot_handle_in_copy_buffer, const bool from_single, const bool to_single, const bool flip)
bool pastebuf_match_path_property(Main *, const FCurve &fcurve_to_match, const FCurve &fcurve_in_copy_buffer, animrig::slot_handle_t, const bool from_single, const bool, const bool)
static void do_curve_mirror_flippping(const FCurve &fcurve, BezTriple &bezt)
bool(*)(Main *bmain, const FCurve &fcurve_to_match, const FCurve &fcurve_in_copy_buffer, animrig::slot_handle_t slot_handle_in_copy_buffer, bool from_single, bool to_single, bool flip) pastebuf_match_func
bool pastebuf_match_path_full(Main *, const FCurve &fcurve_to_match, const FCurve &fcurve_in_copy_buffer, animrig::slot_handle_t, const bool from_single, const bool to_single, const bool flip)
BLI_INLINE Texture * wrap(MTLTexture *texture)
std::variant< Member, LookupIndex, LookupKey > Item
ButterworthCoefficients * ED_anim_allocate_butterworth_coefficients(const int filter_order)
MINLINE float min_ff(float a, float b)
void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor, const float width)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ KEYFRAME_PASTE_NOTHING_TO_PASTE
@ KEYFRAME_PASTE_NOWHERE_TO_PASTE
void ANIM_fcurves_copybuf_reset()
KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
void ANIM_fcurves_copybuf_free()
void scale_from_fcurve_segment_neighbor(FCurve *fcu, FCurveSegment *segment, const float factor, const FCurveSegmentAnchor anchor)
void BKE_fcurve_keyframe_move_value_with_handles(BezTriple *keyframe, float new_value)
bool BKE_fcurve_delete_keys_selected(FCurve &fcu)
static float s_curve(float x, float slope, float width, float height, float xshift, float yshift)
static float paste_get_y_offset(const bAnimContext *ac, const FCurve &fcurve_in_copy_buffer, const bAnimListElem *ale, const eKeyPasteValueOffset value_offset_mode)
MINLINE void copy_v3_v3(float r[3], const float a[3])
bool bool BLI_str_quoted_substr(const char *__restrict str, const char *__restrict prefix, char *result, size_t result_maxncpy)
void ED_anim_calculate_butterworth_coefficients(const float cutoff_frequency, const float sampling_frequency, ButterworthCoefficients *bw_coeff)
PointerRNA RNA_id_pointer_create(ID *id)
void smooth_fcurve(FCurve *fcu)
static bool is_animating_bone(const bAnimListElem *ale)
void clean_fcurve(bAnimListElem *ale, float thresh, bool cleardefault, const bool only_selected_keys)
void butterworth_smooth_fcurve_segment(FCurve *fcu, FCurveSegment *segment, float *samples, const int sample_count, const float factor, const int blend_in_out, const int sample_rate, ButterworthCoefficients *bw_coeff)
void blend_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
int bool bool bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, size_t str_len) ATTR_NONNULL(1
float RNA_property_float_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int index)
const EnumPropertyItem rna_enum_keyframe_paste_merge_items[]
MINLINE int max_ii(int a, int b)
Span< rna_path::Item > ParsedRNAPathRef
bool duplicate_fcurve_keys(FCurve *fcu)
@ KEYFRAME_PASTE_MERGE_OVER
@ KEYFRAME_PASTE_MERGE_MIX
@ KEYFRAME_PASTE_MERGE_OVER_RANGE_ALL
@ KEYFRAME_PASTE_MERGE_OVER_RANGE
@ KEYFRAME_PASTE_OFFSET_NONE
@ KEYFRAME_PASTE_OFFSET_CFRA_START
@ KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE
@ KEYFRAME_PASTE_OFFSET_CFRA_END
short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
static float ease_sigmoid_function(const float x, const float width, const float shift)
void ANIM_nla_mapping_apply_if_needed_fcurve(bAnimListElem *ale, FCurve *fcu, const bool restore, const bool only_keys)
void ANIM_animdata_update(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data)
void time_offset_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float frame_offset)
void push_pull_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
static double butterworth_filter_value(double x, double *w0, double *w1, double *w2, ButterworthCoefficients *bw_coeff)
MINLINE void mul_v3_fl(float r[3], float f)
ListBaseT< FCurveSegment > find_fcurve_segments(FCurve *fcu)
MINLINE float pow2f(float x)
PropertyType RNA_property_type(PropertyRNA *prop)
@ INSERTKEY_OVERWRITE_FULL
bool copy_animedit_keys(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data)
void blend_to_neighbor_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
static bool prepare_for_decimate(FCurve *fcu, int i)
MINLINE void add_v2_v2(float r[2], const float a[2])
void BKE_fcurve_handles_recalc(FCurve &fcu)
float BKE_scene_frame_get(const Scene *scene)
MINLINE int signum_i(float a)
void breakdown_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
static void decimate_fcurve_segment(FCurve *fcu, int bezt_segment_start_idx, int bezt_segment_len, float remove_ratio, float error_sq_max)
void scale_average_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
unsigned int BKE_curve_decimate_bezt_array(BezTriple *bezt_array, unsigned int bezt_array_len, unsigned int resolu, bool is_cyclic, eBezTriple_Flag flag_test, eBezTriple_Flag flag_set, float error_sq_max, unsigned int error_target_len)
static const BezTriple * fcurve_segment_end_get(FCurve *fcu, int index)
bool match_slope_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
@ KEYFRAME_PASTE_VALUE_OFFSET_NONE
@ KEYFRAME_PASTE_VALUE_OFFSET_LEFT_KEY
@ KEYFRAME_PASTE_VALUE_OFFSET_CURSOR
@ KEYFRAME_PASTE_VALUE_OFFSET_RIGHT_KEY
@ KEYFRAME_PASTE_VALUE_OFFSET_CFRA
static float butterworth_calculate_blend_value(float *samples, const float *filtered_values, const int start_index, const int end_index, const int sample_index, const int blend_in_out)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
static bool find_fcurve_segment(FCurve *fcu, const int start_index, int *r_segment_start_idx, int *r_segment_len)
void blend_to_default_fcurve(PointerRNA *id_ptr, FCurve *fcu, const float factor)
void smooth_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float *original_values, float *samples, const int sample_count, const float factor, const int kernel_size, const double *kernel)
void shear_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor, tShearDirection direction)
float RNA_property_float_get_default(PointerRNA *ptr, PropertyRNA *prop)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void ED_anim_free_butterworth_coefficients(ButterworthCoefficients *bw_coeff)
bool BLI_str_quoted_substr_range(const char *__restrict str, const char *__restrict prefix, int *__restrict r_start, int *__restrict r_end) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
float get_default_rna_value(const FCurve *fcu, PropertyRNA *prop, PointerRNA *ptr)
void ED_ANIM_get_1d_gauss_kernel(const float sigma, const int kernel_size, double *r_kernel)
const EnumPropertyItem rna_enum_keyframe_paste_offset_items[]
int RNA_property_int_get_default(PointerRNA *ptr, PropertyRNA *prop)
eKeyPasteError paste_animedit_keys(bAnimContext *ac, ListBaseT< bAnimListElem > *anim_data, const KeyframePasteContext &paste_context)
void BKE_fcurve_delete_keys_all(FCurve &fcu)
MINLINE float interpf(float target, float origin, float t)
int BKE_fcurve_bezt_binarysearch_index(const BezTriple array[], float frame, int arraylen, bool *r_replace)
bool BKE_fcurve_is_empty(const FCurve *fcu)
bool RNA_property_boolean_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int index)
int RNA_property_int_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int index)
MINLINE int min_ii(int a, int b)
MINLINE int clamp_i(int value, int min, int max)
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
static const BezTriple * fcurve_segment_start_get(FCurve *fcu, int index)
const EnumPropertyItem rna_enum_keyframe_paste_offset_value_items[]
bool RNA_property_boolean_get_default(PointerRNA *ptr, PropertyRNA *prop)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
bool decimate_fcurve(bAnimListElem *ale, float remove_ratio, float error_sq_max)
FCurve * BKE_fcurve_create()
MINLINE float floored_fmod(float f, float n)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void blend_to_ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
float evaluate_fcurve(const FCurve *fcu, float evaltime)
MINLINE float clamp_f(float value, float min, float max)
size_t BLI_string_flip_side_name(char *name_dst, const char *name_src, bool strip_number, size_t name_dst_maxncpy) ATTR_NONNULL(1
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
eBezTriple_Interpolation ipo
eKeyPasteOffset offset_mode
eKeyPasteValueOffset value_offset_mode
eAnim_Update_Flags update
Set< const FCurve * > bone_fcurves
bool is_bone(const FCurve &fcurve) const
Map< blender::animrig::slot_handle_t, ID * > slot_animated_ids
bool is_single_fcurve() const
static constexpr const char * SLOTLESS_SLOT_IDENTIFIER
blender::animrig::StripKeyframeData keyframe_data
Map< blender::animrig::slot_handle_t, std::string > slot_identifiers
blender::animrig::slot_handle_t last_used_slot_handle
blender::animrig::Channelbag * channelbag_for_slot(StringRef slot_identifier)