110 bool changed =
false;
117 for (
int i = 0; i < fcu->
totvert; i++) {
157 for (
int i = 0; i < fcu->
totvert; i++) {
198 (!cleardefault && fcu->
totvert == 1)) {
203 old_bezts = fcu->
bezt;
211 if (!(bezt->f2 &
SELECT)) {
213 lastb->
f1 = lastb->f2 = lastb->f3 = 0;
219 for (i = 1; i < totCount; i++) {
220 float prev[2], cur[2],
next[2];
223 if (i < (totCount - 1)) {
224 beztn = (old_bezts + (i + 1));
225 next[0] = beztn->vec[1][0];
226 next[1] = beztn->vec[1][1];
233 bezt = (old_bezts + i);
236 prev[0] = lastb->vec[1][0];
237 prev[1] = lastb->vec[1][1];
238 cur[0] = bezt->vec[1][0];
239 cur[1] = bezt->vec[1][1];
241 if (!(bezt->f2 &
SELECT)) {
244 lastb->f1 = lastb->f2 = lastb->f3 = 0;
249 if (
IS_EQT(cur[0], prev[0], thresh)) {
256 if (cur[1] >
next[1]) {
257 if (
IS_EQT(cur[1], prev[1], thresh) == 0) {
265 if (
IS_EQT(cur[1], prev[1], thresh) == 0) {
275 if (
IS_EQT(cur[1], prev[1], thresh) == 0) {
279 else if (
IS_EQT(cur[1],
next[1], thresh) == 0) {
286 if (
IS_EQT(cur[1], prev[1], thresh) == 0) {
301 if (cleardefault && fcu->
totvert == 1) {
302 float default_value = 0.0f;
314 if (fcu->
bezt->
vec[1][1] == default_value) {
367 int bezt_segment_start_idx,
368 int bezt_segment_len,
372 int selected_len = bezt_segment_len;
378 if (bezt_segment_len + bezt_segment_start_idx != fcu->
totvert &&
383 bezt_segment_start_idx--;
387 const int target_fcurve_verts =
ceil(bezt_segment_len - selected_len * remove_ratio);
397 target_fcurve_verts);
419 int bezt_segment_start_idx = 0;
420 int bezt_segment_len = 0;
423 bool can_decimate_all_selected =
true;
424 bool in_segment =
false;
426 for (
int i = 0; i < fcu->
totvert; i++) {
434 can_decimate_all_selected =
false;
439 bezt_segment_start_idx = i;
444 else if (in_segment) {
448 fcu, bezt_segment_start_idx, bezt_segment_len, remove_ratio, error_sq_max);
450 bezt_segment_len = 0;
457 fcu, bezt_segment_start_idx, bezt_segment_len, remove_ratio, error_sq_max);
464 for (
int i = 0; i < old_totvert; i++) {
475 return can_decimate_all_selected;
498 for (
int i = 0; i < fcu->
totvert; i++, bezt++) {
513 for (
int i = 0,
x = 0; (i < fcu->
totvert) && (
x < totSel); i++, bezt++) {
516 tsb->
h1 = &bezt->
vec[0][1];
517 tsb->
h2 = &bezt->
vec[1][1];
518 tsb->
h3 = &bezt->
vec[2][1];
521 if (
x < totSel - 1) {
539 for (
int i = 0; i < totSel; i++, tsb++) {
542 if (
ELEM(i, 0, (totSel - 1)) == 0) {
548 const float p1 = *tP1->
h2;
549 const float p2 = (tP2) ? (*tP2->
h2) : (*tP1->
h2);
550 const float c1 = *tsb->
h2;
551 const float n1 = *tN1->
h2;
552 const float n2 = (tN2) ? (*tN2->
h2) : (*tN1->
h2);
555 tsb->
y1 = (3 * p2 + 5 * p1 + 2 * c1 + n1 + n2) / 12;
556 tsb->
y3 = (p2 + p1 + 2 * c1 + 5 * n1 + 3 * n2) / 12;
558 tsb->
y2 = (tsb->
y1 + tsb->
y3) / 2;
564 for (
int i = 0; i < totSel; i++, tsb++) {
566 if (
ELEM(i, 0, (totSel - 1)) == 0) {
571 *tsb->
h1 = ((*tsb->
h1) * 0.7f) + (tsb->
y1 * 0.3f);
572 *tsb->
h3 = ((*tsb->
h3) * 0.7f) + (tsb->
y3 * 0.3f);
604 for (i = 0, bezt = fcu->
bezt; i < fcu->totvert; i++, bezt++) {
613 if (i < fcu->totvert - 1) {
627 range = (int)(
ceil(end->vec[1][0] - start->
vec[1][0]));
628 sfra = (int)(
floor(start->
vec[1][0]));
634 for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
635 fp->frame = (
float)(sfra + n);
640 for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
648 bezt = fcu->
bezt + i + range - 1;
741 for (ale = anim_data->
first; ale; ale = ale->
next) {
793 memcpy(newbuf, aci->bezt,
sizeof(
BezTriple) * (aci->totvert));
797 nbezt = &newbuf[aci->totvert];
837 if ((str_start = strstr(aci->
rna_path,
"pose.bones["))) {
840 char *str_iter, *str_end;
841 int length, prefix_l, postfix_l;
844 prefix_l = str_start - aci->
rna_path;
846 str_end = strchr(str_start,
'\"');
848 length = str_end - str_start;
849 postfix_l = strlen(str_end);
856 str_iter = *name =
MEM_mallocN(
sizeof(
char) * (prefix_l + postfix_l +
length + 1),
860 str_iter += prefix_l;
864 str_iter[postfix_l] =
'\0';
873 const short from_single,
874 const short to_simple,
906 const short from_single,
907 const short UNUSED(to_simple))
922 printf(
"paste_animedit_keys: error ID has been removed!\n");
932 int len_id = strlen(identifier);
933 int len_path = strlen(fcu->
rna_path);
934 if (len_id <= len_path) {
936 if (
STREQ(identifier, fcu->
rna_path + (len_path - len_id))) {
944 printf(
"paste_animedit_keys: failed to resolve path id:%s, '%s'!\n",
957 const short from_single,
958 const short UNUSED(to_simple))
977 const size_t slength = strlen(aci->
rna_path);
1016 switch (merge_mode) {
1032 f_min = aci->
bezt[0].
vec[1][0] + offset;
1041 if (f_min < f_max) {
1044 if ((f_min <
bezt[0].vec[1][0]) && (
bezt[0].vec[1][0] < f_max)) {
1094 "Paste keys starting at current frame"},
1100 "Paste keys relative to the current frame when copying"},
1112 "Overwrite keys in pasted range"},
1116 "Overwrite Entire Range",
1117 "Overwrite keys in pasted range, using the range of all copied keys"},
1139 float offset = 0.0f;
1154 switch (offset_mode) {
1169 if (from_single && to_simple) {
1174 ale = anim_data->
first;
1187 for (pass = 0; pass < 3; pass++) {
1190 for (ale = anim_data->
first; ale; ale = ale->
next) {
typedef float(TangentPoint)[2]
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
unsigned int BKE_curve_decimate_bezt_array(struct BezTriple *bezt_array, const unsigned int bezt_array_len, const unsigned int resolu, const bool is_cyclic, const char flag_test, const char flag_set, const float error_sq_max, const unsigned int error_target_len)
void BKE_fcurve_active_keyframe_set(struct FCurve *fcu, const struct BezTriple *active_bezt)
float evaluate_fcurve(struct FCurve *fcu, float evaltime)
bool BKE_fcurve_is_empty(struct FCurve *fcu)
void calchandles_fcurve(struct FCurve *fcu)
struct ListBase * which_libbase(struct Main *bmain, short type)
void BKE_report(ReportList *reports, ReportType type, const char *message)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void void BLI_INLINE bool BLI_listbase_is_single(const struct ListBase *lb)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, size_t length) ATTR_NONNULL()
char * BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
void BLI_string_flip_side_name(char *r_name, const char *from_name, const bool strip_number, const size_t name_len)
@ INSERTKEY_OVERWRITE_FULL
#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
@ KEYFRAME_PASTE_MERGE_OVER_RANGE_ALL
@ KEYFRAME_PASTE_MERGE_OVER_RANGE
@ KEYFRAME_PASTE_MERGE_OVER
@ KEYFRAME_PASTE_MERGE_MIX
@ KEYFRAME_PASTE_OFFSET_NONE
@ KEYFRAME_PASTE_OFFSET_CFRA_END
@ KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE
@ KEYFRAME_PASTE_OFFSET_CFRA_START
Read Guarded memory(de)allocation.
void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *fcu)
void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
AnimData * ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, bool only_keys)
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb)
KeyframeEditFunc ANIM_editkeyframes_ok(short mode)
static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float offset, const eKeyMergeMode merge_mode, bool flip)
struct tSmooth_Bezt tSmooth_Bezt
static float animcopy_cfra
void duplicate_fcurve_keys(FCurve *fcu)
static bool prepare_for_decimate(FCurve *fcu, int i)
const EnumPropertyItem rna_enum_keyframe_paste_offset_items[]
short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip)
static void flip_names(tAnimCopybufItem *aci, char **name)
bool decimate_fcurve(bAnimListElem *ale, float remove_ratio, float error_sq_max)
short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
static tAnimCopybufItem * pastebuf_match_path_property(Main *bmain, FCurve *fcu, const short from_single, const short UNUSED(to_simple))
struct tAnimCopybufItem tAnimCopybufItem
const EnumPropertyItem rna_enum_keyframe_paste_merge_items[]
void sample_fcurve(FCurve *fcu)
void clear_fcurve_keys(FCurve *fcu)
struct TempFrameValCache TempFrameValCache
static void decimate_fcurve_segment(FCurve *fcu, int bezt_segment_start_idx, int bezt_segment_len, float remove_ratio, float error_sq_max)
void smooth_fcurve(FCurve *fcu)
void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
void ANIM_fcurves_copybuf_free(void)
static void do_curve_mirror_flippping(tAnimCopybufItem *aci, BezTriple *bezt)
static ListBase animcopybuf
bool delete_fcurve_keys(FCurve *fcu)
static float animcopy_firstframe
static tAnimCopybufItem * pastebuf_match_path_full(FCurve *fcu, const short from_single, const short to_simple, bool flip)
void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, bool cleardefault)
static tAnimCopybufItem * pastebuf_match_index_only(FCurve *fcu, const short from_single, const short UNUSED(to_simple))
static float animcopy_lastframe
int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType keyframe_type, eInsertKeyFlags flag)
int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
const char * RNA_property_identifier(const PropertyRNA *prop)
float RNA_property_float_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int index)
PropertyType RNA_property_type(PropertyRNA *prop)
bool RNA_path_resolve_property(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
int active_keyframe_index
struct ReportList * reports
struct bAnimListElem * next
struct tAnimCopybufItem * prev
struct tAnimCopybufItem * next
__forceinline const avxi abs(const avxi &a)
ccl_device_inline float2 floor(const float2 &a)
ccl_device_inline float3 ceil(const float3 &a)