Fix for T48988 - Enabling bbone easing for posemode

This fix enables the usage of bbones easing parameters for edit and pose mode seperately. This allows animators to take advantage of the functionality and may eliminate confusion as the parameters now behave similar to other bbone parameters.

Note that splitting the parameters between the modes effectively creates a new parameter set. Blend files of previous versions do not contain this information and will have the values set to 0 on load. As it broke backwards compatibility for pose mode values anyway, I also took the liberty to rename the easing parameters in some places for consistency (which breaks edit mode values).

Reviewers: aligorith

Subscribers: aligorith

Tags: #animation

Differential Revision: https://developer.blender.org/D2796
This commit is contained in:
Joshua Leung 2017-11-01 13:38:51 +13:00
parent 2ae6a93f05
commit a819ef65c0
Notes: blender-bot 2023-02-14 19:33:15 +01:00
Referenced by issue #64908, In Pose Mode, clearing a bones Scale Transform also clears that bone's Bendy Bone Ease in/out values and also Scale in/out values
Referenced by issue #48988, BBones Ease in/out don´t update the mesh deformation at current frame
Referenced by issue blender/blender-addons#53356, Rigify generation broken on current master
13 changed files with 57 additions and 34 deletions

View File

@ -193,13 +193,8 @@ class BONE_PT_curved(BoneButtonsPanel, Panel):
sub = row.column(align=True)
sub.label("Easing:")
if pchan:
# XXX: have these also be an overlay?
sub.prop(bbone.bone, "bbone_in", text="Ease In")
sub.prop(bbone.bone, "bbone_out", text="Ease Out")
else:
sub.prop(bone, "bbone_in", text="Ease In")
sub.prop(bone, "bbone_out", text="Ease Out")
sub.prop(bbone, "bbone_easein", text="Ease In")
sub.prop(bbone, "bbone_easeout", text="Ease Out")
if pchan:
layout.separator()

View File

@ -870,6 +870,8 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan
pchan->curveInY = chan->curveInY;
pchan->curveOutX = chan->curveOutX;
pchan->curveOutY = chan->curveOutY;
pchan->ease1 = chan->ease1;
pchan->ease2 = chan->ease2;
pchan->scaleIn = chan->scaleIn;
pchan->scaleOut = chan->scaleOut;
@ -1361,6 +1363,7 @@ void BKE_pose_rest(bPose *pose)
pchan->roll1 = pchan->roll2 = 0.0f;
pchan->curveInX = pchan->curveInY = 0.0f;
pchan->curveOutX = pchan->curveOutY = 0.0f;
pchan->ease1 = pchan->ease2 = 0.0f;
pchan->scaleIn = pchan->scaleOut = 1.0f;
pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE);
@ -1404,6 +1407,8 @@ bool BKE_pose_copy_result(bPose *to, bPose *from)
pchanto->curveInY = pchanfrom->curveInY;
pchanto->curveOutX = pchanfrom->curveOutX;
pchanto->curveOutY = pchanfrom->curveOutY;
pchanto->ease1 = pchanfrom->ease1;
pchanto->ease2 = pchanfrom->ease2;
pchanto->scaleIn = pchanfrom->scaleIn;
pchanto->scaleOut = pchanfrom->scaleOut;

View File

