diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-21 03:31:37 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-21 03:32:08 +0300 |
commit | 5b45434be4ff8c6e0d1107b11e67d7d50afe3ca8 (patch) | |
tree | 6c8b60458b912f3eb2ee79dd691fcbf535f58f70 /source/blender/editors/transform | |
parent | d433e9de5cb66148344c965ff62abd9f22f0a0e7 (diff) |
Transform: use root/tip for bone normal orientation
When there are no fully selected bones,
use the normal of bones which only have the root/tip selected as a
fallback.
Without this, the extrude gizmo isn't very useful
since extrude is often used with only the tip selected.
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform_orientations.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 447842e9bf0..b8b3929f9b0 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -976,6 +976,14 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 ok = true; } else { + /* When we only have the root/tip are selected. */ + bool fallback_ok = false; + float fallback_normal[3]; + float fallback_plane[3]; + + zero_v3(fallback_normal); + zero_v3(fallback_plane); + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (arm->layer & ebone->layer) { if (ebone->flag & BONE_SELECTED) { @@ -984,8 +992,19 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 add_v3_v3(plane, tmat[1]); ok = true; } + else if ((ok == false) && (ebone->flag & (BONE_ROOTSEL | BONE_TIPSEL))) { + ED_armature_ebone_to_mat3(ebone, tmat); + add_v3_v3(fallback_normal, tmat[2]); + add_v3_v3(fallback_plane, tmat[1]); + fallback_ok = true; + } } } + if ((ok == false) && fallback_ok) { + ok = true; + copy_v3_v3(normal, fallback_normal); + copy_v3_v3(plane, fallback_plane); + } } if (ok) { |