diff options
Diffstat (limited to 'source/blender/editors/armature/armature_select.c')
-rw-r--r-- | source/blender/editors/armature/armature_select.c | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index ba856d4e964..a4e916b8e63 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -67,7 +67,7 @@ Bone *ED_armature_bone_find_index(Object *ob, int index) bPoseChannel *pchan; if (ob->pose == NULL) return NULL; index >>= 16; // bone selection codes use left 2 bytes - + pchan = BLI_findlink(&ob->pose->chanbase, index); return pchan ? pchan->bone : NULL; } @@ -86,21 +86,21 @@ void *get_bone_from_selectbuffer( short i; bool takeNext = false; int minsel = 0xffffffff, minunsel = 0xffffffff; - + for (i = 0; i < hits; i++) { hitresult = buffer[3 + (i * 4)]; - + if (!(hitresult & BONESEL_NOSEL)) { if (hitresult & BONESEL_ANY) { /* to avoid including objects in selection */ bool sel; - + hitresult &= ~(BONESEL_ANY); /* Determine what the current bone is */ if (obedit == NULL || base->object != obedit) { /* no singular posemode, so check for correct object */ if (base->selcol == (hitresult & 0xFFFF)) { bone = ED_armature_bone_find_index(base->object, hitresult); - + if (findunsel) sel = (bone->flag & BONE_SELECTED); else @@ -115,16 +115,16 @@ void *get_bone_from_selectbuffer( } else { bArmature *arm = obedit->data; - + ebone = BLI_findlink(arm->edbo, hitresult); if (findunsel) sel = (ebone->flag & BONE_SELECTED); else sel = !(ebone->flag & BONE_SELECTED); - + data = ebone; } - + if (data) { if (sel) { if (do_nearest) { @@ -154,10 +154,10 @@ void *get_bone_from_selectbuffer( } } } - + if (firstunSel) return firstunSel; - else + else return firstSel; } @@ -170,18 +170,18 @@ void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel) rcti rect; unsigned int buffer[MAXPICKBUF]; short hits; - + ED_view3d_viewcontext_init(C, &vc); - + // rect.xmin = ... mouseco! rect.xmin = rect.xmax = xy[0]; rect.ymin = rect.ymax = xy[1]; - + hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST); if (hits > 0) return get_bone_from_selectbuffer(vc.scene, vc.scene->basact, buffer, hits, findunsel, true); - + return NULL; } @@ -214,7 +214,7 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } } - + if (curBone->flag & BONE_CONNECTED) next = curBone->parent; else @@ -243,11 +243,11 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv if (!curBone) bone = NULL; } - + ED_armature_edit_sync_selection(arm->edbo); - + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); - + return OPERATOR_FINISHED; } @@ -262,15 +262,15 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) ot->name = "Select Connected"; ot->idname = "ARMATURE_OT_select_linked"; ot->description = "Select bones related to selected ones by parent/child relationships"; - + /* api callbacks */ /* leave 'exec' unset */ ot->invoke = armature_select_linked_invoke; ot->poll = armature_select_linked_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); } @@ -380,9 +380,9 @@ cache_end: hitresult = buffer[3 + (i * 4)]; if (!(hitresult & BONESEL_NOSEL)) { int dep; - + ebone = BLI_findlink(arm->edbo, hitresult & ~BONESEL_ANY); - + /* clicks on bone points get advantage */ if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) { /* but also the unselected one */ @@ -391,7 +391,7 @@ cache_end: dep = 1; else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0) dep = 1; - else + else dep = 2; } else { @@ -422,11 +422,11 @@ cache_end: } } } - + if (!(besthitresult & BONESEL_NOSEL)) { - + ebone = BLI_findlink(arm->edbo, besthitresult & ~BONESEL_ANY); - + *r_selmask = 0; if (besthitresult & BONESEL_ROOT) *r_selmask |= BONE_ROOTSEL; @@ -500,10 +500,10 @@ bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, b if (!extend && !deselect && !toggle) { ED_armature_edit_deselect_all(obedit); } - + /* by definition the non-root connected bones have no root point drawn, * so a root selection needs to be delivered to the parent tip */ - + if (selmask & BONE_SELECTED) { if (nearBone->parent && (nearBone->flag & BONE_CONNECTED)) { /* click in a chain */ @@ -568,16 +568,16 @@ bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, b else nearBone->flag |= selmask; } - + ED_armature_edit_sync_selection(arm->edbo); - + if (nearBone) { /* then now check for active status */ if (ebone_select_flag(nearBone)) { arm->act_edbone = nearBone; } } - + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit); return true; } @@ -605,7 +605,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + /* Set the flags */ CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones) { @@ -640,7 +640,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) CTX_DATA_END; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); - + return OPERATOR_FINISHED; } @@ -650,14 +650,14 @@ void ARMATURE_OT_select_all(wmOperatorType *ot) ot->name = "(De)select All"; ot->idname = "ARMATURE_OT_select_all"; ot->description = "Toggle selection status of all bones"; - + /* api callbacks */ ot->exec = armature_de_select_all_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + WM_operator_properties_select_all(ot); } @@ -1085,7 +1085,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) int direction = RNA_enum_get(op->ptr, "direction"); const bool add_to_sel = RNA_boolean_get(op->ptr, "extend"); bool changed = false; - + ob = obedit; arm = (bArmature *)ob->data; @@ -1143,15 +1143,15 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) changed = true; } } - + if (changed == false) { return OPERATOR_CANCELLED; } ED_armature_edit_sync_selection(arm->edbo); - + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + return OPERATOR_FINISHED; } @@ -1162,16 +1162,16 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Select Hierarchy"; ot->idname = "ARMATURE_OT_select_hierarchy"; ot->description = "Select immediate parent/children of selected bones"; - + /* api callbacks */ ot->exec = armature_select_hierarchy_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; |