98 if (fcu && fcu->
bezt) {
111 FCurve **fcurves = alloca(
sizeof(*fcurves) * fkc_len);
113 for (
int i = 0; i < fkc_len; i++) {
114 if (fcurves[i] && fcurves[i]->bezt) {
115 fkc[i].
fcurve = fcurves[i];
129 const float *keyed_frames,
130 int keyed_frames_len)
138 for (
int frame_index = 0; frame_index < keyed_frames_len; frame_index++) {
139 const float evaltime = keyed_frames[frame_index];
150 while (frame_index < keyed_frames_len) {
151 const float evaltime = keyed_frames[frame_index];
152 const float bezt_time = roundf(bezt->
vec[1][0]);
161 if (bezt == bezt_end) {
167 while (frame_index < keyed_frames_len) {
181 char path_xform[256];
184 const int path_xform_prefix_len =
SNPRINTF(path_xform,
"pose.bones[\"%s\"]", pchan_name_esc);
185 char *path_xform_suffix = path_xform + path_xform_prefix_len;
186 const int path_xform_suffix_len =
sizeof(path_xform) - path_xform_prefix_len;
205 } fkc_pchan = {{{
NULL}}};
207 #define FCURVE_ASSIGN_VALUE(id, path_test_suffix, index) \
208 BLI_strncpy(path_xform_suffix, path_test_suffix, path_xform_suffix_len); \
209 action_flip_pchan_cache_fcurve_assign_value(&fkc_pchan.id, index, path_xform, fcache)
211 #define FCURVE_ASSIGN_ARRAY(id, path_test_suffix) \
212 BLI_strncpy(path_xform_suffix, path_test_suffix, path_xform_suffix_len); \
213 action_flip_pchan_cache_fcurve_assign_array( \
214 fkc_pchan.id, ARRAY_SIZE(fkc_pchan.id), path_xform, fcache)
224 #undef FCURVE_ASSIGN_VALUE
225 #undef FCURVE_ASSIGN_ARRAY
228 #define FCURVE_CHANNEL_LEN (sizeof(fkc_pchan) / sizeof(struct FCurve_KeyCache))
230 int fcurve_array_len = 0;
235 fcurve_array[fcurve_array_len++] = fkc->
fcurve;
240 if (fcurve_array_len == 0) {
245 int keyed_frames_len;
247 fcurve_array, fcurve_array_len, &keyed_frames_len);
259 float flip_mtx[4][4];
266 if (!
STREQ(pchan_name_flip, pchan->
name)) {
270 float arm_mat_inv[4][4];
275 for (
int frame_index = 0; frame_index < keyed_frames_len; frame_index++) {
282 #define READ_VALUE_FLT(id) \
283 if (fkc_pchan.id.fcurve_eval != NULL) { \
284 pchan_temp.id = fkc_pchan.id.fcurve_eval[frame_index]; \
288 #define READ_VALUE_INT(id) \
289 if (fkc_pchan.id.fcurve_eval != NULL) { \
290 pchan_temp.id = floorf(fkc_pchan.id.fcurve_eval[frame_index] + 0.5f); \
294 #define READ_ARRAY_FLT(id) \
295 for (int i = 0; i < ARRAY_SIZE(pchan_temp.id); i++) { \
296 READ_VALUE_FLT(id[i]); \
308 #undef READ_ARRAY_FLT
309 #undef READ_VALUE_FLT
310 #undef READ_VALUE_INT
312 float chan_mat[4][4];
328 #define WRITE_VALUE_FLT(id) \
329 if (fkc_pchan.id.fcurve_eval != NULL) { \
330 BezTriple *bezt = fkc_pchan.id.bezt_array[frame_index]; \
331 if (bezt != NULL) { \
332 const float delta = pchan_temp.id - bezt->vec[1][1]; \
333 bezt->vec[0][1] += delta; \
334 bezt->vec[1][1] += delta; \
335 bezt->vec[2][1] += delta; \
340 #define WRITE_ARRAY_FLT(id) \
341 for (int i = 0; i < ARRAY_SIZE(pchan_temp.id); i++) { \
342 WRITE_VALUE_FLT(id[i]); \
355 #undef WRITE_ARRAY_FLT
356 #undef WRITE_VALUE_FLT
360 for (
int i = 0; i < fcurve_array_len; i++) {
382 const char *path_pose_prefix =
"pose.bones[\"";
383 const int path_pose_prefix_len = strlen(path_pose_prefix);
391 if (!
STRPREFIX(fcu->rna_path, path_pose_prefix)) {
395 const char *name_esc = fcu->rna_path + path_pose_prefix_len;
404 const size_t name_esc_len = (size_t)(name_esc_end - name_esc);
409 if (
UNLIKELY(name_len >=
sizeof(name))) {
416 if (!
STREQ(name_flip, name)) {
419 char *path_flip =
BLI_sprintfN(
"pose.bones[\"%s%s", name_flip_esc, name_esc_end);
421 fcu->rna_path = path_flip;
423 if (fcu->grp !=
NULL) {
437 if (!
STREQ(name_flip, agrp->name)) {
438 STRNCPY(agrp->name, name_flip);
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float r_chanmat[4][4])
void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, const float mat[4][4], bool use_compat)
struct FCurvePathCache * BKE_fcurve_pathcache_create(ListBase *list)
float * BKE_fcurves_calc_keyed_frames(struct FCurve **fcurve_array, const int fcurve_array_len, int *r_frames_len)
float evaluate_fcurve_only_curve(struct FCurve *fcu, float evaltime)
void BKE_fcurve_pathcache_destroy(struct FCurvePathCache *fcache)
void calchandles_fcurve_ex(struct FCurve *fcu, eBezTriple_Flag handle_sel_flag)
struct FCurve * BKE_fcurve_pathcache_find(struct FCurvePathCache *fcache, const char rna_path[], const int array_index)
int BKE_fcurve_pathcache_find_array(struct FCurvePathCache *fcache, const char *rna_path, struct FCurve **fcurve_result, int fcurve_result_len)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void unit_m4(float m[4][4])
bool invert_m4_m4(float R[4][4], const float A[4][4])
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
#define STRNCPY(dst, src)
#define SNPRINTF(dst, format,...)
size_t size_t char size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, const size_t dst_maxncpy) ATTR_NONNULL()
size_t BLI_str_unescape(char *__restrict dst, const char *__restrict src, const size_t src_maxncpy) ATTR_NONNULL()
const char * BLI_str_escape_find_quote(const char *str) ATTR_NONNULL()
void BLI_string_flip_side_name(char *r_name, const char *from_name, const bool strip_number, const size_t name_len)
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_COPY_ON_WRITE
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
#define READ_VALUE_FLT(id)
#define WRITE_ARRAY_FLT(id)
static void action_flip_pchan_cache_fcurve_assign_value(struct FCurve_KeyCache *fkc, int index, const char *path, struct FCurvePathCache *fcache)
void BKE_action_flip_with_pose(struct bAction *act, struct Object *ob_arm)
static void action_flip_pchan_cache_init(struct FCurve_KeyCache *fkc, const float *keyed_frames, int keyed_frames_len)
#define READ_VALUE_INT(id)
#define FCURVE_ASSIGN_ARRAY(id, path_test_suffix)
#define FCURVE_CHANNEL_LEN
static void action_flip_pchan_rna_paths(struct bAction *act)
static void action_flip_pchan_cache_fcurve_assign_array(struct FCurve_KeyCache *fkc, int fkc_len, const char *path, struct FCurvePathCache *fcache)
#define WRITE_VALUE_FLT(id)
#define READ_ARRAY_FLT(id)
static void action_flip_pchan(Object *ob_arm, const bPoseChannel *pchan, struct FCurvePathCache *fcache)
#define FCURVE_ASSIGN_VALUE(id, path_test_suffix, index)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)