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:
authorCampbell Barton <ideasman42@gmail.com>2021-06-11 09:27:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-06-11 09:27:55 +0300
commit84f025c6fdba38a1cdf8e3070c9642977837cb33 (patch)
tree88ead37b17652472fc22d905d74c9d96c90945e3 /source/blender/editors/armature
parent066f5a446954b23782556df8739435658761057b (diff)
Cleanup: use sentences for pose slide comments
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r--source/blender/editors/armature/pose_slide.c618
1 files changed, 343 insertions, 275 deletions
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index e41a44a3c12..2f5d2f6c12d 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -19,6 +19,28 @@
/** \file
* \ingroup edarmature
+ *
+ * Pose 'Sliding' Tools
+ * ====================
+ *
+ * - Push & Relax, Breakdowner
+
+ * These tools provide the animator with various capabilities
+ * for interactively controlling the spacing of poses, but also
+ * for 'pushing' and/or 'relaxing' extremes as they see fit.
+ *
+ * - Propagate
+
+ * This tool copies elements of the selected pose to successive
+ * keyframes, allowing the animator to go back and modify the poses
+ * for some "static" pose controls, without having to repeatedly
+ * doing a "next paste" dance.
+ *
+ * - Pose Sculpting (TODO)
+
+ * This is yet to be implemented, but the idea here is to use
+ * sculpting techniques to make it easier to pose rigs by allowing
+ * rigs to be manipulated using a familiar paint-based interface.
*/
#include "MEM_guardedalloc.h"
@@ -75,44 +97,28 @@
#define OVERSHOOT_RANGE_DELTA 0.2f
/* **************************************************** */
-/* == POSE 'SLIDING' TOOLS ==
- *
- * A) Push & Relax, Breakdowner
- * These tools provide the animator with various capabilities
- * for interactively controlling the spacing of poses, but also
- * for 'pushing' and/or 'relaxing' extremes as they see fit.
- *
- * B) Propagate
- * This tool copies elements of the selected pose to successive
- * keyframes, allowing the animator to go back and modify the poses
- * for some "static" pose controls, without having to repeatedly
- * doing a "next paste" dance.
- *
- * C) Pose Sculpting
- * This is yet to be implemented, but the idea here is to use
- * sculpting techniques to make it easier to pose rigs by allowing
- * rigs to be manipulated using a familiar paint-based interface.
- */
-/* **************************************************** */
/* A) Push & Relax, Breakdowner */
-/* Axis Locks */
+/** Axis Locks. */
typedef enum ePoseSlide_AxisLock {
PS_LOCK_X = (1 << 0),
PS_LOCK_Y = (1 << 1),
PS_LOCK_Z = (1 << 2),
} ePoseSlide_AxisLock;
-/* Pose Sliding Modes */
+/** Pose Sliding Modes. */
typedef enum ePoseSlide_Modes {
- POSESLIDE_PUSH = 0, /* exaggerate the pose... */
- POSESLIDE_RELAX, /* soften the pose... */
- POSESLIDE_BREAKDOWN, /* slide between the endpoint poses, finding a 'soft' spot */
+ /** Exaggerate the pose. */
+ POSESLIDE_PUSH = 0,
+ /** soften the pose. */
+ POSESLIDE_RELAX,
+ /** Slide between the endpoint poses, finding a 'soft' spot. */
+ POSESLIDE_BREAKDOWN,
POSESLIDE_PUSH_REST,
POSESLIDE_RELAX_REST,
} ePoseSlide_Modes;
-/* Transforms/Channels to Affect */
+/** Transforms/Channels to Affect. */
typedef enum ePoseSlide_Channels {
PS_TFM_ALL = 0, /* All transforms and properties */
@@ -125,7 +131,7 @@ typedef enum ePoseSlide_Channels {
PS_TFM_PROPS, /* Custom Properties */
} ePoseSlide_Channels;
-/* Temporary data shared between these operators */
+/** Temporary data shared between these operators. */
typedef struct tPoseSlideOp {
/** current scene */
Scene *scene;
@@ -162,41 +168,44 @@ typedef struct tPoseSlideOp {
/** Axis-limits for transforms. */
ePoseSlide_AxisLock axislock;
- /* Allow overshoot or clamp between 0% and 100%. */
+ /** Allow overshoot or clamp between 0% and 100%. */
bool overshoot;
- /* Reduces factor delta from mouse movement. */
+ /** Reduces factor delta from mouse movement. */
bool precision;
- /* Move factor in 10% steps. */
+ /** Move factor in 10% steps. */
bool increments;
- /* Draw callback handler. */
+ /** Draw callback handler. */
void *draw_handle;
- /* Accumulative, unclamped and unrounded factor. */
+ /** Accumulative, unclamped and unrounded factor. */
float raw_factor;
- /* 0-1 value for determining the influence of whatever is relevant. */
+ /** 0-1 value for determining the influence of whatever is relevant. */
float factor;
- /* Last cursor position in screen space used for mouse movement delta calculation. */
+ /** Last cursor position in screen space used for mouse movement delta calculation. */
int last_cursor_x;
- /* Numeric input. */
+ /** Numeric input. */
NumInput num;
struct tPoseSlideObject *ob_data_array;
} tPoseSlideOp;
typedef struct tPoseSlideObject {
- Object *ob; /* active object that Pose Info comes from */
- 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) */
+ /** Active object that Pose Info comes from. */
+ Object *ob;
+ /** `prevFrame`, but in local action time (for F-Curve look-ups to work). */
+ float prevFrameF;
+ /** `nextFrame`, but in local action time (for F-Curve look-ups to work). */
+ float nextFrameF;
bool valid;
} tPoseSlideObject;
-/* Property enum for ePoseSlide_Channels */
+/** Property enum for #ePoseSlide_Channels. */
static const EnumPropertyItem prop_channels_types[] = {
{PS_TFM_ALL,
"ALL",
@@ -363,7 +372,9 @@ static void draw_backdrop(const int fontid,
UI_draw_roundbox_aa(&backdrop_rect, true, 4.0f, color_bg);
}
-/* Draw an on screen Slider for a Pose Slide Operator. */
+/**
+ * Draw an on screen Slider for a Pose Slide Operator.
+ */
static void pose_slide_draw_2d_slider(const struct bContext *UNUSED(C), ARegion *region, void *arg)
{
tPoseSlideOp *pso = arg;
@@ -471,34 +482,34 @@ static void pose_slide_draw_2d_slider(const struct bContext *UNUSED(C), ARegion
BLF_draw(fontid, percentage_string, sizeof(percentage_string));
}
-/* operator init */
+/** Operator custom-data initialization. */
static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode)
{
tPoseSlideOp *pso;
- /* init slide-op data */
+ /* Init slide-op data. */
pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp");
- /* get info from context */
+ /* Get info from context. */
pso->scene = CTX_data_scene(C);
- pso->area = CTX_wm_area(C); /* only really needed when doing modal() */
- pso->region_header = CTX_wm_region(C); /* only really needed when doing modal() */
+ pso->area = CTX_wm_area(C); /* Only really needed when doing modal(). */
+ pso->region_header = 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() */
+ /* Set range info from property values - these may get overridden for the invoke(). */
pso->factor = RNA_float_get(op->ptr, "factor");
pso->raw_factor = pso->factor;
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 */
+ /* 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");
- /* for each Pose-Channel which gets affected, get the F-Curves for that channel
- * and set the relevant transform flags... */
+ /* 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);
Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data(
@@ -518,29 +529,28 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode)
ob_data->ob = ob_iter;
ob_data->valid = true;
- /* apply NLA mapping corrections so the frame lookups work */
+ /* Apply NLA mapping corrections so the frame look-ups work. */
ob_data->prevFrameF = BKE_nla_tweakedit_remap(
ob_data->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
ob_data->nextFrameF = BKE_nla_tweakedit_remap(
ob_data->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
- /* set depsgraph flags */
- /* make sure the lock is set OK, unlock can be accidentally saved? */
+ /* Set depsgraph flags. */
+ /* Make sure the lock is set OK, unlock can be accidentally saved? */
ob_data->ob->pose->flag |= POSE_LOCKED;
ob_data->ob->pose->flag &= ~POSE_DO_UNLOCK;
}
MEM_freeN(objects);
- /* 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).
- */
+ /* 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);
/* Initialize numeric input. */
initNumInput(&pso->num);
- pso->num.idx_max = 0; /* one axis */
+ 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... */
+ pso->num.unit_type[0] = B_UNIT_NONE; /* Percentages don't have any units. */
/* Register UI drawing callback. */
ARegion *region_header = BKE_area_find_region_type(pso->area, RGN_TYPE_HEADER);
@@ -550,11 +560,13 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode)
region_header->type, pose_slide_draw_2d_slider, pso, REGION_DRAW_POST_PIXEL);
}
- /* return status is whether we've got all the data we were requested to get */
+ /* Return status is whether we've got all the data we were requested to get. */
return 1;
}
-/* exiting the operator - free data */
+/**
+ * Exiting the operator (free data).
+ */
static void pose_slide_exit(wmOperator *op)
{
tPoseSlideOp *pso = op->customdata;
@@ -566,32 +578,34 @@ static void pose_slide_exit(wmOperator *op)
/* Remove UI drawing callback. */
ED_region_draw_cb_exit(pso->region_header->type, pso->draw_handle);
- /* if data exists, clear its data and exit */
+ /* If data exists, clear its data and exit. */
if (pso) {
- /* free the temp pchan links and their data */
+ /* Free the temp pchan links and their data. */
poseAnim_mapping_free(&pso->pfLinks);
- /* free RB-BST for keyframes (if it contained data) */
+ /* Free RB-BST for keyframes (if it contained data). */
BLI_dlrbTree_free(&pso->keys);
if (pso->ob_data_array != NULL) {
MEM_freeN(pso->ob_data_array);
}
- /* free data itself */
+ /* Free data itself. */
MEM_freeN(pso);
}
- /* cleanup */
+ /* Cleanup. */
op->customdata = NULL;
}
/* ------------------------------------ */
-/* helper for apply() / reset() - refresh the data */
+/**
+ * Helper for apply() / reset() - refresh the data.
+ */
static void pose_slide_refresh(bContext *C, tPoseSlideOp *pso)
{
- /* wrapper around the generic version, allowing us to add some custom stuff later still */
+ /* Wrapper around the generic version, allowing us to add some custom stuff later still. */
for (uint ob_index = 0; ob_index < pso->objects_len; ob_index++) {
tPoseSlideObject *ob_data = &pso->ob_data_array[ob_index];
if (ob_data->valid) {
@@ -623,7 +637,9 @@ static bool pose_frame_range_from_object_get(tPoseSlideOp *pso,
return false;
}
-/* helper for apply() - perform sliding for some value */
+/**
+ * Helper for apply() - perform sliding for some value.
+ */
static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, float *val)
{
float prevFrameF, nextFrameF;
@@ -633,17 +649,17 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
pose_frame_range_from_object_get(pso, ob, &prevFrameF, &nextFrameF);
- /* get keyframe values for endpoint poses to blend with */
- /* previous/start */
+ /* Get keyframe values for endpoint poses to blend with. */
+ /* Previous/start. */
sVal = evaluate_fcurve(fcu, prevFrameF);
- /* next/end */
+ /* Next/end. */
eVal = evaluate_fcurve(fcu, nextFrameF);
- /* calculate the relative weights of the endpoints */
+ /* Calculate the relative weights of the endpoints. */
if (pso->mode == POSESLIDE_BREAKDOWN) {
- /* get weights from the factor control */
- w1 = pso->factor; /* this must come second */
- w2 = 1.0f - w1; /* this must come first */
+ /* Get weights from the factor control. */
+ w1 = pso->factor; /* This must come second. */
+ w2 = 1.0f - w1; /* This must come first. */
}
else {
/* - these weights are derived from the relative distance of these
@@ -666,19 +682,19 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
* the value the current frame is closer to.
*/
switch (pso->mode) {
- case POSESLIDE_PUSH: /* make the current pose more pronounced */
+ case POSESLIDE_PUSH: /* Make the current pose more pronounced. */
{
/* Slide the pose away from the breakdown pose in the timeline */
(*val) -= ((sVal * w2) + (eVal * w1) - (*val)) * pso->factor;
break;
}
- case POSESLIDE_RELAX: /* make the current pose more like its surrounding ones */
+ case POSESLIDE_RELAX: /* Make the current pose more like its surrounding ones. */
{
/* Slide the pose towards the breakdown pose in the timeline */
(*val) += ((sVal * w2) + (eVal * w1) - (*val)) * pso->factor;
break;
}
- case POSESLIDE_BREAKDOWN: /* make the current pose slide around between the endpoints */
+ case POSESLIDE_BREAKDOWN: /* Make the current pose slide around between the endpoints. */
{
/* Perform simple linear interpolation -
* coefficient for start must come from pso->factor. */
@@ -694,7 +710,9 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
}
}
-/* helper for apply() - perform sliding for some 3-element vector */
+/**
+ * Helper for apply() - perform sliding for some 3-element vector.
+ */
static void pose_slide_apply_vec3(tPoseSlideOp *pso,
tPChanFCurveLink *pfl,
float vec[3],
@@ -703,30 +721,32 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso,
LinkData *ld = NULL;
char *path = NULL;
- /* get the path to use... */
+ /* 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 */
+ /* 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 */
+ /* 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)) ||
((lock & PS_LOCK_Z) && (idx == 2))) {
- /* just work on these channels one by one... there's no interaction between values */
+ /* Just work on these channels one by one... there's no interaction between values. */
pose_slide_apply_val(pso, fcu, pfl->ob, &vec[fcu->array_index]);
}
}
- /* free the temp path we got */
+ /* Free the temp path we got. */
MEM_freeN(path);
}
-/* helper for apply() - perform sliding for custom properties or bbone properties */
+/**
+ * Helper for apply() - perform sliding for custom properties or bbone properties.
+ */
static void pose_slide_apply_props(tPoseSlideOp *pso,
tPChanFCurveLink *pfl,
const char prop_prefix[])
@@ -735,7 +755,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
LinkData *ld;
int len = strlen(pfl->pchan_path);
- /* setup pointer RNA for resolving paths */
+ /* 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,
@@ -751,22 +771,21 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
continue;
}
- /* 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
+ /* 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
- */
+ /* 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... */
+ /* Continuous values that can be smoothly interpolated. */
case PROP_FLOAT: {
float tval = RNA_property_float_get(&ptr, prop);
pose_slide_apply_val(pso, fcu, pfl->ob, &tval);
@@ -780,7 +799,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
break;
}
- /* values which can only take discrete values */
+ /* Values which can only take discrete values. */
case PROP_BOOLEAN: {
float tval = (float)RNA_property_boolean_get(&ptr, prop);
pose_slide_apply_val(pso, fcu, pfl->ob, &tval);
@@ -789,14 +808,13 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
break;
}
case PROP_ENUM: {
- /* don't handle this case - these don't usually represent interchangeable
- * set of values which should be interpolated between
- */
+ /* Don't handle this case - these don't usually represent interchangeable
+ * set of values which should be interpolated between. */
break;
}
default:
- /* cannot handle */
+ /* Cannot handle. */
// printf("Cannot Pose Slide non-numerical property\n");
break;
}
@@ -805,7 +823,9 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
}
}
-/* helper for apply() - perform sliding for quaternion rotations (using quat blending) */
+/**
+ * Helper for apply() - perform sliding for quaternion rotations (using quat blending).
+ */
static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
{
FCurve *fcu_w = NULL, *fcu_x = NULL, *fcu_y = NULL, *fcu_z = NULL;
@@ -820,17 +840,17 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
return;
}
- /* get the path to use - this should be quaternion rotations only (needs care) */
+ /* 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 */
+ /* Get the current frame number. */
cframe = (float)pso->cframe;
- /* using this path, find each matching F-Curve for the variables we're interested in */
+ /* 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... */
+ /* Assign this F-Curve to one of the relevant pointers. */
switch (fcu->array_index) {
case 3: /* z */
fcu_z = fcu;
@@ -847,11 +867,11 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
}
}
- /* only if all channels exist, proceed */
+ /* Only if all channels exist, proceed. */
if (fcu_w && fcu_x && fcu_y && fcu_z) {
float quat_final[4];
- /* perform blending */
+ /* Perform blending. */
if (pso->mode == POSESLIDE_BREAKDOWN) {
/* Just perform the interpolation between quat_prev and
* quat_next using pso->factor as a guide. */
@@ -901,7 +921,7 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
quat_to_compatible_quat(pchan->quat, quat_final, pchan->quat);
}
- /* free the path now */
+ /* Free the path now. */
MEM_freeN(path);
}
@@ -945,47 +965,49 @@ static void pose_slide_rest_pose_apply_other_rot(tPoseSlideOp *pso, float vec[4]
}
}
-/* apply() - perform the pose sliding between the current pose and the rest pose */
+/**
+ * apply() - perform the pose sliding between the current pose and the rest pose.
+ */
static void pose_slide_rest_pose_apply(bContext *C, tPoseSlideOp *pso)
{
tPChanFCurveLink *pfl;
- /* for each link, handle each set of transforms */
+ /* 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,
+ /* Valid transforms for each #bPoseChannel 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...
+ * 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 */
+ /* Calculate these for the 'location' vector, and use location curves. */
pose_slide_rest_pose_apply_vec3(pso, pchan->loc, 0.0f);
}
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_SIZE) && (pchan->flag & POSE_SIZE)) {
- /* calculate these for the 'scale' vector, and use scale curves */
+ /* Calculate these for the 'scale' vector, and use scale curves. */
pose_slide_rest_pose_apply_vec3(pso, pchan->size, 1.0f);
}
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_ROT) && (pchan->flag & POSE_ROT)) {
- /* everything depends on the rotation mode */
+ /* Everything depends on the rotation mode. */
if (pchan->rotmode > 0) {
- /* eulers - so calculate these for the 'eul' vector, and use euler_rotation curves */
+ /* Eulers - so calculate these for the 'eul' vector, and use euler_rotation curves. */
pose_slide_rest_pose_apply_vec3(pso, pchan->eul, 0.0f);
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
pose_slide_rest_pose_apply_other_rot(pso, pchan->quat, false);
}
else {
- /* quaternions - use quaternion blending */
+ /* Quaternions - use quaternion blending. */
pose_slide_rest_pose_apply_other_rot(pso, pchan->quat, true);
}
}
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_BBONE_SHAPE) && (pchan->flag & POSE_BBONE_SHAPE)) {
- /* bbone properties - they all start a "bbone_" prefix */
+ /* Bbone properties - they all start a "bbone_" prefix. */
/* TODO Not implemented */
// pose_slide_apply_props(pso, pfl, "bbone_");
}
@@ -998,18 +1020,20 @@ static void pose_slide_rest_pose_apply(bContext *C, tPoseSlideOp *pso)
}
}
- /* depsgraph updates + redraws */
+ /* Depsgraph updates + redraws. */
pose_slide_refresh(C, pso);
}
-/* apply() - perform the pose sliding based on weighting various poses */
+/**
+ * apply() - perform the pose sliding based on weighting various poses.
+ */
static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
{
tPChanFCurveLink *pfl;
/* Sanitize the frame ranges. */
if (pso->prevFrame == pso->nextFrame) {
- /* move out one step either side */
+ /* Move out one step either side. */
pso->prevFrame--;
pso->nextFrame++;
@@ -1020,7 +1044,7 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
continue;
}
- /* apply NLA mapping corrections so the frame lookups work */
+ /* Apply NLA mapping corrections so the frame look-ups work. */
ob_data->prevFrameF = BKE_nla_tweakedit_remap(
ob_data->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
ob_data->nextFrameF = BKE_nla_tweakedit_remap(
@@ -1028,9 +1052,9 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
}
}
- /* for each link, handle each set of transforms */
+ /* 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
+ /* Valid transforms for each #bPoseChannel 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...
@@ -1038,32 +1062,32 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
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 */
+ /* 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 */
+ /* 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 */
+ /* Everything depends on the rotation mode. */
if (pchan->rotmode > 0) {
- /* eulers - so calculate these for the 'eul' vector, and use euler_rotation curves */
+ /* Eulers - so calculate these for the 'eul' vector, and use euler_rotation curves. */
pose_slide_apply_vec3(pso, pfl, pchan->eul, "rotation_euler");
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
/* TODO: need to figure out how to do this! */
}
else {
- /* quaternions - use quaternion blending */
+ /* Quaternions - use quaternion blending. */
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 */
+ /* Bbone properties - they all start a "bbone_" prefix. */
pose_slide_apply_props(pso, pfl, "bbone_");
}
@@ -1074,28 +1098,35 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
}
}
- /* depsgraph updates + redraws */
+ /* Depsgraph updates + redraws. */
pose_slide_refresh(C, pso);
}
-/* perform auto-key-framing after changes were made + confirmed */
+/**
+ * Perform auto-key-framing after changes were made + confirmed.
+ */
static void pose_slide_autoKeyframe(bContext *C, tPoseSlideOp *pso)
{
- /* wrapper around the generic call */
+ /* Wrapper around the generic call. */
poseAnim_mapping_autoKeyframe(C, pso->scene, &pso->pfLinks, (float)pso->cframe);
}
-/* reset changes made to current pose */
+/**
+ * Reset changes made to current pose.
+ */
static void pose_slide_reset(tPoseSlideOp *pso)
{
- /* wrapper around the generic call, so that custom stuff can be added later */
+ /* Wrapper around the generic call, so that custom stuff can be added later. */
poseAnim_mapping_reset(&pso->pfLinks);
}
/* ------------------------------------ */
-/* Draw percentage indicator in workspace footer. */
-/* TODO: Include hints about locks here... */
+/**
+ * Draw percentage indicator in status-bar.
+ *
+ * TODO: Include hints about locks here.
+ */
static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso)
{
char status_str[UI_MAX_DRAW_STR];
@@ -1119,7 +1150,7 @@ static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso)
break;
default:
- /* unknown */
+ /* Unknown. */
strcpy(mode_str, TIP_("Sliding-Tool"));
break;
}
@@ -1222,57 +1253,59 @@ static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso)
ED_area_status_text(pso->area, "");
}
-/* common code for invoke() methods */
+/**
+ * Common code for invoke() methods.
+ */
static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *pso)
{
tPChanFCurveLink *pfl;
wmWindow *win = CTX_wm_window(C);
- /* for each link, add all its keyframes to the search tree */
+ /* 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 */
+ /* Do this for each F-Curve. */
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
fcurve_to_keylist(pfl->ob->adt, fcu, &pso->keys, 0);
}
}
- /* cancel if no keyframes found... */
+ /* 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... */
+ /* 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 */
+ /* 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 */
+ /* New set the frames. */
+ /* Prev frame. */
pso->prevFrame = (pk) ? (pk->cfra) : (pso->cframe - 1);
RNA_int_set(op->ptr, "prev_frame", pso->prevFrame);
- /* next frame */
+ /* Next frame. */
pso->nextFrame = (nk) ? (nk->cfra) : (pso->cframe + 1);
RNA_int_set(op->ptr, "next_frame", pso->nextFrame);
}
else {
- /* current frame itself is a keyframe, so just take keyframes on either side */
- /* prev frame */
+ /* Current frame itself is a keyframe, so just take keyframes on either side. */
+ /* Prev frame. */
pso->prevFrame = (ak->prev) ? (ak->prev->cfra) : (pso->cframe - 1);
RNA_int_set(op->ptr, "prev_frame", pso->prevFrame);
- /* next frame */
+ /* Next frame. */
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 */
+ /* Apply NLA mapping corrections so the frame look-ups work. */
for (uint ob_index = 0; ob_index < pso->objects_len; ob_index++) {
tPoseSlideObject *ob_data = &pso->ob_data_array[ob_index];
if (ob_data->valid) {
@@ -1289,8 +1322,8 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
return OPERATOR_CANCELLED;
}
- /* initial apply for operator... */
- /* TODO: need to calculate factor for initial round too... */
+ /* Initial apply for operator. */
+ /* TODO: need to calculate factor for initial round too. */
if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) {
pose_slide_apply(C, pso);
}
@@ -1298,16 +1331,16 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
pose_slide_rest_pose_apply(C, pso);
}
- /* depsgraph updates + redraws */
+ /* Depsgraph updates + redraws. */
pose_slide_refresh(C, pso);
- /* set cursor to indicate modal */
+ /* Set cursor to indicate modal. */
WM_cursor_modal_set(win, WM_CURSOR_EW_SCROLL);
- /* header print */
+ /* Header print. */
pose_slide_draw_status(C, pso);
- /* add a modal handler for this operator */
+ /* Add a modal handler for this operator. */
WM_event_add_modal_handler(C, op);
/* Hide Bone Overlay. */
@@ -1318,7 +1351,8 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
return OPERATOR_RUNNING_MODAL;
}
-/* Calculate factor based on mouse movement, clamp or round to increments if
+/**
+ * Calculate factor based on mouse movement, clamp or round to increments if
* enabled by the user. Store the new factor value.
*/
static void pose_slide_mouse_update_factor(tPoseSlideOp *pso, wmOperator *op, const wmEvent *event)
@@ -1340,7 +1374,9 @@ static void pose_slide_mouse_update_factor(tPoseSlideOp *pso, wmOperator *op, co
RNA_float_set(op->ptr, "factor", pso->factor);
}
-/* handle an event to toggle channels mode */
+/**
+ * Handle an event to toggle channels mode.
+ */
static void pose_slide_toggle_channels_mode(wmOperator *op,
tPoseSlideOp *pso,
ePoseSlide_Channels channel)
@@ -1361,7 +1397,9 @@ static void pose_slide_toggle_channels_mode(wmOperator *op,
RNA_enum_set(op->ptr, "axis_lock", pso->axislock);
}
-/* handle an event to toggle axis locks - returns whether any change in state is needed */
+/**
+ * Handle an event to toggle axis locks - returns whether any change in state is needed.
+ */
static bool pose_slide_toggle_axis_locks(wmOperator *op,
tPoseSlideOp *pso,
ePoseSlide_AxisLock axis)
@@ -1388,7 +1426,9 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op,
return true;
}
-/* common code for modal() */
+/**
+ * Operator `modal()` callback.
+ */
static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso = op->customdata;
@@ -1398,11 +1438,11 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
const bool has_numinput = hasNumInput(&pso->num);
switch (event->type) {
- case LEFTMOUSE: /* confirm */
+ case LEFTMOUSE: /* Confirm. */
case EVT_RETKEY:
case EVT_PADENTER: {
if (event->val == KM_PRESS) {
- /* return to normal cursor and header status */
+ /* Return to normal cursor and header status. */
ED_workspace_status_text(C, NULL);
ED_area_status_text(pso->area, NULL);
WM_cursor_modal_restore(win);
@@ -1410,48 +1450,48 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Depsgraph updates + redraws. Redraw needed to remove UI. */
pose_slide_refresh(C, pso);
- /* insert keyframes as required... */
+ /* Insert keyframes as required. */
pose_slide_autoKeyframe(C, pso);
pose_slide_exit(op);
- /* done! */
+ /* Done! */
return OPERATOR_FINISHED;
}
break;
}
- case EVT_ESCKEY: /* cancel */
+ case EVT_ESCKEY: /* Cancel. */
case RIGHTMOUSE: {
if (event->val == KM_PRESS) {
- /* return to normal cursor and header status */
+ /* Return to normal cursor and header status. */
ED_workspace_status_text(C, NULL);
ED_area_status_text(pso->area, NULL);
WM_cursor_modal_restore(win);
- /* reset transforms back to original state */
+ /* Reset transforms back to original state. */
pose_slide_reset(pso);
/* Depsgraph updates + redraws.*/
pose_slide_refresh(C, pso);
- /* clean up temp data */
+ /* Clean up temp data. */
pose_slide_exit(op);
- /* canceled! */
+ /* Canceled! */
return OPERATOR_CANCELLED;
}
break;
}
/* Factor Change... */
- case MOUSEMOVE: /* calculate new position */
+ case MOUSEMOVE: /* Calculate new position. */
{
- /* only handle mousemove if not doing numinput */
+ /* Only handle mouse-move if not doing numinput. */
if (has_numinput == false) {
- /* update factor based on position of mouse */
+ /* Update factor based on position of mouse. */
pose_slide_mouse_update_factor(pso, op, event);
- /* update pose to reflect the new values (see below) */
+ /* Update pose to reflect the new values (see below). */
do_pose_update = true;
}
break;
@@ -1583,8 +1623,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
else {
- /* unhandled event - maybe it was some view manipulation? */
- /* allow to pass through */
+ /* Unhandled event - maybe it was some view manipulation? */
+ /* Allow to pass through. */
return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH;
}
}
@@ -1593,13 +1633,13 @@ 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 */
+ /* Update percentage indicator in header. */
pose_slide_draw_status(C, pso);
- /* reset transforms (to avoid accumulation errors) */
+ /* Reset transforms (to avoid accumulation errors). */
pose_slide_reset(pso);
- /* apply... */
+ /* Apply. */
if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) {
pose_slide_apply(C, pso);
}
@@ -1608,21 +1648,25 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- /* still running... */
+ /* Still running. */
return OPERATOR_RUNNING_MODAL;
}
-/* common code for cancel() */
+/**
+ * Common code for cancel()
+ */
static void pose_slide_cancel(bContext *UNUSED(C), wmOperator *op)
{
- /* cleanup and done */
+ /* Cleanup and done. */
pose_slide_exit(op);
}
-/* common code for exec() methods */
+/**
+ * Common code for exec() methods.
+ */
static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso)
{
- /* settings should have been set up ok for applying, so just apply! */
+ /* Settings should have been set up ok for applying, so just apply! */
if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) {
pose_slide_apply(C, pso);
}
@@ -1630,10 +1674,10 @@ static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso
pose_slide_rest_pose_apply(C, pso);
}
- /* insert keyframes if needed */
+ /* Insert keyframes if needed. */
pose_slide_autoKeyframe(C, pso);
- /* cleanup and done */
+ /* Cleanup and done. */
pose_slide_exit(op);
return OPERATOR_FINISHED;
@@ -1697,12 +1741,14 @@ static void pose_slide_opdef_properties(wmOperatorType *ot)
/* ------------------------------------ */
-/* invoke() - for 'push from breakdown' mode */
+/**
+ * Operator `invoke()` callback for 'push from breakdown' mode.
+ */
static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
- /* initialize data */
+ /* Initialize data. */
if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) {
pose_slide_exit(op);
return OPERATOR_CANCELLED;
@@ -1715,16 +1761,18 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev
/* Initialize factor so that it won't pop on first mouse move. */
pose_slide_mouse_update_factor(pso, op, event);
- /* do common setup work */
+ /* Do common setup work. */
return pose_slide_invoke_common(C, op, pso);
}
-/* exec() - for push */
+/**
+ * Operator `exec()` callback - for push.
+ */
static int pose_slide_push_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
- /* initialize data (from RNA-props) */
+ /* Initialize data (from RNA-props). */
if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) {
pose_slide_exit(op);
return OPERATOR_CANCELLED;
@@ -1732,7 +1780,7 @@ static int pose_slide_push_exec(bContext *C, wmOperator *op)
pso = op->customdata;
- /* do common exec work */
+ /* Do common exec work. */
return pose_slide_exec_common(C, op, pso);
}
@@ -1759,12 +1807,14 @@ void POSE_OT_push(wmOperatorType *ot)
/* ........................ */
-/* invoke() - for 'relax to breakdown' mode */
+/**
+ * Invoke callback - for 'relax to breakdown' mode.
+ */
static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
- /* initialize data */
+ /* Initialize data. */
if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) {
pose_slide_exit(op);
return OPERATOR_CANCELLED;
@@ -1777,16 +1827,18 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e
/* Initialize factor so that it won't pop on first mouse move. */
pose_slide_mouse_update_factor(pso, op, event);
- /* do common setup work */
+ /* Do common setup work. */
return pose_slide_invoke_common(C, op, pso);
}
-/* exec() - for relax */
+/**
+ * Operator exec() - for relax.
+ */
static int pose_slide_relax_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
- /* initialize data (from RNA-props) */
+ /* Initialize data (from RNA-props). */
if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) {
pose_slide_exit(op);
return OPERATOR_CANCELLED;
@@ -1794,7 +1846,7 @@ static int pose_slide_relax_exec(bContext *C, wmOperator *op)
pso = op->customdata;
- /* do common exec work */
+ /* Do common exec work. */
return pose_slide_exec_common(C, op, pso);
}
@@ -1820,12 +1872,14 @@ void POSE_OT_relax(wmOperatorType *ot)
}
/* ........................ */
-/* invoke() - for 'push from rest pose' mode */
+/**
+ * Operator `invoke()` - for 'push from rest pose' mode.
+ */
static int pose_slide_push_rest_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
- /* initialize data */
+ /* Initialize data. */
if (pose_slide_init(C, op, POSESLIDE_PUSH_REST) == 0) {
pose_slide_exit(op);
return OPERATOR_CANCELLED;
@@ -1842,12 +1896,14 @@ static int pose_slide_push_rest_invoke(bContext *C, wmOperator *op, const wmEven
return pose_slide_invoke_common(C, op, pso);
}
-/* exec() - for push */
+/**
+ * Operator `exec()` - for push.
+ */
static int pose_slide_push_rest_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
- /* initialize data (from RNA-props) */
+ /* Initialize data (from RNA-props). */
if (pose_slide_init(C, op, POSESLIDE_PUSH_REST) == 0) {
pose_slide_exit(op);
return OPERATOR_CANCELLED;
@@ -1855,7 +1911,7 @@ static int pose_slide_push_rest_exec(bContext *C, wmOperator *op)
pso = op->customdata;
- /* do common exec work */
+ /* Do common exec work. */
return pose_slide_exec_common(C, op, pso);
}
@@ -1882,12 +1938,14 @@ void POSE_OT_push_rest(wmOperatorType *ot)
/* ........................ */
-/* invoke() - for 'relax' mode */
+/**
+ * Operator `invoke()` - for 'relax' mode.
+ */
static int pose_slide_relax_rest_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
- /* initialize data */
+ /* Initialize data. */
if (pose_slide_init(C, op, POSESLIDE_RELAX_REST) == 0) {
pose_slide_exit(op);
return OPERATOR_CANCELLED;
@@ -1900,16 +1958,18 @@ static int pose_slide_relax_rest_invoke(bContext *C, wmOperator *op, const wmEve
/* Initialize factor so that it won't pop on first mouse move. */
pose_slide_mouse_update_factor(pso, op, event);
- /* do common setup work */
+ /* Do common setup work. */
return pose_slide_invoke_common(C, op, pso);
}
-/* exec() - for relax */
+/**
+ * Operator `exec()` - for relax.
+ */
static int pose_slide_relax_rest_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
- /* initialize data (from RNA-props) */
+ /* Initialize data (from RNA-props). */
if (pose_slide_init(C, op, POSESLIDE_RELAX_REST) == 0) {
pose_slide_exit(op);
return OPERATOR_CANCELLED;
@@ -1917,7 +1977,7 @@ static int pose_slide_relax_rest_exec(bContext *C, wmOperator *op)
pso = op->customdata;
- /* do common exec work */
+ /* Do common exec work. */
return pose_slide_exec_common(C, op, pso);
}
@@ -1944,12 +2004,14 @@ void POSE_OT_relax_rest(wmOperatorType *ot)
/* ........................ */
-/* invoke() - for 'breakdown' mode */
+/**
+ * Operator `invoke()` - for 'breakdown' mode.
+ */
static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
- /* initialize data */
+ /* Initialize data. */
if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) {
pose_slide_exit(op);
return OPERATOR_CANCELLED;
@@ -1962,16 +2024,18 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven
/* Initialize factor so that it won't pop on first mouse move. */
pose_slide_mouse_update_factor(pso, op, event);
- /* do common setup work */
+ /* Do common setup work. */
return pose_slide_invoke_common(C, op, pso);
}
-/* exec() - for breakdown */
+/**
+ * Operator exec() - for breakdown.
+ */
static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
- /* initialize data (from RNA-props) */
+ /* Initialize data (from RNA-props). */
if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) {
pose_slide_exit(op);
return OPERATOR_CANCELLED;
@@ -1979,7 +2043,7 @@ static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
pso = op->customdata;
- /* do common exec work */
+ /* Do common exec work. */
return pose_slide_exec_common(C, op, pso);
}
@@ -2009,36 +2073,39 @@ void POSE_OT_breakdown(wmOperatorType *ot)
/* "termination conditions" - i.e. when we stop */
typedef enum ePosePropagate_Termination {
- /* stop after the current hold ends */
+ /** Stop after the current hold ends. */
POSE_PROPAGATE_SMART_HOLDS = 0,
- /* only do on the last keyframe */
+ /** Only do on the last keyframe. */
POSE_PROPAGATE_LAST_KEY,
- /* stop after the next keyframe */
+ /** Stop after the next keyframe. */
POSE_PROPAGATE_NEXT_KEY,
- /* stop after the specified frame */
+ /** Stop after the specified frame. */
POSE_PROPAGATE_BEFORE_FRAME,
- /* stop when we run out of keyframes */
+ /** Stop when we run out of keyframes. */
POSE_PROPAGATE_BEFORE_END,
- /* only do on keyframes that are selected */
+ /** Only do on keyframes that are selected. */
POSE_PROPAGATE_SELECTED_KEYS,
- /* only do on the frames where markers are selected */
+ /** Only do on the frames where markers are selected. */
POSE_PROPAGATE_SELECTED_MARKERS,
} ePosePropagate_Termination;
-/* Termination data needed for some modes -
- * assumes only one of these entries will be needed at a time. */
+/**
+ * Termination data needed for some modes -
+ * assumes only one of these entries will be needed at a time.
+ */
typedef union tPosePropagate_ModeData {
- /* smart holds + before frame: frame number to stop on */
+ /** Smart holds + before frame: frame number to stop on. */
float end_frame;
- /* selected markers: listbase for CfraElem's marking these frames */
+ /** 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
@@ -2052,7 +2119,7 @@ static float pose_propagate_get_boneHoldEndFrame(tPChanFCurveLink *pfl, float st
LinkData *ld;
float endFrame = startFrame;
- /* set up optimized data-structures for searching for relevant keyframes + holds */
+ /* Set up optimized data-structures for searching for relevant keyframes + holds. */
BLI_dlrbTree_init(&keys);
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
@@ -2060,7 +2127,7 @@ static float pose_propagate_get_boneHoldEndFrame(tPChanFCurveLink *pfl, float st
fcurve_to_keylist(adt, fcu, &keys, 0);
}
- /* 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
*/
ActKeyColumn *ab = (ActKeyColumn *)BLI_dlrbTree_search_exact(
@@ -2074,67 +2141,68 @@ static float pose_propagate_get_boneHoldEndFrame(tPChanFCurveLink *pfl, float st
* otherwise forget it, as we'd be overwriting some valid data.
*/
if (ab == NULL) {
- /* we've got case 1, so try the one after */
+ /* We've got case 1, so try the one after. */
ab = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &startFrame);
if ((actkeyblock_get_valid_hold(ab) & ACTKEYBLOCK_FLAG_STATIC_HOLD) == 0) {
- /* try the block before this frame then as last resort */
+ /* Try the block before this frame then as last resort. */
ab = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &startFrame);
}
}
- /* whatever happens, stop searching now... */
+ /* Whatever happens, stop searching now.... */
if ((actkeyblock_get_valid_hold(ab) & ACTKEYBLOCK_FLAG_STATIC_HOLD) == 0) {
- /* restrict range to just the frame itself
- * i.e. everything is in motion, so no holds to safely overwrite
- */
+ /* Restrict range to just the frame itself
+ * i.e. everything is in motion, so no holds to safely overwrite. */
ab = NULL;
}
- /* check if we can go any further than we've already gone */
+ /* 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 */
+ /* Go to next if it is also valid and meets "extension" criteria. */
while (ab->next) {
ActKeyColumn *abn = ab->next;
- /* must be valid */
+ /* Must be valid. */
if ((actkeyblock_get_valid_hold(abn) & ACTKEYBLOCK_FLAG_STATIC_HOLD) == 0) {
break;
}
- /* should have the same number of curves */
+ /* Should have the same number of curves. */
if (ab->totblock != abn->totblock) {
break;
}
- /* we can extend the bounds to the end of this "next" block now */
+ /* 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 */
+ /* End frame can now take the value of the end of the block. */
endFrame = ab->next->cfra;
}
- /* free temp memory */
+ /* Free temp memory. */
BLI_dlrbTree_free(&keys);
- /* return the end frame we've found */
+ /* Return the end frame we've found. */
return endFrame;
}
-/* get reference value from F-Curve using RNA */
+/**
+ * Get reference value from F-Curve using RNA.
+ */
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 */
+ /* Base pointer is always the `object -> id_ptr`. */
RNA_id_pointer_create(&ob->id, &id_ptr);
- /* resolve the property... */
+ /* Resolve the property. */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
if (RNA_property_array_check(prop)) {
- /* array */
+ /* Array. */
if (fcu->array_index < RNA_property_array_length(&ptr, prop)) {
found = true;
switch (RNA_property_type(prop)) {
@@ -2154,7 +2222,7 @@ static bool pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value)
}
}
else {
- /* not an array */
+ /* Not an array. */
found = true;
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
@@ -2179,7 +2247,9 @@ static bool pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value)
return found;
}
-/* propagate just works along each F-Curve in turn */
+/**
+ * Propagate just works along each F-Curve in turn.
+ */
static void pose_propagate_fcurve(
wmOperator *op, Object *ob, FCurve *fcu, float startFrame, tPosePropagate_ModeData modeData)
{
@@ -2191,22 +2261,21 @@ static void pose_propagate_fcurve(
int i, match;
bool first = true;
- /* skip if no keyframes to edit */
+ /* 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
+ /* 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
- * they can't either)
- */
+ * 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
+ * since it may be as of yet un-keyed
* - if starting before the starting frame, don't touch the key, as it may have had some valid
* values
* - if only doing selected keyframes, start from the first one
@@ -2222,58 +2291,58 @@ static void pose_propagate_fcurve(
}
}
else {
- /* selected - start from first keyframe */
+ /* 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... */
+ /* 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 */
+ /* Stop if keyframe is outside the accepted range. */
if (bezt->vec[1][0] > modeData.end_frame) {
break;
}
}
else if (mode == POSE_PROPAGATE_NEXT_KEY) {
- /* stop after the first keyframe has been processed */
+ /* Stop after the first keyframe has been processed. */
if (first == false) {
break;
}
}
else if (mode == POSE_PROPAGATE_LAST_KEY) {
- /* only affect this frame if it will be the last one */
+ /* Only affect this frame if it will be the last one. */
if (i != (fcu->totvert - 1)) {
continue;
}
}
else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
- /* only allow if there's a marker on this frame */
+ /* Only allow if there's a marker on this frame. */
CfraElem *ce = NULL;
- /* stop on matching marker if there is one */
+ /* 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 */
+ /* Skip this keyframe if no marker. */
if (ce == NULL) {
continue;
}
}
else if (mode == POSE_PROPAGATE_SELECTED_KEYS) {
- /* only allow if this keyframe is already selected - skip otherwise */
+ /* Only allow if this keyframe is already selected - skip otherwise. */
if (BEZT_ISSEL_ANY(bezt) == 0) {
continue;
}
}
- /* just flatten handles, since values will now be the same either side... */
+ /* 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 */
+ /* Select keyframe to indicate that it's been changed. */
bezt->f2 |= SELECT;
first = false;
}
@@ -2293,7 +2362,7 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
tPosePropagate_ModeData modeData;
const int mode = RNA_enum_get(op->ptr, "mode");
- /* isolate F-Curves related to the selected bones */
+ /* Isolate F-Curves related to the selected bones. */
poseAnim_mapping_get(C, &pflinks);
if (BLI_listbase_is_empty(&pflinks)) {
@@ -2304,42 +2373,41 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* mode-specific data preprocessing (requiring no access to curves) */
+ /* Mode-specific data preprocessing (requiring no access to curves). */
if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
- /* get a list of selected markers */
+ /* Get a list of selected markers. */
ED_markers_make_cfra_list(&scene->markers, &modeData.sel_markers, SELECT);
}
else {
- /* assume everything else wants endFrame */
+ /* Assume everything else wants endFrame. */
modeData.end_frame = RNA_float_get(op->ptr, "end_frame");
}
- /* for each bone, perform the copying required */
+ /* 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) */
+ /* 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
- * from the keyframe that occurs after the current frame
- */
+ /* We store in endFrame the end frame of the "long keyframe" (i.e. a held value) starting
+ * from the keyframe that occurs after the current frame. */
modeData.end_frame = pose_propagate_get_boneHoldEndFrame(pfl, (float)CFRA);
}
- /* go through propagating pose to keyframes, curve by curve */
+ /* Go through propagating pose to keyframes, curve by curve. */
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
pose_propagate_fcurve(op, pfl->ob, (FCurve *)ld->data, (float)CFRA, modeData);
}
}
- /* free temp data */
+ /* Free temp data. */
poseAnim_mapping_free(&pflinks);
if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
BLI_freelistN(&modeData.sel_markers);
}
- /* updates + notifiers */
+ /* Updates + notifiers. */
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {
poseAnim_mapping_refresh(C, scene, ob);
}