Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-11-20 10:24:18 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-11-20 10:24:33 +0300
commit812205f936cb5f78bfa611d7e15c621795ba0f15 (patch)
treed7efd899214366d41582f92b3557ec0f8f86d553 /source/blender/editors/object/object_select.c
parent1edc3f74ed4637ff620e8c0fef47de5be259b227 (diff)
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.
Diffstat (limited to 'source/blender/editors/object/object_select.c')
-rw-r--r--source/blender/editors/object/object_select.c29
1 files changed, 20 insertions, 9 deletions
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;