diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-02-28 13:35:11 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-02-28 13:35:11 +0400 |
commit | 2e0a33745dbf7d70e313bf3cb9a3c413ed66f3b9 (patch) | |
tree | ed767c3483cf83f74925e7a715398cce8c491862 /source/blender/editors/transform | |
parent | 5ac1b38b4b21959b552c0787e2f86a104624c615 (diff) |
Revert editbone roll correction changes.
This reverts commit f72acc38d 65c5be967 eff6b385e 3fe487217
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform.h | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 27 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 43 |
3 files changed, 26 insertions, 46 deletions
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index d1085cf9933..5cac49aff34 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -257,7 +257,7 @@ typedef struct TransData { float *loc; /* Location of the data to transform */ float iloc[3]; /* Initial location */ float *val; /* Value pointer for special transforms */ - float ival; /* Old value */ + float ival; /* Old value*/ float center[3]; /* Individual data center */ float mtx[3][3]; /* Transformation matrix from data space to global space */ float smtx[3][3]; /* Transformation matrix from global space to data space */ diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 91bac74e8e6..31123827c4c 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1061,27 +1061,6 @@ 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. */ - ebo->temp_f = ebo->roll; - } - else { - ebo->temp_f = ebo->roll - ED_rollBoneToVector(ebo, z_axis, false); - } - td->ival = ebo->roll; -} - static void createTransArmatureVerts(TransInfo *t) { EditBone *ebo; @@ -1217,7 +1196,8 @@ static void createTransArmatureVerts(TransInfo *t) ED_armature_ebone_to_mat3(ebo, td->axismtx); if ((ebo->flag & BONE_ROOTSEL) == 0) { - createTransArmatureVerts_init_roll_fix(td, ebo); + td->extra = ebo; + td->ival = ebo->roll; } td->ext = NULL; @@ -1239,7 +1219,8 @@ static void createTransArmatureVerts(TransInfo *t) ED_armature_ebone_to_mat3(ebo, td->axismtx); - createTransArmatureVerts_init_roll_fix(td, ebo); + td->extra = ebo; /* to fix roll */ + td->ival = ebo->roll; td->ext = NULL; td->val = NULL; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 4e93d3a89a3..af4beff4bc9 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -798,35 +798,34 @@ static void recalcData_objects(TransInfo *t) if (!ELEM3(t->mode, TFM_BONE_ROLL, TFM_BONE_ENVELOPE, TFM_BONESIZE)) { /* fix roll */ - /* Previous method basically tried to get a rotation transform from org ebo Y axis to final ebo Y axis, - * apply this same rotation to org ebo Z axis to get an "up_axis", and compute a new roll value - * so that final ebo's Z axis would be "aligned" with that up_axis. - * There are two issues with that method: - * - There are many cases where the computed up_axis does not gives a result people would expect. - * - Applying a same transform in a single step or in several smaller ones would not give the same - * result! See e.g. T38407. - * Now, instead of trying to be smart with complex axis/angle handling, just store diff roll - * (diff between real init roll and virtual init roll where bone's Z axis would be "aligned" with - * 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]; - + float vec[3], up_axis[3]; + float qrot[4]; + float roll; + ebo = td->extra; - 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. */ + if (t->state == TRANS_CANCEL) { + /* restore roll */ ebo->roll = td->ival; } else { - ebo->roll = ebo->temp_f + ED_rollBoneToVector(ebo, z_axis, false); + copy_v3_v3(up_axis, td->axismtx[2]); + + if (t->mode != TFM_ROTATION) { + sub_v3_v3v3(vec, ebo->tail, ebo->head); + normalize_v3(vec); + rotation_between_vecs_to_quat(qrot, td->axismtx[1], vec); + mul_qt_v3(qrot, up_axis); + } + else { + mul_m3_v3(t->mat, up_axis); + } + + /* roll has a tendency to flip in certain orientations - [#34283], [#33974] */ + roll = ED_rollBoneToVector(ebo, up_axis, false); + ebo->roll = angle_compat_rad(roll, td->ival); } } } |