Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_generics.c
| Show First 20 Lines • Show All 804 Lines • ▼ Show 20 Lines | else if (t->obedit->type == OB_ARMATURE) { /* no recalc flag, does pose */ | ||||
| * - There are many cases where the computed up_axis does not gives a result people would expect. | * - 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 | * - Applying a same transform in a single step or in several smaller ones would not give the same | ||||
| * result! See e.g. T38407. | * result! See e.g. T38407. | ||||
| * Now, instead of trying to be smart with complex axis/angle handling, just store diff roll | * 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 | * (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. | * 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" | * This method at least gives predictable, consistent results (the bone basically keeps "facing" | ||||
| * the armature's Z axis). | * the armature's Z axis). | ||||
| * Note we need some special handling when bone is Z-aligned... sigh. | * Note that if we are too much aligned with Z axis at start, then we use X axis as ref instead. | ||||
| */ | */ | ||||
| for (i = 0; i < t->total; i++, td++) { | for (i = 0; i < t->total; i++, td++) { | ||||
| if (td->extra) { | if (td->extra) { | ||||
| const float x_axis[3] = {1.0f, 0.0f, 0.0f}; | |||||
| const float z_axis[3] = {0.0f, 0.0f, 1.0f}; | const float z_axis[3] = {0.0f, 0.0f, 1.0f}; | ||||
| float vec[3]; | float vec[3]; | ||||
| ebo = td->extra; | ebo = td->extra; | ||||
| if (t->state == TRANS_CANCEL) { | |||||
| ebo->roll = td->ival; | |||||
| } | |||||
| else { | |||||
| sub_v3_v3v3(vec, ebo->tail, ebo->head); | sub_v3_v3v3(vec, ebo->tail, ebo->head); | ||||
| normalize_v3(vec); | normalize_v3(vec); | ||||
| if (fabsf(dot_v3v3(vec, z_axis)) > 0.999999f) { | if (ebo->temp_i) { | ||||
| /* If our bone is Z-aligned, do not alter roll. See T38843. */ | /* Reference roll stored relative to X axis. */ | ||||
| ebo->roll = td->ival; | ebo->roll = ebo->temp_f + ED_rollBoneToVector(ebo, x_axis, false); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Reference roll stored relative to Z axis. */ | |||||
| ebo->roll = ebo->temp_f + ED_rollBoneToVector(ebo, z_axis, false); | ebo->roll = ebo->temp_f + ED_rollBoneToVector(ebo, z_axis, false); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| if (arm->flag & ARM_MIRROR_EDIT) | if (arm->flag & ARM_MIRROR_EDIT) | ||||
| transform_armature_mirror_update(t->obedit); | transform_armature_mirror_update(t->obedit); | ||||
| } | } | ||||
| else { | else { | ||||
| if (t->state != TRANS_CANCEL) { | if (t->state != TRANS_CANCEL) { | ||||
| applyProject(t); | applyProject(t); | ||||
| ▲ Show 20 Lines • Show All 1,042 Lines • Show Last 20 Lines | |||||