Commit: 5b45434be4ff8c6e0d1107b11e67d7d50afe3ca8
Author: Campbell Barton
Date:   Wed Nov 21 11:31:37 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB5b45434be4ff8c6e0d1107b11e67d7d50afe3ca8

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.

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

M       source/blender/editors/transform/transform_orientations.c

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

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) {

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to