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:
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_select.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c573
1 files changed, 300 insertions, 273 deletions
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 079db789a3c..a4a0d332c51 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -114,7 +114,7 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m
initgrabz(vc->rv3d, fp[0], fp[1], fp[2]);
- if(mval_cpy[0]!=IS_CLIPPED) {
+ if (mval_cpy[0]!=IS_CLIPPED) {
float mval_f[2];
VECSUB2D(mval_f, mval_cpy, mval);
ED_view3d_win_to_delta(vc->ar, mval_f, dvec);
@@ -124,7 +124,7 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m
}
else {
/* fallback to the view center */
- if(do_fallback) {
+ if (do_fallback) {
negate_v3_v3(fp, vc->rv3d->ofs);
return view3d_get_view_aligned_coordinate(vc, fp, mval, FALSE);
}
@@ -144,12 +144,13 @@ void view3d_get_transformation(const ARegion *ar, RegionView3D *rv3d, Object *ob
if (ob) {
mult_m4_m4m4(cpy, rv3d->viewmat, ob->obmat);
- } else {
+ }
+ else {
copy_m4_m4(cpy, rv3d->viewmat);
}
- for(i = 0; i < 4; ++i) {
- for(j = 0; j < 4; ++j) {
+ for (i = 0; i < 4; ++i) {
+ for (j = 0; j < 4; ++j) {
mats->projection[i*4+j] = rv3d->winmat[i][j];
mats->modelview[i*4+j] = cpy[i][j];
}
@@ -173,8 +174,8 @@ static void EDBM_backbuf_checkAndSelectVerts(BMEditMesh *em, int select)
eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
for ( ; eve; eve=BM_iter_step(&iter), index++) {
- if(!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
- if(EDBM_check_backbuf(index)) {
+ if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+ if (EDBM_check_backbuf(index)) {
BM_vert_select_set(em->bm, eve, select);
}
}
@@ -189,8 +190,8 @@ static void EDBM_backbuf_checkAndSelectEdges(BMEditMesh *em, int select)
eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
for ( ; eed; eed=BM_iter_step(&iter), index++) {
- if(!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
- if(EDBM_check_backbuf(index)) {
+ if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
+ if (EDBM_check_backbuf(index)) {
BM_edge_select_set(em->bm, eed, select);
}
}
@@ -205,8 +206,8 @@ static void EDBM_backbuf_checkAndSelectFaces(BMEditMesh *em, int select)
efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL);
for ( ; efa; efa=BM_iter_step(&iter), index++) {
- if(!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
- if(EDBM_check_backbuf(index)) {
+ if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
+ if (EDBM_check_backbuf(index)) {
BM_face_select_set(em->bm, efa, select);
}
}
@@ -221,9 +222,9 @@ static void EDBM_backbuf_checkAndSelectVerts_obmode(Mesh *me, int select)
int a;
if (mv) {
- for(a=1; a<=me->totvert; a++, mv++) {
- if(EDBM_check_backbuf(a)) {
- if(!(mv->flag & ME_HIDE)) {
+ for (a=1; a<=me->totvert; a++, mv++) {
+ if (EDBM_check_backbuf(a)) {
+ if (!(mv->flag & ME_HIDE)) {
mv->flag = select?(mv->flag|SELECT):(mv->flag&~SELECT);
}
}
@@ -238,8 +239,8 @@ static void EDBM_backbuf_checkAndSelectTFaces(Mesh *me, int select)
int a;
if (mpoly) {
- for(a=1; a<=me->totpoly; a++, mpoly++) {
- if(EDBM_check_backbuf(a)) {
+ for (a=1; a<=me->totpoly; a++, mpoly++) {
+ if (EDBM_check_backbuf(a)) {
mpoly->flag = select?(mpoly->flag|ME_FACE_SEL):(mpoly->flag&~ME_FACE_SEL);
}
}
@@ -261,9 +262,9 @@ static int view3d_selectable_data(bContext *C)
if (!ED_operator_region_view3d_active(C))
return 0;
- if(ob) {
+ if (ob) {
if (ob->mode & OB_MODE_EDIT) {
- if(ob->type == OB_FONT) {
+ if (ob->type == OB_FONT) {
return 0;
}
}
@@ -294,13 +295,13 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2)
int d1, d2, d3, d4;
/* check points in rect */
- if(edge_fully_inside_rect(rect, x1, y1, x2, y2)) return 1;
+ if (edge_fully_inside_rect(rect, x1, y1, x2, y2)) return 1;
/* check points completely out rect */
- if(x1<rect->xmin && x2<rect->xmin) return 0;
- if(x1>rect->xmax && x2>rect->xmax) return 0;
- if(y1<rect->ymin && y2<rect->ymin) return 0;
- if(y1>rect->ymax && y2>rect->ymax) return 0;
+ if (x1<rect->xmin && x2<rect->xmin) return 0;
+ if (x1>rect->xmax && x2>rect->xmax) return 0;
+ if (y1<rect->ymin && y2<rect->ymin) return 0;
+ if (y1>rect->ymax && y2>rect->ymax) return 0;
/* simple check lines intersecting. */
d1= (y1-y2)*(x1- rect->xmin ) + (x2-x1)*(y1- rect->ymin );
@@ -308,8 +309,8 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2)
d3= (y1-y2)*(x1- rect->xmax ) + (x2-x1)*(y1- rect->ymax );
d4= (y1-y2)*(x1- rect->xmax ) + (x2-x1)*(y1- rect->ymin );
- if(d1<0 && d2<0 && d3<0 && d4<0) return 0;
- if(d1>0 && d2>0 && d3>0 && d4>0) return 0;
+ if (d1<0 && d2<0 && d3<0 && d4<0) return 0;
+ if (d1>0 && d2>0 && d3>0 && d4>0) return 0;
return 1;
}
@@ -325,7 +326,7 @@ int lasso_inside(int mcords[][2], short moves, int sx, int sy)
int a;
int *p1, *p2;
- if(sx==IS_CLIPPED)
+ if (sx==IS_CLIPPED)
return 0;
p1= mcords[moves-1];
@@ -338,7 +339,7 @@ int lasso_inside(int mcords[][2], short moves, int sx, int sy)
fp1[0]/= len;
fp1[1]/= len;
- for(a=0; a<moves; a++) {
+ for (a=0; a<moves; a++) {
/* second vector */
fp2[0]= (float)(p2[0]-sx);
fp2[1]= (float)(p2[1]-sy);
@@ -352,7 +353,7 @@ int lasso_inside(int mcords[][2], short moves, int sx, int sy)
cross= (float)((p1[1]-p2[1])*(p1[0]-sx) + (p2[0]-p1[0])*(p1[1]-sy));
- if(cross<0.0f) angletot-= ang;
+ if (cross<0.0f) angletot-= ang;
else angletot+= ang;
/* circulate */
@@ -361,7 +362,7 @@ int lasso_inside(int mcords[][2], short moves, int sx, int sy)
p2= mcords[a+1];
}
- if( fabs(angletot) > 4.0 ) return 1;
+ if ( fabs(angletot) > 4.0 ) return 1;
return 0;
}
@@ -371,21 +372,21 @@ int lasso_inside_edge(int mcords[][2], short moves, int x0, int y0, int x1, int
int v1[2], v2[2];
int a;
- if(x0==IS_CLIPPED || x1==IS_CLIPPED)
+ if (x0==IS_CLIPPED || x1==IS_CLIPPED)
return 0;
v1[0] = x0, v1[1] = y0;
v2[0] = x1, v2[1] = y1;
/* check points in lasso */
- if(lasso_inside(mcords, moves, v1[0], v1[1])) return 1;
- if(lasso_inside(mcords, moves, v2[0], v2[1])) return 1;
+ if (lasso_inside(mcords, moves, v1[0], v1[1])) return 1;
+ if (lasso_inside(mcords, moves, v2[0], v2[1])) return 1;
/* no points in lasso, so we have to intersect with lasso edge */
- if( isect_line_line_v2_int(mcords[0], mcords[moves-1], v1, v2) > 0) return 1;
- for(a=0; a<moves-1; a++) {
- if( isect_line_line_v2_int(mcords[a], mcords[a+1], v1, v2) > 0) return 1;
+ if ( isect_line_line_v2_int(mcords[0], mcords[moves-1], v1, v2) > 0) return 1;
+ for (a=0; a<moves-1; a++) {
+ if ( isect_line_line_v2_int(mcords[a], mcords[a+1], v1, v2) > 0) return 1;
}
return 0;
@@ -402,17 +403,17 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, int mcords[][2], s
int sco1[2], sco2[2];
bArmature *arm= ob->data;
- if(ob->type!=OB_ARMATURE || ob->pose==NULL) return;
+ if (ob->type!=OB_ARMATURE || ob->pose==NULL) return;
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if (PBONE_VISIBLE(arm, pchan->bone) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) {
mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
project_int(vc->ar, vec, sco1);
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
project_int(vc->ar, vec, sco2);
- if(lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) {
- if(select) pchan->bone->flag |= BONE_SELECTED;
+ if (lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) {
+ if (select) pchan->bone->flag |= BONE_SELECTED;
else pchan->bone->flag &= ~BONE_SELECTED;
}
}
@@ -423,8 +424,8 @@ static void object_deselect_all_visible(Scene *scene, View3D *v3d)
{
Base *base;
- for(base= scene->base.first; base; base= base->next) {
- if(BASE_SELECTABLE(v3d, base)) {
+ for (base= scene->base.first; base; base= base->next) {
+ if (BASE_SELECTABLE(v3d, base)) {
ED_base_object_select(base, BA_DESELECT);
}
}
@@ -437,16 +438,16 @@ static void do_lasso_select_objects(ViewContext *vc, int mcords[][2], short move
if (extend == 0 && select)
object_deselect_all_visible(vc->scene, vc->v3d);
- for(base= vc->scene->base.first; base; base= base->next) {
- if(BASE_SELECTABLE(vc->v3d, base)) { /* use this to avoid un-needed lasso lookups */
+ for (base= vc->scene->base.first; base; base= base->next) {
+ if (BASE_SELECTABLE(vc->v3d, base)) { /* use this to avoid un-needed lasso lookups */
project_short(vc->ar, base->object->obmat[3], &base->sx);
- if(lasso_inside(mcords, moves, base->sx, base->sy)) {
+ if (lasso_inside(mcords, moves, base->sx, base->sy)) {
- if(select) ED_base_object_select(base, BA_SELECT);
+ if (select) ED_base_object_select(base, BA_SELECT);
else ED_base_object_select(base, BA_DESELECT);
base->object->flag= base->flag;
}
- if(base->object->mode & OB_MODE_POSE) {
+ if (base->object->mode & OB_MODE_POSE) {
do_lasso_select_pose(vc, base->object, mcords, moves, select);
}
}
@@ -460,11 +461,11 @@ static void lasso_select_boundbox(rcti *rect, int mcords[][2], short moves)
rect->xmin= rect->xmax= mcords[0][0];
rect->ymin= rect->ymax= mcords[0][1];
- for(a=1; a<moves; a++) {
- if(mcords[a][0]<rect->xmin) rect->xmin= mcords[a][0];
- else if(mcords[a][0]>rect->xmax) rect->xmax= mcords[a][0];
- if(mcords[a][1]<rect->ymin) rect->ymin= mcords[a][1];
- else if(mcords[a][1]>rect->ymax) rect->ymax= mcords[a][1];
+ for (a=1; a<moves; a++) {
+ if (mcords[a][0]<rect->xmin) rect->xmin= mcords[a][0];
+ else if (mcords[a][0]>rect->xmax) rect->xmax= mcords[a][0];
+ if (mcords[a][1]<rect->ymin) rect->ymin= mcords[a][1];
+ else if (mcords[a][1]>rect->ymax) rect->ymax= mcords[a][1];
}
}
@@ -488,7 +489,8 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, int
BM_elem_select_set(data->vc->em->bm, eed, data->select);
data->done = 1;
}
- } else {
+ }
+ else {
if (lasso_inside_edge(data->mcords, data->moves, x0, y0, x1, y1)) {
BM_elem_select_set(data->vc->em->bm, eed, data->select);
}
@@ -533,7 +535,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves,
glLoadMatrixf(vc->rv3d->viewmat);
bbsel= EDBM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
- if(ts->selectmode & SCE_SELECT_VERTEX) {
+ if (ts->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) {
EDBM_backbuf_checkAndSelectVerts(vc->em, select);
}
@@ -541,7 +543,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves,
mesh_foreachScreenVert(vc, do_lasso_select_mesh__doSelectVert, &data, V3D_CLIP_TEST_RV3D_CLIPPING);
}
}
- if(ts->selectmode & SCE_SELECT_EDGE) {
+ if (ts->selectmode & SCE_SELECT_EDGE) {
/* Does both bbsel and non-bbsel versions (need screen cos for both) */
data.pass = 0;
mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_CLIP_TEST_OFF);
@@ -552,7 +554,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves,
}
}
- if(ts->selectmode & SCE_SELECT_FACE) {
+ if (ts->selectmode & SCE_SELECT_FACE) {
if (bbsel) {
EDBM_backbuf_checkAndSelectFaces(vc->em, select);
}
@@ -595,18 +597,20 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select)
if (ok)
uvface_setsel__internal(select);
- } else { /* Vert Sel*/
+ }
+ else { /* Vert Sel*/
for (efa= em->faces.first; efa; efa= efa->next) {
tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
if (uvedit_face_visible(scene, ima, efa, tf)) {
nverts= efa->v4? 4: 3;
- for(i=0; i<nverts; i++) {
+ for (i=0; i<nverts; i++) {
if ((select) != (simaUVSel_Check(efa, tf, i))) {
uvco_to_areaco_noclip(tf->uv[i], screenUV);
if (BLI_in_rcti(&rect, screenUV[0], screenUV[1]) && lasso_inside(mcords, moves, screenUV[0], screenUV[1])) {
if (select) {
simaUVSel_Set(efa, tf, i);
- } else {
+ }
+ else {
simaUVSel_UnSet(efa, tf, i);
}
}
@@ -632,16 +636,20 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP
if (bp) {
bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL;
- } else {
+ }
+ else {
if (cu->drawflag & CU_HIDE_HANDLES) {
/* can only be beztindex==0 here since handles are hidden */
bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT);
- } else {
+ }
+ else {
if (beztindex==0) {
bezt->f1 = data->select?(bezt->f1|SELECT):(bezt->f1&~SELECT);
- } else if (beztindex==1) {
+ }
+ else if (beztindex==1) {
bezt->f2 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT);
- } else {
+ }
+ else {
bezt->f3 = data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT);
}
}
@@ -713,28 +721,28 @@ static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short mov
project_short(vc->ar, vec, sco2);
didpoint= 0;
- if(lasso_inside(mcords, moves, sco1[0], sco1[1])) {
- if(select) ebone->flag |= BONE_ROOTSEL;
+ if (lasso_inside(mcords, moves, sco1[0], sco1[1])) {
+ if (select) ebone->flag |= BONE_ROOTSEL;
else ebone->flag &= ~BONE_ROOTSEL;
didpoint= 1;
change= TRUE;
}
- if(lasso_inside(mcords, moves, sco2[0], sco2[1])) {
- if(select) ebone->flag |= BONE_TIPSEL;
+ if (lasso_inside(mcords, moves, sco2[0], sco2[1])) {
+ if (select) ebone->flag |= BONE_TIPSEL;
else ebone->flag &= ~BONE_TIPSEL;
didpoint= 1;
change= TRUE;
}
/* if one of points selected, we skip the bone itself */
- if(didpoint==0 && lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) {
- if(select) ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED;
+ if (didpoint==0 && lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) {
+ if (select) ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED;
else ebone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
change= TRUE;
}
}
}
- if(change) {
+ if (change) {
ED_armature_sync_selection(arm->edbo);
ED_armature_validate_active(arm);
WM_main_add_notifier(NC_OBJECT|ND_BONE_SELECT, vc->obedit);
@@ -752,18 +760,18 @@ static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves,
short sco[2];
if (extend == 0 && select) {
- for(ml= mb->editelems->first; ml; ml= ml->next) {
+ for (ml= mb->editelems->first; ml; ml= ml->next) {
ml->flag &= ~SELECT;
}
}
- for(ml= mb->editelems->first; ml; ml= ml->next) {
+ for (ml= mb->editelems->first; ml; ml= ml->next) {
mul_v3_m4v3(vec, vc->obedit->obmat, &ml->x);
project_short(vc->ar, vec, sco);
- if(lasso_inside(mcords, moves, sco[0], sco[1])) {
- if(select) ml->flag |= SELECT;
+ if (lasso_inside(mcords, moves, sco[0], sco[1])) {
+ if (select) ml->flag |= SELECT;
else ml->flag &= ~SELECT;
}
}
@@ -782,7 +790,7 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend)
me= vc->obact->data;
- if(me==NULL || me->totvert==0 || sx*sy <= 0)
+ if (me==NULL || me->totvert==0 || sx*sy <= 0)
return OPERATOR_CANCELLED;
selar= MEM_callocN(me->totvert+1, "selar");
@@ -795,23 +803,23 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend)
ibuf = IMB_allocImBuf(sx,sy,32,IB_rect);
rt = ibuf->rect;
glReadPixels(rect->xmin+vc->ar->winrct.xmin, rect->ymin+vc->ar->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
- if(ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
+ if (ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
a= sx*sy;
- while(a--) {
- if(*rt) {
+ while (a--) {
+ if (*rt) {
index= WM_framebuffer_to_index(*rt);
- if(index<=me->totvert) selar[index]= 1;
+ if (index<=me->totvert) selar[index]= 1;
}
rt++;
}
mvert= me->mvert;
- for(a=1; a<=me->totvert; a++, mvert++) {
- if(selar[a]) {
- if(mvert->flag & ME_HIDE);
+ for (a=1; a<=me->totvert; a++, mvert++) {
+ if (selar[a]) {
+ if (mvert->flag & ME_HIDE);
else {
- if(select) mvert->flag |= SELECT;
+ if (select) mvert->flag |= SELECT;
else mvert->flag &= ~SELECT;
}
}
@@ -835,10 +843,10 @@ static void do_lasso_select_paintvert(ViewContext *vc, int mcords[][2], short mo
Mesh *me= ob?ob->data:NULL;
rcti rect;
- if(me==NULL || me->totvert==0)
+ if (me==NULL || me->totvert==0)
return;
- if(extend==0 && select)
+ if (extend==0 && select)
paintvert_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */
bm_vertoffs= me->totvert+1; /* max index array */
@@ -857,10 +865,10 @@ static void do_lasso_select_paintface(ViewContext *vc, int mcords[][2], short mo
Mesh *me= ob?ob->data:NULL;
rcti rect;
- if(me==NULL || me->totpoly==0)
+ if (me==NULL || me->totpoly==0)
return;
- if(extend==0 && select)
+ if (extend==0 && select)
paintface_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */
bm_vertoffs= me->totpoly+1; /* max index array */
@@ -888,7 +896,7 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select)
lasso_select_boundbox(&rect, mcords, moves);
/* store selection in temp test flag */
- for(node= snode->edittree->nodes.first; node; node= node->next) {
+ for (node= snode->edittree->nodes.first; node; node= node->next) {
node_centf[0] = (node->totr.xmin+node->totr.xmax)/2;
node_centf[1] = (node->totr.ymin+node->totr.ymax)/2;
@@ -897,7 +905,8 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select)
if (BLI_in_rcti(&rect, node_cent[0], node_cent[1]) && lasso_inside(mcords, moves, node_cent[0], node_cent[1])) {
if (select) {
node->flag |= SELECT;
- } else {
+ }
+ else {
node->flag &= ~SELECT;
}
}
@@ -910,14 +919,14 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc, int mcords[][2], s
{
Object *ob = CTX_data_active_object(C);
- if(vc->obedit==NULL) { /* Object Mode */
- if(paint_facesel_test(ob))
+ if (vc->obedit==NULL) { /* Object Mode */
+ if (paint_facesel_test(ob))
do_lasso_select_paintface(vc, mcords, moves, extend, select);
- else if(paint_vertsel_test(ob))
+ else if (paint_vertsel_test(ob))
do_lasso_select_paintvert(vc, mcords, moves, extend, select);
- else if(ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))
+ else if (ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))
;
- else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT)
+ else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT)
PE_lasso_select(C, mcords, moves, extend, select);
else {
do_lasso_select_objects(vc, mcords, moves, extend, select);
@@ -966,11 +975,11 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op)
mcords[i][0]= (int)loc[0];
mcords[i][1]= (int)loc[1];
i++;
- if(i>=1024) break;
+ if (i>=1024) break;
}
RNA_END;
- if(i>1) {
+ if (i>1) {
short extend, select;
view3d_operator_needs_opengl(C);
@@ -1019,7 +1028,7 @@ static unsigned int samplerect(unsigned int *buf, int size, unsigned int dontdo)
unsigned int retval=0;
base= LASTBASE;
- if(base==0) return 0;
+ if (base==0) return 0;
maxob= base->selcol;
len= (size-1)/2;
@@ -1038,17 +1047,17 @@ static unsigned int samplerect(unsigned int *buf, int size, unsigned int dontdo)
bufmax= buf+ size*size;
buf+= len*size+ len;
- for(tel=1;tel<=size;tel++) {
+ for (tel=1;tel<=size;tel++) {
- for(a=0;a<2;a++) {
- for(b=0;b<tel;b++) {
+ for (a=0;a<2;a++) {
+ for (b=0;b<tel;b++) {
- if(*buf && *buf<=maxob && *buf!=dontdo) return *buf;
- if( *buf==dontdo ) retval= dontdo; /* if only color dontdo is available, still return dontdo */
+ if (*buf && *buf<=maxob && *buf!=dontdo) return *buf;
+ if ( *buf==dontdo ) retval= dontdo; /* if only color dontdo is available, still return dontdo */
buf+= (dirvec[rc][0]+dirvec[rc][1]);
- if(buf<bufmin || buf>=bufmax) return retval;
+ if (buf<bufmin || buf>=bufmax) return retval;
}
rc++;
rc &= 3;
@@ -1103,9 +1112,9 @@ static int object_select_menu_exec(bContext *C, wmOperator *op)
short changed = 0;
const char *name= object_mouse_select_menu_data[name_index].idname;
- if(!extend) {
+ if (!extend) {
CTX_DATA_BEGIN(C, Base*, base, selectable_bases) {
- if(base->flag & SELECT) {
+ if (base->flag & SELECT) {
ED_base_object_select(base, BA_DESELECT);
changed= 1;
}
@@ -1115,7 +1124,7 @@ static int object_select_menu_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Base*, base, selectable_bases) {
/* this is a bit dodjy, there should only be ONE object with this name, but library objects can mess this up */
- if(strcmp(name, base->object->id.name+2)==0) {
+ if (strcmp(name, base->object->id.name+2)==0) {
ED_base_object_activate(C, base);
ED_base_object_select(base, BA_SELECT);
changed= 1;
@@ -1127,7 +1136,7 @@ static int object_select_menu_exec(bContext *C, wmOperator *op)
memset(object_mouse_select_menu_data, 0, sizeof(object_mouse_select_menu_data));
/* undo? */
- if(changed) {
+ if (changed) {
WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
@@ -1165,9 +1174,9 @@ static void deselectall_except(Scene *scene, Base *b) /* deselect all except b
{
Base *base;
- for(base= FIRSTBASE; base; base= base->next) {
+ for (base= FIRSTBASE; base; base= base->next) {
if (base->flag & SELECT) {
- if(b!=base) {
+ if (b!=base) {
ED_base_object_select(base, BA_DESELECT);
}
}
@@ -1184,11 +1193,11 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int
ok= FALSE;
/* two selection methods, the CTRL select uses max dist of 15 */
- if(buffer) {
+ if (buffer) {
int a;
- for(a=0; a<hits; a++) {
+ for (a=0; a<hits; a++) {
/* index was converted */
- if(base->selcol==buffer[ (4 * a) + 3 ])
+ if (base->selcol==buffer[ (4 * a) + 3 ])
ok= TRUE;
}
}
@@ -1198,11 +1207,11 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int
project_short(vc->ar, base->object->obmat[3], &base->sx);
temp= abs(base->sx -mval[0]) + abs(base->sy -mval[1]);
- if(temp < dist)
+ if (temp < dist)
ok= TRUE;
}
- if(ok) {
+ if (ok) {
baseCount++;
BLI_linklist_prepend(&linklist, base);
@@ -1212,10 +1221,10 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int
}
CTX_DATA_END;
- if(baseCount==0) {
+ if (baseCount==0) {
return NULL;
}
- if(baseCount == 1) {
+ if (baseCount == 1) {
Base *base= (Base *)linklist->link;
BLI_linklist_free(linklist, NULL);
return base;
@@ -1261,43 +1270,43 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff
BLI_init_rcti(&rect, mval[0]-14, mval[0]+14, mval[1]-14, mval[1]+14);
hits15= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect);
- if(hits15>0) {
- for(a=0; a<hits15; a++) if(buffer[4*a+3] & 0xFFFF0000) has_bones15= 1;
+ if (hits15>0) {
+ for (a=0; a<hits15; a++) if (buffer[4*a+3] & 0xFFFF0000) has_bones15= 1;
offs= 4*hits15;
BLI_init_rcti(&rect, mval[0]-9, mval[0]+9, mval[1]-9, mval[1]+9);
hits9= view3d_opengl_select(vc, buffer+offs, MAXPICKBUF-offs, &rect);
- if(hits9>0) {
- for(a=0; a<hits9; a++) if(buffer[offs+4*a+3] & 0xFFFF0000) has_bones9= 1;
+ if (hits9>0) {
+ for (a=0; a<hits9; a++) if (buffer[offs+4*a+3] & 0xFFFF0000) has_bones9= 1;
offs+= 4*hits9;
BLI_init_rcti(&rect, mval[0]-5, mval[0]+5, mval[1]-5, mval[1]+5);
hits5= view3d_opengl_select(vc, buffer+offs, MAXPICKBUF-offs, &rect);
- if(hits5>0) {
- for(a=0; a<hits5; a++) if(buffer[offs+4*a+3] & 0xFFFF0000) has_bones5= 1;
+ if (hits5>0) {
+ for (a=0; a<hits5; a++) if (buffer[offs+4*a+3] & 0xFFFF0000) has_bones5= 1;
}
}
- if(has_bones5) {
+ if (has_bones5) {
offs= 4*hits15 + 4*hits9;
memcpy(buffer, buffer+offs, 4*offs);
return hits5;
}
- if(has_bones9) {
+ if (has_bones9) {
offs= 4*hits15;
memcpy(buffer, buffer+offs, 4*offs);
return hits9;
}
- if(has_bones15) {
+ if (has_bones15) {
return hits15;
}
- if(hits5>0) {
+ if (hits5>0) {
offs= 4*hits15 + 4*hits9;
memcpy(buffer, buffer+offs, 4*offs);
return hits5;
}
- if(hits9>0) {
+ if (hits9>0) {
offs= 4*hits15;
memcpy(buffer, buffer+offs, 4*offs);
return hits9;
@@ -1318,24 +1327,24 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
int a, donearest= 0;
/* define if we use solid nearest select or not */
- if(v3d->drawtype>OB_WIRE) {
+ if (v3d->drawtype>OB_WIRE) {
donearest= 1;
- if( ABS(mval[0]-lastmval[0])<3 && ABS(mval[1]-lastmval[1])<3) {
- if(!has_bones) /* hrms, if theres bones we always do nearest */
+ if ( ABS(mval[0]-lastmval[0])<3 && ABS(mval[1]-lastmval[1])<3) {
+ if (!has_bones) /* hrms, if theres bones we always do nearest */
donearest= 0;
}
}
lastmval[0]= mval[0]; lastmval[1]= mval[1];
- if(donearest) {
+ if (donearest) {
unsigned int min= 0xFFFFFFFF;
int selcol= 0, notcol=0;
- if(has_bones) {
+ if (has_bones) {
/* we skip non-bone hits */
- for(a=0; a<hits; a++) {
- if( min > buffer[4*a+1] && (buffer[4*a+3] & 0xFFFF0000) ) {
+ for (a=0; a<hits; a++) {
+ if ( min > buffer[4*a+1] && (buffer[4*a+3] & 0xFFFF0000) ) {
min= buffer[4*a+1];
selcol= buffer[4*a+3] & 0xFFFF;
}
@@ -1343,10 +1352,10 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
}
else {
/* only exclude active object when it is selected... */
- if(BASACT && (BASACT->flag & SELECT) && hits>1) notcol= BASACT->selcol;
+ if (BASACT && (BASACT->flag & SELECT) && hits>1) notcol= BASACT->selcol;
- for(a=0; a<hits; a++) {
- if( min > buffer[4*a+1] && notcol!=(buffer[4*a+3] & 0xFFFF)) {
+ for (a=0; a<hits; a++) {
+ if ( min > buffer[4*a+1] && notcol!=(buffer[4*a+3] & 0xFFFF)) {
min= buffer[4*a+1];
selcol= buffer[4*a+3] & 0xFFFF;
}
@@ -1354,47 +1363,47 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int
}
base= FIRSTBASE;
- while(base) {
- if(BASE_SELECTABLE(v3d, base)) {
- if(base->selcol==selcol) break;
+ while (base) {
+ if (BASE_SELECTABLE(v3d, base)) {
+ if (base->selcol==selcol) break;
}
base= base->next;
}
- if(base) basact= base;
+ if (base) basact= base;
}
else {
base= startbase;
- while(base) {
+ while (base) {
/* skip objects with select restriction, to prevent prematurely ending this loop
* with an un-selectable choice */
if (base->object->restrictflag & OB_RESTRICT_SELECT) {
base=base->next;
- if(base==NULL) base= FIRSTBASE;
- if(base==startbase) break;
+ if (base==NULL) base= FIRSTBASE;
+ if (base==startbase) break;
}
- if(BASE_SELECTABLE(v3d, base)) {
- for(a=0; a<hits; a++) {
- if(has_bones) {
+ if (BASE_SELECTABLE(v3d, base)) {
+ for (a=0; a<hits; a++) {
+ if (has_bones) {
/* skip non-bone objects */
- if((buffer[4*a+3] & 0xFFFF0000)) {
- if(base->selcol== (buffer[(4*a)+3] & 0xFFFF))
+ if ((buffer[4*a+3] & 0xFFFF0000)) {
+ if (base->selcol== (buffer[(4*a)+3] & 0xFFFF))
basact= base;
}
}
else {
- if(base->selcol== (buffer[(4*a)+3] & 0xFFFF))
+ if (base->selcol== (buffer[(4*a)+3] & 0xFFFF))
basact= base;
}
}
}
- if(basact) break;
+ if (basact) break;
base= base->next;
- if(base==NULL) base= FIRSTBASE;
- if(base==startbase) break;
+ if (base==NULL) base= FIRSTBASE;
+ if (base==startbase) break;
}
}
@@ -1415,10 +1424,10 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2])
hits= mixed_bones_object_selectbuffer(&vc, buffer, mval);
- if(hits>0) {
+ if (hits>0) {
int a, has_bones= 0;
- for(a=0; a<hits; a++) if(buffer[4*a+3] & 0xFFFF0000) has_bones= 1;
+ for (a=0; a<hits; a++) if (buffer[4*a+3] & 0xFFFF0000) has_bones= 1;
basact= mouse_select_eval_buffer(&vc, buffer, hits, mval, vc.scene->base.first, has_bones);
}
@@ -1431,11 +1440,11 @@ static void deselect_all_tracks(MovieTracking *tracking)
MovieTrackingObject *object;
object= tracking->objects.first;
- while(object) {
+ while (object) {
ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object);
MovieTrackingTrack *track= tracksbase->first;
- while(track) {
+ while (track) {
BKE_tracking_deselect_track(track, TRACK_AREA_ALL);
track= track->next;
@@ -1462,24 +1471,25 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
/* always start list from basact in wire mode */
startbase= FIRSTBASE;
- if(BASACT && BASACT->next) startbase= BASACT->next;
+ if (BASACT && BASACT->next) startbase= BASACT->next;
/* This block uses the control key to make the object selected by its center point rather than its contents */
/* in editmode do not activate */
- if(obcenter) {
+ if (obcenter) {
/* note; shift+alt goes to group-flush-selecting */
- if(enumerate) {
+ if (enumerate) {
basact= object_mouse_select_menu(C, &vc, NULL, 0, mval, extend);
- } else {
+ }
+ else {
base= startbase;
- while(base) {
+ while (base) {
if (BASE_SELECTABLE(v3d, base)) {
project_short(ar, base->object->obmat[3], &base->sx);
temp= abs(base->sx -mval[0]) + abs(base->sy -mval[1]);
- if(base==BASACT) temp+=10;
- if(temp<dist ) {
+ if (base==BASACT) temp+=10;
+ if (temp<dist ) {
dist= temp;
basact= base;
@@ -1487,8 +1497,8 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
}
base= base->next;
- if(base==NULL) base= FIRSTBASE;
- if(base==startbase) break;
+ if (base==NULL) base= FIRSTBASE;
+ if (base==startbase) break;
}
}
}
@@ -1499,22 +1509,23 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
hits= mixed_bones_object_selectbuffer(&vc, buffer, mval);
- if(hits>0) {
+ if (hits>0) {
int has_bones= 0;
/* note: bundles are handling in the same way as bones */
- for(a=0; a<hits; a++) if(buffer[4*a+3] & 0xFFFF0000) has_bones= 1;
+ for (a=0; a<hits; a++) if (buffer[4*a+3] & 0xFFFF0000) has_bones= 1;
/* note; shift+alt goes to group-flush-selecting */
- if(has_bones==0 && enumerate) {
+ if (has_bones==0 && enumerate) {
basact= object_mouse_select_menu(C, &vc, buffer, hits, mval, extend);
- } else {
+ }
+ else {
basact= mouse_select_eval_buffer(&vc, buffer, hits, mval, startbase, has_bones);
}
- if(has_bones && basact) {
- if(basact->object->type==OB_CAMERA) {
- if(BASACT==basact) {
+ if (has_bones && basact) {
+ if (basact->object->type==OB_CAMERA) {
+ if (BASACT==basact) {
int i, hitresult;
int changed= 0;
@@ -1523,13 +1534,13 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
/* if there's bundles in buffer select bundles first,
so non-camera elements should be ignored in buffer */
- if(basact->selcol != (hitresult & 0xFFFF)) {
+ if (basact->selcol != (hitresult & 0xFFFF)) {
continue;
}
/* index of bundle is 1<<16-based. if there's no "bone" index
in hight word, this buffer value belongs to camera,. not to bundle */
- if(buffer[4*i+3] & 0xFFFF0000) {
+ if (buffer[4*i+3] & 0xFFFF0000) {
MovieClip *clip= object_get_movieclip(scene, basact->object, 0);
MovieTracking *tracking= &clip->tracking;
ListBase *tracksbase;
@@ -1537,18 +1548,18 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
track= BKE_tracking_indexed_track(&clip->tracking, hitresult >> 16, &tracksbase);
- if(TRACK_SELECTED(track) && extend) {
+ if (TRACK_SELECTED(track) && extend) {
changed= 0;
BKE_tracking_deselect_track(track, TRACK_AREA_ALL);
}
else {
int oldsel= TRACK_SELECTED(track) ? 1 : 0;
- if(!extend)
+ if (!extend)
deselect_all_tracks(tracking);
BKE_tracking_select_track(tracksbase, track, TRACK_AREA_ALL, extend);
- if(oldsel!=(TRACK_SELECTED(track) ? 1 : 0))
+ if (oldsel!=(TRACK_SELECTED(track) ? 1 : 0))
changed= 1;
}
@@ -1564,14 +1575,14 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
}
}
- if(!changed) {
+ if (!changed) {
/* fallback to regular object selection if no new bundles were selected,
allows to select object parented to reconstruction object */
basact= mouse_select_eval_buffer(&vc, buffer, hits, mval, startbase, 0);
}
}
}
- else if(ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend) ) { /* then bone is found */
+ else if (ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend) ) { /* then bone is found */
/* we make the armature selected:
not-selected active object in posemode won't work well for tools */
@@ -1583,24 +1594,24 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, basact->object);
/* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */
- if(BASACT && BASACT->object->mode & OB_MODE_WEIGHT_PAINT) {
+ if (BASACT && BASACT->object->mode & OB_MODE_WEIGHT_PAINT) {
/* prevent activating */
basact= NULL;
}
}
/* prevent bone selecting to pass on to object selecting */
- if(basact==BASACT)
+ if (basact==BASACT)
basact= NULL;
}
}
}
/* so, do we have something selected? */
- if(basact) {
+ if (basact) {
retval = 1;
- if(vc.obedit) {
+ if (vc.obedit) {
/* only do select */
deselectall_except(scene, basact);
ED_base_object_select(basact, BA_SELECT);
@@ -1610,22 +1621,22 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce
oldbasact= BASACT;
- if(!extend) {
+ if (!extend) {
deselectall_except(scene, basact);
ED_base_object_select(basact, BA_SELECT);
}
- else if(0) {
+ else if (0) {
// XXX select_all_from_groups(basact);
}
else {
- if(basact->flag & SELECT) {
- if(basact==oldbasact)
+ if (basact->flag & SELECT) {
+ if (basact==oldbasact)
ED_base_object_select(basact, BA_DESELECT);
}
else ED_base_object_select(basact, BA_SELECT);
}
- if(oldbasact != basact) {
+ if (oldbasact != basact) {
ED_base_object_activate(C, basact); /* adds notifier */
}
}
@@ -1650,8 +1661,8 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1,
float v1[2], v2[2], v3[2];
/* check points in circle itself */
- if( (x1-centx)*(x1-centx) + (y1-centy)*(y1-centy) <= radsq ) return 1;
- if( (x2-centx)*(x2-centx) + (y2-centy)*(y2-centy) <= radsq ) return 1;
+ if ( (x1-centx)*(x1-centx) + (y1-centy)*(y1-centy) <= radsq ) return 1;
+ if ( (x2-centx)*(x2-centx) + (y2-centy)*(y2-centy) <= radsq ) return 1;
/* pointdistline */
v3[0]= centx;
@@ -1661,7 +1672,7 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1,
v2[0]= x2;
v2[1]= y2;
- if( dist_to_line_segment_v2(v3, v1, v2) < (float)rad ) return 1;
+ if ( dist_to_line_segment_v2(v3, v1, v2) < (float)rad ) return 1;
return 0;
}
@@ -1676,16 +1687,20 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi
if (bp) {
bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL;
- } else {
+ }
+ else {
if (cu->drawflag & CU_HIDE_HANDLES) {
/* can only be beztindex==0 here since handles are hidden */
bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT);
- } else {
+ }
+ else {
if (beztindex==0) {
bezt->f1 = data->select?(bezt->f1|SELECT):(bezt->f1&~SELECT);
- } else if (beztindex==1) {
+ }
+ else if (beztindex==1) {
bezt->f2 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT);
- } else {
+ }
+ else {
bezt->f3 = data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT);
}
}
@@ -1748,13 +1763,14 @@ static void do_mesh_box_select__doSelectEdge(void *userData, BMEdge *eed, int x0
{
BoxSelectUserData *data = userData;
- if(EDBM_check_backbuf(bm_solidoffs+index)) {
+ if (EDBM_check_backbuf(bm_solidoffs+index)) {
if (data->pass==0) {
if (edge_fully_inside_rect(data->rect, x0, y0, x1, y1)) {
BM_elem_select_set(data->vc->em->bm, eed, data->select);
data->done = 1;
}
- } else {
+ }
+ else {
if (edge_inside_rect(data->rect, x0, y0, x1, y1)) {
BM_elem_select_set(data->vc->em->bm, eed, data->select);
}
@@ -1790,14 +1806,15 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten
glLoadMatrixf(vc->rv3d->viewmat);
bbsel= EDBM_init_backbuf_border(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
- if(ts->selectmode & SCE_SELECT_VERTEX) {
+ if (ts->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) {
EDBM_backbuf_checkAndSelectVerts(vc->em, select);
- } else {
+ }
+ else {
mesh_foreachScreenVert(vc, do_mesh_box_select__doSelectVert, &data, V3D_CLIP_TEST_RV3D_CLIPPING);
}
}
- if(ts->selectmode & SCE_SELECT_EDGE) {
+ if (ts->selectmode & SCE_SELECT_EDGE) {
/* Does both bbsel and non-bbsel versions (need screen cos for both) */
data.pass = 0;
@@ -1809,10 +1826,11 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten
}
}
- if(ts->selectmode & SCE_SELECT_FACE) {
- if(bbsel) {
+ if (ts->selectmode & SCE_SELECT_FACE) {
+ if (bbsel) {
EDBM_backbuf_checkAndSelectFaces(vc->em, select);
- } else {
+ }
+ else {
mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data);
}
}
@@ -1836,22 +1854,22 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, int select, int exten
hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, rect);
if (extend == 0 && select) {
- for(ml= mb->editelems->first; ml; ml= ml->next) {
+ for (ml= mb->editelems->first; ml; ml= ml->next) {
ml->flag &= ~SELECT;
}
}
- for(ml= mb->editelems->first; ml; ml= ml->next) {
- for(a=0; a<hits; a++) {
- if(ml->selcol1==buffer[ (4 * a) + 3 ]) {
+ for (ml= mb->editelems->first; ml; ml= ml->next) {
+ for (a=0; a<hits; a++) {
+ if (ml->selcol1==buffer[ (4 * a) + 3 ]) {
ml->flag |= MB_SCALE_RAD;
- if(select) ml->flag |= SELECT;
+ if (select) ml->flag |= SELECT;
else ml->flag &= ~SELECT;
break;
}
- if(ml->selcol2==buffer[ (4 * a) + 3 ]) {
+ if (ml->selcol2==buffer[ (4 * a) + 3 ]) {
ml->flag &= ~MB_SCALE_RAD;
- if(select) ml->flag |= SELECT;
+ if (select) ml->flag |= SELECT;
else ml->flag &= ~SELECT;
break;
}
@@ -1873,14 +1891,14 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, short select, sho
hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, rect);
/* clear flag we use to detect point was affected */
- for(ebone= arm->edbo->first; ebone; ebone= ebone->next)
+ for (ebone= arm->edbo->first; ebone; ebone= ebone->next)
ebone->flag &= ~BONE_DONE;
if (extend==0 && select)
ED_armature_deselect_all_visible(vc->obedit);
/* first we only check points inside the border */
- for (a=0; a<hits; a++){
+ for (a=0; a<hits; a++) {
int index = buffer[(4*a)+3];
if (index!=-1) {
ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
@@ -1901,21 +1919,21 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, short select, sho
}
/* now we have to flush tag from parents... */
- for(ebone= arm->edbo->first; ebone; ebone= ebone->next) {
- if(ebone->parent && (ebone->flag & BONE_CONNECTED)) {
- if(ebone->parent->flag & BONE_DONE)
+ for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+ if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
+ if (ebone->parent->flag & BONE_DONE)
ebone->flag |= BONE_DONE;
}
}
/* only select/deselect entire bones when no points where in the rect */
- for (a=0; a<hits; a++){
+ for (a=0; a<hits; a++) {
int index = buffer[(4*a)+3];
if (index!=-1) {
ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
if (index & BONESEL_BONE) {
if ((ebone->flag & BONE_UNSELECTABLE)==0) {
- if(!(ebone->flag & BONE_DONE)) {
+ if (!(ebone->flag & BONE_DONE)) {
if (select)
ebone->flag |= (BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED);
else
@@ -1942,7 +1960,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i
int totobj= MAXPICKBUF; // XXX solve later
short hits;
- if((ob) && (ob->mode & OB_MODE_POSE))
+ if ((ob) && (ob->mode & OB_MODE_POSE))
bone_only= 1;
else
bone_only= 0;
@@ -1955,7 +1973,8 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i
}
}
CTX_DATA_END;
- } else {
+ }
+ else {
object_deselect_all_visible(vc->scene, vc->v3d);
}
}
@@ -1979,14 +1998,14 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i
Base *base;
col = vbuffer + 3;
- for(base= vc->scene->base.first; base && hits; base= base->next) {
- if(BASE_SELECTABLE(vc->v3d, base)) {
+ for (base= vc->scene->base.first; base && hits; base= base->next) {
+ if (BASE_SELECTABLE(vc->v3d, base)) {
while (base->selcol == (*col & 0xFFFF)) { /* we got an object */
- if(*col & 0xFFFF0000) { /* we got a bone */
+ if (*col & 0xFFFF0000) { /* we got a bone */
bone = get_indexed_bone(base->object, *col & ~(BONESEL_ANY));
- if(bone) {
- if(select) {
+ if (bone) {
+ if (select) {
if ((bone->flag & BONE_UNSELECTABLE)==0) {
bone->flag |= BONE_SELECTED;
bone_selected=1;
@@ -1997,13 +2016,13 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i
bArmature *arm= base->object->data;
bone->flag &= ~BONE_SELECTED;
// XXX select_actionchannel_by_name(base->object->action, bone->name, 0);
- if(arm->act_bone==bone)
+ if (arm->act_bone==bone)
arm->act_bone= NULL;
}
}
}
- else if(!bone_only) {
+ else if (!bone_only) {
if (select)
ED_base_object_select(base, BA_SELECT);
else
@@ -2012,7 +2031,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i
col+=4; /* next color */
hits--;
- if(hits==0) break;
+ if (hits==0) break;
}
}
@@ -2050,38 +2069,38 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
rect.ymax= RNA_int_get(op->ptr, "ymax");
extend = RNA_boolean_get(op->ptr, "extend");
- if(vc.obedit) {
+ if (vc.obedit) {
switch(vc.obedit->type) {
case OB_MESH:
vc.em= ((Mesh *)vc.obedit->data)->edit_btmesh;
ret= do_mesh_box_select(&vc, &rect, select, extend);
// if (EM_texFaceCheck())
- if(ret & OPERATOR_FINISHED) {
+ if (ret & OPERATOR_FINISHED) {
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
}
break;
case OB_CURVE:
case OB_SURF:
ret= do_nurbs_box_select(&vc, &rect, select, extend);
- if(ret & OPERATOR_FINISHED) {
+ if (ret & OPERATOR_FINISHED) {
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
}
break;
case OB_MBALL:
ret= do_meta_box_select(&vc, &rect, select, extend);
- if(ret & OPERATOR_FINISHED) {
+ if (ret & OPERATOR_FINISHED) {
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
}
break;
case OB_ARMATURE:
ret= do_armature_box_select(&vc, &rect, select, extend);
- if(ret & OPERATOR_FINISHED) {
+ if (ret & OPERATOR_FINISHED) {
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit);
}
break;
case OB_LATTICE:
ret= do_lattice_box_select(&vc, &rect, select, extend);
- if(ret & OPERATOR_FINISHED) {
+ if (ret & OPERATOR_FINISHED) {
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
}
break;
@@ -2090,16 +2109,16 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
}
}
else { /* no editmode, unified for bones and objects */
- if(vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
+ if (vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
/* pass */
}
- else if(vc.obact && paint_facesel_test(vc.obact)) {
+ else if (vc.obact && paint_facesel_test(vc.obact)) {
ret= do_paintface_box_select(&vc, &rect, select, extend);
}
- else if(vc.obact && paint_vertsel_test(vc.obact)) {
+ else if (vc.obact && paint_vertsel_test(vc.obact)) {
ret= do_paintvert_box_select(&vc, &rect, select, extend);
}
- else if(vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) {
+ else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) {
ret= PE_border_select(C, &rect, select, extend);
}
else { /* object mode with none active */
@@ -2173,11 +2192,12 @@ static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], shor
unsigned int index = 0;
MVert *mv;
- if(vertsel_vert_pick(C, me, mval, &index, 50)) {
+ if (vertsel_vert_pick(C, me, mval, &index, 50)) {
mv = me->mvert+index;
- if(extend) {
+ if (extend) {
mv->flag ^= SELECT;
- } else {
+ }
+ else {
paintvert_deselect_all_visible(obact, SEL_DESELECT, FALSE);
mv->flag |= SELECT;
}
@@ -2203,7 +2223,7 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
view3d_operator_needs_opengl(C);
- if(object) {
+ if (object) {
obedit= NULL;
obact= NULL;
@@ -2213,24 +2233,24 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
center= FALSE;
}
- if(obedit && object==FALSE) {
- if(obedit->type==OB_MESH)
+ if (obedit && object==FALSE) {
+ if (obedit->type==OB_MESH)
retval = mouse_mesh(C, event->mval, extend);
- else if(obedit->type==OB_ARMATURE)
+ else if (obedit->type==OB_ARMATURE)
retval = mouse_armature(C, event->mval, extend);
- else if(obedit->type==OB_LATTICE)
+ else if (obedit->type==OB_LATTICE)
retval = mouse_lattice(C, event->mval, extend);
- else if(ELEM(obedit->type, OB_CURVE, OB_SURF))
+ else if (ELEM(obedit->type, OB_CURVE, OB_SURF))
retval = mouse_nurb(C, event->mval, extend);
- else if(obedit->type==OB_MBALL)
+ else if (obedit->type==OB_MBALL)
retval = mouse_mball(C, event->mval, extend);
}
- else if(obact && obact->mode & OB_MODE_SCULPT)
+ else if (obact && obact->mode & OB_MODE_SCULPT)
return OPERATOR_CANCELLED;
- else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT)
+ else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT)
return PE_mouse_particles(C, event->mval, extend);
- else if(obact && paint_facesel_test(obact))
+ else if (obact && paint_facesel_test(obact))
retval = paintface_mouse_select(C, obact, event->mval, extend);
else if (paint_vertsel_test(obact))
retval = mouse_weight_paint_vertex_select(C, event->mval, extend, obact);
@@ -2323,26 +2343,29 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f
data.mval[1] = mval[1];
data.radius = rad;
- if(ts->selectmode & SCE_SELECT_VERTEX) {
- if(bbsel) {
+ if (ts->selectmode & SCE_SELECT_VERTEX) {
+ if (bbsel) {
EDBM_backbuf_checkAndSelectVerts(vc->em, select==LEFTMOUSE);
- } else {
+ }
+ else {
mesh_foreachScreenVert(vc, mesh_circle_doSelectVert, &data, V3D_CLIP_TEST_RV3D_CLIPPING);
}
}
- if(ts->selectmode & SCE_SELECT_EDGE) {
+ if (ts->selectmode & SCE_SELECT_EDGE) {
if (bbsel) {
EDBM_backbuf_checkAndSelectEdges(vc->em, select==LEFTMOUSE);
- } else {
+ }
+ else {
mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_CLIP_TEST_OFF);
}
}
- if(ts->selectmode & SCE_SELECT_FACE) {
- if(bbsel) {
+ if (ts->selectmode & SCE_SELECT_FACE) {
+ if (bbsel) {
EDBM_backbuf_checkAndSelectFaces(vc->em, select==LEFTMOUSE);
- } else {
+ }
+ else {
mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data);
}
}
@@ -2398,16 +2421,20 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint
bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL;
- } else {
+ }
+ else {
if (cu->drawflag & CU_HIDE_HANDLES) {
/* can only be beztindex==0 here since handles are hidden */
bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT);
- } else {
+ }
+ else {
if (beztindex==0) {
bezt->f1 = data->select?(bezt->f1|SELECT):(bezt->f1&~SELECT);
- } else if (beztindex==1) {
+ }
+ else if (beztindex==1) {
bezt->f2 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT);
- } else {
+ }
+ else {
bezt->f3 = data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT);
}
}
@@ -2598,7 +2625,7 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2
change |= didpoint;
}
- if(change) {
+ if (change) {
ED_armature_sync_selection(arm->edbo);
ED_armature_validate_active(arm);
WM_main_add_notifier(NC_OBJECT|ND_BONE_SELECT, vc->obedit);
@@ -2644,7 +2671,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
select= (gesture_mode==GESTURE_MODAL_SELECT);
- if( CTX_data_edit_object(C) || paint_facesel_test(obact) || paint_vertsel_test(obact) ||
+ if ( CTX_data_edit_object(C) || paint_facesel_test(obact) || paint_vertsel_test(obact) ||
(obact && (obact->mode & (OB_MODE_PARTICLE_EDIT|OB_MODE_POSE))) )
{
ViewContext vc;
@@ -2656,36 +2683,36 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
mval[0]= x;
mval[1]= y;
- if(CTX_data_edit_object(C)) {
+ if (CTX_data_edit_object(C)) {
obedit_circle_select(&vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data);
}
- else if(paint_facesel_test(obact)) {
+ else if (paint_facesel_test(obact)) {
paint_facesel_circle_select(&vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data);
}
- else if(paint_vertsel_test(obact)) {
+ else if (paint_vertsel_test(obact)) {
paint_vertsel_circle_select(&vc, select, mval, (float)radius);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data);
}
- else if(obact->mode & OB_MODE_POSE)
+ else if (obact->mode & OB_MODE_POSE)
pose_circle_select(&vc, select, mval, (float)radius);
else
return PE_circle_select(C, select, mval, (float)radius);
}
- else if(obact && obact->mode & OB_MODE_SCULPT) {
+ else if (obact && obact->mode & OB_MODE_SCULPT) {
return OPERATOR_CANCELLED;
}
else {
Base *base;
select= select?BA_SELECT:BA_DESELECT;
- for(base= FIRSTBASE; base; base= base->next) {
- if(BASE_SELECTABLE(v3d, base)) {
+ for (base= FIRSTBASE; base; base= base->next) {
+ if (BASE_SELECTABLE(v3d, base)) {
project_short(ar, base->object->obmat[3], &base->sx);
- if(base->sx!=IS_CLIPPED) {
+ if (base->sx!=IS_CLIPPED) {
int dx= base->sx-x;
int dy= base->sy-y;
- if( dx*dx + dy*dy < radius*radius)
+ if ( dx*dx + dy*dy < radius*radius)
ED_base_object_select(base, select);
}
}