diff options
Diffstat (limited to 'source/blender/editors/transform/transform_conversions.c')
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 14f8fa0ad71..0e2bdc11e47 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1061,6 +1061,27 @@ static void createTransPose(TransInfo *t, Object *ob) /* ********************* armature ************** */ +static void createTransArmatureVerts_init_roll_fix(TransData *td, EditBone *ebo) +{ + /* To fix roll, see comments in transform_generic.c::recalcData_objects() */ + const float z_axis[3] = {0.0f, 0.0f, 1.0f}; + float vec[3]; + + sub_v3_v3v3(vec, ebo->tail, ebo->head); + normalize_v3(vec); + + td->extra = ebo; + + if (fabsf(dot_v3v3(vec, z_axis)) > 0.999999f) { + /* If nearly aligned with Z axis, do not alter roll. See T38843. */ + td->ival = ebo->roll; + } + else { + td->ival = ebo->roll - ED_rollBoneToVector(ebo, z_axis, false); + } + td->ival2 = ebo->roll; +} + static void createTransArmatureVerts(TransInfo *t) { EditBone *ebo; @@ -1182,7 +1203,6 @@ static void createTransArmatureVerts(TransInfo *t) } } else { - const float z_axis[3] = {0.0f, 0.0f, 1.0f}; if (ebo->flag & BONE_TIPSEL) { copy_v3_v3(td->iloc, ebo->tail); copy_v3_v3(td->center, (t->around == V3D_LOCAL) ? ebo->head : td->iloc); @@ -1197,9 +1217,7 @@ static void createTransArmatureVerts(TransInfo *t) ED_armature_ebone_to_mat3(ebo, td->axismtx); if ((ebo->flag & BONE_ROOTSEL) == 0) { - /* To fix roll, see comments in transform_generic.c::recalcData_objects() */ - td->extra = ebo; - td->ival = ebo->roll - ED_rollBoneToVector(ebo, z_axis, false); + createTransArmatureVerts_init_roll_fix(td, ebo); } td->ext = NULL; @@ -1221,9 +1239,7 @@ static void createTransArmatureVerts(TransInfo *t) ED_armature_ebone_to_mat3(ebo, td->axismtx); - /* To fix roll, see comments in transform_generic.c::recalcData_objects() */ - td->extra = ebo; - td->ival = ebo->roll - ED_rollBoneToVector(ebo, z_axis, false); + createTransArmatureVerts_init_roll_fix(td, ebo); td->ext = NULL; td->val = NULL; |