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:
authorAlexander Gavrilov <angavrilov@gmail.com>2021-06-15 13:51:19 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2021-06-18 18:56:04 +0300
commitb6030711a24f154de9c1c7287cf91d3cde3721c8 (patch)
treec40bde218083bb8134a50da182224487fdf4866b /source/blender/blenkernel/intern/armature.c
parent638c16f41010d716a3ee47017eb0155044dd825a (diff)
Armature: add automatic B-Bone Scale toggles.
Currently B-Bone scaling can only be controlled via their properties, thus requiring up to 8 drivers per joint between B-Bones to transfer scaling factors from the handle bone. A Scale Easing option is added to multiply the easing value by the Y scale channels to synchronize them - this produces a natural scaling effect where both the shape of the curve and the scale is affected. In addition, four toggles are added for each handle, which multiply each of the X, Y, Z and Ease values by the matching Local Scale channel of the handle bone, thus replacing trivial drivers. The Scale Easing option has no effect on this process since it's easy to just enable both Length and Ease buttons. Differential Revision: https://developer.blender.org/D9870
Diffstat (limited to 'source/blender/blenkernel/intern/armature.c')
-rw-r--r--source/blender/blenkernel/intern/armature.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 93ad6f37233..2cd089545e8 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -959,7 +959,7 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan,
{
bPoseChannel *next, *prev;
Bone *bone = pchan->bone;
- float imat[4][4], posemat[4][4];
+ float imat[4][4], posemat[4][4], tmpmat[4][4];
float delta[3];
memset(param, 0, sizeof(*param));
@@ -996,6 +996,11 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan,
invert_m4_m4(imat, pchan->pose_mat);
}
+ float prev_scale[3], next_scale[3];
+
+ copy_v3_fl(prev_scale, 1.0f);
+ copy_v3_fl(next_scale, 1.0f);
+
if (prev) {
float h1[3];
bool done = false;
@@ -1041,6 +1046,12 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan,
if (!param->prev_bbone) {
/* Find the previous roll to interpolate. */
mul_m4_m4m4(param->prev_mat, imat, rest ? prev->bone->arm_mat : prev->pose_mat);
+
+ /* Retrieve the local scale of the bone if necessary. */
+ if ((bone->bbone_prev_flag & BBONE_HANDLE_SCALE_ANY) && !rest) {
+ BKE_armature_mat_pose_to_bone(prev, prev->pose_mat, tmpmat);
+ mat4_to_size(prev_scale, tmpmat);
+ }
}
}
@@ -1088,6 +1099,12 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan,
/* Find the next roll to interpolate as well. */
mul_m4_m4m4(param->next_mat, imat, rest ? next->bone->arm_mat : next->pose_mat);
+
+ /* Retrieve the local scale of the bone if necessary. */
+ if ((bone->bbone_next_flag & BBONE_HANDLE_SCALE_ANY) && !rest) {
+ BKE_armature_mat_pose_to_bone(next, next->pose_mat, tmpmat);
+ mat4_to_size(next_scale, tmpmat);
+ }
}
/* Add effects from bbone properties over the top
@@ -1137,6 +1154,47 @@ void BKE_pchan_bbone_spline_params_get(struct bPoseChannel *pchan,
param->curve_out_x = bone->curve_out_x + (!rest ? pchan->curve_out_x : 0.0f);
param->curve_out_z = bone->curve_out_z + (!rest ? pchan->curve_out_z : 0.0f);
+
+ if (bone->bbone_flag & BBONE_SCALE_EASING) {
+ param->ease1 *= param->scale_in[1];
+ param->curve_in_x *= param->scale_in[1];
+ param->curve_in_z *= param->scale_in[1];
+
+ param->ease2 *= param->scale_out[1];
+ param->curve_out_x *= param->scale_out[1];
+ param->curve_out_z *= param->scale_out[1];
+ }
+
+ /* Custom handle scale. */
+ if (bone->bbone_prev_flag & BBONE_HANDLE_SCALE_X) {
+ param->scale_in[0] *= prev_scale[0];
+ }
+ if (bone->bbone_prev_flag & BBONE_HANDLE_SCALE_Y) {
+ param->scale_in[1] *= prev_scale[1];
+ }
+ if (bone->bbone_prev_flag & BBONE_HANDLE_SCALE_Z) {
+ param->scale_in[2] *= prev_scale[2];
+ }
+ if (bone->bbone_prev_flag & BBONE_HANDLE_SCALE_EASE) {
+ param->ease1 *= prev_scale[1];
+ param->curve_in_x *= prev_scale[1];
+ param->curve_in_z *= prev_scale[1];
+ }
+
+ if (bone->bbone_next_flag & BBONE_HANDLE_SCALE_X) {
+ param->scale_out[0] *= next_scale[0];
+ }
+ if (bone->bbone_next_flag & BBONE_HANDLE_SCALE_Y) {
+ param->scale_out[1] *= next_scale[1];
+ }
+ if (bone->bbone_next_flag & BBONE_HANDLE_SCALE_Z) {
+ param->scale_out[2] *= next_scale[2];
+ }
+ if (bone->bbone_next_flag & BBONE_HANDLE_SCALE_EASE) {
+ param->ease2 *= next_scale[1];
+ param->curve_out_x *= next_scale[1];
+ param->curve_out_z *= next_scale[1];
+ }
}
}