From 3c0736bc4b88bd4081ab25e2bd99908fb549ded1 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 5 Oct 2018 12:35:59 +0300 Subject: [PATCH] Redefine the Relative custom B-Bone handle type to be more reasonable. Specifically, it should always use the position of the custom handle bone head, even when affecting the handle at the tail of the main bone, and shouldn't apply the special handling for joining two B-Bones. This handle type was unusably broken before a bug fix included in recent changes, so it should be safe to break backward compatibility. --- source/blender/blenkernel/intern/armature.c | 12 ++++++++---- source/blender/draw/intern/draw_armature.c | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 5ffb38414a8..91661f0a4e3 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -508,7 +508,6 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB bool done = false; param.use_prev = true; - param.prev_bbone = (prev->bone->segments > 1); /* Transform previous point inside this bone space. */ if (bone->bbone_prev_type == BBONE_HANDLE_RELATIVE) { @@ -525,6 +524,9 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB } } else { + /* Apply special handling for smoothly joining B-Bone chains */ + param.prev_bbone = (prev->bone->segments > 1); + /* Use bone head as absolute position. */ copy_v3_v3(h1, rest ? prev->bone->arm_head : prev->pose_head); } @@ -544,23 +546,25 @@ void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BB bool done = false; param.use_next = true; - param.next_bbone = (next->bone->segments > 1); /* Transform next point inside this bone space. */ if (bone->bbone_next_type == BBONE_HANDLE_RELATIVE) { /* Use delta movement (from restpose), and apply this relative to the current bone's tail. */ if (rest) { - /* In restpose, arm_tail == pose_tail */ + /* In restpose, arm_head == pose_head */ copy_v3_fl3(param.next_h, 0.0f, param.length, 0.0); done = true; } else { float delta[3]; - sub_v3_v3v3(delta, next->pose_tail, next->bone->arm_tail); + sub_v3_v3v3(delta, next->pose_head, next->bone->arm_head); add_v3_v3v3(h2, pchan->pose_tail, delta); } } else { + /* Apply special handling for smoothly joining B-Bone chains */ + param.next_bbone = (next->bone->segments > 1); + /* Use bone tail as absolute position. */ copy_v3_v3(h2, rest ? next->bone->arm_tail : next->pose_tail); } diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c index a2394a6716c..a73bddf880f 100644 --- a/source/blender/draw/intern/draw_armature.c +++ b/source/blender/draw/intern/draw_armature.c @@ -975,12 +975,13 @@ static void ebone_spline_preview(EditBone *ebone, float result_array[MAX_BBONE_S if (prev) { param.use_prev = true; - param.prev_bbone = (prev->segments > 1); if (ebone->bbone_prev_type == BBONE_HANDLE_RELATIVE) { zero_v3(param.prev_h); } else { + param.prev_bbone = (prev->segments > 1); + mul_v3_m4v3(param.prev_h, imat, prev->head); } @@ -992,12 +993,13 @@ static void ebone_spline_preview(EditBone *ebone, float result_array[MAX_BBONE_S if (next) { param.use_next = true; - param.next_bbone = (next->segments > 1); if (ebone->bbone_next_type == BBONE_HANDLE_RELATIVE) { copy_v3_fl3(param.next_h, 0.0f, param.length, 0.0); } else { + param.next_bbone = (next->segments > 1); + mul_v3_m4v3(param.next_h, imat, next->tail); }