Commit: 2e0a33745dbf7d70e313bf3cb9a3c413ed66f3b9
Author: Bastien Montagne
Date:   Fri Feb 28 10:35:11 2014 +0100
https://developer.blender.org/rB2e0a33745dbf7d70e313bf3cb9a3c413ed66f3b9

Revert editbone roll correction changes.

This reverts commit f72acc38d 65c5be967 eff6b385e 3fe487217

===================================================================

M       source/blender/editors/include/ED_armature.h
M       source/blender/editors/transform/transform.h
M       source/blender/editors/transform/transform_conversions.c
M       source/blender/editors/transform/transform_generics.c

===================================================================

diff --git a/source/blender/editors/include/ED_armature.h 
b/source/blender/editors/include/ED_armature.h
index b78fa4f..dea4b24 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -59,10 +59,7 @@ typedef struct EditBone {
        struct EditBone *parent; /* Editbones have a one-way link  (i.e. 
children refer
                                  * to parents.  This is converted to a two-way 
link for
                                  * normal bones when leaving editmode. */
-       union {                  /* Used to store temporary data */
-               void    *temp;
-               float    temp_f;
-       };
+       void    *temp;          /* Used to store temporary data */
 
        char    name[64];       /* MAXBONENAME */
        float   roll;           /* Roll along axis.  We'll ultimately use the 
axis/angle method
diff --git a/source/blender/editors/transform/transform.h 
b/source/blender/editors/transform/transform.h
index d1085cf..5cac49a 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 91bac74..3112382 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 4e93d3a..af4beff 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);
                                                }
                                        }
                                }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to