56#include "RNA_prototypes.hh"
78#define SLIDE_PIXEL_DISTANCE (300 * U.pixelsize)
79#define OVERSHOOT_RANGE_DELTA 0.2f
176 "All properties, including transforms, bendy bone shape, and custom properties"},
177 {
PS_TFM_LOC,
"LOC", 0,
"Location",
"Location only"},
178 {
PS_TFM_ROT,
"ROT", 0,
"Rotation",
"Rotation only"},
181 {
PS_TFM_PROPS,
"CUSTOM", 0,
"Custom Properties",
"Custom properties"},
182 {0,
nullptr, 0,
nullptr,
nullptr},
187 {0,
"FREE", 0,
"Free",
"All axes are affected"},
188 {
PS_LOCK_X,
"X", 0,
"X",
"Only X-axis transforms are affected"},
189 {
PS_LOCK_Y,
"Y", 0,
"Y",
"Only Y-axis transforms are affected"},
190 {
PS_LOCK_Z,
"Z", 0,
"Z",
"Only Z-axis transforms are affected"},
191 {0,
nullptr, 0,
nullptr,
nullptr},
229 for (
const int ob_index : objects.index_range()) {
234 if (ob_iter ==
nullptr) {
238 ob_data->
ob = ob_iter;
239 ob_data->
valid =
true;
319 Object *ob_iter = ob_data.ob;
322 *prev_frame = ob_data.prev_frame;
323 *next_frame = ob_data.next_frame;
327 *prev_frame = *next_frame = 0.0f;
336 float prev_frame, next_frame;
337 float prev_weight, next_weight;
346 next_weight = factor;
347 prev_weight = 1.0f - next_weight;
358 const float total_weight = next_weight + prev_weight;
359 next_weight = (next_weight / total_weight);
360 prev_weight = (prev_weight / total_weight);
373 (*val) -= ((prev_frame_y * prev_weight) + (next_frame_y * next_weight) - (*val)) * factor;
379 (*val) += ((prev_frame_y * prev_weight) + (next_frame_y * next_weight) - (*val)) * factor;
385 (*val) =
interpf(next_frame_y, prev_frame_y, factor);
392 const float blend_factor =
fabs((factor - 0.5f) * 2);
396 (*val) =
interpf(prev_frame_y, current_frame_y, blend_factor);
400 (*val) =
interpf(next_frame_y, current_frame_y, blend_factor);
418 const char propName[])
421 char *path =
nullptr;
452 const char prop_prefix[])
466 const char *bPtr, *pPtr;
477 pPtr = strstr(bPtr, prop_prefix);
580 const FCurve *fcu_w =
nullptr, *fcu_x =
nullptr, *fcu_y =
nullptr, *fcu_z =
nullptr;
583 char *path =
nullptr;
584 float prev_frame, next_frame;
620 if (fcu_w && fcu_x && fcu_y && fcu_z) {
625 float quat_prev[4], quat_next[4];
646 float quat_curr[4], quat_breakdown[4];
651 const float interp_factor = (current_frame - pso->
prev_frame) /
654 interp_qt_qtqt(quat_breakdown, quat_prev, quat_next, interp_factor);
657 interp_qt_qtqt(quat_final, quat_breakdown, quat_curr, 1.0f + factor);
687 const float blend_factor =
fabs((factor - 0.5f) * 2);
705 for (
int idx = 0; idx < 3; idx++) {
709 float diff_val = default_value - vec[idx];
710 vec[idx] += factor * diff_val;
718 float default_values[] = {1.0f, 0.0f, 0.0f, 0.0f};
721 default_values[0] = 0.0f;
722 default_values[2] = 1.0f;
725 for (
int idx = 0; idx < 4; idx++) {
726 float diff_val = default_values[idx] - vec[idx];
727 vec[idx] += factor * diff_val;
800 if (!ob_data.valid) {
894 char bone_vis_str[50];
939 SNPRINTF(limits_str,
IFACE_(
"[G]/R/S/B/C - Location only (G to clear) | %s"), axis_str);
942 SNPRINTF(limits_str,
IFACE_(
"G/[R]/S/B/C - Rotation only (R to clear) | %s"), axis_str);
945 SNPRINTF(limits_str,
IFACE_(
"G/R/[S]/B/C - Scale only (S to clear) | %s"), axis_str);
948 STRNCPY(limits_str,
IFACE_(
"G/R/S/[B]/C - Bendy Bone properties only (B to clear) | %s"));
951 STRNCPY(limits_str,
IFACE_(
"G/R/S/B/[C] - Custom Properties only (C to clear) | %s"));
954 STRNCPY(limits_str,
IFACE_(
"G/R/S/B/C - Limit to Transform/Property Set"));
958 STRNCPY(bone_vis_str,
IFACE_(
"[H] - Toggle bone visibility"));
968 SNPRINTF(status_str,
"%s: %s | %s", mode_str, str_offs, limits_str);
971 SNPRINTF(status_str,
"%s: %s | %s | %s", mode_str, limits_str, slider_str, bone_vis_str);
1011 if (ak ==
nullptr) {
1036 if (ob_data.valid) {
1131 bool do_pose_update =
false;
1137 switch (event->
type) {
1187 if (has_numinput ==
false) {
1189 do_pose_update =
true;
1203 float factor = value / 100;
1208 do_pose_update =
true;
1212 switch (event->
type) {
1218 do_pose_update =
true;
1224 do_pose_update =
true;
1230 do_pose_update =
true;
1236 do_pose_update =
true;
1242 do_pose_update =
true;
1250 do_pose_update =
true;
1256 do_pose_update =
true;
1262 do_pose_update =
true;
1288 if (do_pose_update) {
1354 "Weighting factor for which keyframe is favored more",
1364 "Previous Keyframe",
1365 "Frame number of keyframe immediately before the current frame",
1376 "Frame number of keyframe immediately after the current frame",
1386 "Set of properties that are affected");
1393 "Transform axis to restrict effects to");
1436 ot->
name =
"Push Pose from Breakdown";
1438 ot->
description =
"Exaggerate the current pose in regards to the breakdown pose";
1493 ot->
name =
"Relax Pose to Breakdown";
1495 ot->
description =
"Make the current pose more similar to its breakdown pose";
1553 ot->
name =
"Blend Pose with Rest Pose";
1554 ot->
idname =
"POSE_OT_blend_with_rest";
1555 ot->
description =
"Make the current pose more similar to, or further away from, the rest pose";
1610 ot->
name =
"Pose Breakdowner";
1612 ot->
description =
"Create a suitable breakdown pose on the current frame";
1660 ot->
name =
"Blend to Neighbor";
1661 ot->
idname =
"POSE_OT_blend_to_neighbor";
1662 ot->
description =
"Blend from current position to previous or next keyframe";
1706 const float source_frame,
1739 current_frame_index += 1;
1741 const int bezt_index =
min_ii(current_frame_index, fcu->
totvert - 1);
1742 target_frame =
min_ff(target_frame, fcu->
bezt[bezt_index].
vec[1][0]);
1746 return target_frame;
1751 float target_frame = FLT_MIN;
1762 return target_frame;
1767 ListBase selected_markers = {
nullptr,
nullptr};
1771 link->
frame = marker->cfra;
1778 const float start_frame,
1779 const float end_frame,
1790 if (column->cfra <= start_frame) {
1793 if (column->cfra > end_frame) {
1797 link->
frame = column->cfra;
1817 link->
frame = column->cfra;
1831 ListBase pflinks = {
nullptr,
nullptr};
1849 ListBase target_frames = {
nullptr,
nullptr};
1853 float target_frame =
find_next_key(&pflinks, current_frame);
1855 link->
frame = target_frame;
1864 link->
frame = target_frame;
1916 "Propagate pose to first keyframe following the current frame only"},
1921 "Propagate pose to the last keyframe only (i.e. making action cyclic)"},
1926 "Propagate pose to all keyframes between current frame and 'Frame' property"},
1930 "Before Last Keyframe",
1931 "Propagate pose to all keyframes from current frame until no more are found"},
1935 "On Selected Keyframes",
1936 "Propagate pose to all selected keyframes"},
1940 "On Selected Markers",
1941 "Propagate pose to all keyframes occurring on frames with Scene Markers after the current "
1943 {0,
nullptr, 0,
nullptr,
nullptr},
1947 ot->
name =
"Propagate Pose";
1950 "Copy selected aspects of the current pose to subsequent poses already keyframed";
1966 "Method used to determine when to stop propagating pose to keyframes");
1973 "Frame to stop propagating frames to (for 'Before Frame' mode)",
Functions to modify FCurves.
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
int BKE_fcurve_bezt_binarysearch_index(const BezTriple array[], float frame, int arraylen, bool *r_replace)
float evaluate_fcurve(const FCurve *fcu, float evaltime)
#define FOREACH_OBJECT_IN_MODE_END
blender::Vector< Object * > BKE_view_layer_array_from_objects_in_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d, eObjectMode mode)
#define FOREACH_OBJECT_IN_MODE_BEGIN(_scene, _view_layer, _v3d, _object_type, _object_mode, _instance)
float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode)
void BKE_report(ReportList *reports, eReportType type, const char *message)
float BKE_scene_frame_get(const Scene *scene)
#define BLI_assert_msg(a, msg)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
MINLINE int min_ii(int a, int b)
MINLINE float min_ff(float a, float b)
MINLINE float interpf(float target, float origin, float t)
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
float normalize_qt(float q[4])
float normalize_qt_qt(float r[4], const float q[4])
void copy_qt_qt(float q[4], const float a[4])
void quat_to_compatible_quat(float q[4], const float a[4], const float old[4])
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,...)
Object is a sort of wrapper for general info.
void ED_area_status_text(ScrArea *area, const char *str)
bool ED_operator_posemode(bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
void ED_region_tag_redraw(ARegion *region)
void ED_slider_status_string_get(const tSlider *slider, char *status_string, size_t size_of_status_string)
void ED_slider_init(tSlider *slider, const wmEvent *event)
void ED_slider_destroy(bContext *C, tSlider *slider)
tSlider * ED_slider_create(bContext *C)
bool ED_slider_modal(tSlider *slider, const wmEvent *event)
void ED_slider_factor_bounds_set(tSlider *slider, float factor_bound_lower, float factor_bound_upper)
float ED_slider_factor_get(const tSlider *slider)
void ED_slider_factor_set(tSlider *slider, float factor)
Read Guarded memory(de)allocation.
void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, const bool only_selected)
void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks, float cframe)
void poseAnim_mapping_free(ListBase *pfLinks)
void poseAnim_mapping_reset(ListBase *pfLinks)
void poseAnim_mapping_get(bContext *C, ListBase *pfLinks)
Object * poseAnim_object_get(Object *ob_)
void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
LinkData * poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, const char *path)
void reinitialize(const int64_t new_size)
draw_view in_light_buf[] float
const ActKeyColumn * ED_keylist_find_prev(const AnimKeylist *keylist, const float cfra)
void ED_keylist_prepare_for_direct_access(AnimKeylist *keylist)
AnimKeylist * ED_keylist_create()
void ED_keylist_free(AnimKeylist *keylist)
void fcurve_to_keylist(AnimData *adt, FCurve *fcu, AnimKeylist *keylist, const int saction_flag, blender::float2 range)
const ActKeyColumn * ED_keylist_find_next(const AnimKeylist *keylist, const float cfra)
const ListBase * ED_keylist_listbase(const AnimKeylist *keylist)
bool ED_keylist_is_empty(const AnimKeylist *keylist)
const ActKeyColumn * ED_keylist_find_exact(const AnimKeylist *keylist, const float cfra)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float2 fabs(const float2 a)
static void pose_slide_toggle_channels_mode(wmOperator *op, tPoseSlideOp *pso, ePoseSlide_Channels channel)
static int pose_slide_invoke_common(bContext *C, wmOperator *op, const wmEvent *event)
static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
void POSE_OT_breakdown(wmOperatorType *ot)
static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static const EnumPropertyItem prop_channels_types[]
static void pose_slide_apply_val(tPoseSlideOp *pso, const FCurve *fcu, Object *ob, float *val)
static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void pose_slide_reset(tPoseSlideOp *pso)
static void pose_slide_cancel(bContext *C, wmOperator *op)
static int pose_slide_blend_to_neighbors_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void get_keyed_frames_in_range(ListBase *pflinks, const float start_frame, const float end_frame, ListBase *target_frames)
static const EnumPropertyItem prop_axis_lock_types[]
static bool pose_slide_toggle_axis_locks(wmOperator *op, tPoseSlideOp *pso, ePoseSlide_AxisLock axis)
static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso)
static void pose_slide_rest_pose_apply_other_rot(tPoseSlideOp *pso, float vec[4], bool quat)
static void pose_slide_opdef_properties(wmOperatorType *ot)
static void pose_slide_refresh(bContext *C, tPoseSlideOp *pso)
static float find_next_key(ListBase *pflinks, const float start_frame)
static int pose_slide_blend_rest_exec(bContext *C, wmOperator *op)
static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
static int pose_slide_blend_to_neighbors_exec(bContext *C, wmOperator *op)
void POSE_OT_blend_with_rest(wmOperatorType *ot)
void POSE_OT_propagate(wmOperatorType *ot)
static void pose_slide_rest_pose_apply(bContext *C, tPoseSlideOp *pso)
static int pose_slide_blend_rest_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void pose_slide_autoKeyframe(bContext *C, tPoseSlideOp *pso)
static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
static float find_last_key(ListBase *pflinks)
static void propagate_curve_values(ListBase *pflinks, const float source_frame, ListBase *target_frames)
static int pose_slide_push_exec(bContext *C, wmOperator *op)
static int pose_propagate_exec(bContext *C, wmOperator *op)
static bool pose_frame_range_from_object_get(tPoseSlideOp *pso, Object *ob, float *prev_frame, float *next_frame)
void POSE_OT_relax(wmOperatorType *ot)
static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, float vec[3], const char propName[])
static int pose_slide_relax_exec(bContext *C, wmOperator *op)
void POSE_OT_push(wmOperatorType *ot)
static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode)
static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void pose_slide_rest_pose_apply_vec3(tPoseSlideOp *pso, float vec[3], float default_value)
static void get_selected_frames(ListBase *pflinks, ListBase *target_frames)
static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso)
ePosePropagate_Termination
@ POSE_PROPAGATE_LAST_KEY
@ POSE_PROPAGATE_BEFORE_FRAME
@ POSE_PROPAGATE_SELECTED_MARKERS
@ POSE_PROPAGATE_BEFORE_END
@ POSE_PROPAGATE_NEXT_KEY
@ POSE_PROPAGATE_SELECTED_KEYS
static void get_selected_marker_positions(Scene *scene, ListBase *target_frames)
static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, const char prop_prefix[])
static void pose_slide_exit(bContext *C, wmOperator *op)
void POSE_OT_blend_to_neighbors(wmOperatorType *ot)
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_boolean_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, bool value)
void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value)
bool RNA_property_array_check(PropertyRNA *prop)
int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
void RNA_property_float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, float value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
PropertyType RNA_property_type(PropertyRNA *prop)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_int_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, int value)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
int RNA_int_get(PointerRNA *ptr, const char *name)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
float RNA_float_get(PointerRNA *ptr, const char *name)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
bool RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
ePoseSlide_Channels channels
ePoseSlide_AxisLock axislock
blender::Array< tPoseSlideObject > ob_data_array
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* cancel)(bContext *C, wmOperator *op)
struct ReportList * reports
void WM_cursor_modal_set(wmWindow *win, int val)
void WM_cursor_modal_restore(wmWindow *win)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)