diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-11-05 11:54:33 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-11-05 11:54:33 +0300 |
commit | 63d6d6cb742ab741e91126e5055f3172f6dacad1 (patch) | |
tree | be1e7a70ec11d5f9ffa4fb20a52fb5e9872f3db3 /source/blender/editors/space_view3d/view3d_select.c | |
parent | ce973efd4f7c4ff85b1ff434154fde8ddf89530c (diff) |
Armature Editing Bugfixes:
* #19790: Circle Select doesn't work for Armature edit mode or pose mode
* Duplicate bones (Shift-D) was calling the wrong operator. This now uses the macro version, instead of the copy only.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_select.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b13d83c0157..0c90347063f 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1810,6 +1810,79 @@ static void lattice_circle_select(ViewContext *vc, int selecting, short *mval, f lattice_foreachScreenVert(vc, latticecurve_circle_doSelect, &data); } + +static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int x, int y, short head) +{ + struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + int mx = x - data->mval[0], my = y - data->mval[1]; + float r = sqrt(mx*mx + my*my); + + if (r <= data->radius) { + if (head) { + if (data->select) + ebone->flag |= BONE_ROOTSEL; + else + ebone->flag &= ~BONE_ROOTSEL; + } + else { + if (data->select) + ebone->flag |= BONE_TIPSEL; + else + ebone->flag &= ~BONE_TIPSEL; + } + return 1; + } + return 0; +} +static void armature_circle_select(ViewContext *vc, int selecting, short *mval, float rad) +{ + struct {ViewContext *vc; short select, mval[2]; float radius; } data; + bArmature *arm= vc->obedit->data; + EditBone *ebone; + + /* set vc->edit data */ + data.select = selecting; + data.mval[0] = mval[0]; + data.mval[1] = mval[1]; + data.radius = rad; + + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ + + /* check each EditBone... */ + // TODO: could be optimised at some point + for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { + short sco1[2], sco2[2], didpoint=0; + float vec[3]; + + /* project head location to screenspace */ + VECCOPY(vec, ebone->head); + Mat4MulVecfl(vc->obedit->obmat, vec); + project_short(vc->ar, vec, sco1); + + /* project tail location to screenspace */ + VECCOPY(vec, ebone->tail); + Mat4MulVecfl(vc->obedit->obmat, vec); + project_short(vc->ar, vec, sco2); + + /* check if the head and/or tail is in the circle + * - the call to check also does the selection already + */ + if (armature_circle_doSelectJoint(&data, ebone, sco1[0], sco1[1], 1)) + didpoint= 1; + if (armature_circle_doSelectJoint(&data, ebone, sco2[0], sco2[1], 0)) + didpoint= 1; + + /* only if the endpoints didn't get selected, deal with the middle of the bone too */ + // XXX should we just do this always? + if ( (didpoint==0) && edge_inside_circle(mval[0], mval[1], rad, sco1[0], sco1[1], sco2[0], sco2[1]) ) { + if (selecting) + ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED; + else + ebone->flag &= ~(BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + } + } +} + /** Callbacks for circle selection in Editmode */ static void obedit_circle_select(ViewContext *vc, short selecting, short *mval, float rad) @@ -1825,6 +1898,9 @@ static void obedit_circle_select(ViewContext *vc, short selecting, short *mval, case OB_LATTICE: lattice_circle_select(vc, selecting, mval, rad); break; + case OB_ARMATURE: + armature_circle_select(vc, selecting, mval, rad); + break; default: return; } |