Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/armature/armature_select.c
| Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel) | ||||
| short hits; | short hits; | ||||
| view3d_set_viewcontext(C, &vc); | view3d_set_viewcontext(C, &vc); | ||||
| // rect.xmin = ... mouseco! | // rect.xmin = ... mouseco! | ||||
| rect.xmin = rect.xmax = xy[0]; | rect.xmin = rect.xmax = xy[0]; | ||||
| rect.ymin = rect.ymax = xy[1]; | rect.ymin = rect.ymax = xy[1]; | ||||
| hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, true); | hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST); | ||||
| if (hits > 0) | if (hits > 0) | ||||
| return get_bone_from_selectbuffer(vc.scene, vc.scene->basact, buffer, hits, findunsel, true); | return get_bone_from_selectbuffer(vc.scene, vc.scene->basact, buffer, hits, findunsel, true); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* **************** EditMode stuff ********************** */ | /* **************** EditMode stuff ********************** */ | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | void ARMATURE_OT_select_linked(wmOperatorType *ot) | ||||
| /* properties */ | /* properties */ | ||||
| RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); | RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); | ||||
| } | } | ||||
| /* does bones and points */ | /* does bones and points */ | ||||
| /* note that BONE ROOT only gets drawn for root bones (or without IK) */ | /* note that BONE ROOT only gets drawn for root bones (or without IK) */ | ||||
| static EditBone *get_nearest_editbonepoint( | static EditBone *get_nearest_editbonepoint( | ||||
| ViewContext *vc, const int mval[2], | ViewContext *vc, const int mval[2], | ||||
| ListBase *edbo, bool findunsel, int *r_selmask) | ListBase *edbo, bool findunsel, bool use_cycle, int *r_selmask) | ||||
| { | { | ||||
| bArmature *arm = (bArmature *)vc->obedit->data; | bArmature *arm = (bArmature *)vc->obedit->data; | ||||
| EditBone *ebone_next_act = arm->act_edbone; | EditBone *ebone_next_act = arm->act_edbone; | ||||
| EditBone *ebone; | EditBone *ebone; | ||||
| rcti rect; | rcti rect; | ||||
| unsigned int buffer[MAXPICKBUF]; | unsigned int buffer[MAXPICKBUF]; | ||||
| unsigned int hitresult, besthitresult = BONESEL_NOSEL; | unsigned int hitresult, besthitresult = BONESEL_NOSEL; | ||||
| int i, mindep = 5; | int i, mindep = 5; | ||||
| short hits; | short hits; | ||||
| static int last_mval[2] = {-100, -100}; | |||||
| /* find the bone after the current active bone, so as to bump up its chances in selection. | /* find the bone after the current active bone, so as to bump up its chances in selection. | ||||
| * this way overlapping bones will cycle selection state as with objects. */ | * this way overlapping bones will cycle selection state as with objects. */ | ||||
| if (ebone_next_act && | if (ebone_next_act && | ||||
| EBONE_VISIBLE(arm, ebone_next_act) && | EBONE_VISIBLE(arm, ebone_next_act) && | ||||
| ebone_next_act->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) | ebone_next_act->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) | ||||
| { | { | ||||
| ebone_next_act = ebone_next_act->next ? ebone_next_act->next : arm->edbo->first; | ebone_next_act = ebone_next_act->next ? ebone_next_act->next : arm->edbo->first; | ||||
| } | } | ||||
| else { | else { | ||||
| ebone_next_act = NULL; | ebone_next_act = NULL; | ||||
| } | } | ||||
| bool do_nearest = false; | |||||
| /* define if we use solid nearest select or not */ | |||||
| if (use_cycle) { | |||||
| if (vc->v3d->drawtype > OB_WIRE) { | |||||
| do_nearest = true; | |||||
| if (len_manhattan_v2v2_int(mval, last_mval) < 3) { | |||||
| do_nearest = false; | |||||
| } | |||||
| } | |||||
| copy_v2_v2_int(last_mval, mval); | |||||
| } | |||||
| else { | |||||
| if (vc->v3d->drawtype > OB_WIRE) { | |||||
| do_nearest = true; | |||||
| } | |||||
| } | |||||
| const int select_mode = (do_nearest ? VIEW3D_SELECT_PICK_NEAREST : VIEW3D_SELECT_PICK_ALL); | |||||
| /* TODO: select larger region first (so we can use GPU_select_cache) */ | |||||
| BLI_rcti_init_pt_radius(&rect, mval, 5); | BLI_rcti_init_pt_radius(&rect, mval, 5); | ||||
| hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, select_mode); | |||||
| hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, true); | |||||
| if (hits == 0) { | if (hits == 0) { | ||||
| BLI_rcti_init_pt_radius(&rect, mval, 12); | BLI_rcti_init_pt_radius(&rect, mval, 12); | ||||
| hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, true); | hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect, select_mode); | ||||
| } | } | ||||
| /* See if there are any selected bones in this group */ | /* See if there are any selected bones in this group */ | ||||
| if (hits > 0) { | if (hits > 0) { | ||||
| if (hits == 1) { | if (hits == 1) { | ||||
| if (!(buffer[3] & BONESEL_NOSEL)) | if (!(buffer[3] & BONESEL_NOSEL)) | ||||
| besthitresult = buffer[3]; | besthitresult = buffer[3]; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | bool ED_armature_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) | ||||
| int selmask; | int selmask; | ||||
| view3d_set_viewcontext(C, &vc); | view3d_set_viewcontext(C, &vc); | ||||
| if (BIF_sk_selectStroke(C, mval, extend)) { | if (BIF_sk_selectStroke(C, mval, extend)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| nearBone = get_nearest_editbonepoint(&vc, mval, arm->edbo, true, &selmask); | nearBone = get_nearest_editbonepoint(&vc, mval, arm->edbo, true, true, &selmask); | ||||
| if (nearBone) { | if (nearBone) { | ||||
| if (!extend && !deselect && !toggle) { | if (!extend && !deselect && !toggle) { | ||||
| ED_armature_deselect_all(obedit); | ED_armature_deselect_all(obedit); | ||||
| } | } | ||||
| /* by definition the non-root connected bones have no root point drawn, | /* by definition the non-root connected bones have no root point drawn, | ||||
| * so a root selection needs to be delivered to the parent tip */ | * so a root selection needs to be delivered to the parent tip */ | ||||
| ▲ Show 20 Lines • Show All 831 Lines • Show Last 20 Lines | |||||