[Bf-blender-cvs] [812205f936c] blender2.8: UI: unhide bones in Jump To Target instead of failing.

Alexander Gavrilov noreply at git.blender.org
Tue Nov 20 08:25:38 CET 2018


Commit: 812205f936cb5f78bfa611d7e15c621795ba0f15
Author: Alexander Gavrilov
Date:   Tue Nov 20 10:24:18 2018 +0300
Branches: blender2.8
https://developer.blender.org/rB812205f936cb5f78bfa611d7e15c621795ba0f15

UI: unhide bones in Jump To Target instead of failing.

The whole point is to avoid the need to manually hunt for the
bone, so it makes more sense to unhide it automatically.

If the bone is on multiple layers, just the first one is enabled.

Also, ED_pose_bone_select already checks PBONE_SELECTABLE.

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

M	source/blender/editors/object/object_select.c

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

diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 25c2c61eb0a..366cca9fe0d 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -44,6 +44,7 @@
 #include "DNA_gpencil_types.h"
 
 #include "BLI_math.h"
+#include "BLI_math_bits.h"
 #include "BLI_listbase.h"
 #include "BLI_rand.h"
 #include "BLI_string_utils.h"
@@ -284,6 +285,7 @@ bool ED_object_jump_to_object(bContext *C, Object *ob)
 /**
  * Select and make the target object and bone active.
  * Switches to Pose mode if in Object mode so the selection is visible.
+ * Unhides the target bone and bone layer if necessary.
  *
  * \returns false if object not in layer, bone not found, or other error
  */
@@ -314,6 +316,14 @@ bool ED_object_jump_to_bone(bContext *C, Object *ob, const char *bone_name)
 		/* In Edit mode select and activate the target Edit-Bone. */
 		EditBone *ebone = ED_armature_ebone_find_name(arm->edbo, bone_name);
 		if (ebone != NULL) {
+			/* Unhide the bone. */
+			ebone->flag &= ~BONE_HIDDEN_A;
+
+			if ((arm->layer & ebone->layer) == 0) {
+				arm->layer |= 1U << bitscan_forward_uint(ebone->layer);
+			}
+
+			/* Select it. */
 			ED_armature_edit_deselect_all(ob);
 
 			if (EBONE_SELECTABLE(arm, ebone)) {
@@ -321,9 +331,7 @@ bool ED_object_jump_to_bone(bContext *C, Object *ob, const char *bone_name)
 				ED_armature_edit_sync_selection(arm->edbo);
 			}
 
-			if (EBONE_VISIBLE(arm, ebone)) {
-				arm->act_edbone = ebone;
-			}
+			arm->act_edbone = ebone;
 
 			ED_pose_bone_select_tag_update(ob);
 			return true;
@@ -333,15 +341,18 @@ bool ED_object_jump_to_bone(bContext *C, Object *ob, const char *bone_name)
 		/* In Pose mode select and activate the target Bone/Pose-Channel. */
 		bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
 		if (pchan != NULL) {
-			ED_pose_deselect_all(ob, SEL_DESELECT, true);
+			/* Unhide the bone. */
+			pchan->bone->flag &= ~BONE_HIDDEN_P;
 
-			if (PBONE_SELECTABLE(arm, pchan->bone)) {
-				ED_pose_bone_select(ob, pchan, true);
+			if ((arm->layer & pchan->bone->layer) == 0) {
+				arm->layer |= 1U << bitscan_forward_uint(pchan->bone->layer);
 			}
 
-			if (PBONE_VISIBLE(arm, pchan->bone)) {
-				arm->act_bone = pchan->bone;
-			}
+			/* Select it. */
+			ED_pose_deselect_all(ob, SEL_DESELECT, true);
+			ED_pose_bone_select(ob, pchan, true);
+
+			arm->act_bone = pchan->bone;
 
 			ED_pose_bone_select_tag_update(ob);
 			return true;



More information about the Bf-blender-cvs mailing list