From 65c5be967668e3d1fa993db644e01f159c522294 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 26 Feb 2014 21:28:11 +0100 Subject: Fix T38843: Bone parallel to world z axis flicking when scale in edit mode. This commit hopefully fixes all glitches we had when bone was Z-aligned. Note that when you init a transform with a Z-aligned bone and change it to be non-Z-aligned, you will still get some brutal roll change, there is not much things we can do here afaik... --- source/blender/editors/transform/transform_generics.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/transform/transform_generics.c') diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 5128ee3c9b6..7b4f0b8eca3 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -810,13 +810,24 @@ static void recalcData_objects(TransInfo *t) * armature's Z axis), and do the reverse to get final roll. * This method at least gives predictable, consistent results (the bone basically keeps "facing" * the armature's Z axis). + * Note we need some special handling when bone is Z-aligned... sigh. */ for (i = 0; i < t->total; i++, td++) { if (td->extra) { const float z_axis[3] = {0.0f, 0.0f, 1.0f}; + float vec[3]; ebo = td->extra; - ebo->roll = td->ival + ED_rollBoneToVector(ebo, z_axis, false); + sub_v3_v3v3(vec, ebo->tail, ebo->head); + normalize_v3(vec); + + if (fabsf(dot_v3v3(vec, z_axis)) > 0.999999f) { + /* If our bone is Z-aligned, do not alter roll. See T38843. */ + ebo->roll = td->ival2; + } + else { + ebo->roll = td->ival + ED_rollBoneToVector(ebo, z_axis, false); + } } } } -- cgit v1.2.3