@ -614,8 +614,10 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB
{
const float circle_factor = length * (cubic_tangent_factor_circle_v3(h1, h2) / 0.75f);
const float hlength1 = bone->ease1 * circle_factor;
const float hlength2 = bone->ease2 * circle_factor;
const float combined_ease1 = bone->ease1 + (!rest ? pchan->ease1 : 0.0f);
const float combined_ease2 = bone->ease2 + (!rest ? pchan->ease2 : 0.0f);
const float hlength1 = combined_ease1 * circle_factor;
const float hlength2 = combined_ease2 * circle_factor;
/* and only now negate h2 */
mul_v3_fl(h1, hlength1);

View File

@ -77,19 +77,20 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
bone->dist = 0.25f;
bone->xwidth = 0.1f;
bone->zwidth = 0.1f;
bone->ease1 = 1.0f;
bone->ease2 = 1.0f;
bone->rad_head = 0.10f;
bone->rad_tail = 0.05f;
bone->segments = 1;
bone->layer = arm->layer;
/* Bendy-Bone parameters */
bone->roll1 = 0.0f;
bone->roll2 = 0.0f;
bone->curveInX = 0.0f;
bone->curveInY = 0.0f;
bone->curveOutX = 0.0f;
bone->curveOutY = 0.0f;
bone->ease1 = 1.0f;
bone->ease2 = 1.0f;
bone->scaleIn = 1.0f;
bone->scaleOut = 1.0f;
@ -899,19 +900,20 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
newbone->dist = ebone->dist;
newbone->xwidth = ebone->xwidth;
newbone->zwidth = ebone->zwidth;
newbone->ease1 = ebone->ease1;
newbone->ease2 = ebone->ease2;
newbone->rad_head = ebone->rad_tail; // don't copy entire bone...
newbone->rad_tail = ebone->rad_tail;
newbone->segments = 1;
newbone->layer = ebone->layer;
/* Bendy-Bone parameters */
newbone->roll1 = ebone->roll1;
newbone->roll2 = ebone->roll2;
newbone->curveInX = ebone->curveInX;
newbone->curveInY = ebone->curveInY;
newbone->curveOutX = ebone->curveOutX;
newbone->curveOutY = ebone->curveOutY;
newbone->ease1 = ebone->ease1;
newbone->ease2 = ebone->ease2;
newbone->scaleIn = ebone->scaleIn;
newbone->scaleOut = ebone->scaleOut;

View File

@ -173,6 +173,7 @@ typedef struct tPChanFCurveLink {
float roll1, roll2; /* old bbone values (to be restored along with the transform properties) */
float curveInX, curveInY; /* (NOTE: we haven't renamed these this time, as their names are already long enough) */
float curveOutX, curveOutY;
float ease1, ease2;
float scaleIn, scaleOut;
struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */

View File

@ -462,19 +462,20 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
eBone->weight = curBone->weight;
eBone->xwidth = curBone->xwidth;
eBone->zwidth = curBone->zwidth;
eBone->ease1 = curBone->ease1;
eBone->ease2 = curBone->ease2;
eBone->rad_head = curBone->rad_head;
eBone->rad_tail = curBone->rad_tail;
eBone->segments = curBone->segments;
eBone->layer = curBone->layer;
/* Bendy-Bone parameters */
eBone->roll1 = curBone->roll1;
eBone->roll2 = curBone->roll2;
eBone->curveInX = curBone->curveInX;
eBone->curveInY = curBone->curveInY;
eBone->curveOutX = curBone->curveOutX;
eBone->curveOutY = curBone->curveOutY;
eBone->ease1 = curBone->ease1;
eBone->ease2 = curBone->ease2;
eBone->scaleIn = curBone->scaleIn;
eBone->scaleOut = curBone->scaleOut;
@ -626,19 +627,20 @@ void ED_armature_from_edit(bArmature *arm)
newBone->xwidth = eBone->xwidth;
newBone->zwidth = eBone->zwidth;
newBone->ease1 = eBone->ease1;
newBone->ease2 = eBone->ease2;
newBone->rad_head = eBone->rad_head;
newBone->rad_tail = eBone->rad_tail;
newBone->segments = eBone->segments;
newBone->layer = eBone->layer;
/* Bendy-Bone parameters */
newBone->roll1 = eBone->roll1;
newBone->roll2 = eBone->roll2;
newBone->curveInX = eBone->curveInX;
newBone->curveInY = eBone->curveInY;
newBone->curveOutX = eBone->curveOutX;
newBone->curveOutY = eBone->curveOutY;
newBone->ease1 = eBone->ease1;
newBone->ease2 = eBone->ease2;
newBone->scaleIn = eBone->scaleIn;
newBone->scaleOut = eBone->scaleOut;

View File

@ -1444,19 +1444,20 @@ static EditBone *add_editbonetolist(char *name, ListBase *list)
bone->dist = 0.25F;
bone->xwidth = 0.1;
bone->zwidth = 0.1;
bone->ease1 = 1.0;
bone->ease2 = 1.0;
bone->rad_head = 0.10;
bone->rad_tail = 0.05;
bone->segments = 1;
bone->layer = 1; //arm->layer;
/* Bendy-Bone parameters */
bone->roll1 = 0.0f;
bone->roll2 = 0.0f;
bone->curveInX = 0.0f;
bone->curveInY = 0.0f;
bone->curveOutX = 0.0f;
bone->curveOutY = 0.0f;
bone->ease1 = 1.0f;
bone->ease2 = 1.0f;
bone->scaleIn = 1.0f;
bone->scaleOut = 1.0f;

View File

@ -355,6 +355,8 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
pchan->roll1 = chan->roll1;
pchan->roll2 = chan->roll2;
pchan->ease1 = chan->ease1;
pchan->ease2 = chan->ease2;
pchan->scaleIn = chan->scaleIn;
pchan->scaleOut = chan->scaleOut;
@ -577,6 +579,8 @@ static void pchan_clear_scale(bPoseChannel *pchan)
if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0)
pchan->size[2] = 1.0f;
pchan->ease1 = 0.0f;
pchan->ease2 = 0.0f;
pchan->scaleIn = 1.0f;
pchan->scaleOut = 1.0f;
}
@ -735,7 +739,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
/* clear any unkeyed tags */
if (pchan->bone)
pchan->bone->flag &= ~BONE_UNKEYED;
/* tag for autokeying later */
autokey = 1;
}

