Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/armature/pose_slide.c')
-rw-r--r--source/blender/editors/armature/pose_slide.c432
1 files changed, 216 insertions, 216 deletions
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 88203474d03..b82535f013b 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -63,7 +63,7 @@
#include "armature_intern.h"
/* **************************************************** */
-/* == POSE 'SLIDING' TOOLS ==
+/* == POSE 'SLIDING' TOOLS ==
*
* A) Push & Relax, Breakdowner
* These tools provide the animator with various capabilities
@@ -96,21 +96,21 @@ typedef struct tPoseSlideOp {
DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */
int cframe; /* current frame number - global time */
-
+
int prevFrame; /* frame before current frame (blend-from) - global time */
int nextFrame; /* frame after current frame (blend-to) - global time */
-
+
float prevFrameF; /* prevFrame, but in local action time (for F-Curve lookups to work) */
float nextFrameF; /* nextFrame, but in local action time (for F-Curve lookups to work) */
-
+
short mode; /* sliding mode (ePoseSlide_Modes) */
short flag; /* unused for now, but can later get used for storing runtime settings.... */
-
+
short channels; /* which transforms/channels are affected (ePoseSlide_Channels) */
short axislock; /* axis-limits for transforms (ePoseSlide_AxisLock) */
-
+
float percentage; /* 0-1 value for determining the influence of whatever is relevant */
-
+
NumInput num; /* numeric input */
} tPoseSlideOp;
@@ -125,19 +125,19 @@ typedef enum ePoseSlide_Modes {
/* Transforms/Channels to Affect */
typedef enum ePoseSlide_Channels {
PS_TFM_ALL = 0, /* All transforms and properties */
-
+
PS_TFM_LOC, /* Loc/Rot/Scale */
PS_TFM_ROT,
PS_TFM_SIZE,
-
+
PS_TFM_BBONE_SHAPE, /* Bendy Bones */
-
+
PS_TFM_PROPS /* Custom Properties */
} ePoseSlide_Channels;
/* Property enum for ePoseSlide_Channels */
static const EnumPropertyItem prop_channels_types[] = {
- {PS_TFM_ALL, "ALL", 0, "All Properties",
+ {PS_TFM_ALL, "ALL", 0, "All Properties",
"All properties, including transforms, bendy bone shape, and custom properties"},
{PS_TFM_LOC, "LOC", 0, "Location", "Location only"},
{PS_TFM_ROT, "ROT", 0, "Rotation", "Rotation only"},
@@ -171,60 +171,60 @@ static int pose_slide_init(bContext *C, wmOperator *op, short mode)
{
tPoseSlideOp *pso;
bAction *act = NULL;
-
+
/* init slide-op data */
pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp");
-
+
/* get info from context */
pso->scene = CTX_data_scene(C);
pso->ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
pso->arm = (pso->ob) ? pso->ob->data : NULL;
pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */
pso->ar = CTX_wm_region(C); /* only really needed when doing modal() */
-
+
pso->cframe = pso->scene->r.cfra;
pso->mode = mode;
-
+
/* set range info from property values - these may get overridden for the invoke() */
pso->percentage = RNA_float_get(op->ptr, "percentage");
pso->prevFrame = RNA_int_get(op->ptr, "prev_frame");
pso->nextFrame = RNA_int_get(op->ptr, "next_frame");
-
+
/* get the set of properties/axes that can be operated on */
pso->channels = RNA_enum_get(op->ptr, "channels");
pso->axislock = RNA_enum_get(op->ptr, "axis_lock");
-
+
/* ensure validity of the settings from the context */
if (ELEM(NULL, pso->ob, pso->arm, pso->ob->adt, pso->ob->adt->action))
return 0;
-
+
act = pso->ob->adt->action;
-
+
/* apply NLA mapping corrections so the frame lookups work */
pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
-
- /* for each Pose-Channel which gets affected, get the F-Curves for that channel
+
+ /* for each Pose-Channel which gets affected, get the F-Curves for that channel
* and set the relevant transform flags...
*/
poseAnim_mapping_get(C, &pso->pfLinks, pso->ob, act);
-
+
/* set depsgraph flags */
/* make sure the lock is set OK, unlock can be accidentally saved? */
pso->ob->pose->flag |= POSE_LOCKED;
pso->ob->pose->flag &= ~POSE_DO_UNLOCK;
-
- /* do basic initialize of RB-BST used for finding keyframes, but leave the filling of it up
+
+ /* do basic initialize of RB-BST used for finding keyframes, but leave the filling of it up
* to the caller of this (usually only invoke() will do it, to make things more efficient).
*/
BLI_dlrbTree_init(&pso->keys);
-
+
/* initialise numeric input */
initNumInput(&pso->num);
pso->num.idx_max = 0; /* one axis */
pso->num.val_flag[0] |= NUM_NO_NEGATIVE;
pso->num.unit_type[0] = B_UNIT_NONE; /* percentages don't have any units... */
-
+
/* return status is whether we've got all the data we were requested to get */
return 1;
}
@@ -233,19 +233,19 @@ static int pose_slide_init(bContext *C, wmOperator *op, short mode)
static void pose_slide_exit(wmOperator *op)
{
tPoseSlideOp *pso = op->customdata;
-
+
/* if data exists, clear its data and exit */
if (pso) {
/* free the temp pchan links and their data */
poseAnim_mapping_free(&pso->pfLinks);
-
+
/* free RB-BST for keyframes (if it contained data) */
BLI_dlrbTree_free(&pso->keys);
-
+
/* free data itself */
MEM_freeN(pso);
}
-
+
/* cleanup */
op->customdata = NULL;
}
@@ -265,19 +265,19 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
float cframe = (float)pso->cframe;
float sVal, eVal;
float w1, w2;
-
+
/* get keyframe values for endpoint poses to blend with */
/* previous/start */
sVal = evaluate_fcurve(fcu, pso->prevFrameF);
/* next/end */
eVal = evaluate_fcurve(fcu, pso->nextFrameF);
-
+
/* if both values are equal, don't do anything */
if (IS_EQF(sVal, eVal)) {
(*val) = sVal;
return;
}
-
+
/* calculate the relative weights of the endpoints */
if (pso->mode == POSESLIDE_BREAKDOWN) {
/* get weights from the percentage control */
@@ -285,20 +285,20 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
w2 = 1.0f - w1; /* this must come first */
}
else {
- /* - these weights are derived from the relative distance of these
+ /* - these weights are derived from the relative distance of these
* poses from the current frame
* - they then get normalized so that they only sum up to 1
*/
- float wtot;
-
+ float wtot;
+
w1 = cframe - (float)pso->prevFrame;
w2 = (float)pso->nextFrame - cframe;
-
+
wtot = w1 + w2;
w1 = (w1 / wtot);
w2 = (w2 / wtot);
}
-
+
/* depending on the mode, calculate the new value
* - in all of these, the start+end values are multiplied by w2 and w1 (respectively),
* since multiplication in another order would decrease the value the current frame is closer to
@@ -311,7 +311,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
* - perform this weighting a number of times given by the percentage...
*/
int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */
-
+
while (iters-- > 0) {
(*val) = (-((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f;
}
@@ -324,7 +324,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
* - perform this weighting a number of times given by the percentage...
*/
int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */
-
+
while (iters-- > 0) {
(*val) = ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f;
}
@@ -345,19 +345,19 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, floa
{
LinkData *ld = NULL;
char *path = NULL;
-
+
/* get the path to use... */
path = BLI_sprintfN("%s.%s", pfl->pchan_path, propName);
-
+
/* using this path, find each matching F-Curve for the variables we're interested in */
while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) {
FCurve *fcu = (FCurve *)ld->data;
const int idx = fcu->array_index;
const int lock = pso->axislock;
-
+
/* check if this F-Curve is ok given the current axis locks */
BLI_assert(fcu->array_index < 3);
-
+
if ((lock == 0) ||
((lock & PS_LOCK_X) && (idx == 0)) ||
((lock & PS_LOCK_Y) && (idx == 1)) ||
@@ -367,7 +367,7 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, floa
pose_slide_apply_val(pso, fcu, &vec[fcu->array_index]);
}
}
-
+
/* free the temp path we got */
MEM_freeN(path);
}
@@ -378,11 +378,11 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
PointerRNA ptr = {{NULL}};
LinkData *ld;
int len = strlen(pfl->pchan_path);
-
+
/* setup pointer RNA for resolving paths */
RNA_pointer_create(NULL, &RNA_PoseBone, pfl->pchan, &ptr);
-
- /* - custom properties are just denoted using ["..."][etc.] after the end of the base path,
+
+ /* - custom properties are just denoted using ["..."][etc.] after the end of the base path,
* so just check for opening pair after the end of the path
* - bbone properties are similar, but they always start with a prefix "bbone_*",
* so a similar method should work here for those too
@@ -390,23 +390,23 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
const char *bPtr, *pPtr;
-
+
if (fcu->rna_path == NULL)
continue;
-
- /* do we have a match?
+
+ /* do we have a match?
* - bPtr is the RNA Path with the standard part chopped off
* - pPtr is the chunk of the path which is left over
*/
bPtr = strstr(fcu->rna_path, pfl->pchan_path) + len;
pPtr = strstr(bPtr, prop_prefix);
-
+
if (pPtr) {
/* use RNA to try and get a handle on this property, then, assuming that it is just
* numerical, try and grab the value as a float for temp editing before setting back
*/
PropertyRNA *prop = RNA_struct_find_property(&ptr, pPtr);
-
+
if (prop) {
switch (RNA_property_type(prop)) {
/* continuous values that can be smoothly interpolated... */
@@ -424,7 +424,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
RNA_property_int_set(&ptr, prop, (int)tval);
break;
}
-
+
/* values which can only take discrete values */
case PROP_BOOLEAN:
{
@@ -440,7 +440,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
*/
break;
}
-
+
default:
/* cannot handle */
//printf("Cannot Pose Slide non-numerical property\n");
@@ -459,17 +459,17 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
LinkData *ld = NULL;
char *path = NULL;
float cframe;
-
+
/* get the path to use - this should be quaternion rotations only (needs care) */
path = BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion");
-
+
/* get the current frame number */
cframe = (float)pso->cframe;
-
+
/* using this path, find each matching F-Curve for the variables we're interested in */
while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) {
FCurve *fcu = (FCurve *)ld->data;
-
+
/* assign this F-Curve to one of the relevant pointers... */
switch (fcu->array_index) {
case 3: /* z */
@@ -486,22 +486,22 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
break;
}
}
-
+
/* only if all channels exist, proceed */
if (fcu_w && fcu_x && fcu_y && fcu_z) {
float quat_prev[4], quat_next[4];
-
+
/* get 2 quats */
quat_prev[0] = evaluate_fcurve(fcu_w, pso->prevFrameF);
quat_prev[1] = evaluate_fcurve(fcu_x, pso->prevFrameF);
quat_prev[2] = evaluate_fcurve(fcu_y, pso->prevFrameF);
quat_prev[3] = evaluate_fcurve(fcu_z, pso->prevFrameF);
-
+
quat_next[0] = evaluate_fcurve(fcu_w, pso->nextFrameF);
quat_next[1] = evaluate_fcurve(fcu_x, pso->nextFrameF);
quat_next[2] = evaluate_fcurve(fcu_y, pso->nextFrameF);
quat_next[3] = evaluate_fcurve(fcu_z, pso->nextFrameF);
-
+
/* perform blending */
if (pso->mode == POSESLIDE_BREAKDOWN) {
/* just perform the interpol between quat_prev and quat_next using pso->percentage as a guide */
@@ -509,35 +509,35 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
}
else if (pso->mode == POSESLIDE_PUSH) {
float quat_diff[4], quat_orig[4];
-
+
/* calculate the delta transform from the previous to the current */
/* TODO: investigate ways to favour one transform more? */
sub_qt_qtqt(quat_diff, pchan->quat, quat_prev);
-
+
/* make a copy of the original rotation */
copy_qt_qt(quat_orig, pchan->quat);
-
+
/* increase the original by the delta transform, by an amount determined by percentage */
add_qt_qtqt(pchan->quat, quat_orig, quat_diff, pso->percentage);
}
else {
float quat_interp[4], quat_orig[4];
int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */
-
+
/* perform this blending several times until a satisfactory result is reached */
while (iters-- > 0) {
/* calculate the interpolation between the endpoints */
interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe - pso->prevFrame) / (pso->nextFrame - pso->prevFrame));
-
+
/* make a copy of the original rotation */
copy_qt_qt(quat_orig, pchan->quat);
-
+
/* tricky interpolations - blending between original and new */
interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f / 6.0f);
}
}
}
-
+
/* free the path now */
MEM_freeN(path);
}
@@ -546,37 +546,37 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
{
tPChanFCurveLink *pfl;
-
+
/* sanitise the frame ranges */
if (pso->prevFrame == pso->nextFrame) {
/* move out one step either side */
pso->prevFrame--;
pso->nextFrame++;
-
+
/* apply NLA mapping corrections so the frame lookups work */
pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
}
-
+
/* for each link, handle each set of transforms */
for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) {
- /* valid transforms for each PoseChannel should have been noted already
- * - sliding the pose should be a straightforward exercise for location+rotation,
- * but rotations get more complicated since we may want to use quaternion blending
+ /* valid transforms for each PoseChannel should have been noted already
+ * - sliding the pose should be a straightforward exercise for location+rotation,
+ * but rotations get more complicated since we may want to use quaternion blending
* for quaternions instead...
*/
bPoseChannel *pchan = pfl->pchan;
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_LOC) && (pchan->flag & POSE_LOC)) {
/* calculate these for the 'location' vector, and use location curves */
pose_slide_apply_vec3(pso, pfl, pchan->loc, "location");
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_SIZE) && (pchan->flag & POSE_SIZE)) {
/* calculate these for the 'scale' vector, and use scale curves */
pose_slide_apply_vec3(pso, pfl, pchan->size, "scale");
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_ROT) && (pchan->flag & POSE_ROT)) {
/* everything depends on the rotation mode */
if (pchan->rotmode > 0) {
@@ -591,12 +591,12 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
pose_slide_apply_quat(pso, pfl);
}
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_BBONE_SHAPE) && (pchan->flag & POSE_BBONE_SHAPE)) {
/* bbone properties - they all start a "bbone_" prefix */
- pose_slide_apply_props(pso, pfl, "bbone_");
+ pose_slide_apply_props(pso, pfl, "bbone_");
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_PROPS) && (pfl->oldprops)) {
/* not strictly a transform, but custom properties contribute to the pose produced in many rigs
* (e.g. the facial rigs used in Sintel)
@@ -604,7 +604,7 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
pose_slide_apply_props(pso, pfl, "[\""); /* dummy " for texteditor bugs */
}
}
-
+
/* depsgraph updates + redraws */
pose_slide_refresh(C, pso);
}
@@ -633,7 +633,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
char limits_str[UI_MAX_DRAW_STR];
char axis_str[50];
char mode_str[32];
-
+
switch (pso->mode) {
case POSESLIDE_PUSH:
strcpy(mode_str, "Push Pose");
@@ -644,13 +644,13 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
case POSESLIDE_BREAKDOWN:
strcpy(mode_str, "Breakdown");
break;
-
+
default:
/* unknown */
strcpy(mode_str, "Sliding-Tool");
break;
}
-
+
switch (pso->axislock) {
case PS_LOCK_X:
BLI_strncpy(axis_str, "[X]/Y/Z axis only (X to clear)", sizeof(axis_str));
@@ -661,7 +661,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
case PS_LOCK_Z:
BLI_strncpy(axis_str, "X/Y/[Z] axis only (Z to clear)", sizeof(axis_str));
break;
-
+
default:
if (ELEM(pso->channels, PS_TFM_LOC, PS_TFM_ROT, PS_TFM_SIZE)) {
BLI_strncpy(axis_str, "X/Y/Z = Axis Constraint", sizeof(axis_str));
@@ -671,7 +671,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
}
break;
}
-
+
switch (pso->channels) {
case PS_TFM_LOC:
BLI_snprintf(limits_str, sizeof(limits_str), "[G]/R/S/B/C - Location only (G to clear) | %s", axis_str);
@@ -692,19 +692,19 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
BLI_strncpy(limits_str, "G/R/S/B/C - Limit to Transform/Property Set", sizeof(limits_str));
break;
}
-
+
if (hasNumInput(&pso->num)) {
Scene *scene = pso->scene;
char str_offs[NUM_STR_REP_LEN];
-
+
outputNumInput(&pso->num, str_offs, &scene->unit);
-
+
BLI_snprintf(status_str, sizeof(status_str), "%s: %s | %s", mode_str, str_offs, limits_str);
}
else {
BLI_snprintf(status_str, sizeof(status_str), "%s: %d %% | %s", mode_str, (int)(pso->percentage * 100.0f), limits_str);
}
-
+
ED_area_headerprint(pso->sa, status_str);
}
@@ -714,34 +714,34 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
tPChanFCurveLink *pfl;
AnimData *adt = pso->ob->adt;
wmWindow *win = CTX_wm_window(C);
-
+
/* for each link, add all its keyframes to the search tree */
for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) {
LinkData *ld;
-
+
/* do this for each F-Curve */
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
fcurve_to_keylist(adt, fcu, &pso->keys, NULL);
}
}
-
+
/* consolidate these keyframes, and figure out the nearest ones */
BLI_dlrbTree_linkedlist_sync(&pso->keys);
-
+
/* cancel if no keyframes found... */
if (pso->keys.root) {
ActKeyColumn *ak;
float cframe = (float)pso->cframe;
-
+
/* firstly, check if the current frame is a keyframe... */
ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe);
-
+
if (ak == NULL) {
/* current frame is not a keyframe, so search */
ActKeyColumn *pk = (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe);
ActKeyColumn *nk = (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe);
-
+
/* new set the frames */
/* prev frame */
pso->prevFrame = (pk) ? (pk->cfra) : (pso->cframe - 1);
@@ -759,7 +759,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
pso->nextFrame = (ak->next) ? (ak->next->cfra) : (pso->cframe + 1);
RNA_int_set(op->ptr, "next_frame", pso->nextFrame);
}
-
+
/* apply NLA mapping corrections so the frame lookups work */
pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
@@ -769,20 +769,20 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
-
+
/* initial apply for operator... */
/* TODO: need to calculate percentage for initial round too... */
pose_slide_apply(C, pso);
-
+
/* depsgraph updates + redraws */
pose_slide_refresh(C, pso);
-
+
/* set cursor to indicate modal */
WM_cursor_modal_set(win, BC_EW_SCROLLCURSOR);
-
+
/* header print */
pose_slide_draw_status(pso);
-
+
/* add a modal handler for this operator */
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -810,8 +810,8 @@ static void pose_slide_toggle_channels_mode(wmOperator *op, tPoseSlideOp *pso, e
pso->channels = channel;
}
RNA_enum_set(op->ptr, "channels", pso->channels);
-
-
+
+
/* Reset axis limits too for good measure */
pso->axislock = 0;
RNA_enum_set(op->ptr, "axis_lock", pso->axislock);
@@ -826,7 +826,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, tPoseSlideOp *pso, ePos
RNA_enum_set(op->ptr, "axis_lock", pso->axislock);
return false;
}
-
+
/* Turn on or off? */
if (pso->axislock == axis) {
/* Already limiting on this axis, so turn off */
@@ -837,7 +837,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, tPoseSlideOp *pso, ePos
pso->axislock = axis;
}
RNA_enum_set(op->ptr, "axis_lock", pso->axislock);
-
+
/* Setting changed, so pose update is needed */
return true;
}
@@ -848,9 +848,9 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
tPoseSlideOp *pso = op->customdata;
wmWindow *win = CTX_wm_window(C);
bool do_pose_update = false;
-
+
const bool has_numinput = hasNumInput(&pso->num);
-
+
switch (event->type) {
case LEFTMOUSE: /* confirm */
case RETKEY:
@@ -859,35 +859,35 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* return to normal cursor and header status */
ED_area_headerprint(pso->sa, NULL);
WM_cursor_modal_restore(win);
-
+
/* insert keyframes as required... */
pose_slide_autoKeyframe(C, pso);
pose_slide_exit(op);
-
+
/* done! */
return OPERATOR_FINISHED;
}
-
+
case ESCKEY: /* cancel */
- case RIGHTMOUSE:
+ case RIGHTMOUSE:
{
/* return to normal cursor and header status */
ED_area_headerprint(pso->sa, NULL);
WM_cursor_modal_restore(win);
-
+
/* reset transforms back to original state */
pose_slide_reset(pso);
-
+
/* depsgraph updates + redraws */
pose_slide_refresh(C, pso);
-
+
/* clean up temp data */
pose_slide_exit(op);
-
+
/* canceled! */
return OPERATOR_CANCELLED;
}
-
+
/* Percentage Chane... */
case MOUSEMOVE: /* calculate new position */
{
@@ -895,7 +895,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (has_numinput == false) {
/* update percentage based on position of mouse */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* update pose to reflect the new values (see below) */
do_pose_update = true;
}
@@ -905,17 +905,17 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
if ((event->val == KM_PRESS) && handleNumInput(C, &pso->num, event)) {
float value;
-
- /* Grab percentage from numeric input, and store this new value for redo
+
+ /* Grab percentage from numeric input, and store this new value for redo
* NOTE: users see ints, while internally we use a 0-1 float
*/
value = pso->percentage * 100.0f;
applyNumInput(&pso->num, &value);
-
+
pso->percentage = value / 100.0f;
CLAMP(pso->percentage, 0.0f, 1.0f);
RNA_float_set(op->ptr, "percentage", pso->percentage);
-
+
/* Update pose to reflect the new values (see below) */
do_pose_update = true;
break;
@@ -954,8 +954,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
do_pose_update = true;
break;
}
-
-
+
+
/* Axis Locks */
/* XXX: Hardcoded... */
case XKEY:
@@ -979,8 +979,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
break;
}
-
-
+
+
default: /* Some other unhandled key... */
break;
}
@@ -992,20 +992,20 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
}
-
-
+
+
/* perform pose updates - in response to some user action (e.g. pressing a key or moving the mouse) */
if (do_pose_update) {
/* update percentage indicator in header */
pose_slide_draw_status(pso);
-
+
/* reset transforms (to avoid accumulation errors) */
pose_slide_reset(pso);
-
+
/* apply... */
pose_slide_apply(C, pso);
}
-
+
/* still running... */
return OPERATOR_RUNNING_MODAL;
}
@@ -1022,13 +1022,13 @@ static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso
{
/* settings should have been set up ok for applying, so just apply! */
pose_slide_apply(C, pso);
-
+
/* insert keyframes if needed */
pose_slide_autoKeyframe(C, pso);
-
+
/* cleanup and done */
pose_slide_exit(op);
-
+
return OPERATOR_FINISHED;
}
@@ -1037,10 +1037,10 @@ static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso
static void pose_slide_opdef_properties(wmOperatorType *ot)
{
RNA_def_float_percentage(ot->srna, "percentage", 0.5f, 0.0f, 1.0f, "Percentage", "Weighting factor for which keyframe is favored more", 0.3, 0.7);
-
+
RNA_def_int(ot->srna, "prev_frame", 0, MINAFRAME, MAXFRAME, "Previous Keyframe", "Frame number of keyframe immediately before the current frame", 0, 50);
RNA_def_int(ot->srna, "next_frame", 0, MINAFRAME, MAXFRAME, "Next Keyframe", "Frame number of keyframe immediately after the current frame", 0, 50);
-
+
RNA_def_enum(ot->srna, "channels", prop_channels_types, PS_TFM_ALL, "Channels", "Set of properties that are affected");
RNA_def_enum(ot->srna, "axis_lock", prop_axis_lock_types, 0, "Axis Lock", "Transform axis to restrict effects to");
}
@@ -1051,7 +1051,7 @@ static void pose_slide_opdef_properties(wmOperatorType *ot)
static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
-
+
/* initialize data */
if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) {
pose_slide_exit(op);
@@ -1059,10 +1059,10 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev
}
else
pso = op->customdata;
-
+
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
@@ -1071,7 +1071,7 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev
static int pose_slide_push_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
-
+
/* initialize data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) {
pose_slide_exit(op);
@@ -1079,7 +1079,7 @@ static int pose_slide_push_exec(bContext *C, wmOperator *op)
}
else
pso = op->customdata;
-
+
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
@@ -1090,17 +1090,17 @@ void POSE_OT_push(wmOperatorType *ot)
ot->name = "Push Pose";
ot->idname = "POSE_OT_push";
ot->description = "Exaggerate the current pose";
-
+
/* callbacks */
ot->exec = pose_slide_push_exec;
ot->invoke = pose_slide_push_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* Properties */
pose_slide_opdef_properties(ot);
}
@@ -1111,7 +1111,7 @@ void POSE_OT_push(wmOperatorType *ot)
static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
-
+
/* initialize data */
if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) {
pose_slide_exit(op);
@@ -1119,10 +1119,10 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
else
pso = op->customdata;
-
+
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
@@ -1131,7 +1131,7 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e
static int pose_slide_relax_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
-
+
/* initialize data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) {
pose_slide_exit(op);
@@ -1139,7 +1139,7 @@ static int pose_slide_relax_exec(bContext *C, wmOperator *op)
}
else
pso = op->customdata;
-
+
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
@@ -1150,17 +1150,17 @@ void POSE_OT_relax(wmOperatorType *ot)
ot->name = "Relax Pose";
ot->idname = "POSE_OT_relax";
ot->description = "Make the current pose more similar to its surrounding ones";
-
+
/* callbacks */
ot->exec = pose_slide_relax_exec;
ot->invoke = pose_slide_relax_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* Properties */
pose_slide_opdef_properties(ot);
}
@@ -1171,7 +1171,7 @@ void POSE_OT_relax(wmOperatorType *ot)
static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
-
+
/* initialize data */
if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) {
pose_slide_exit(op);
@@ -1179,10 +1179,10 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven
}
else
pso = op->customdata;
-
+
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
@@ -1191,7 +1191,7 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven
static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
-
+
/* initialize data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) {
pose_slide_exit(op);
@@ -1199,7 +1199,7 @@ static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
}
else
pso = op->customdata;
-
+
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
@@ -1210,17 +1210,17 @@ void POSE_OT_breakdown(wmOperatorType *ot)
ot->name = "Pose Breakdowner";
ot->idname = "POSE_OT_breakdown";
ot->description = "Create a suitable breakdown pose on the current frame";
-
+
/* callbacks */
ot->exec = pose_slide_breakdown_exec;
ot->invoke = pose_slide_breakdown_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* Properties */
pose_slide_opdef_properties(ot);
}
@@ -1240,7 +1240,7 @@ typedef enum ePosePropagate_Termination {
POSE_PROPAGATE_BEFORE_FRAME,
/* stop when we run out of keyframes */
POSE_PROPAGATE_BEFORE_END,
-
+
/* only do on keyframes that are selected */
POSE_PROPAGATE_SELECTED_KEYS,
/* only do on the frames where markers are selected */
@@ -1251,14 +1251,14 @@ typedef enum ePosePropagate_Termination {
typedef union tPosePropagate_ModeData {
/* smart holds + before frame: frame number to stop on */
float end_frame;
-
+
/* selected markers: listbase for CfraElem's marking these frames */
ListBase sel_markers;
} tPosePropagate_ModeData;
/* --------------------------------- */
-/* get frame on which the "hold" for the bone ends
+/* get frame on which the "hold" for the bone ends
* XXX: this may not really work that well if a bone moves on some channels and not others
* if this happens to be a major issue, scrap this, and just make this happen
* independently per F-Curve
@@ -1267,47 +1267,47 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p
{
DLRBT_Tree keys, blocks;
ActKeyBlock *ab;
-
+
AnimData *adt = ob->adt;
LinkData *ld;
float endFrame = startFrame;
-
+
/* set up optimized data-structures for searching for relevant keyframes + holds */
BLI_dlrbTree_init(&keys);
BLI_dlrbTree_init(&blocks);
-
+
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
fcurve_to_keylist(adt, fcu, &keys, &blocks);
}
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
BLI_dlrbTree_linkedlist_sync(&blocks);
-
- /* find the long keyframe (i.e. hold), and hence obtain the endFrame value
+
+ /* find the long keyframe (i.e. hold), and hence obtain the endFrame value
* - the best case would be one that starts on the frame itself
*/
ab = (ActKeyBlock *)BLI_dlrbTree_search_exact(&blocks, compare_ab_cfraPtr, &startFrame);
-
+
if (actkeyblock_is_valid(ab, &keys) == 0) {
/* There are only two cases for no-exact match:
* 1) the current frame is just before another key but not on a key itself
* 2) the current frame is on a key, but that key doesn't link to the next
*
- * If we've got the first case, then we can search for another block,
+ * If we've got the first case, then we can search for another block,
* otherwise forget it, as we'd be overwriting some valid data.
*/
if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &startFrame) == NULL) {
/* we've got case 1, so try the one after */
ab = (ActKeyBlock *)BLI_dlrbTree_search_next(&blocks, compare_ab_cfraPtr, &startFrame);
-
+
if (actkeyblock_is_valid(ab, &keys) == 0) {
/* try the block before this frame then as last resort */
ab = (ActKeyBlock *)BLI_dlrbTree_search_prev(&blocks, compare_ab_cfraPtr, &startFrame);
-
+
/* whatever happens, stop searching now... */
if (actkeyblock_is_valid(ab, &keys) == 0) {
- /* restrict range to just the frame itself
+ /* restrict range to just the frame itself
* i.e. everything is in motion, so no holds to safely overwrite
*/
ab = NULL;
@@ -1319,13 +1319,13 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p
ab = NULL;
}
}
-
+
/* check if we can go any further than we've already gone */
if (ab) {
/* go to next if it is also valid and meets "extension" criteria */
while (ab->next) {
ActKeyBlock *abn = (ActKeyBlock *)ab->next;
-
+
/* must be valid */
if (actkeyblock_is_valid(abn, &keys) == 0)
break;
@@ -1335,24 +1335,24 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p
/* should have the same number of curves */
if (ab->totcurve != abn->totcurve)
break;
- /* should have the same value
+ /* should have the same value
* XXX: this may be a bit fuzzy on larger data sets, so be careful
*/
if (ab->val != abn->val)
break;
-
+
/* we can extend the bounds to the end of this "next" block now */
ab = abn;
}
-
+
/* end frame can now take the value of the end of the block */
endFrame = ab->end;
}
-
+
/* free temp memory */
BLI_dlrbTree_free(&keys);
BLI_dlrbTree_free(&blocks);
-
+
/* return the end frame we've found */
return endFrame;
}
@@ -1363,10 +1363,10 @@ static bool pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value)
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
bool found = false;
-
+
/* base pointer is always the object -> id_ptr */
RNA_id_pointer_create(&ob->id, &id_ptr);
-
+
/* resolve the property... */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
if (RNA_property_array_check(prop)) {
@@ -1411,7 +1411,7 @@ static bool pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value)
}
}
}
-
+
return found;
}
@@ -1420,25 +1420,25 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
float startFrame, tPosePropagate_ModeData modeData)
{
const int mode = RNA_enum_get(op->ptr, "mode");
-
+
BezTriple *bezt;
float refVal = 0.0f;
bool keyExists;
int i, match;
short first = 1;
-
+
/* skip if no keyframes to edit */
if ((fcu->bezt == NULL) || (fcu->totvert < 2))
return;
-
+
/* find the reference value from bones directly, which means that the user
- * doesn't need to firstly keyframe the pose (though this doesn't mean that
+ * doesn't need to firstly keyframe the pose (though this doesn't mean that
* they can't either)
*/
if (!pose_propagate_get_refVal(ob, fcu, &refVal))
return;
-
- /* find the first keyframe to start propagating from
+
+ /* find the first keyframe to start propagating from
* - if there's a keyframe on the current frame, we probably want to save this value there too
* since it may be as of yet unkeyed
* - if starting before the starting frame, don't touch the key, as it may have had some valid
@@ -1447,7 +1447,7 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
*/
if (mode != POSE_PROPAGATE_SELECTED_KEYS) {
match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists);
-
+
if (fcu->bezt[match].vec[1][0] < startFrame)
i = match + 1;
else
@@ -1457,13 +1457,13 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
/* selected - start from first keyframe */
i = 0;
}
-
+
for (bezt = &fcu->bezt[i]; i < fcu->totvert; i++, bezt++) {
/* additional termination conditions based on the operator 'mode' property go here... */
if (ELEM(mode, POSE_PROPAGATE_BEFORE_FRAME, POSE_PROPAGATE_SMART_HOLDS)) {
/* stop if keyframe is outside the accepted range */
if (bezt->vec[1][0] > modeData.end_frame)
- break;
+ break;
}
else if (mode == POSE_PROPAGATE_NEXT_KEY) {
/* stop after the first keyframe has been processed */
@@ -1478,13 +1478,13 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
/* only allow if there's a marker on this frame */
CfraElem *ce = NULL;
-
+
/* stop on matching marker if there is one */
for (ce = modeData.sel_markers.first; ce; ce = ce->next) {
if (ce->cfra == round_fl_to_int(bezt->vec[1][0]))
break;
}
-
+
/* skip this keyframe if no marker */
if (ce == NULL)
continue;
@@ -1494,11 +1494,11 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
if (BEZT_ISSEL_ANY(bezt) == 0)
continue;
}
-
+
/* just flatten handles, since values will now be the same either side... */
/* TODO: perhaps a fade-out modulation of the value is required here (optional once again)? */
bezt->vec[0][1] = bezt->vec[1][1] = bezt->vec[2][1] = refVal;
-
+
/* select keyframe to indicate that it's been changed */
bezt->f2 |= SELECT;
first = 0;
@@ -1512,13 +1512,13 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bAction *act = (ob && ob->adt) ? ob->adt->action : NULL;
-
+
ListBase pflinks = {NULL, NULL};
tPChanFCurveLink *pfl;
-
+
tPosePropagate_ModeData modeData;
const int mode = RNA_enum_get(op->ptr, "mode");
-
+
/* sanity checks */
if (ob == NULL) {
BKE_report(op->reports, RPT_ERROR, "No object to propagate poses for");
@@ -1528,10 +1528,10 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No keyframed poses to propagate to");
return OPERATOR_CANCELLED;
}
-
+
/* isolate F-Curves related to the selected bones */
poseAnim_mapping_get(C, &pflinks, ob, act);
-
+
/* mode-specific data preprocessing (requiring no access to curves) */
if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
/* get a list of selected markers */
@@ -1541,11 +1541,11 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
/* assume everything else wants endFrame */
modeData.end_frame = RNA_float_get(op->ptr, "end_frame");
}
-
+
/* for each bone, perform the copying required */
for (pfl = pflinks.first; pfl; pfl = pfl->next) {
LinkData *ld;
-
+
/* mode-specific data preprocessing (requiring access to all curves) */
if (mode == POSE_PROPAGATE_SMART_HOLDS) {
/* we store in endFrame the end frame of the "long keyframe" (i.e. a held value) starting
@@ -1553,21 +1553,21 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
*/
modeData.end_frame = pose_propagate_get_boneHoldEndFrame(ob, pfl, (float)CFRA);
}
-
+
/* go through propagating pose to keyframes, curve by curve */
for (ld = pfl->fcurves.first; ld; ld = ld->next)
pose_propagate_fcurve(op, ob, (FCurve *)ld->data, (float)CFRA, modeData);
}
-
+
/* free temp data */
poseAnim_mapping_free(&pflinks);
-
+
if (mode == POSE_PROPAGATE_SELECTED_MARKERS)
BLI_freelistN(&modeData.sel_markers);
-
+
/* updates + notifiers */
poseAnim_mapping_refresh(C, scene, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1591,19 +1591,19 @@ void POSE_OT_propagate(wmOperatorType *ot)
{POSE_PROPAGATE_SELECTED_MARKERS, "SELECTED_MARKERS", 0, "On Selected Markers",
"Propagate pose to all keyframes occurring on frames with Scene Markers after the current frame"},
{0, NULL, 0, NULL, NULL}};
-
+
/* identifiers */
ot->name = "Propagate Pose";
ot->idname = "POSE_OT_propagate";
ot->description = "Copy selected aspects of the current pose to subsequent poses already keyframed";
-
+
/* callbacks */
ot->exec = pose_propagate_exec;
ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */
-
+
/* flag */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
/* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */
ot->prop = RNA_def_enum(ot->srna, "mode", terminate_items, POSE_PROPAGATE_SMART_HOLDS, "Terminate Mode", "Method used to determine when to stop propagating pose to keyframes");