diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2020-12-11 19:17:39 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2021-06-18 18:56:03 +0300 |
commit | 682a74e0909ba4e669a3f282b3bc5da0ae81e4da (patch) | |
tree | 85aecf8652ddc680973a8cf9eed3a5b60b8a36d7 /source/blender/editors/armature | |
parent | aee04d496035c2b11b640a91b2e7eca86e878cf2 (diff) |
Armature: add B-Bone Y scale channel and extra flag fields to DNA.
In addition to the base bone transformation itself, B-Bones have
controls that affect transformation of its segments. For rotation
the features are quite complete, allowing to both reorient the
Bezier handles via properties, and to control them using custom
handle bones. However for scaling there are two deficiencies.
First, there are only X and Y scale factors (actually X and Z),
while lengthwise all segments have the same scaling. The ease
option merely affects the shape of the curve, and does not cause
actual scaling.
Second, scaling can only be controlled via properties, thus
requiring up to 6 drivers per joint between B-Bones to transfer
scaling factors from the handle bone. This is very inefficient.
Finally, the Z channels are confusingly called Y.
This commit adds a B-Bone Y Scale channel and extra B-Bone flag
fields to DNA with appropriate versioning (including for F-Curves
and drivers) in preparation to addressing these limitations.
Functionality is not changed, so the new fields are not used
until the following commits.
Differential Revision: https://developer.blender.org/D9870
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r-- | source/blender/editors/armature/armature_add.c | 26 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_intern.h | 8 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_utils.c | 39 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_transform.c | 37 | ||||
-rw-r--r-- | source/blender/editors/armature/pose_utils.c | 22 |
5 files changed, 67 insertions, 65 deletions
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index 3902f6613a1..1d4936bdf5e 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -89,15 +89,14 @@ EditBone *ED_armature_ebone_add(bArmature *arm, const char *name) bone->roll1 = 0.0f; bone->roll2 = 0.0f; bone->curve_in_x = 0.0f; - bone->curve_in_y = 0.0f; + bone->curve_in_z = 0.0f; bone->curve_out_x = 0.0f; - bone->curve_out_y = 0.0f; + bone->curve_out_z = 0.0f; bone->ease1 = 1.0f; bone->ease2 = 1.0f; - bone->scale_in_x = 1.0f; - bone->scale_in_y = 1.0f; - bone->scale_out_x = 1.0f; - bone->scale_out_y = 1.0f; + + copy_v3_fl(bone->scale_in, 1.0f); + copy_v3_fl(bone->scale_out, 1.0f); return bone; } @@ -1265,6 +1264,10 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) ebone->bbone_prev_type = ebone_iter->bbone_prev_type; ebone->bbone_next_type = ebone_iter->bbone_next_type; + ebone->bbone_flag = ebone_iter->bbone_flag; + ebone->bbone_prev_flag = ebone_iter->bbone_prev_flag; + ebone->bbone_next_flag = ebone_iter->bbone_next_flag; + /* Lets try to fix any constraint subtargets that might * have been duplicated */ @@ -1464,15 +1467,14 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) newbone->roll1 = ebone->roll1; newbone->roll2 = ebone->roll2; newbone->curve_in_x = ebone->curve_in_x; - newbone->curve_in_y = ebone->curve_in_y; + newbone->curve_in_z = ebone->curve_in_z; newbone->curve_out_x = ebone->curve_out_x; - newbone->curve_out_y = ebone->curve_out_y; + newbone->curve_out_z = ebone->curve_out_z; newbone->ease1 = ebone->ease1; newbone->ease2 = ebone->ease2; - newbone->scale_in_x = ebone->scale_in_x; - newbone->scale_in_y = ebone->scale_in_y; - newbone->scale_out_x = ebone->scale_out_x; - newbone->scale_out_y = ebone->scale_out_y; + + copy_v3_v3(newbone->scale_in, ebone->scale_in); + copy_v3_v3(newbone->scale_out, ebone->scale_out); BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name)); diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 4fff2ae03b0..d429e51061b 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -161,11 +161,11 @@ typedef struct tPChanFCurveLink { /** old bbone values (to be restored along with the transform properties) */ float roll1, roll2; /** (NOTE: we haven't renamed these this time, as their names are already long enough) */ - float curve_in_x, curve_in_y; - float curve_out_x, curve_out_y; + float curve_in_x, curve_in_z; + float curve_out_x, curve_out_z; float ease1, ease2; - float scale_in_x, scale_in_y; - float scale_out_x, scale_out_y; + float scale_in[3]; + float scale_out[3]; /** copy of custom properties at start of operator (to be restored before each modal step) */ struct IDProperty *oldprops; diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 3d1d8d0d1f1..ffcdb99c5a3 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -414,9 +414,8 @@ void ED_armature_ebone_transform_mirror_update(bArmature *arm, EditBone *ebo, bo eboflip->tail[2] = ebo->tail[2]; eboflip->rad_tail = ebo->rad_tail; eboflip->curve_out_x = -ebo->curve_out_x; - eboflip->curve_out_y = ebo->curve_out_y; - eboflip->scale_out_x = ebo->scale_out_x; - eboflip->scale_out_y = ebo->scale_out_y; + eboflip->curve_out_z = ebo->curve_out_z; + copy_v3_v3(eboflip->scale_out, ebo->scale_out); eboflip->ease2 = ebo->ease2; eboflip->roll2 = -ebo->roll2; @@ -438,9 +437,8 @@ void ED_armature_ebone_transform_mirror_update(bArmature *arm, EditBone *ebo, bo eboflip->rad_head = ebo->rad_head; eboflip->curve_in_x = -ebo->curve_in_x; - eboflip->curve_in_y = ebo->curve_in_y; - eboflip->scale_in_x = ebo->scale_in_x; - eboflip->scale_in_y = ebo->scale_in_y; + eboflip->curve_in_z = ebo->curve_in_z; + copy_v3_v3(eboflip->scale_in, ebo->scale_in); eboflip->ease1 = ebo->ease1; eboflip->roll1 = -ebo->roll1; @@ -542,19 +540,22 @@ static EditBone *make_boneList_recursive(ListBase *edbo, eBone->roll1 = curBone->roll1; eBone->roll2 = curBone->roll2; eBone->curve_in_x = curBone->curve_in_x; - eBone->curve_in_y = curBone->curve_in_y; + eBone->curve_in_z = curBone->curve_in_z; eBone->curve_out_x = curBone->curve_out_x; - eBone->curve_out_y = curBone->curve_out_y; + eBone->curve_out_z = curBone->curve_out_z; eBone->ease1 = curBone->ease1; eBone->ease2 = curBone->ease2; - eBone->scale_in_x = curBone->scale_in_x; - eBone->scale_in_y = curBone->scale_in_y; - eBone->scale_out_x = curBone->scale_out_x; - eBone->scale_out_y = curBone->scale_out_y; + + copy_v3_v3(eBone->scale_in, curBone->scale_in); + copy_v3_v3(eBone->scale_out, curBone->scale_out); eBone->bbone_prev_type = curBone->bbone_prev_type; eBone->bbone_next_type = curBone->bbone_next_type; + eBone->bbone_flag = curBone->bbone_flag; + eBone->bbone_prev_flag = curBone->bbone_prev_flag; + eBone->bbone_next_flag = curBone->bbone_next_flag; + if (curBone->prop) { eBone->prop = IDP_CopyProperty(curBone->prop); } @@ -757,19 +758,21 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm) newBone->roll1 = eBone->roll1; newBone->roll2 = eBone->roll2; newBone->curve_in_x = eBone->curve_in_x; - newBone->curve_in_y = eBone->curve_in_y; + newBone->curve_in_z = eBone->curve_in_z; newBone->curve_out_x = eBone->curve_out_x; - newBone->curve_out_y = eBone->curve_out_y; + newBone->curve_out_z = eBone->curve_out_z; newBone->ease1 = eBone->ease1; newBone->ease2 = eBone->ease2; - newBone->scale_in_x = eBone->scale_in_x; - newBone->scale_in_y = eBone->scale_in_y; - newBone->scale_out_x = eBone->scale_out_x; - newBone->scale_out_y = eBone->scale_out_y; + copy_v3_v3(newBone->scale_in, eBone->scale_in); + copy_v3_v3(newBone->scale_out, eBone->scale_out); newBone->bbone_prev_type = eBone->bbone_prev_type; newBone->bbone_next_type = eBone->bbone_next_type; + newBone->bbone_flag = eBone->bbone_flag; + newBone->bbone_prev_flag = eBone->bbone_prev_flag; + newBone->bbone_next_flag = eBone->bbone_next_flag; + if (eBone->prop) { newBone->prop = IDP_CopyProperty(eBone->prop); } diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 43ab20eb71c..6466773daac 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -144,26 +144,25 @@ static void applyarmature_transfer_properties(EditBone *curbone, if (pchan->bone->segments > 1) { /* Combine rest/pose values. */ curbone->curve_in_x += pchan_eval->curve_in_x; - curbone->curve_in_y += pchan_eval->curve_in_y; + curbone->curve_in_z += pchan_eval->curve_in_z; curbone->curve_out_x += pchan_eval->curve_out_x; - curbone->curve_out_y += pchan_eval->curve_out_y; + curbone->curve_out_z += pchan_eval->curve_out_z; curbone->roll1 += pchan_eval->roll1; curbone->roll2 += pchan_eval->roll2; curbone->ease1 += pchan_eval->ease1; curbone->ease2 += pchan_eval->ease2; - curbone->scale_in_x *= pchan_eval->scale_in_x; - curbone->scale_in_y *= pchan_eval->scale_in_y; - curbone->scale_out_x *= pchan_eval->scale_out_x; - curbone->scale_out_y *= pchan_eval->scale_out_y; + mul_v3_v3(curbone->scale_in, pchan_eval->scale_in); + mul_v3_v3(curbone->scale_out, pchan_eval->scale_out); /* Reset pose values. */ pchan->curve_in_x = pchan->curve_out_x = 0.0f; - pchan->curve_in_y = pchan->curve_out_y = 0.0f; + pchan->curve_in_z = pchan->curve_out_z = 0.0f; pchan->roll1 = pchan->roll2 = 0.0f; pchan->ease1 = pchan->ease2 = 0.0f; - pchan->scale_in_x = pchan->scale_in_y = 1.0f; - pchan->scale_out_x = pchan->scale_out_y = 1.0f; + + copy_v3_fl(pchan->scale_in, 1.0f); + copy_v3_fl(pchan->scale_out, 1.0f); } /* Clear transform values for pchan. */ @@ -699,18 +698,17 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, /* B-Bone posing options should also be included... */ pchan->curve_in_x = chan->curve_in_x; - pchan->curve_in_y = chan->curve_in_y; + pchan->curve_in_z = chan->curve_in_z; pchan->curve_out_x = chan->curve_out_x; - pchan->curve_out_y = chan->curve_out_y; + pchan->curve_out_z = chan->curve_out_z; pchan->roll1 = chan->roll1; pchan->roll2 = chan->roll2; pchan->ease1 = chan->ease1; pchan->ease2 = chan->ease2; - pchan->scale_in_x = chan->scale_in_x; - pchan->scale_in_y = chan->scale_in_y; - pchan->scale_out_x = chan->scale_out_x; - pchan->scale_out_y = chan->scale_out_y; + + copy_v3_v3(pchan->scale_in, chan->scale_in); + copy_v3_v3(pchan->scale_out, chan->scale_out); /* paste flipped pose? */ if (flip) { @@ -972,8 +970,9 @@ static void pchan_clear_scale(bPoseChannel *pchan) pchan->ease1 = 0.0f; pchan->ease2 = 0.0f; - pchan->scale_in_x = pchan->scale_in_y = 1.0f; - pchan->scale_out_x = pchan->scale_out_y = 1.0f; + + copy_v3_fl(pchan->scale_in, 1.0f); + copy_v3_fl(pchan->scale_out, 1.0f); } /* Clear the scale. When X-mirror is enabled, * also clear the scale of the mirrored pose channel. */ @@ -1136,9 +1135,9 @@ static void pchan_clear_rot(bPoseChannel *pchan) pchan->roll2 = 0.0f; pchan->curve_in_x = 0.0f; - pchan->curve_in_y = 0.0f; + pchan->curve_in_z = 0.0f; pchan->curve_out_x = 0.0f; - pchan->curve_out_y = 0.0f; + pchan->curve_out_z = 0.0f; } /* Clear the rotation. When X-mirror is enabled, * also clear the rotation of the mirrored pose channel. */ diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c index 75348c2b196..8eae5288f7a 100644 --- a/source/blender/editors/armature/pose_utils.c +++ b/source/blender/editors/armature/pose_utils.c @@ -116,15 +116,14 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, pfl->roll1 = pchan->roll1; pfl->roll2 = pchan->roll2; pfl->curve_in_x = pchan->curve_in_x; - pfl->curve_in_y = pchan->curve_in_y; + pfl->curve_in_z = pchan->curve_in_z; pfl->curve_out_x = pchan->curve_out_x; - pfl->curve_out_y = pchan->curve_out_y; + pfl->curve_out_z = pchan->curve_out_z; pfl->ease1 = pchan->ease1; pfl->ease2 = pchan->ease2; - pfl->scale_in_x = pchan->scale_in_x; - pfl->scale_in_y = pchan->scale_in_y; - pfl->scale_out_x = pchan->scale_out_x; - pfl->scale_out_y = pchan->scale_out_y; + + copy_v3_v3(pfl->scale_in, pchan->scale_in); + copy_v3_v3(pfl->scale_out, pchan->scale_out); /* make copy of custom properties */ if (pchan->prop && (transFlags & ACT_TRANS_PROP)) { @@ -251,15 +250,14 @@ void poseAnim_mapping_reset(ListBase *pfLinks) pchan->roll1 = pfl->roll1; pchan->roll2 = pfl->roll2; pchan->curve_in_x = pfl->curve_in_x; - pchan->curve_in_y = pfl->curve_in_y; + pchan->curve_in_z = pfl->curve_in_z; pchan->curve_out_x = pfl->curve_out_x; - pchan->curve_out_y = pfl->curve_out_y; + pchan->curve_out_z = pfl->curve_out_z; pchan->ease1 = pfl->ease1; pchan->ease2 = pfl->ease2; - pchan->scale_in_x = pfl->scale_in_x; - pchan->scale_in_y = pfl->scale_in_y; - pchan->scale_out_x = pfl->scale_out_x; - pchan->scale_out_y = pfl->scale_out_y; + + copy_v3_v3(pchan->scale_in, pfl->scale_in); + copy_v3_v3(pchan->scale_out, pfl->scale_out); /* just overwrite values of properties from the stored copies (there should be some) */ if (pfl->oldprops) { |