Revert editbone roll correction changes.
This reverts commitf72acc38d65c5be967eff6b385e3fe487217
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user