View File

@ -114,6 +114,8 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
pfl->curveInY = pchan->curveInY;
pfl->curveOutX = pchan->curveOutX;
pfl->curveOutY = pchan->curveOutY;
pfl->ease1 = pchan->ease1;
pfl->ease2 = pchan->ease2;
pfl->scaleIn = pchan->scaleIn;
pfl->scaleOut = pchan->scaleOut;
@ -219,6 +221,8 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
pchan->curveInY = pfl->curveInY;
pchan->curveOutX = pfl->curveOutX;
pchan->curveOutY = pfl->curveOutY;
pchan->ease1 = pfl->ease1;
pchan->ease2 = pfl->ease2;
pchan->scaleIn = pfl->scaleIn;
pchan->scaleOut = pfl->scaleOut;

View File

@ -72,12 +72,15 @@ typedef struct EditBone {
float dist, weight;
float xwidth, length, zwidth; /* put them in order! transform uses this as scale */
float ease1, ease2;
float rad_head, rad_tail;
/* Bendy-Bone parameters */
float roll1, roll2;
float curveOutX, curveOutY;
float curveInX, curveInY;
float ease1, ease2;
float scaleIn, scaleOut;
float oldlength; /* for envelope scaling */
short segments;

View File

@ -254,6 +254,7 @@ typedef struct bPoseChannel {
float roll1, roll2;
float curveInX, curveInY;
float curveOutX, curveOutY;
float ease1, ease2;
float scaleIn, scaleOut;
struct bPoseChannel *bbone_prev; /* next/prev bones to use as handle references when calculating bbones (optional) */

View File

@ -66,12 +66,12 @@ typedef struct Bone {
float dist, weight; /* dist, weight: for non-deformgroup deforms */
float xwidth, length, zwidth; /* width: for block bones. keep in this order, transform! */
float ease1, ease2; /* length of bezier handles */
float rad_head, rad_tail; /* radius for head/tail sphere, defining deform as well, parent->rad_tip overrides rad_head */
float roll1, roll2; /* curved bones settings - these define the "restpose" for a curved bone */
float curveInX, curveInY;
float curveOutX, curveOutY;
float ease1, ease2; /* length of bezier handles */
float scaleIn, scaleOut;
float size[3]; /* patch for upward compat, UNUSED! */

View File

@ -542,7 +542,22 @@ void rna_def_bone_curved_common(StructRNA *srna, bool is_posebone)
RNA_def_property_range(prop, -5.0f, 5.0f);
RNA_def_property_ui_text(prop, "Out Y", "Y-axis handle offset for end of the B-Bone's curve, adjusts curvature");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
/* Ease In/Out */
prop = RNA_def_property(srna, "bbone_easein", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ease1");
RNA_def_property_range(prop, -5.0f, 5.0f);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "B-Bone Ease In", "Length of first Bezier Handle (for B-Bones only)");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
prop = RNA_def_property(srna, "bbone_easeout", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ease2");
RNA_def_property_range(prop, -5.0f, 5.0f);
RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "B-Bone Ease Out", "Length of second Bezier Handle (for B-Bones only)");
RNA_DEF_CURVEBONE_UPDATE(prop, is_posebone);
/* Scale In/Out */
prop = RNA_def_property(srna, "bbone_scalein", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "scaleIn");
@ -680,18 +695,6 @@ static void rna_def_bone_common(StructRNA *srna, int editbone)
RNA_def_property_ui_text(prop, "B-Bone Segments", "Number of subdivisions of bone (for B-Bones only)");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop = RNA_def_property(srna, "bbone_in", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ease1");
RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_ui_text(prop, "B-Bone Ease In", "Length of first Bezier Handle (for B-Bones only)");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop = RNA_def_property(srna, "bbone_out", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "ease2");
RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_ui_text(prop, "B-Bone Ease Out", "Length of second Bezier Handle (for B-Bones only)");
RNA_def_property_update(prop, 0, "rna_Armature_update_data");
prop = RNA_def_property(srna, "bbone_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "xwidth");
RNA_def_property_range(prop, 0.0f, 1000.0f);