diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-05 19:55:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-05 19:55:28 +0400 |
commit | 11d5a2d2eba127e2f8502e570addb08c22cbb9c1 (patch) | |
tree | b4fe58b49cb097f31ab088c78e40852dcadc8fbd | |
parent | d186719f6d85647e640fdb7b61c092bb80c6069b (diff) |
Code Cleanup: style change only
31 files changed, 1201 insertions, 1057 deletions
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 821e9393fde..644a4f00a3f 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -82,7 +82,7 @@ BMVert *BM_Make_Vert(BMesh *bm, float co[3], BMVert *example) { BMVert *v = NULL; v = bmesh_mv(bm, co); - if(example) + if (example) CustomData_bmesh_copy_data(&bm->vdata, &bm->vdata, example->head.data, &v->head.data); return v; } @@ -106,13 +106,13 @@ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge *example, int nod { BMEdge *e = NULL; - if(nodouble) /*test if edge already exists.*/ + if (nodouble) /*test if edge already exists.*/ e = BM_Edge_Exist(v1, v2); - if(!e) { + if (!e) { e = bmesh_me(bm, v1, v2); - if(example) + if (example) CustomData_bmesh_copy_data(&bm->edata, &bm->edata, example->head.data, &e->head.data); } @@ -155,7 +155,7 @@ BMFace *BM_Make_Face_QuadTri_v(BMesh *bm, BMVert **verts, int len, const BMFace edar[0] = BM_Edge_Exist(verts[0], verts[1]); edar[1] = BM_Edge_Exist(verts[1], verts[2]); - if(len == 4) { + if (len == 4) { edar[2] = BM_Edge_Exist(verts[2], verts[3]); edar[3] = BM_Edge_Exist(verts[3], verts[0]); } @@ -163,9 +163,9 @@ BMFace *BM_Make_Face_QuadTri_v(BMesh *bm, BMVert **verts, int len, const BMFace edar[2] = BM_Edge_Exist(verts[2], verts[0]); } - if(nodouble) { + if (nodouble) { /*check if face exists or overlaps*/ - if(len == 4) { + if (len == 4) { overlap = BM_Exist_Face_Overlaps(bm, verts, len, &f); } else { @@ -174,21 +174,22 @@ BMFace *BM_Make_Face_QuadTri_v(BMesh *bm, BMVert **verts, int len, const BMFace } /*make new face*/ - if((!f) && (!overlap)) { - if(!edar[0]) edar[0] = BM_Make_Edge(bm, verts[0], verts[1], NULL, 0); - if(!edar[1]) edar[1] = BM_Make_Edge(bm, verts[1], verts[2], NULL, 0); - if(len == 4) { - if(!edar[2]) edar[2] = BM_Make_Edge(bm, verts[2], verts[3], NULL, 0); - if(!edar[3]) edar[3] = BM_Make_Edge(bm, verts[3], verts[0], NULL, 0); - } else { - if(!edar[2]) edar[2] = BM_Make_Edge(bm, verts[2], verts[0], NULL, 0); + if ((!f) && (!overlap)) { + if (!edar[0]) edar[0] = BM_Make_Edge(bm, verts[0], verts[1], NULL, 0); + if (!edar[1]) edar[1] = BM_Make_Edge(bm, verts[1], verts[2], NULL, 0); + if (len == 4) { + if (!edar[2]) edar[2] = BM_Make_Edge(bm, verts[2], verts[3], NULL, 0); + if (!edar[3]) edar[3] = BM_Make_Edge(bm, verts[3], verts[0], NULL, 0); + } + else { + if (!edar[2]) edar[2] = BM_Make_Edge(bm, verts[2], verts[0], NULL, 0); } f = BM_Make_Face(bm, verts, edar, len, 0); - if(example && f) + if (example && f) { BM_Copy_Attributes(bm, bm, example, f); - + } } return f; @@ -204,13 +205,14 @@ void BM_Face_CopyShared(BMesh *bm, BMFace *f) if (!f) return; l=BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); - for (; l; l=BMIter_Step(&iter)) { + for ( ; l; l=BMIter_Step(&iter)) { l2 = l->radial_next; if (l2 && l2 != l) { if (l2->v == l->v) { bm_copy_loop_attributes(bm, bm, l2, l); - } else { + } + else { l2 = l2->next; bm_copy_loop_attributes(bm, bm, l2, l); } @@ -371,7 +373,7 @@ void BM_remove_tagged_faces(BMesh *bm, int flag) BMIter iter; BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { - if(BMO_TestFlag(bm, f, flag)) BM_Kill_Face(bm, f); + if (BMO_TestFlag(bm, f, flag)) BM_Kill_Face(bm, f); } } @@ -381,7 +383,7 @@ void BM_remove_tagged_edges(BMesh *bm, int flag) BMIter iter; BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { - if(BMO_TestFlag(bm, e, flag)) BM_Kill_Edge(bm, e); + if (BMO_TestFlag(bm, e, flag)) BM_Kill_Edge(bm, e); } } @@ -391,7 +393,7 @@ void BM_remove_tagged_verts(BMesh *bm, int flag) BMIter iter; BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { - if(BMO_TestFlag(bm, v, flag)) BM_Kill_Vert(bm, v); + if (BMO_TestFlag(bm, v, flag)) BM_Kill_Vert(bm, v); } } @@ -441,23 +443,23 @@ void BM_Copy_Attributes(BMesh *source_mesh, BMesh *target_mesh, const void *sour const BMHeader *sheader = source; BMHeader *theader = target; - if(sheader->htype != theader->htype) + if (sheader->htype != theader->htype) return; /*First we copy select*/ - if(BM_Selected(source_mesh, source)) BM_Select(target_mesh, target, TRUE); + if (BM_Selected(source_mesh, source)) BM_Select(target_mesh, target, TRUE); /*Now we copy flags*/ theader->hflag = sheader->hflag; /*Copy specific attributes*/ - if(theader->htype == BM_VERT) + if (theader->htype == BM_VERT) bm_copy_vert_attributes(source_mesh, target_mesh, (const BMVert*)source, (BMVert*)target); - else if(theader->htype == BM_EDGE) + else if (theader->htype == BM_EDGE) bm_copy_edge_attributes(source_mesh, target_mesh, (const BMEdge*)source, (BMEdge*)target); - else if(theader->htype == BM_LOOP) + else if (theader->htype == BM_LOOP) bm_copy_loop_attributes(source_mesh, target_mesh, (const BMLoop*)source, (BMLoop*)target); - else if(theader->htype == BM_FACE) + else if (theader->htype == BM_FACE) bm_copy_face_attributes(source_mesh, target_mesh, (const BMFace*)source, (BMFace*)target); } diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 265c245359d..c9c17a738ab 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -118,15 +118,15 @@ void BM_Data_Facevert_Edgeinterp(BMesh *bm, BMVert *v1, BMVert *UNUSED(v2), BMVe w[1] = 1.0f - fac; w[0] = fac; - if(!e1->l) return; + if (!e1->l) return; l = e1->l; do { - if(l->v == v1) { + if (l->v == v1) { v1loop = l; vloop = v1loop->next; v2loop = vloop->next; } - else if(l->v == v) { + else if (l->v == v) { v1loop = l->next; vloop = l; v2loop = l->prev; @@ -140,7 +140,7 @@ void BM_Data_Facevert_Edgeinterp(BMesh *bm, BMVert *v1, BMVert *UNUSED(v2), BMVe CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, vloop->head.data); l = l->radial_next; - } while(l!=e1->l); + } while (l!=e1->l); } void BM_loops_to_corners(BMesh *bm, Mesh *me, int findex, @@ -155,7 +155,7 @@ void BM_loops_to_corners(BMesh *bm, Mesh *me, int findex, MLoopUV *mloopuv; int i, j; - for(i=0; i < numTex; i++) { + for (i=0; i < numTex; i++) { texface = CustomData_get_n(&me->fdata, CD_MTFACE, findex, i); texpoly = CustomData_bmesh_get_n(&bm->pdata, f->head.data, CD_MTEXPOLY, i); @@ -176,7 +176,7 @@ void BM_loops_to_corners(BMesh *bm, Mesh *me, int findex, } - for(i=0; i < numCol; i++) { + for (i=0; i < numCol; i++) { mcol = CustomData_get_n(&me->fdata, CD_MCOL, findex, i); j = 0; @@ -265,11 +265,13 @@ static void UNUSED_FUNCTION(closest_to_line_segment_v3_d)(double *closest, doubl lambda= closest_to_line_v3_d(cp,v1, v2, v3); - if(lambda <= 0.0) { + if (lambda <= 0.0) { VECCOPY(closest, v2); - } else if(lambda >= 1.0) { + } + else if (lambda >= 1.0) { VECCOPY(closest, v3); - } else { + } + else { VECCOPY(closest, cp); } } @@ -316,18 +318,18 @@ static double UNUSED_FUNCTION(dist_to_line_segment_v2_d)(double v1[3], double v2 rc[0]= v3[0]-v2[0]; rc[1]= v3[1]-v2[1]; len= rc[0]*rc[0]+ rc[1]*rc[1]; - if(len==0.0) { + if (len==0.0) { rc[0]= v1[0]-v2[0]; rc[1]= v1[1]-v2[1]; return sqrt(rc[0]*rc[0]+ rc[1]*rc[1]); } labda= (rc[0]*(v1[0]-v2[0]) + rc[1]*(v1[1]-v2[1]))/len; - if(labda<=0.0) { + if (labda<=0.0) { pt[0]= v2[0]; pt[1]= v2[1]; } - else if(labda>=1.0) { + else if (labda>=1.0) { pt[0]= v3[0]; pt[1]= v3[1]; } @@ -359,7 +361,8 @@ static int isect_point_quad_v2_d(double pt[2], double v1[2], double v2[2], doubl } } } - } else { + } + else { if (! (line_point_side_v2_d(v2,v3,pt)>=0.0)) { if (! (line_point_side_v2_d(v3,v4,pt)>=0.0)) { if (! (line_point_side_v2_d(v4,v1,pt)>=0.0)) { @@ -436,7 +439,8 @@ static double quad_coord(double aa[3], double bb[3], double cc[3], double dd[3], f2= fabs(f2); f1 = MIN2(f1, f2); CLAMP(f1, 0.0, 1.0+DBL_EPSILON); - } else { + } + else { f1 = -z/(y - 2*z); CLAMP(f1, 0.0, 1.0+DBL_EPSILON); @@ -685,7 +689,8 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f) o1 = sides*y + sides-1; o2 = (sides-1)*sides + y; - } else { + } + else { a1 = sides*y + sides-2; a2 = sides*y + sides-2; o1 = sides*y + sides-1; diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index 4357f3ca8e3..9f446eec1f8 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -167,7 +167,7 @@ void *bmiter__face_of_mesh_step(BMIter *iter) void bmiter__edge_of_vert_begin(BMIter *iter) { init_iterator(iter); - if(iter->vdata->e) { + if (iter->vdata->e) { iter->firstedge = iter->vdata->e; iter->nextedge = iter->vdata->e; } @@ -177,10 +177,10 @@ void *bmiter__edge_of_vert_step(BMIter *iter) { BMEdge *current = iter->nextedge; - if(iter->nextedge) + if (iter->nextedge) iter->nextedge = bmesh_disk_nextedge(iter->nextedge, iter->vdata); - if(iter->nextedge == iter->firstedge) iter->nextedge = NULL; + if (iter->nextedge == iter->firstedge) iter->nextedge = NULL; return current; } @@ -194,9 +194,9 @@ void bmiter__face_of_vert_begin(BMIter *iter) { init_iterator(iter); iter->count = 0; - if(iter->vdata->e) + if (iter->vdata->e) iter->count = bmesh_disk_count_facevert(iter->vdata); - if(iter->count) { + if (iter->count) { iter->firstedge = bmesh_disk_find_first_faceedge(iter->vdata->e, iter->vdata); iter->nextedge = iter->firstedge; iter->firstloop = bmesh_radial_find_first_facevert(iter->firstedge->l, iter->vdata); @@ -207,20 +207,20 @@ void *bmiter__face_of_vert_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->count && iter->nextloop) { + if (iter->count && iter->nextloop) { iter->count--; iter->nextloop = bmesh_radial_find_next_facevert(iter->nextloop, iter->vdata); - if(iter->nextloop == iter->firstloop) { + if (iter->nextloop == iter->firstloop) { iter->nextedge = bmesh_disk_find_next_faceedge(iter->nextedge, iter->vdata); iter->firstloop = bmesh_radial_find_first_facevert(iter->nextedge->l, iter->vdata); iter->nextloop = iter->firstloop; } } - if(!iter->count) iter->nextloop = NULL; + if (!iter->count) iter->nextloop = NULL; - if(current) return current->f; + if (current) return current->f; return NULL; } @@ -234,9 +234,9 @@ void bmiter__loop_of_vert_begin(BMIter *iter) { init_iterator(iter); iter->count = 0; - if(iter->vdata->e) + if (iter->vdata->e) iter->count = bmesh_disk_count_facevert(iter->vdata); - if(iter->count) { + if (iter->count) { iter->firstedge = bmesh_disk_find_first_faceedge(iter->vdata->e, iter->vdata); iter->nextedge = iter->firstedge; iter->firstloop = bmesh_radial_find_first_facevert(iter->firstedge->l, iter->vdata); @@ -247,20 +247,20 @@ void *bmiter__loop_of_vert_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->count) { + if (iter->count) { iter->count--; iter->nextloop = bmesh_radial_find_next_facevert(iter->nextloop, iter->vdata); - if(iter->nextloop == iter->firstloop) { + if (iter->nextloop == iter->firstloop) { iter->nextedge = bmesh_disk_find_next_faceedge(iter->nextedge, iter->vdata); iter->firstloop = bmesh_radial_find_first_facevert(iter->nextedge->l, iter->vdata); iter->nextloop = iter->firstloop; } } - if(!iter->count) iter->nextloop = NULL; + if (!iter->count) iter->nextloop = NULL; - if(current) return current; + if (current) return current; return NULL; } @@ -281,13 +281,13 @@ void *bmiter__loops_of_edge_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->nextloop) + if (iter->nextloop) iter->nextloop = bmesh_radial_nextloop(iter->nextloop); - if(iter->nextloop == iter->firstloop) + if (iter->nextloop == iter->firstloop) iter->nextloop = NULL; - if(current) return current; + if (current) return current; return NULL; } @@ -311,10 +311,10 @@ void *bmiter__loops_of_loop_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->nextloop) iter->nextloop = bmesh_radial_nextloop(iter->nextloop); + if (iter->nextloop) iter->nextloop = bmesh_radial_nextloop(iter->nextloop); - if(iter->nextloop == iter->firstloop) iter->nextloop = NULL; - if(current) return current; + if (iter->nextloop == iter->firstloop) iter->nextloop = NULL; + if (current) return current; return NULL; } @@ -327,7 +327,7 @@ void bmiter__face_of_edge_begin(BMIter *iter) { init_iterator(iter); - if(iter->edata->l) { + if (iter->edata->l) { iter->firstloop = iter->edata->l; iter->nextloop = iter->edata->l; } @@ -337,10 +337,10 @@ void *bmiter__face_of_edge_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->nextloop) iter->nextloop = bmesh_radial_nextloop(iter->nextloop); + if (iter->nextloop) iter->nextloop = bmesh_radial_nextloop(iter->nextloop); - if(iter->nextloop == iter->firstloop) iter->nextloop = NULL; - if(current) return current->f; + if (iter->nextloop == iter->firstloop) iter->nextloop = NULL; + if (current) return current->f; return NULL; } @@ -359,10 +359,10 @@ void *bmiter__vert_of_face_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->nextloop) iter->nextloop = iter->nextloop->next; - if(iter->nextloop == iter->firstloop) iter->nextloop = NULL; + if (iter->nextloop) iter->nextloop = iter->nextloop->next; + if (iter->nextloop == iter->firstloop) iter->nextloop = NULL; - if(current) return current->v; + if (current) return current->v; return NULL; } @@ -381,10 +381,10 @@ void *bmiter__edge_of_face_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->nextloop) iter->nextloop = iter->nextloop->next; - if(iter->nextloop == iter->firstloop) iter->nextloop = NULL; + if (iter->nextloop) iter->nextloop = iter->nextloop->next; + if (iter->nextloop == iter->firstloop) iter->nextloop = NULL; - if(current) return current->e; + if (current) return current->e; return NULL; } @@ -403,8 +403,8 @@ void *bmiter__loop_of_face_step(BMIter *iter) { BMLoop *current = iter->nextloop; - if(iter->nextloop) iter->nextloop = iter->nextloop->next; - if(iter->nextloop == iter->firstloop) iter->nextloop = NULL; + if (iter->nextloop) iter->nextloop = iter->nextloop->next; + if (iter->nextloop == iter->firstloop) iter->nextloop = NULL; return current; } diff --git a/source/blender/bmesh/intern/bmesh_iterators_inline.c b/source/blender/bmesh/intern/bmesh_iterators_inline.c index 2e5a2a06e84..cf621ee938f 100644 --- a/source/blender/bmesh/intern/bmesh_iterators_inline.c +++ b/source/blender/bmesh/intern/bmesh_iterators_inline.c @@ -63,7 +63,7 @@ BM_INLINE void *BMIter_New(BMIter *iter, BMesh *bm, const char itype, void *data iter->bm = bm; /* inlining optimizes out this switch when called with the defined type */ - switch(itype) { + switch (itype) { case BM_VERTS_OF_MESH: iter->begin = bmiter__vert_of_mesh_begin; iter->step = bmiter__vert_of_mesh_step; diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 2c99599f797..7275648fd22 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -87,25 +87,25 @@ void BM_SelectMode_Flush(BMesh *bm) int totsel; - if(bm->selectmode & SCE_SELECT_VERTEX) { - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm ); e; e= BMIter_Step(&edges)) { - if(BM_TestHFlag(e->v1, BM_SELECT) && BM_TestHFlag(e->v2, BM_SELECT) && !BM_TestHFlag(e, BM_HIDDEN)) { + if (bm->selectmode & SCE_SELECT_VERTEX) { + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e= BMIter_Step(&edges)) { + if (BM_TestHFlag(e->v1, BM_SELECT) && BM_TestHFlag(e->v2, BM_SELECT) && !BM_TestHFlag(e, BM_HIDDEN)) { BM_SetHFlag(e, BM_SELECT); } else { BM_ClearHFlag(e, BM_SELECT); } } - for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f= BMIter_Step(&faces)) { + for (f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f= BMIter_Step(&faces)) { totsel = 0; l=(BMLoop*) bm_firstfaceloop(f); do { - if(BM_TestHFlag(l->v, BM_SELECT)) + if (BM_TestHFlag(l->v, BM_SELECT)) totsel++; l = l->next; - } while(l != bm_firstfaceloop(f)); + } while (l != bm_firstfaceloop(f)); - if(totsel == f->len && !BM_TestHFlag(f, BM_HIDDEN)) { + if (totsel == f->len && !BM_TestHFlag(f, BM_HIDDEN)) { BM_SetHFlag(f, BM_SELECT); } else { @@ -113,17 +113,17 @@ void BM_SelectMode_Flush(BMesh *bm) } } } - else if(bm->selectmode & SCE_SELECT_EDGE) { - for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f= BMIter_Step(&faces)) { + else if (bm->selectmode & SCE_SELECT_EDGE) { + for (f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f= BMIter_Step(&faces)) { totsel = 0; l = bm_firstfaceloop(f); do { - if(BM_TestHFlag(&(l->e->head), BM_SELECT)) + if (BM_TestHFlag(&(l->e->head), BM_SELECT)) totsel++; l = l->next; - } while(l!=bm_firstfaceloop(f)); + } while (l!=bm_firstfaceloop(f)); - if(totsel == f->len && !BM_TestHFlag(f, BM_HIDDEN)) { + if (totsel == f->len && !BM_TestHFlag(f, BM_HIDDEN)) { BM_SetHFlag(f, BM_SELECT); } else { @@ -155,12 +155,13 @@ void BM_Select_Vert(BMesh *bm, BMVert *v, int select) return; } - if(select) { + if (select) { if (!BM_TestHFlag(v, BM_SELECT)) { bm->totvertsel += 1; BM_SetHFlag(v, BM_SELECT); } - } else { + } + else { if (BM_TestHFlag(v, BM_SELECT)) { bm->totvertsel -= 1; BM_ClearHFlag(v, BM_SELECT); @@ -182,7 +183,7 @@ void BM_Select_Edge(BMesh *bm, BMEdge *e, int select) return; } - if(select) { + if (select) { if (!BM_TestHFlag(e, BM_SELECT)) bm->totedgesel += 1; BM_SetHFlag(&(e->head), BM_SELECT); @@ -203,11 +204,11 @@ void BM_Select_Edge(BMesh *bm, BMEdge *e, int select) BMEdge *e2; int i; - for(i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { int deselect = 1; - for(e2 = BMIter_New(&iter, bm, BM_EDGES_OF_VERT, verts[i]); e2; e2 = BMIter_Step(&iter)) { - if(e2 == e) { + for (e2 = BMIter_New(&iter, bm, BM_EDGES_OF_VERT, verts[i]); e2; e2 = BMIter_Step(&iter)) { + if (e2 == e) { continue; } @@ -217,7 +218,7 @@ void BM_Select_Edge(BMesh *bm, BMEdge *e, int select) } } - if(deselect) BM_Select_Vert(bm, verts[i], FALSE); + if (deselect) BM_Select_Vert(bm, verts[i], FALSE); } } else { @@ -245,7 +246,7 @@ void BM_Select_Face(BMesh *bm, BMFace *f, int select) return; } - if(select) { + if (select) { if (!BM_TestHFlag(f, BM_SELECT)) bm->totfacesel += 1; BM_SetHFlag(&(f->head), BM_SELECT); @@ -254,7 +255,7 @@ void BM_Select_Face(BMesh *bm, BMFace *f, int select) BM_Select_Vert(bm, l->v, TRUE); BM_Select_Edge(bm, l->e, TRUE); l = l->next; - } while(l != bm_firstfaceloop(f)); + } while (l != bm_firstfaceloop(f)); } else { BMIter liter; @@ -313,28 +314,28 @@ void BM_Selectmode_Set(BMesh *bm, int selectmode) bm->selectmode = selectmode; - if(bm->selectmode & SCE_SELECT_VERTEX) { - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm ); e; e= BMIter_Step(&edges)) + if (bm->selectmode & SCE_SELECT_VERTEX) { + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e= BMIter_Step(&edges)) BM_ClearHFlag(e, 0); - for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f= BMIter_Step(&faces)) + for (f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f= BMIter_Step(&faces)) BM_ClearHFlag(f, 0); BM_SelectMode_Flush(bm); } - else if(bm->selectmode & SCE_SELECT_EDGE) { - for(v= BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm ); v; v= BMIter_Step(&verts)) + else if (bm->selectmode & SCE_SELECT_EDGE) { + for (v= BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v= BMIter_Step(&verts)) BM_ClearHFlag(v, 0); - for(e= BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm ); e; e= BMIter_Step(&edges)) { - if(BM_TestHFlag(&(e->head), BM_SELECT)) { + for (e= BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e= BMIter_Step(&edges)) { + if (BM_TestHFlag(&(e->head), BM_SELECT)) { BM_Select_Edge(bm, e, TRUE); } } BM_SelectMode_Flush(bm); } - else if(bm->selectmode & SCE_SELECT_FACE) { - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm ); e; e= BMIter_Step(&edges)) + else if (bm->selectmode & SCE_SELECT_FACE) { + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e= BMIter_Step(&edges)) BM_ClearHFlag(e, 0); - for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f= BMIter_Step(&faces)) { - if(BM_TestHFlag(&(f->head), BM_SELECT)) { + for (f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f= BMIter_Step(&faces)) { + if (BM_TestHFlag(&(f->head), BM_SELECT)) { BM_Select_Face(bm, f, TRUE); } } @@ -377,8 +378,8 @@ void BM_Select(struct BMesh *bm, void *element, int select) BMHeader *head = element; if (head->htype == BM_VERT) BM_Select_Vert(bm, (BMVert*)element, select); - else if(head->htype == BM_EDGE) BM_Select_Edge(bm, (BMEdge*)element, select); - else if(head->htype == BM_FACE) BM_Select_Face(bm, (BMFace*)element, select); + else if (head->htype == BM_EDGE) BM_Select_Edge(bm, (BMEdge*)element, select); + else if (head->htype == BM_FACE) BM_Select_Face(bm, (BMFace*)element, select); } int BM_Selected(BMesh *UNUSED(bm), const void *element) @@ -399,15 +400,16 @@ BMFace *BM_get_actFace(BMesh *bm, int sloppy) { if (bm->act_face) { return bm->act_face; - } else if (sloppy) { + } + else if (sloppy) { BMIter iter; BMFace *f= NULL; BMEditSelection *ese; /* Find the latest non-hidden face from the BMEditSelection */ ese = bm->selected.last; - for (; ese; ese=ese->prev) { - if(ese->htype == BM_FACE) { + for ( ; ese; ese=ese->prev) { + if (ese->htype == BM_FACE) { f= (BMFace *)ese->data; if (BM_TestHFlag(f, BM_HIDDEN)) { @@ -499,7 +501,8 @@ void BM_editselection_plane(BMesh *bm, float r_plane[3], BMEditSelection *ese) if (ese->prev) { /*use previously selected data to make a useful vertex plane */ BM_editselection_center(bm, vec, ese->prev); sub_v3_v3v3(r_plane, vec, eve->co); - } else { + } + else { /* make a fake plane thats at rightangles to the normal we cant make a crossvec from a vec thats the same as the vec unlikely but possible, so make sure if the normal is (0,0,1) @@ -587,8 +590,8 @@ static int BM_check_selection(BMesh *bm, void *data) { BMEditSelection *ese; - for(ese = bm->selected.first; ese; ese = ese->next) { - if(ese->data == data) return 1; + for (ese = bm->selected.first; ese; ese = ese->next) { + if (ese->data == data) return 1; } return 0; @@ -597,8 +600,8 @@ static int BM_check_selection(BMesh *bm, void *data) void BM_remove_selection(BMesh *bm, void *data) { BMEditSelection *ese; - for(ese=bm->selected.first; ese; ese = ese->next) { - if(ese->data == data) { + for (ese=bm->selected.first; ese; ese = ese->next) { + if (ese->data == data) { BLI_freelinkN(&(bm->selected),ese); break; } @@ -614,8 +617,8 @@ void BM_clear_selection_history(BMesh *bm) void BM_store_selection(BMesh *bm, void *data) { BMEditSelection *ese; - if(!BM_check_selection(bm, data)) { - ese = (BMEditSelection*) MEM_callocN( sizeof(BMEditSelection), "BMEdit Selection"); + if (!BM_check_selection(bm, data)) { + ese = (BMEditSelection*) MEM_callocN(sizeof(BMEditSelection), "BMEdit Selection"); ese->htype = ((BMHeader*)data)->htype; ese->data = data; BLI_addtail(&(bm->selected),ese); @@ -628,7 +631,7 @@ void BM_validate_selections(BMesh *bm) ese = bm->selected.first; - while(ese) { + while (ese) { nextese = ese->next; if (!BM_TestHFlag(ese->data, BM_SELECT)) { BLI_freelinkN(&(bm->selected), ese); diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index fe1a5ac9455..202a2fe7cfa 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -117,18 +117,18 @@ void BM_Free_Mesh_Data(BMesh *bm) BMIter faces; BMIter loops; - for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm ); v; v = BMIter_Step(&verts)) CustomData_bmesh_free_block( &(bm->vdata), &(v->head.data) ); - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm ); e; e = BMIter_Step(&edges)) CustomData_bmesh_free_block( &(bm->edata), &(e->head.data) ); - for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm ); f; f = BMIter_Step(&faces)) { - CustomData_bmesh_free_block( &(bm->pdata), &(f->head.data) ); - for(l = BMIter_New(&loops, bm, BM_LOOPS_OF_FACE, f ); l; l = BMIter_Step(&loops)) CustomData_bmesh_free_block( &(bm->ldata), &(l->head.data) ); + for (v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)) CustomData_bmesh_free_block(&(bm->vdata), &(v->head.data)); + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) CustomData_bmesh_free_block(&(bm->edata), &(e->head.data)); + for (f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)) { + CustomData_bmesh_free_block(&(bm->pdata), &(f->head.data)); + for (l = BMIter_New(&loops, bm, BM_LOOPS_OF_FACE, f); l; l = BMIter_Step(&loops)) CustomData_bmesh_free_block(&(bm->ldata), &(l->head.data)); } /*Free custom data pools, This should probably go in CustomData_free?*/ - if(bm->vdata.totlayer) BLI_mempool_destroy(bm->vdata.pool); - if(bm->edata.totlayer) BLI_mempool_destroy(bm->edata.pool); - if(bm->ldata.totlayer) BLI_mempool_destroy(bm->ldata.pool); - if(bm->pdata.totlayer) BLI_mempool_destroy(bm->pdata.pool); + if (bm->vdata.totlayer) BLI_mempool_destroy(bm->vdata.pool); + if (bm->edata.totlayer) BLI_mempool_destroy(bm->edata.pool); + if (bm->ldata.totlayer) BLI_mempool_destroy(bm->ldata.pool); + if (bm->pdata.totlayer) BLI_mempool_destroy(bm->pdata.pool); /*free custom data*/ CustomData_free(&bm->vdata,0); @@ -232,11 +232,11 @@ void BM_Compute_Normals(BMesh *bm) if (BM_TestHFlag(f, BM_HIDDEN)) continue; - if(f->len > maxlength) maxlength = f->len; + if (f->len > maxlength) maxlength = f->len; } /*make sure we actually have something to do*/ - if(maxlength < 3) return; + if (maxlength < 3) return; /*allocate projectverts array*/ projectverts = MEM_callocN(sizeof(float) * maxlength * 3, "BM normal computation array"); @@ -396,7 +396,8 @@ static void bmesh_set_mdisps_space(BMesh *bm, int from, int to) if (lmd->disps && lmd->totdisp == mdisps->totdisp) { memcpy(lmd->disps, mdisps->disps, sizeof(float)*3*lmd->totdisp); - } else if (mdisps->disps) { + } + else if (mdisps->disps) { if (lmd->disps) MEM_freeN(lmd->disps); @@ -447,7 +448,8 @@ void bmesh_begin_edit(BMesh *bm, int flag) /*ensure correct normals, if possible*/ bmesh_rationalize_normals(bm, 0); BM_Compute_Normals(bm); - } else if (flag & BMOP_RATIONALIZE_NORMALS) { + } + else if (flag & BMOP_RATIONALIZE_NORMALS) { bmesh_rationalize_normals(bm, 0); } #else @@ -466,7 +468,8 @@ void bmesh_end_edit(BMesh *bm, int flag) /*set normals to their previous winding*/ bmesh_rationalize_normals(bm, 1); bmesh_set_mdisps_space(bm, MULTIRES_SPACE_ABSOLUTE, MULTIRES_SPACE_TANGENT); - } else if (flag & BMOP_RATIONALIZE_NORMALS) { + } + else if (flag & BMOP_RATIONALIZE_NORMALS) { bmesh_rationalize_normals(bm, 1); } #else diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 806a0eedecf..09cdc80a76e 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -73,7 +73,7 @@ int BM_Dissolve_Vert(BMesh *bm, BMVert *v) if (!v) return 0; e = BMIter_New(&iter, bm, BM_EDGES_OF_VERT, v); - for (; e; e=BMIter_Step(&iter)) { + for ( ; e; e=BMIter_Step(&iter)) { len++; } @@ -84,12 +84,15 @@ int BM_Dissolve_Vert(BMesh *bm, BMVert *v) return 1; } - if(BM_Nonmanifold_Vert(bm, v)) { + if (BM_Nonmanifold_Vert(bm, v)) { if (!v->e) BM_Kill_Vert(bm, v); else if (!v->e->l) { BM_Kill_Edge(bm, v->e); BM_Kill_Vert(bm, v); - } else return 0; + } + else { + return 0; + } return 1; } @@ -103,22 +106,22 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) BMEdge *e, *keepedge=NULL, *baseedge=NULL; int len= 0; - if(BM_Nonmanifold_Vert(bm, v)) { + if (BM_Nonmanifold_Vert(bm, v)) { return 0; } - if(v->e) { + if (v->e) { /*v->e we keep, what else?*/ e = v->e; do { e = bmesh_disk_nextedge(e,v); - if(!(BM_Edge_Share_Faces(e, v->e))) { + if (!(BM_Edge_Share_Faces(e, v->e))) { keepedge = e; baseedge = v->e; break; } len++; - } while(e != v->e); + } while (e != v->e); } /*this code for handling 2 and 3-valence verts @@ -155,16 +158,16 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) return 1; } - if(keepedge) { + if (keepedge) { int done = 0; - while(!done) { + while (!done) { done = 1; e = v->e; do { f = NULL; len = bmesh_radial_length(e->l); - if(len == 2 && (e!=baseedge) && (e!=keepedge)) { + if (len == 2 && (e!=baseedge) && (e!=keepedge)) { f = BM_Join_TwoFaces(bm, e->l->f, e->l->radial_next->f, e); /*return if couldn't join faces in manifold conditions.*/ @@ -172,12 +175,12 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) if (!f) return 0; } - if(f) { + if (f) { done = 0; break; } e = bmesh_disk_nextedge(e, v); - } while(e != v->e); + } while (e != v->e); } /*collapse the vertex*/ @@ -209,9 +212,9 @@ void BM_Dissolve_Disk(BMesh *bm, BMVert *v) BMIter iter; int done, len; - if(v->e) { + if (v->e) { done = 0; - while(!done) { + while (!done) { done = 1; /*loop the edges looking for an edge to dissolve*/ @@ -219,12 +222,12 @@ void BM_Dissolve_Disk(BMesh *bm, BMVert *v) e = BMIter_Step(&iter)) { f = NULL; len = bmesh_cycle_length(&(e->l->radial)); - if(len == 2) { + if (len == 2) { f = BM_Join_TwoFaces(bm,e->l->f,((BMLoop*) (e->l->radial_next))->f, e); } - if(f) { + if (f) { done = 0; break; } @@ -259,16 +262,16 @@ BMFace *BM_Join_TwoFaces(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) BMFace *faces[2] = {f1, f2}; jed = e; - if(!jed) { + if (!jed) { /*search for an edge that has both these faces in its radial cycle*/ l1 = bm_firstfaceloop(f1); do { - if(l1->radial_next->f == f2 ) { + if (l1->radial_next->f == f2) { jed = l1->e; break; } l1 = l1->next; - } while(l1!=bm_firstfaceloop(f1)); + } while (l1!=bm_firstfaceloop(f1)); } if (!jed) { @@ -431,7 +434,7 @@ BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, con if (ke->l) { l = ke->l; do { - if(l->v == tv && l->next->v == kv) { + if (l->v == tv && l->next->v == kv) { tvloop = l; kvloop = l->next; @@ -650,7 +653,7 @@ BMVert *BM_Split_Edge_Multi(BMesh *bm, BMEdge *e, int numcuts) float percent; BMVert *nv = NULL; - for(i=0; i < numcuts; i++) { + for (i=0; i < numcuts; i++) { percent = 1.0f / (float)(numcuts + 1 - i); nv = BM_Split_Edge(bm, e->v2, e, NULL, percent); } @@ -740,7 +743,8 @@ BMEdge *BM_Rotate_Edge(BMesh *bm, BMEdge *e, int ccw) if (ccw) { l1 = l1->prev; l2 = l2->prev; - } else { + } + else { l1 = l1->next; l2 = l2->next; } diff --git a/source/blender/bmesh/intern/bmesh_newcore.c b/source/blender/bmesh/intern/bmesh_newcore.c index fba0f74c41f..56a24e0fd73 100644 --- a/source/blender/bmesh/intern/bmesh_newcore.c +++ b/source/blender/bmesh/intern/bmesh_newcore.c @@ -174,7 +174,7 @@ static BMLoop *bmesh_create_loop(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f, con bm->totloop++; - if(example) + if (example) CustomData_bmesh_copy_data(&bm->ldata, &bm->ldata, example->head.data, &l->head.data); else CustomData_bmesh_set_default(&bm->ldata, &l->head.data); @@ -212,7 +212,8 @@ BMFace *BM_Copy_Face(BMesh *bm, BMFace *f, int copyedges, int copyverts) if (copyverts) { BMVert *v = BM_Make_Vert(bm, l->v->co, l->v); BLI_array_append(verts, v); - } else { + } + else { BLI_array_append(verts, l->v); } l = l->next; @@ -228,14 +229,16 @@ BMFace *BM_Copy_Face(BMesh *bm, BMFace *f, int copyedges, int copyverts) if (l->e->v1 == verts[i]) { v1 = verts[i]; v2 = verts[(i+1)%f->len]; - } else { + } + else { v2 = verts[i]; v1 = verts[(i+1)%f->len]; } e = BM_Make_Edge(bm, v1, v2, l->e, 0); BLI_array_append(edges, e); - } else { + } + else { BLI_array_append(edges, l->e); } @@ -648,14 +651,14 @@ static int bmesh_loop_reverse_loop(BMesh *bm, BMFace *f, BMLoopList *lst) len = bmesh_loop_length(l); - for(i=0, curloop = l; i< len; i++, curloop= curloop->next) { + for (i=0, curloop = l; i< len; i++, curloop= curloop->next) { BMEdge *curedge = curloop->e; bmesh_radial_remove_loop(curloop, curedge); BLI_array_append(edar, curedge); } /*actually reverse the loop.*/ - for(i=0, curloop = l; i < len; i++) { + for (i=0, curloop = l; i < len; i++) { oldnext = curloop->next; oldprev = curloop->prev; curloop->next = oldprev; @@ -681,17 +684,17 @@ static int bmesh_loop_reverse_loop(BMesh *bm, BMFace *f, BMLoopList *lst) } } - if(len == 2) { /* two edged face */ + if (len == 2) { /* two edged face */ /* do some verification here! */ l->e = edar[1]; l->next->e = edar[0]; } else { - for(i=0, curloop = l; i < len; i++, curloop = curloop->next) { + for (i=0, curloop = l; i < len; i++, curloop = curloop->next) { edok = 0; - for(j=0; j < len; j++) { + for (j=0; j < len; j++) { edok = bmesh_verts_in_edge(curloop->v, curloop->next->v, edar[j]); - if(edok) { + if (edok) { curloop->e = edar[j]; break; } @@ -699,11 +702,11 @@ static int bmesh_loop_reverse_loop(BMesh *bm, BMFace *f, BMLoopList *lst) } } /*rebuild radial*/ - for(i=0, curloop = l; i < len; i++, curloop = curloop->next) + for (i=0, curloop = l; i < len; i++, curloop = curloop->next) bmesh_radial_append(curloop->e, curloop); /*validate radial*/ - for(i=0, curloop = l; i < len; i++, curloop = curloop->next) { + for (i=0, curloop = l; i < len; i++, curloop = curloop->next) { BM_CHECK_ELEMENT(bm, curloop); BM_CHECK_ELEMENT(bm, curloop->e); BM_CHECK_ELEMENT(bm, curloop->v); @@ -865,7 +868,8 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) if (rlen > 2) { err = "Input faces do not form a contiguous manifold region"; goto error; - } else if (rlen == 1) { + } + else if (rlen == 1) { BLI_array_append(edges, l->e); if (!v1) { @@ -873,7 +877,8 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) v2 = BM_OtherEdgeVert(l->e, l->v); } tote++; - } else if (rlen == 2) { + } + else if (rlen == 2) { int d1, d2; d1 = disk_is_flagged(l->e->v1, _FLAG_JF); @@ -882,7 +887,8 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) if (!d1 && !d2 && !bmesh_api_getflag(l->e, _FLAG_JF)) { BLI_array_append(deledges, l->e); bmesh_api_setflag(l->e, _FLAG_JF); - } else { + } + else { if (d1 && !bmesh_api_getflag(l->e->v1, _FLAG_JF)) { BLI_array_append(delverts, l->e->v1); bmesh_api_setflag(l->e->v1, _FLAG_JF); @@ -1074,12 +1080,12 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, /*verify that v1 and v2 are in face.*/ len = f->len; - for(i = 0, curloop = bm_firstfaceloop(f); i < len; i++, curloop = curloop->next) { - if(curloop->v == v1) v1loop = curloop; - else if(curloop->v == v2) v2loop = curloop; + for (i = 0, curloop = bm_firstfaceloop(f); i < len; i++, curloop = curloop->next) { + if (curloop->v == v1) v1loop = curloop; + else if (curloop->v == v2) v2loop = curloop; } - if(!v1loop || !v2loop) return NULL; + if (!v1loop || !v2loop) return NULL; /*allocate new edge between v1 and v2*/ e = BM_Make_Edge(bm, v1, v2, NULL, 0); @@ -1132,12 +1138,13 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, f->len = f1len; - if(rl) *rl = f2loop; + if (rl) *rl = f2loop; if (holes) { BLI_movelisttolist(&f2->loops, holes); - } else { - /*this code is not significant until holes actually work ;) */ + } + else { + /* this code is not significant until holes actually work ;) */ //printf("warning: call to split face euler without holes argument; holes will be tossed.\n"); for (lst=f->loops.last; lst != f->loops.first; lst=lst2) { lst2 = lst->prev; @@ -1174,7 +1181,7 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) BMVert *nv, *ov; int i, edok, valence1=0, valence2=0; - if(bmesh_vert_in_edge(e,tv) == 0) return NULL; + if (bmesh_vert_in_edge(e,tv) == 0) return NULL; ov = bmesh_edge_getothervert(e,tv); /*count valence of v1*/ @@ -1206,22 +1213,22 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) /*verify disk cycles*/ edok = bmesh_disk_validate(valence1, ov->e, ov); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); edok = bmesh_disk_validate(valence2, tv->e, tv); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); edok = bmesh_disk_validate(2, nv->e, nv); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); /*Split the radial cycle if present*/ nextl = e->l; e->l = NULL; - if(nextl) { + if (nextl) { BMLoop *nl, *l; int radlen = bmesh_radial_length(nextl); int first1=0, first2=0; /*Take the next loop. Remove it from radial. Split it. Append to appropriate radials.*/ - while(nextl) { + while (nextl) { l=nextl; l->f->len++; nextl = nextl!=nextl->radial_next ? nextl->radial_next : NULL; @@ -1235,17 +1242,17 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) nl->v = nv; /*assign the correct edge to the correct loop*/ - if(bmesh_verts_in_edge(nl->v, nl->next->v, e)) { + if (bmesh_verts_in_edge(nl->v, nl->next->v, e)) { nl->e = e; l->e = ne; /*append l into ne's rad cycle*/ - if(!first1) { + if (!first1) { first1 = 1; l->radial_next = l->radial_prev = NULL; } - if(!first2) { + if (!first2) { first2 = 1; l->radial_next = l->radial_prev = NULL; } @@ -1253,17 +1260,17 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) bmesh_radial_append(nl->e, nl); bmesh_radial_append(l->e, l); } - else if(bmesh_verts_in_edge(nl->v, nl->next->v, ne)) { + else if (bmesh_verts_in_edge(nl->v, nl->next->v, ne)) { nl->e = ne; l->e = e; /*append l into ne's rad cycle*/ - if(!first1) { + if (!first1) { first1 = 1; l->radial_next = l->radial_prev = NULL; } - if(!first2) { + if (!first2) { first2 = 1; l->radial_next = l->radial_prev = NULL; } @@ -1276,19 +1283,19 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) /*verify length of radial cycle*/ edok = bmesh_radial_validate(radlen, e->l); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); edok = bmesh_radial_validate(radlen, ne->l); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); /*verify loop->v and loop->next->v pointers for e*/ - for(i=0,l=e->l; i < radlen; i++, l = l->radial_next) { - if(!(l->e == e)) bmesh_error(); - //if(!(l->radial_next == l)) bmesh_error(); - if(l->prev->e != ne && l->next->e != ne) bmesh_error(); + for (i=0,l=e->l; i < radlen; i++, l = l->radial_next) { + if (!(l->e == e)) bmesh_error(); + //if (!(l->radial_next == l)) bmesh_error(); + if (l->prev->e != ne && l->next->e != ne) bmesh_error(); edok = bmesh_verts_in_edge(l->v, l->next->v, e); - if(!edok) bmesh_error(); - if(l->v == l->next->v) bmesh_error(); - if(l->e == l->next->e) bmesh_error(); + if (!edok) bmesh_error(); + if (l->v == l->next->v) bmesh_error(); + if (l->e == l->next->e) bmesh_error(); /*verify loop cycle for kloop->f*/ BM_CHECK_ELEMENT(bm, l); @@ -1297,14 +1304,14 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) BM_CHECK_ELEMENT(bm, l->f); } /*verify loop->v and loop->next->v pointers for ne*/ - for(i=0,l=ne->l; i < radlen; i++, l = l->radial_next) { - if(!(l->e == ne)) bmesh_error(); - //if(!(l->radial_next == l)) bmesh_error(); - if( l->prev->e != e && l->next->e != e) bmesh_error(); + for (i=0,l=ne->l; i < radlen; i++, l = l->radial_next) { + if (!(l->e == ne)) bmesh_error(); + //if (!(l->radial_next == l)) bmesh_error(); + if (l->prev->e != e && l->next->e != e) bmesh_error(); edok = bmesh_verts_in_edge(l->v, l->next->v, ne); - if(!edok) bmesh_error(); - if(l->v == l->next->v) bmesh_error(); - if(l->e == l->next->e) bmesh_error(); + if (!edok) bmesh_error(); + if (l->v == l->next->v) bmesh_error(); + if (l->e == l->next->e) bmesh_error(); BM_CHECK_ELEMENT(bm, l); BM_CHECK_ELEMENT(bm, l->v); @@ -1319,7 +1326,7 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) BM_CHECK_ELEMENT(bm, e); BM_CHECK_ELEMENT(bm, tv); - if(re) *re = ne; + if (re) *re = ne; return nv; } @@ -1361,16 +1368,16 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) BMLoop *killoop, *l; int len,radlen=0, halt = 0, i, valence1, valence2,edok; - if(bmesh_vert_in_edge(ke,kv) == 0) return 0; + if (bmesh_vert_in_edge(ke,kv) == 0) return 0; len = bmesh_disk_count(kv); - if(len == 2) { + if (len == 2) { oe = bmesh_disk_nextedge(ke, kv); tv = bmesh_edge_getothervert(ke, kv); ov = bmesh_edge_getothervert(oe, kv); halt = bmesh_verts_in_edge(kv, tv, oe); /*check for double edges*/ - if(halt) { + if (halt) { return 0; } else { @@ -1389,11 +1396,11 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) /*deal with radial cycle of ke*/ radlen = bmesh_radial_length(ke->l); - if(ke->l) { + if (ke->l) { /*first step, fix the neighboring loops of all loops in ke's radial cycle*/ - for(i=0,killoop = ke->l; i<radlen; i++, killoop = bmesh_radial_nextloop(killoop)) { + for (i=0,killoop = ke->l; i<radlen; i++, killoop = bmesh_radial_nextloop(killoop)) { /*relink loops and fix vertex pointer*/ - if( killoop->next->v == kv ) killoop->next->v = tv; + if (killoop->next->v == kv) killoop->next->v = tv; killoop->next->prev = killoop->prev; killoop->prev->next = killoop->next; @@ -1428,7 +1435,7 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) /*Validate radial cycle of oe*/ edok = bmesh_radial_validate(radlen,oe->l); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); } @@ -1440,17 +1447,17 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) /*Validate disk cycle lengths of ov,tv are unchanged*/ edok = bmesh_disk_validate(valence1, ov->e, ov); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); edok = bmesh_disk_validate(valence2, tv->e, tv); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); /*Validate loop cycle of all faces attached to oe*/ - for(i=0,l = oe->l; i<radlen; i++, l = bmesh_radial_nextloop(l)) { - if(l->e != oe) bmesh_error(); + for (i=0,l = oe->l; i<radlen; i++, l = bmesh_radial_nextloop(l)) { + if (l->e != oe) bmesh_error(); edok = bmesh_verts_in_edge(l->v, l->next->v, oe); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); edok = bmesh_loop_validate(l->f); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); BM_CHECK_ELEMENT(bm, l); BM_CHECK_ELEMENT(bm, l->v); @@ -1506,18 +1513,18 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) BMIter iter; /*can't join a face to itself*/ - if(f1 == f2) return NULL; + if (f1 == f2) return NULL; /*verify that e is in both f1 and f2*/ f1len = f1->len; f2len = f2->len; BM_ITER(curloop, &iter, bm, BM_LOOPS_OF_FACE, f1) { - if(curloop->e == e) { + if (curloop->e == e) { f1loop = curloop; break; } } BM_ITER(curloop, &iter, bm, BM_LOOPS_OF_FACE, f2) { - if(curloop->e == e) { + if (curloop->e == e) { f2loop = curloop; break; } @@ -1526,45 +1533,45 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) /*validate that edge is 2-manifold edge*/ radlen = bmesh_radial_length(f1loop); - if(radlen != 2) return NULL; + if (radlen != 2) return NULL; /*validate direction of f2's loop cycle is compatible.*/ - if(f1loop->v == f2loop->v) return NULL; + if (f1loop->v == f2loop->v) return NULL; /* validate that for each face, each vertex has another edge in its disk cycle that is not e, and not shared. */ - if(bmesh_radial_find_face(f1loop->next->e,f2)) return NULL; - if(bmesh_radial_find_face(f1loop->prev->e,f2)) return NULL; - if(bmesh_radial_find_face(f2loop->next->e,f1)) return NULL; - if(bmesh_radial_find_face(f2loop->prev->e,f1)) return NULL; + if (bmesh_radial_find_face(f1loop->next->e,f2)) return NULL; + if (bmesh_radial_find_face(f1loop->prev->e,f2)) return NULL; + if (bmesh_radial_find_face(f2loop->next->e,f1)) return NULL; + if (bmesh_radial_find_face(f2loop->prev->e,f1)) return NULL; /*validate only one shared edge*/ shared = BM_Face_Share_Edges(f1,f2); - if(shared > 1) return NULL; + if (shared > 1) return NULL; /*validate no internal joins*/ - for(i=0, curloop = bm_firstfaceloop(f1); i < f1len; i++, curloop = curloop->next) + for (i=0, curloop = bm_firstfaceloop(f1); i < f1len; i++, curloop = curloop->next) bmesh_api_setindex(curloop->v, 0); - for(i=0, curloop = bm_firstfaceloop(f2); i < f2len; i++, curloop = curloop->next) + for (i=0, curloop = bm_firstfaceloop(f2); i < f2len; i++, curloop = curloop->next) bmesh_api_setindex(curloop->v, 0); - for(i=0, curloop = bm_firstfaceloop(f1); i < f1len; i++, curloop = curloop->next) { + for (i=0, curloop = bm_firstfaceloop(f1); i < f1len; i++, curloop = curloop->next) { if (curloop != f1loop) bmesh_api_setindex(curloop->v, bmesh_api_getindex(curloop->v) + 1); } - for(i=0, curloop = bm_firstfaceloop(f2); i < f2len; i++, curloop = curloop->next) { + for (i=0, curloop = bm_firstfaceloop(f2); i < f2len; i++, curloop = curloop->next) { if (curloop != f2loop) bmesh_api_setindex(curloop->v, bmesh_api_getindex(curloop->v) + 1); } - for(i=0, curloop = bm_firstfaceloop(f1); i < f1len; i++, curloop = curloop->next) { + for (i=0, curloop = bm_firstfaceloop(f1); i < f1len; i++, curloop = curloop->next) { if (bmesh_api_getindex(curloop->v) > 1) return NULL; } - for(i=0, curloop = bm_firstfaceloop(f2); i < f2len; i++, curloop = curloop->next) { + for (i=0, curloop = bm_firstfaceloop(f2); i < f2len; i++, curloop = curloop->next) { if (bmesh_api_getindex(curloop->v) > 1) return NULL; } @@ -1577,7 +1584,7 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) f2loop->prev->next = f1loop->next; /*if f1loop was baseloop, make f1loop->next the base.*/ - if(bm_firstfaceloop(f1) == f1loop) + if (bm_firstfaceloop(f1) == f1loop) bm_firstfaceloop(f1) = f1loop->next; /*increase length of f1*/ @@ -1585,7 +1592,7 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) /*make sure each loop points to the proper face*/ newlen = f1->len; - for(i = 0, curloop = bm_firstfaceloop(f1); i < newlen; i++, curloop = curloop->next) + for (i = 0, curloop = bm_firstfaceloop(f1); i < newlen; i++, curloop = curloop->next) curloop->f = f1; /*remove edge from the disk cycle of its two vertices.*/ @@ -1610,7 +1617,7 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) /*validate the new loop cycle*/ edok = bmesh_loop_validate(f1); - if(!edok) bmesh_error(); + if (!edok) bmesh_error(); return f1; } diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 7ebf686c9d8..4695cda4a3f 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -119,7 +119,7 @@ void BMO_push(BMesh *bm, BMOperator *UNUSED(op)) */ void BMO_pop(BMesh *bm) { - if(bm->stackdepth > 1) + if (bm->stackdepth > 1) free_flag_layer(bm); bm->stackdepth--; @@ -150,7 +150,7 @@ void BMO_Init_Op(BMesh *bm, BMOperator *op, const char *opname) op->flag = opdefines[opcode]->flag; /*initialize the operator slot types*/ - for(i = 0; opdefines[opcode]->slottypes[i].type; i++) { + for (i = 0; opdefines[opcode]->slottypes[i].type; i++) { op->slots[i].slottype = opdefines[opcode]->slottypes[i].type; op->slots[i].index = i; } @@ -177,11 +177,11 @@ void BMO_Exec_Op(BMesh *bm, BMOperator *op) BMO_push(bm, op); - if(bm->stackdepth == 2) + if (bm->stackdepth == 2) bmesh_begin_edit(bm, op->flag); op->exec(bm, op); - if(bm->stackdepth == 2) + if (bm->stackdepth == 2) bmesh_end_edit(bm, op->flag); BMO_pop(bm); @@ -254,10 +254,10 @@ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, const char *src, c BMOpSlot *source_slot = BMO_GetSlot(source_op, src); BMOpSlot *dest_slot = BMO_GetSlot(dest_op, dst); - if(source_slot == dest_slot) + if (source_slot == dest_slot) return; - if(source_slot->slottype != dest_slot->slottype) + if (source_slot->slottype != dest_slot->slottype) return; if (dest_slot->slottype > BMOP_OPSLOT_VEC) { @@ -265,11 +265,12 @@ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, const char *src, c /*do buffer copy*/ dest_slot->data.buf = NULL; dest_slot->len = source_slot->len; - if(dest_slot->len) { + if (dest_slot->len) { dest_slot->data.buf = BLI_memarena_alloc(dest_op->arena, BMOP_OPSLOT_TYPEINFO[dest_slot->slottype] * dest_slot->len); memcpy(dest_slot->data.buf, source_slot->data.buf, BMOP_OPSLOT_TYPEINFO[dest_slot->slottype] * dest_slot->len); } - } else { + } + else { GHashIterator it; element_mapping *srcmap, *dstmap; @@ -283,7 +284,7 @@ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, const char *src, c } BLI_ghashIterator_init(&it, source_slot->data.ghash); - for (; (srcmap=BLI_ghashIterator_getValue(&it)); + for ( ; (srcmap=BLI_ghashIterator_getValue(&it)); BLI_ghashIterator_step(&it)) { dstmap = BLI_memarena_alloc(dest_op->arena, @@ -297,7 +298,8 @@ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, const char *src, c dstmap->element, dstmap); } } - } else { + } + else { dest_slot->data = source_slot->data; } } @@ -313,7 +315,7 @@ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, const char *src, c void BMO_Set_Float(BMOperator *op, const char *slotname, float f) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_FLT) ) + if (!(slot->slottype == BMOP_OPSLOT_FLT)) return; slot->data.f = f; @@ -322,7 +324,7 @@ void BMO_Set_Float(BMOperator *op, const char *slotname, float f) void BMO_Set_Int(BMOperator *op, const char *slotname, int i) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_INT) ) + if (!(slot->slottype == BMOP_OPSLOT_INT)) return; slot->data.i = i; @@ -332,7 +334,7 @@ void BMO_Set_Int(BMOperator *op, const char *slotname, int i) void BMO_Set_Mat(struct BMOperator *op, const char *slotname, float *mat, int size) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_MAT) ) + if (!(slot->slottype == BMOP_OPSLOT_MAT)) return; slot->len = 4; @@ -340,9 +342,11 @@ void BMO_Set_Mat(struct BMOperator *op, const char *slotname, float *mat, int si if (size == 4) { memcpy(slot->data.p, mat, sizeof(float)*4*4); - } else if (size == 3) { + } + else if (size == 3) { copy_m4_m3(slot->data.p, (float (*)[3])mat); - } else { + } + else { fprintf(stderr, "%s: invalid size argument %d (bmesh internal error)\n", __func__, size); memset(slot->data.p, 0, sizeof(float)*4*4); @@ -353,7 +357,7 @@ void BMO_Set_Mat(struct BMOperator *op, const char *slotname, float *mat, int si void BMO_Get_Mat4(struct BMOperator *op, const char *slotname, float mat[4][4]) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_MAT) ) + if (!(slot->slottype == BMOP_OPSLOT_MAT)) return; memcpy(mat, slot->data.p, sizeof(float)*4*4); @@ -362,7 +366,7 @@ void BMO_Get_Mat4(struct BMOperator *op, const char *slotname, float mat[4][4]) void BMO_Get_Mat3(struct BMOperator *op, const char *slotname, float mat[3][3]) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_MAT) ) + if (!(slot->slottype == BMOP_OPSLOT_MAT)) return; copy_m3_m4(mat, slot->data.p); @@ -371,7 +375,7 @@ void BMO_Get_Mat3(struct BMOperator *op, const char *slotname, float mat[3][3]) void BMO_Set_Pnt(BMOperator *op, const char *slotname, void *p) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_PNT) ) + if (!(slot->slottype == BMOP_OPSLOT_PNT)) return; slot->data.p = p; @@ -380,7 +384,7 @@ void BMO_Set_Pnt(BMOperator *op, const char *slotname, void *p) void BMO_Set_Vec(BMOperator *op, const char *slotname, const float vec[3]) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_VEC) ) + if (!(slot->slottype == BMOP_OPSLOT_VEC)) return; copy_v3_v3(slot->data.vec, vec); @@ -390,7 +394,7 @@ void BMO_Set_Vec(BMOperator *op, const char *slotname, const float vec[3]) float BMO_Get_Float(BMOperator *op, const char *slotname) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_FLT) ) + if (!(slot->slottype == BMOP_OPSLOT_FLT)) return 0.0f; return slot->data.f; @@ -399,7 +403,7 @@ float BMO_Get_Float(BMOperator *op, const char *slotname) int BMO_Get_Int(BMOperator *op, const char *slotname) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_INT) ) + if (!(slot->slottype == BMOP_OPSLOT_INT)) return 0; return slot->data.i; @@ -409,7 +413,7 @@ int BMO_Get_Int(BMOperator *op, const char *slotname) void *BMO_Get_Pnt(BMOperator *op, const char *slotname) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_PNT) ) + if (!(slot->slottype == BMOP_OPSLOT_PNT)) return NULL; return slot->data.p; @@ -418,7 +422,7 @@ void *BMO_Get_Pnt(BMOperator *op, const char *slotname) void BMO_Get_Vec(BMOperator *op, const char *slotname, float r_vec[3]) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - if( !(slot->slottype == BMOP_OPSLOT_VEC) ) + if (!(slot->slottype == BMOP_OPSLOT_VEC)) return; copy_v3_v3(r_vec, slot->data.vec); @@ -438,21 +442,21 @@ int BMO_CountFlag(BMesh *bm, int flag, const char htype) BMHeader *e; int count = 0; - if(htype & BM_VERT) { - for(e = BMIter_New(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(BMO_TestFlag(bm, e, flag)) + if (htype & BM_VERT) { + for (e = BMIter_New(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BMIter_Step(&elements)) { + if (BMO_TestFlag(bm, e, flag)) count++; } } - if(htype & BM_EDGE) { - for(e = BMIter_New(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(BMO_TestFlag(bm, e, flag)) + if (htype & BM_EDGE) { + for (e = BMIter_New(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { + if (BMO_TestFlag(bm, e, flag)) count++; } } - if(htype & BM_FACE) { - for(e = BMIter_New(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(BMO_TestFlag(bm, e, flag)) + if (htype & BM_FACE) { + for (e = BMIter_New(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { + if (BMO_TestFlag(bm, e, flag)) count++; } } @@ -485,7 +489,7 @@ int BMO_CountSlotBuf(struct BMesh *UNUSED(bm), struct BMOperator *op, const char BMOpSlot *slot = BMO_GetSlot(op, slotname); /*check if its actually a buffer*/ - if( !(slot->slottype > BMOP_OPSLOT_VEC) ) + if (!(slot->slottype > BMOP_OPSLOT_VEC)) return 0; return slot->len; @@ -496,7 +500,7 @@ int BMO_CountSlotMap(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) BMOpSlot *slot = BMO_GetSlot(op, slotname); /*check if its actually a buffer*/ - if( !(slot->slottype == BMOP_OPSLOT_MAPPING) ) + if (!(slot->slottype == BMOP_OPSLOT_MAPPING)) return 0; return slot->data.ghash ? BLI_ghash_size(slot->data.ghash) : 0; @@ -509,7 +513,7 @@ void *BMO_Grow_Array(BMesh *bm, BMOperator *op, int slotcode, int totadd) void *tmp; /*check if its actually a buffer*/ - if( !(slot->slottype > BMOP_OPSLOT_VEC) ) + if (!(slot->slottype > BMOP_OPSLOT_VEC)) return NULL; if (slot->flag & BMOS_DYNAMIC_ARRAY) { @@ -523,7 +527,8 @@ void *BMO_Grow_Array(BMesh *bm, BMOperator *op, int slotcode, int totadd) } slot->len += totadd; - } else { + } + else { slot->flag |= BMOS_DYNAMIC_ARRAY; slot->len += totadd; slot->size = slot->len+2; @@ -558,11 +563,11 @@ static void *alloc_slot_buffer(BMOperator *op, const char *slotname, int len) BMOpSlot *slot = BMO_GetSlot(op, slotname); /*check if its actually a buffer*/ - if( !(slot->slottype > BMOP_OPSLOT_VEC) ) + if (!(slot->slottype > BMOP_OPSLOT_VEC)) return NULL; slot->len = len; - if(len) + if (len) slot->data.buf = BLI_memarena_alloc(op->arena, BMOP_OPSLOT_TYPEINFO[slot->slottype] * len); return slot->data.buf; } @@ -587,7 +592,7 @@ static void BMO_All_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, con if (htype & BM_EDGE) totelement += bm->totedge; if (htype & BM_FACE) totelement += bm->totface; - if(totelement) { + if (totelement) { alloc_slot_buffer(op, slotname, totelement); if (htype & BM_VERT) { @@ -632,12 +637,12 @@ void BMO_HeaderFlag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, totelement = BM_CountFlag(bm, htype, hflag, 1); - if(totelement) { + if (totelement) { alloc_slot_buffer(op, slotname, totelement); if (htype & BM_VERT) { for (e = BMIter_New(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, hflag)) { + if (!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, hflag)) { ((BMHeader**)output->data.p)[i] = e; i++; } @@ -646,7 +651,7 @@ void BMO_HeaderFlag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, if (htype & BM_EDGE) { for (e = BMIter_New(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, hflag)) { + if (!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, hflag)) { ((BMHeader**)output->data.p)[i] = e; i++; } @@ -655,13 +660,14 @@ void BMO_HeaderFlag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, if (htype & BM_FACE) { for (e = BMIter_New(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, hflag)) { + if (!BM_TestHFlag(e, BM_HIDDEN) && BM_TestHFlag(e, hflag)) { ((BMHeader**)output->data.p)[i] = e; i++; } } } - } else { + } + else { output->len = 0; } } @@ -681,12 +687,12 @@ void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, BMOpSlot *output = BMO_GetSlot(op, slotname); int totelement = BMO_CountFlag(bm, flag, htype), i=0; - if(totelement) { + if (totelement) { alloc_slot_buffer(op, slotname, totelement); if (htype & BM_VERT) { for (e = BMIter_New(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(BMO_TestFlag(bm, e, flag)) { + if (BMO_TestFlag(bm, e, flag)) { ((BMHeader**)output->data.p)[i] = e; i++; } @@ -695,7 +701,7 @@ void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, if (htype & BM_EDGE) { for (e = BMIter_New(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(BMO_TestFlag(bm, e, flag)) { + if (BMO_TestFlag(bm, e, flag)) { ((BMHeader**)output->data.p)[i] = e; i++; } @@ -704,13 +710,14 @@ void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, if (htype & BM_FACE) { for (e = BMIter_New(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - if(BMO_TestFlag(bm, e, flag)) { + if (BMO_TestFlag(bm, e, flag)) { ((BMHeader**)output->data.p)[i] = e; i++; } } } - } else { + } + else { output->len = 0; } } @@ -729,7 +736,7 @@ void BMO_HeaderFlag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, BMHeader **data = slot->data.p; int i; - for(i = 0; i < slot->len; i++) { + for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) continue; @@ -754,7 +761,7 @@ void BMO_UnHeaderFlag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, BMHeader **data = slot->data.p; int i; - for(i = 0; i < slot->len; i++) { + for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) continue; @@ -769,12 +776,12 @@ int BMO_Vert_CountEdgeFlags(BMesh *bm, BMVert *v, int toolflag) { int count= 0; - if(v->e) { + if (v->e) { BMEdge *curedge; const int len= bmesh_disk_count(v); int i; - for(i = 0, curedge=v->e; i<len; i++) { + for (i = 0, curedge=v->e; i<len; i++) { if (BMO_TestFlag(bm, curedge, toolflag)) count++; curedge = bmesh_disk_nextedge(curedge, v); @@ -797,7 +804,7 @@ void BMO_Flag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, BMHeader **data = slot->data.p; int i; - for(i = 0; i < slot->len; i++) { + for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) continue; @@ -818,7 +825,7 @@ void BMO_Unflag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, BMHeader **data = slot->data.p; int i; - for(i = 0; i < slot->len; i++) { + for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) continue; @@ -942,13 +949,13 @@ static void clear_flag_layer(BMesh *bm) BMIter faces; /*now go through and memcpy all the flags*/ - for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)) { + for (v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)) { memset(v->head.flags+(bm->totflags-1), 0, sizeof(BMFlagLayer)); } - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) { + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) { memset(e->head.flags+(bm->totflags-1), 0, sizeof(BMFlagLayer)); } - for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)) { + for (f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)) { memset(f->head.flags+(bm->totflags-1), 0, sizeof(BMFlagLayer)); } } @@ -997,7 +1004,8 @@ void *BMO_IterStep(BMOIter *iter) } return h; - } else if (iter->slot->slottype == BMOP_OPSLOT_MAPPING) { + } + else if (iter->slot->slottype == BMOP_OPSLOT_MAPPING) { struct element_mapping *map; void *ret = BLI_ghashIterator_getKey(&iter->giter); map = BLI_ghashIterator_getValue(&iter->giter); @@ -1227,7 +1235,8 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) state = 0; fmt += i; - } else { + } + else { switch (*fmt) { case ' ': case '\t': @@ -1290,7 +1299,8 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) nextc(fmt)==0) { BMO_Set_Float(op,slotname,va_arg(vlist,double)); - } else { + } + else { ret = 0; stop = 0; while (1) { @@ -1434,7 +1444,7 @@ static void BMO_ClearFlag(BMesh *bm, void *element, const int flag) static int BMO_TestFlag(BMesh *bm, void *element, int flag) { BMHeader *head = element; - if(head->flags[bm->stackdepth-1].f & flag) + if (head->flags[bm->stackdepth-1].f & flag) return 1; return 0; } diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 62755d6b558..dd163d3e248 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -66,10 +66,10 @@ static short testedgeside(const double v1[2], const double v2[2], const double v //inp= (v2[cox]-v1[cox])*(v1[coy]-v3[coy]) +(v1[coy]-v2[coy])*(v1[cox]-v3[cox]); inp= (v2[0]-v1[0])*(v1[1]-v3[1]) +(v1[1]-v2[1])*(v1[0]-v3[0]); - if(inp<0.0) return 0; - else if(inp==0) { - if(v1[0]==v3[0] && v1[1]==v3[1]) return 0; - if(v2[0]==v3[0] && v2[1]==v3[1]) return 0; + if (inp<0.0) return 0; + else if (inp==0) { + if (v1[0]==v3[0] && v1[1]==v3[1]) return 0; + if (v2[0]==v3[0] && v2[1]==v3[1]) return 0; } return 1; } @@ -82,17 +82,17 @@ static short testedgesidef(const float v1[2], const float v2[2], const float v3[ //inp= (v2[cox]-v1[cox])*(v1[coy]-v3[coy]) +(v1[coy]-v2[coy])*(v1[cox]-v3[cox]); inp= (v2[0]-v1[0])*(v1[1]-v3[1]) +(v1[1]-v2[1])*(v1[0]-v3[0]); - if(inp<0.0) return 0; - else if(inp==0) { - if(v1[0]==v3[0] && v1[1]==v3[1]) return 0; - if(v2[0]==v3[0] && v2[1]==v3[1]) return 0; + if (inp<0.0) return 0; + else if (inp==0) { + if (v1[0]==v3[0] && v1[1]==v3[1]) return 0; + if (v2[0]==v3[0] && v2[1]==v3[1]) return 0; } return 1; } static int point_in_triangle(const double v1[2], const double v2[2], const double v3[2], const double pt[2]) { - if(testedgeside(v1,v2,pt) && testedgeside(v2,v3,pt) && testedgeside(v3,v1,pt)) + if (testedgeside(v1,v2,pt) && testedgeside(v2,v3,pt) && testedgeside(v3,v1,pt)) return 1; return 0; } @@ -117,7 +117,7 @@ static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts) /*this fixes some weird numerical error*/ add_v3_fl(verts[0], 0.0001f); - for(i = 0; i < nverts; i++) { + for (i = 0; i < nverts; i++) { copy_v3_v3(u, verts[i]); copy_v3_v3(v, verts[(i+1) % nverts]); copy_v3_v3(w, verts[(i+2) % nverts]); @@ -150,7 +150,7 @@ static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts) n[2] += (u[0] - v[0]) * (u[1] + v[1]); } - if(normalize_v3_v3(normal, n) == 0.0f) { + if (normalize_v3_v3(normal, n) == 0.0f) { normal[2] = 1.0f; /* other axis set to 0.0 */ } @@ -170,7 +170,10 @@ static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts) normal[2] = 1.0f; return; - } else l = 1.0f / l; + } + else { + l = 1.0f / l; + } mul_v3_fl(n, l); @@ -194,13 +197,13 @@ static int compute_poly_center(float center[3], float *r_area, float (*verts)[3] zero_v3(center); - if(nverts < 3) + if (nverts < 3) return 0; i = nverts-1; j = 0; - while(j < nverts) { + while (j < nverts) { ai = verts[i][0] * verts[j][1] - verts[j][0] * verts[i][1]; atmp += ai; xtmp += (verts[j][0] + verts[i][0]) * ai; @@ -209,7 +212,7 @@ static int compute_poly_center(float center[3], float *r_area, float (*verts)[3] j += 1; } - if(r_area) + if (r_area) *r_area = atmp / 2.0f; if (atmp != 0) { @@ -295,17 +298,17 @@ void compute_poly_plane(float (*verts)[3], int nverts) float *v1, *v2, *v3; int i; - if(nverts < 3) + if (nverts < 3) return; zero_v3(avgn); zero_v3(avgc); - for(i = 0; i < nverts; i++) { + for (i = 0; i < nverts; i++) { v1 = verts[i]; v2 = verts[(i+1) % nverts]; v3 = verts[(i+2) % nverts]; - normal_tri_v3( norm,v1, v2, v3); + normal_tri_v3(norm,v1, v2, v3); add_v3_v3(avgn, norm); } @@ -315,7 +318,8 @@ void compute_poly_plane(float (*verts)[3], int nverts) avgn[0] = 0.0f; avgn[1] = 0.0f; avgn[2] = 1.0f; - } else { + } + else { /* XXX, why is this being divided and _then_ normalized * division could be removed? - campbell */ avgn[0] /= nverts; @@ -324,7 +328,7 @@ void compute_poly_plane(float (*verts)[3], int nverts) normalize_v3(avgn); } - for(i = 0; i < nverts; i++) { + for (i = 0; i < nverts; i++) { v1 = verts[i]; mag = dot_v3v3(v1, avgn); madd_v3_v3fl(v1, avgn, -mag); @@ -398,7 +402,7 @@ void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nvert axis_angle_to_quat(q, axis, (float)angle); quat_to_mat3(mat, q); - for(i = 0; i < nverts; i++) + for (i = 0; i < nverts; i++) mul_m3_v3(mat, verts[i]); } @@ -445,7 +449,7 @@ void BM_Edge_UpdateNormals(BMesh *bm, BMEdge *e) BMFace *f; f = BMIter_New(&iter, bm, BM_FACES_OF_EDGE, e); - for (; f; f=BMIter_Step(&iter)) { + for ( ; f; f=BMIter_Step(&iter)) { BM_Face_UpdateNormal(bm, f); } @@ -493,7 +497,7 @@ void BM_Vert_UpdateAllNormals(BMesh *bm, BMVert *v) int len=0; f = BMIter_New(&iter, bm, BM_FACES_OF_VERT, v); - for (; f; f=BMIter_Step(&iter), len++) { + for ( ; f; f=BMIter_Step(&iter), len++) { BM_Face_UpdateNormal(bm, f); } @@ -795,9 +799,9 @@ static BMLoop *find_ear(BMesh *UNUSED(bm), BMFace *f, float (*verts)[3], BM_GetIndex(v3), nvert)) isear = 0; - if(isear) { + if (isear) { /*angle = angle_v3v3v3(verts[v1->head.eflag2], verts[v2->head.eflag2], verts[v3->head.eflag2]); - if(!bestear || ABS(angle-45.0f) < bestangle) { + if (!bestear || ABS(angle-45.0f) < bestangle) { bestear = l; bestangle = ABS(45.0f-angle); } @@ -810,7 +814,7 @@ static BMLoop *find_ear(BMesh *UNUSED(bm), BMFace *f, float (*verts)[3], } l = l->next; } - while(l != bm_firstfaceloop(f)); + while (l != bm_firstfaceloop(f)); return bestear; } @@ -846,7 +850,7 @@ void BM_Triangulate_Face(BMesh *bm, BMFace *f, float (*projectverts)[3], BM_SetIndex(l->v, i); /* set dirty! */ i++; l = l->next; - } while(l != bm_firstfaceloop(f)); + } while (l != bm_firstfaceloop(f)); bm->elem_index_dirty |= BM_VERT; /* see above */ @@ -863,10 +867,10 @@ void BM_Triangulate_Face(BMesh *bm, BMFace *f, float (*projectverts)[3], } done = 0; - while(!done && f->len > 3) { + while (!done && f->len > 3) { done = 1; l = find_ear(bm, f, projectverts, nvert); - if(l) { + if (l) { done = 0; /* v = l->v; */ /* UNUSED */ f = BM_Split_Face(bm, l->f, l->prev->v, @@ -943,7 +947,7 @@ void BM_LegalSplits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len) i = 0; l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); - for (; l; l=BMIter_Step(&iter)) { + for ( ; l; l=BMIter_Step(&iter)) { BM_SetIndex(l, i); /* set_loop */ copy_v3_v3(projverts[i], l->v->co); i++; diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index e2ed7043bbb..aea7a7ab908 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -54,9 +54,9 @@ int BM_Count_Element(BMesh *bm, const char htype) { - if(htype == BM_VERT) return bm->totvert; - else if(htype == BM_EDGE) return bm->totedge; - else if(htype == BM_FACE) return bm->totface; + if (htype == BM_VERT) return bm->totvert; + else if (htype == BM_EDGE) return bm->totedge; + else if (htype == BM_FACE) return bm->totface; return 0; } @@ -112,7 +112,7 @@ int BM_Vert_In_Face(BMFace *f, BMVert *v) for (lst=f->loops.first; lst; lst=lst->next) { l = lst->first; do { - if(l->v == v) return 1; + if (l->v == v) return 1; l = l->next; } while (l != lst->first); } @@ -133,20 +133,20 @@ int BM_Verts_In_Face(BMesh *bm, BMFace *f, BMVert **varr, int len) BMLoop *curloop = NULL; int i, count = 0; - for(i=0; i < len; i++) BMO_SetFlag(bm, varr[i], BM_OVERLAP); + for (i=0; i < len; i++) BMO_SetFlag(bm, varr[i], BM_OVERLAP); for (lst=f->loops.first; lst; lst=lst->next) { curloop = lst->first; do { - if(BMO_TestFlag(bm, curloop->v, BM_OVERLAP)) + if (BMO_TestFlag(bm, curloop->v, BM_OVERLAP)) count++; curloop = curloop->next; } while (curloop != lst->first); } - for(i=0; i < len; i++) BMO_ClearFlag(bm, varr[i], BM_OVERLAP); + for (i=0; i < len; i++) BMO_ClearFlag(bm, varr[i], BM_OVERLAP); return count; } @@ -166,9 +166,9 @@ int BM_Edge_In_Face(BMFace *f, BMEdge *e) l = bm_firstfaceloop(f); do { - if(l->e == e) return 1; + if (l->e == e) return 1; l = l->next; - } while(l != bm_firstfaceloop(f)); + } while (l != bm_firstfaceloop(f)); return 0; } @@ -221,12 +221,12 @@ int BM_Edge_FaceCount(BMEdge *e) int count = 0; BMLoop *curloop = NULL; - if(e->l) { + if (e->l) { curloop = e->l; do { count++; curloop = bmesh_radial_nextloop(curloop); - } while(curloop != e->l); + } while (curloop != e->l); } return count; @@ -251,12 +251,12 @@ int BM_Vert_FaceCount(BMVert *v) #if 0 //this code isn't working BMEdge *curedge = NULL; - if(v->e) { + if (v->e) { curedge = v->e; do { - if(curedge->l) count += BM_Edge_FaceCount(curedge); + if (curedge->l) count += BM_Edge_FaceCount(curedge); curedge = bmesh_disk_nextedge(curedge,v); - } while(curedge != v->e); + } while (curedge != v->e); } return count; #endif @@ -276,13 +276,13 @@ int BM_Wire_Vert(BMesh *UNUSED(bm), BMVert *v) { BMEdge *curedge; - if(!(v->e)) return 0; + if (!(v->e)) return 0; curedge = v->e; do { - if(curedge->l) return 0; + if (curedge->l) return 0; curedge = bmesh_disk_nextedge(curedge, v); - } while(curedge != v->e); + } while (curedge != v->e); return 1; } @@ -299,7 +299,7 @@ int BM_Wire_Vert(BMesh *UNUSED(bm), BMVert *v) int BM_Wire_Edge(BMesh *UNUSED(bm), BMEdge *e) { - if(e->l) return 0; + if (e->l) return 0; return 1; } @@ -346,7 +346,7 @@ int BM_Nonmanifold_Vert(BMesh *UNUSED(bm), BMVert *v) e = NULL; oe = v->e; l = oe->l; - while(e != oe) { + while (e != oe) { l = (l->v == v) ? l->prev : l->next; e = l->e; count++; /* count the edges */ @@ -390,7 +390,7 @@ int BM_Nonmanifold_Vert(BMesh *UNUSED(bm), BMVert *v) int BM_Nonmanifold_Edge(BMesh *UNUSED(bm), BMEdge *e) { int count = BM_Edge_FaceCount(e); - if(count != 2 && count != 1) return 1; + if (count != 2 && count != 1) return 1; return 0; } @@ -407,7 +407,7 @@ int BM_Nonmanifold_Edge(BMesh *UNUSED(bm), BMEdge *e) int BM_Boundary_Edge(BMEdge *e) { int count = BM_Edge_FaceCount(e); - if(count == 1) return 1; + if (count == 1) return 1; return 0; } @@ -430,9 +430,9 @@ int BM_Face_Share_Edges(BMFace *f1, BMFace *f2) l = bm_firstfaceloop(f1); do { - if(bmesh_radial_find_face(l->e,f2)) count++; + if (bmesh_radial_find_face(l->e,f2)) count++; l = l->next; - } while(l != bm_firstfaceloop(f1)); + } while (l != bm_firstfaceloop(f1)); return count; } @@ -450,15 +450,15 @@ int BM_Edge_Share_Faces(BMEdge *e1, BMEdge *e2) BMLoop *l; BMFace *f; - if(e1->l && e2->l) { + if (e1->l && e2->l) { l = e1->l; do { f = l->f; - if(bmesh_radial_find_face(e2,f)) { + if (bmesh_radial_find_face(e2,f)) { return 1; } l = l->radial_next; - } while(l != e1->l); + } while (l != e1->l); } return 0; } @@ -551,11 +551,11 @@ int BM_Exist_Face_Overlaps(BMesh *bm, BMVert **varr, int len, BMFace **overlapfa if (overlapface) *overlapface = NULL; - for(i=0; i < len; i++) { - f = BMIter_New(&vertfaces, bm, BM_FACES_OF_VERT, varr[i] ); - while(f) { + for (i=0; i < len; i++) { + f = BMIter_New(&vertfaces, bm, BM_FACES_OF_VERT, varr[i]); + while (f) { amount = BM_Verts_In_Face(bm, f, varr, len); - if(amount >= len) { + if (amount >= len) { if (overlapface) *overlapface = f; return 1; } @@ -587,11 +587,11 @@ int BM_Face_Exists(BMesh *bm, BMVert **varr, int len, BMFace **existface) if (existface) *existface = NULL; - for(i=0; i < len; i++) { - f = BMIter_New(&vertfaces, bm, BM_FACES_OF_VERT, varr[i] ); - while(f) { + for (i=0; i < len; i++) { + f = BMIter_New(&vertfaces, bm, BM_FACES_OF_VERT, varr[i]); + while (f) { amount = BM_Verts_In_Face(bm, f, varr, len); - if(amount == len && amount == f->len) { + if (amount == len && amount == f->len) { if (existface) *existface = f; return 1; } diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c index e17206518cb..b022a7f8853 100644 --- a/source/blender/bmesh/intern/bmesh_structure.c +++ b/source/blender/bmesh/intern/bmesh_structure.c @@ -53,30 +53,30 @@ int bmesh_vert_in_edge(BMEdge *e, BMVert *v) { - if(e->v1 == v || e->v2 == v) return 1; + if (e->v1 == v || e->v2 == v) return 1; return 0; } int bmesh_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e) { - if(e->v1 == v1 && e->v2 == v2) return 1; - else if(e->v1 == v2 && e->v2 == v1) return 1; + if (e->v1 == v1 && e->v2 == v2) return 1; + else if (e->v1 == v2 && e->v2 == v1) return 1; return 0; } BMVert *bmesh_edge_getothervert(BMEdge *e, BMVert *v) { - if(e->v1 == v) return e->v2; - else if(e->v2 == v) return e->v1; + if (e->v1 == v) return e->v2; + else if (e->v2 == v) return e->v1; return NULL; } int bmesh_edge_swapverts(BMEdge *e, BMVert *orig, BMVert *newv) { - if(e->v1 == orig) { + if (e->v1 == orig) { e->v1 = newv; e->dlink1.next = e->dlink1.prev = NULL; return 1; } - else if(e->v2 == orig) { + else if (e->v2 == orig) { e->v2 = newv; e->dlink2.next = e->dlink2.prev = NULL; return 1; @@ -163,7 +163,8 @@ int bmesh_disk_append_edge(struct BMEdge *e, struct BMVert *v) v->e = e; e1->next = e1->prev = (Link*)e; - } else { + } + else { Link *e1, *e2, *e3; e1 = bm_get_edge_link(e, v); @@ -224,7 +225,7 @@ BMEdge *bmesh_disk_existedge(BMVert *v1, BMVert *v2) { BMEdge *curedge, *startedge; - if(v1->e) { + if (v1->e) { startedge = v1->e; curedge = startedge; do { @@ -296,15 +297,15 @@ int bmesh_disk_count_facevert(BMVert *v) int count = 0; /*is there an edge on this vert at all?*/ - if(!v->e) + if (!v->e) return count; /*first, loop around edges*/ curedge = v->e; do { - if(curedge->l) count += bmesh_radial_count_facevert(curedge->l, v); + if (curedge->l) count += bmesh_radial_count_facevert(curedge->l, v); curedge = bmesh_disk_nextedge(curedge, v); - } while(curedge != v->e); + } while (curedge != v->e); return count; } @@ -314,9 +315,9 @@ struct BMEdge *bmesh_disk_find_first_faceedge(struct BMEdge *e, struct BMVert *v BMEdge *searchedge = NULL; searchedge = e; do { - if(searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; + if (searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; searchedge = bmesh_disk_nextedge(searchedge,v); - } while(searchedge != e); + } while (searchedge != e); return NULL; } @@ -326,9 +327,9 @@ struct BMEdge *bmesh_disk_find_next_faceedge(struct BMEdge *e, struct BMVert *v) BMEdge *searchedge = NULL; searchedge = bmesh_disk_nextedge(e,v); do { - if(searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; + if (searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; searchedge = bmesh_disk_nextedge(searchedge,v); - } while(searchedge !=e); + } while (searchedge !=e); return e; } @@ -385,7 +386,8 @@ void bmesh_radial_remove_loop(BMLoop *l, BMEdge *e) l->radial_next->radial_prev = l->radial_prev; l->radial_prev->radial_next = l->radial_next; - } else { + } + else { if (e) { if (l == e->l) { e->l = NULL; @@ -415,9 +417,9 @@ BMLoop *bmesh_radial_find_first_facevert(BMLoop *l, BMVert *v) BMLoop *curloop; curloop = l; do { - if(curloop->v == v) return curloop; + if (curloop->v == v) return curloop; curloop = bmesh_radial_nextloop(curloop); - } while(curloop != l); + } while (curloop != l); return NULL; } @@ -426,9 +428,9 @@ BMLoop *bmesh_radial_find_next_facevert(BMLoop *l, BMVert *v) BMLoop *curloop; curloop = bmesh_radial_nextloop(l); do { - if(curloop->v == v) return curloop; + if (curloop->v == v) return curloop; curloop = bmesh_radial_nextloop(curloop); - } while(curloop !=l); + } while (curloop !=l); return l; } @@ -465,10 +467,11 @@ int bmesh_radial_length(BMLoop *l) void bmesh_radial_append(BMEdge *e, BMLoop *l) { - if(e->l == NULL) { + if (e->l == NULL) { e->l = l; l->radial_next = l->radial_prev = l; - } else { + } + else { l->radial_prev = e->l; l->radial_next = e->l->radial_next; @@ -492,8 +495,8 @@ int bmesh_radial_find_face(BMEdge *e, BMFace *f) int i, len; len = bmesh_radial_length(e->l); - for(i = 0, curloop = e->l; i < len; i++, curloop = curloop->radial_next) { - if(curloop->f == f) + for (i = 0, curloop = e->l; i < len; i++, curloop = curloop->radial_next) { + if (curloop->f == f) return 1; } return 0; @@ -513,9 +516,9 @@ int bmesh_radial_count_facevert(BMLoop *l, BMVert *v) int count = 0; curloop = l; do { - if(curloop->v == v) count++; + if (curloop->v == v) count++; curloop = bmesh_radial_nextloop(curloop); - } while(curloop != l); + } while (curloop != l); return count; } @@ -531,17 +534,17 @@ int bmesh_loop_validate(BMFace *f) return 0; /* Validate that the face loop cycle is the length specified by f->len */ - for(i = 1, curloop = head->next; i < len; i++, curloop = curloop->next) { + for (i = 1, curloop = head->next; i < len; i++, curloop = curloop->next) { if (curloop->f != f) return 0; if (curloop == head) return 0; } - if(curloop != head) return 0; + if (curloop != head) return 0; /* Validate the loop->prev links also form a cycle of length f->len */ - for(i = 1, curloop = head->prev; i < len; i++, curloop = curloop->prev) { + for (i = 1, curloop = head->prev; i < len; i++, curloop = curloop->prev) { if (curloop == head) return 0; } - if(curloop != head) return 0; + if (curloop != head) return 0; return 1; } @@ -555,7 +558,7 @@ void bmesh_cycle_append(void *h, void *nt) head = (BMNode*)h; newtail = (BMNode*)nt; - if(head->next == NULL) { + if (head->next == NULL) { head->next = newtail; head->prev = newtail; newtail->next = head; @@ -619,14 +622,14 @@ int bmesh_cycle_remove(void *h, void *remn) remnode = (BMNode*)remn; len = bmesh_cycle_length(h); - if(len == 1 && head == remnode) { + if (len == 1 && head == remnode) { head->next = NULL; head->prev = NULL; return 1; } else { - for(i=0, curnode = head; i < len; curnode = curnode->next) { - if(curnode == remnode) { + for (i=0, curnode = head; i < len; curnode = curnode->next) { + if (curnode == remnode) { remnode->prev->next = remnode->next; remnode->next->prev = remnode->prev; /*zero out remnode pointers, important!*/ @@ -658,12 +661,12 @@ int bmesh_cycle_validate(int len, void *h) head = (BMNode*)h; /*forward validation*/ - for(i = 0, curnode = head; i < len; i++, curnode = curnode->next); - if(curnode != head) return 0; + for (i = 0, curnode = head; i < len; i++, curnode = curnode->next); + if (curnode != head) return 0; /*reverse validation*/ - for(i = 0, curnode = head; i < len; i++, curnode = curnode->prev); - if(curnode != head) return 0; + for (i = 0, curnode = head; i < len; i++, curnode = curnode->prev); + if (curnode != head) return 0; return 1; } @@ -681,9 +684,9 @@ int bmesh_cycle_validate(int len, void *h) BMEdge *bmesh_disk_nextedge(BMEdge *e, BMVert *v) { - if(bmesh_vert_in_edge(e, v)) { - if(e->v1 == v) return e->d1.next->data; - else if(e->v2 == v) return e->d2.next->data; + if (bmesh_vert_in_edge(e, v)) { + if (e->v1 == v) return e->d1.next->data; + else if (e->v2 == v) return e->d2.next->data; } return NULL; } @@ -699,7 +702,7 @@ BMEdge *bmesh_disk_nextedge(BMEdge *e, BMVert *v) BMNode *bmesh_disk_getpointer(BMEdge *e, BMVert *v) { /*returns pointer to the cycle node for the appropriate vertex in this disk*/ - if(e->v1 == v) return &(e->d1); + if (e->v1 == v) return &(e->d1); else if (e->v2 == v) return &(e->d2); return NULL; } @@ -718,10 +721,10 @@ int bmesh_disk_append_edge(BMEdge *e, BMVert *v) BMNode *base, *tail; - if(bmesh_vert_in_edge(e, v) == 0) return 0; /*check to make sure v is in e*/ + if (bmesh_vert_in_edge(e, v) == 0) return 0; /*check to make sure v is in e*/ /*check for loose vert first*/ - if(v->e == NULL) { + if (v->e == NULL) { v->e = e; base = tail = bmesh_disk_getpointer(e, v); bmesh_cycle_append(base, tail); /*circular reference is ok!*/ @@ -757,8 +760,8 @@ void bmesh_disk_remove_edge(BMEdge *e, BMVert *v) /*first deal with v->e pointer...*/ len = bmesh_cycle_length(base); - if(len == 1) newbase = NULL; - else if(v->e == e) newbase = base->next-> data; + if (len == 1) newbase = NULL; + else if (v->e == e) newbase = base->next-> data; else newbase = v->e; /*remove and rebase*/ @@ -782,16 +785,16 @@ BMEdge *bmesh_disk_next_edgeflag(BMEdge *e, BMVert *v, int eflag, int tflag) BMEdge *curedge; int len, ok; - if(eflag && tflag) return NULL; + if (eflag && tflag) return NULL; ok = bmesh_vert_in_edge(e,v); - if(ok) { + if (ok) { diskbase = bmesh_disk_getpointer(e, v); len = bmesh_cycle_length(diskbase); curedge = bmesh_disk_nextedge(e,v); - while(curedge != e) { - if(eflag) { - if(curedge->head.eflag1 == eflag) return curedge; + while (curedge != e) { + if (eflag) { + if (curedge->head.eflag1 == eflag) return curedge; } curedge = bmesh_disk_nextedge(curedge, v); } @@ -815,14 +818,14 @@ int bmesh_disk_count_edgeflag(BMVert *v, int eflag, int tflag) BMEdge *curedge; int i, len=0, count=0; - if(v->e) { - if(eflag && tflag) return 0; /*tflag and eflag are reserved for different functions!*/ + if (v->e) { + if (eflag && tflag) return 0; /*tflag and eflag are reserved for different functions!*/ diskbase = bmesh_disk_getpointer(v->e, v); len = bmesh_cycle_length(diskbase); - for(i = 0, curedge=v->e; i<len; i++) { - if(eflag) { - if(curedge->head.eflag1 == eflag) count++; + for (i = 0, curedge=v->e; i<len; i++) { + if (eflag) { + if (curedge->head.eflag1 == eflag) count++; } curedge = bmesh_disk_nextedge(curedge, v); } @@ -837,12 +840,12 @@ int bmesh_disk_hasedge(BMVert *v, BMEdge *e) BMEdge *curedge; int i, len=0; - if(v->e) { + if (v->e) { diskbase = bmesh_disk_getpointer(v->e,v); len = bmesh_cycle_length(diskbase); - for(i = 0, curedge=v->e; i<len; i++) { - if(curedge == e) return 1; + for (i = 0, curedge=v->e; i<len; i++) { + if (curedge == e) return 1; else curedge=bmesh_disk_nextedge(curedge, v); } } @@ -855,12 +858,12 @@ BMEdge *bmesh_disk_existedge(BMVert *v1, BMVert *v2) BMEdge *curedge; int i, len=0; - if(v1->e) { + if (v1->e) { diskbase = bmesh_disk_getpointer(v1->e,v1); len = bmesh_cycle_length(diskbase); - for(i=0,curedge=v1->e;i<len;i++,curedge = bmesh_disk_nextedge(curedge,v1)) { - if(bmesh_verts_in_edge(v1,v2,curedge)) return curedge; + for (i=0,curedge=v1->e;i<len;i++,curedge = bmesh_disk_nextedge(curedge,v1)) { + if (bmesh_verts_in_edge(v1,v2,curedge)) return curedge; } } @@ -875,7 +878,7 @@ BMLoop *bmesh_radial_nextloop(BMLoop *l) void bmesh_radial_append(BMEdge *e, BMLoop *l) { - if(e->l == NULL) e->l = l; + if (e->l == NULL) e->l = l; bmesh_cycle_append(&(e->l->radial), &(l->radial)); } @@ -886,8 +889,8 @@ void bmesh_radial_remove_loop(BMLoop *l, BMEdge *e) /*deal with edge->l pointer*/ len = bmesh_cycle_length(&(e->l->radial)); - if(len == 1) newbase = NULL; - else if(e->l == l) newbase = e->l->radial_next; + if (len == 1) newbase = NULL; + else if (e->l == l) newbase = e->l->radial_next; else newbase = e->l; /*remove and rebase*/ @@ -902,8 +905,8 @@ int bmesh_radial_find_face(BMEdge *e,BMFace *f) int i, len; len = bmesh_cycle_length(&(e->l->radial)); - for(i = 0, curloop = e->l; i < len; i++, curloop = curloop->radial_next) { - if(curloop->f == f) return 1; + for (i = 0, curloop = e->l; i < len; i++, curloop = curloop->radial_next) { + if (curloop->f == f) return 1; } return 0; } @@ -923,9 +926,9 @@ int bmesh_radial_count_facevert(BMLoop *l, BMVert *v) int count = 0; curloop = l; do { - if(curloop->v == v) count++; + if (curloop->v == v) count++; curloop = bmesh_radial_nextloop(curloop); - } while(curloop != l); + } while (curloop != l); return count; } @@ -945,15 +948,15 @@ int bmesh_disk_count_facevert(BMVert *v) int count = 0; /*is there an edge on this vert at all?*/ - if(!v->e) + if (!v->e) return count; /*first, loop around edges*/ curedge = v->e; do { - if(curedge->l) count += bmesh_radial_count_facevert(curedge->l, v); + if (curedge->l) count += bmesh_radial_count_facevert(curedge->l, v); curedge = bmesh_disk_nextedge(curedge, v); - } while(curedge != v->e); + } while (curedge != v->e); return count; } @@ -970,9 +973,9 @@ BMLoop *bmesh_radial_find_first_facevert(BMLoop *l, BMVert *v) BMLoop *curloop; curloop = l; do { - if(curloop->v == v) return curloop; + if (curloop->v == v) return curloop; curloop = bmesh_radial_nextloop(curloop); - } while(curloop != l); + } while (curloop != l); return NULL; } @@ -981,9 +984,9 @@ BMLoop *bmesh_radial_find_next_facevert(BMLoop *l, BMVert *v) BMLoop *curloop; curloop = bmesh_radial_nextloop(l); do { - if(curloop->v == v) return curloop; + if (curloop->v == v) return curloop; curloop = bmesh_radial_nextloop(curloop); - } while(curloop !=l); + } while (curloop !=l); return l; } @@ -1004,9 +1007,9 @@ BMEdge *bmesh_disk_find_first_faceedge(BMEdge *e, BMVert *v) BMEdge *searchedge = NULL; searchedge = e; do { - if(searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; + if (searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; searchedge = bmesh_disk_nextedge(searchedge,v); - } while(searchedge != e); + } while (searchedge != e); return NULL; } @@ -1016,9 +1019,9 @@ BMEdge *bmesh_disk_find_next_faceedge(BMEdge *e, BMVert *v) BMEdge *searchedge = NULL; searchedge = bmesh_disk_nextedge(e,v); do { - if(searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; + if (searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; searchedge = bmesh_disk_nextedge(searchedge,v); - } while(searchedge !=e); + } while (searchedge !=e); return e; } diff --git a/source/blender/bmesh/intern/bmesh_walkers.c b/source/blender/bmesh/intern/bmesh_walkers.c index 5c57ab5968b..e29b8ccdd79 100644 --- a/source/blender/bmesh/intern/bmesh_walkers.c +++ b/source/blender/bmesh/intern/bmesh_walkers.c @@ -182,9 +182,9 @@ void *BMW_walk(BMWalker *walker) { void *current = NULL; - while(BMW_currentstate(walker)) { + while (BMW_currentstate(walker)) { current = walker->step(walker); - if(current) return current; + if (current) return current; } return NULL; } diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 213b63995ec..b8a3ed778ff 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -151,7 +151,7 @@ static void *shellWalker_step(BMWalker *walker) curedge = shellWalk.curedge; do { if (!BLI_ghash_haskey(walker->visithash, curedge)) { - if(!walker->restrictflag || (walker->restrictflag && + if (!walker->restrictflag || (walker->restrictflag && BMO_TestFlag(walker->bm, curedge, walker->restrictflag))) { shellWalker *newstate; @@ -169,7 +169,7 @@ static void *shellWalker_step(BMWalker *walker) } } curedge = bmesh_disk_nextedge(curedge, shellWalk.base); - } while(curedge != shellWalk.curedge); + } while (curedge != shellWalk.curedge); return shellWalk.curedge; } @@ -297,11 +297,12 @@ static void *islandboundWalker_step(BMWalker *walker) l = bmesh_radial_nextloop(l); f = l->f; e = l->e; - if(walker->mask_face && !BMO_TestFlag(walker->bm, f, walker->mask_face)) { + if (walker->mask_face && !BMO_TestFlag(walker->bm, f, walker->mask_face)) { l = l->radial_next; break; } - } else { + } + else { f = l->f; e = l->e; break; @@ -366,14 +367,14 @@ static void *islandWalker_step(BMWalker *walker) BMW_removestate(walker); l = BMIter_New(&liter, walker->bm, BM_LOOPS_OF_FACE, iwalk->cur); - for (; l; l=BMIter_Step(&liter)) { + for ( ; l; l=BMIter_Step(&liter)) { /* could skip loop here too, but dont add unless we need it */ if (walker->mask_edge && !BMO_TestFlag(walker->bm, l->e, walker->mask_edge)) { continue; } f = BMIter_New(&iter, walker->bm, BM_FACES_OF_EDGE, l->e); - for (; f; f=BMIter_Step(&iter)) { + for ( ; f; f=BMIter_Step(&iter)) { if (walker->mask_face && !BMO_TestFlag(walker->bm, f, walker->mask_face)) { continue; } @@ -638,8 +639,10 @@ static void *faceloopWalker_step(BMWalker *walker) if (l->f->len != 4) { lwalk->nocalc = 1; lwalk->l = origl; - } else + } + else { lwalk->nocalc = 0; + } BLI_ghash_insert(walker->visithash, l->f, NULL); } @@ -666,7 +669,8 @@ static void edgeringWalker_begin(BMWalker *walker, void *data) if (!lwalk->l) { lwalk->wireedge = e; return; - } else { + } + else { lwalk->wireedge = NULL; } diff --git a/source/blender/bmesh/operators/bevel.c b/source/blender/bmesh/operators/bevel.c index b2be4d74f7f..b3ba6e154fd 100644 --- a/source/blender/bmesh/operators/bevel.c +++ b/source/blender/bmesh/operators/bevel.c @@ -230,7 +230,8 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) BMO_SetFlag(bm, l->f, BEVEL_FLAG); BLI_array_append(faces, l->f); } - } else { + } + else { BM_SetIndex(e, -1); /* set_dirty! */ } } @@ -333,7 +334,8 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) tag = tags + BM_GetIndex(l); calc_corner_co(bm, l, fac, co, do_dist, do_even); tag->newv = BM_Make_Vert(bm, co, l->v); - } else { + } + else { tag = tags + BM_GetIndex(l); tag->newv = ETAG_GET(l->prev->e, l->v); @@ -354,7 +356,8 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) ETAG_SET(l->prev->e, l->v, tag->newv); } } - } else if (BMO_TestFlag(bm, l->v, BEVEL_FLAG)) { + } + else if (BMO_TestFlag(bm, l->v, BEVEL_FLAG)) { tag = tags + BM_GetIndex(l); tag->newv = ETAG_GET(l->e, l->v); @@ -375,7 +378,8 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) ETAG_SET(l->e, l->v, tag->newv); } - } else { + } + else { tag = tags + BM_GetIndex(l); tag->newv = l->v; BMO_ClearFlag(bm, l->v, BEVEL_DEL); @@ -458,10 +462,12 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) if (l->radial_next->next->v == l->next->v) { v4 = v3; v3 = tags[BM_GetIndex(l->radial_next->next)].newv; - } else { + } + else { v4 = tags[BM_GetIndex(l->radial_next->next)].newv; } - } else { + } + else { /*the loop is on a boundary*/ v3 = l->next->v; v4 = l->v; @@ -518,7 +524,8 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) if (l->radial_next->v == l->v) { l2 = l->radial_next->prev; l3 = l->radial_next->next; - } else { + } + else { l2 = l->radial_next->next; l3 = l->radial_next->prev; } @@ -551,7 +558,8 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) BM_ITER(l2, &liter2, bm, BM_LOOPS_OF_FACE, f) { BMO_ClearFlag(bm, l2->e, BEVEL_DEL); } - } else { + } + else { f = NULL; } } @@ -720,7 +728,8 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) f = BM_Make_Ngon(bm, lastv, vstart, edges, BLI_array_count(edges), 0); if (!f) { fprintf(stderr, "%s: in bevel vert fill! (bmesh internal error)\n", __func__); - } else { + } + else { BMO_SetFlag(bm, f, FACE_NEW|FACE_HOLE); } } @@ -748,7 +757,8 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) if (tag->newv != l->v || HasMDisps) { BM_Copy_Attributes(bm, bm, l->f, l2->f); BM_loop_interp_from_face(bm, l2, l->f, 1, 1); - } else { + } + else { BM_Copy_Attributes(bm, bm, l->f, l2->f); BM_Copy_Attributes(bm, bm, l, l2); } diff --git a/source/blender/bmesh/operators/bmesh_dupeops.c b/source/blender/bmesh/operators/bmesh_dupeops.c index 4dd9960d6c5..b3610ea8bfb 100644 --- a/source/blender/bmesh/operators/bmesh_dupeops.c +++ b/source/blender/bmesh/operators/bmesh_dupeops.c @@ -180,8 +180,8 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) vhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh dupeops v"); ehash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh dupeops e"); - for(v = BMIter_New(&verts, source, BM_VERTS_OF_MESH, source); v; v = BMIter_Step(&verts)) { - if(BMO_TestFlag(source, (BMHeader*)v, DUPE_INPUT) && (!BMO_TestFlag(source, (BMHeader*)v, DUPE_DONE))) { + for (v = BMIter_New(&verts, source, BM_VERTS_OF_MESH, source); v; v = BMIter_Step(&verts)) { + if (BMO_TestFlag(source, (BMHeader*)v, DUPE_INPUT) && (!BMO_TestFlag(source, (BMHeader*)v, DUPE_DONE))) { BMIter iter; int iso = 1; @@ -211,14 +211,14 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) } /*now we dupe all the edges*/ - for(e = BMIter_New(&edges, source, BM_EDGES_OF_MESH, source); e; e = BMIter_Step(&edges)) { - if(BMO_TestFlag(source, (BMHeader*)e, DUPE_INPUT) && (!BMO_TestFlag(source, (BMHeader*)e, DUPE_DONE))) { + for (e = BMIter_New(&edges, source, BM_EDGES_OF_MESH, source); e; e = BMIter_Step(&edges)) { + if (BMO_TestFlag(source, (BMHeader*)e, DUPE_INPUT) && (!BMO_TestFlag(source, (BMHeader*)e, DUPE_DONE))) { /*make sure that verts are copied*/ - if(!BMO_TestFlag(source, (BMHeader*)e->v1, DUPE_DONE)) { + if (!BMO_TestFlag(source, (BMHeader*)e->v1, DUPE_DONE)) { copy_vertex(source, e->v1, target, vhash); BMO_SetFlag(source, (BMHeader*)e->v1, DUPE_DONE); } - if(!BMO_TestFlag(source, (BMHeader*)e->v2, DUPE_DONE)) { + if (!BMO_TestFlag(source, (BMHeader*)e->v2, DUPE_DONE)) { copy_vertex(source, e->v2, target, vhash); BMO_SetFlag(source, (BMHeader*)e->v2, DUPE_DONE); } @@ -229,19 +229,19 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) } /*first we dupe all flagged faces and their elements from source*/ - for(f = BMIter_New(&faces, source, BM_FACES_OF_MESH, source); f; f= BMIter_Step(&faces)) { - if(BMO_TestFlag(source, (BMHeader*)f, DUPE_INPUT)) { + for (f = BMIter_New(&faces, source, BM_FACES_OF_MESH, source); f; f= BMIter_Step(&faces)) { + if (BMO_TestFlag(source, (BMHeader*)f, DUPE_INPUT)) { /*vertex pass*/ - for(v = BMIter_New(&verts, source, BM_VERTS_OF_FACE, f); v; v = BMIter_Step(&verts)) { - if(!BMO_TestFlag(source, (BMHeader*)v, DUPE_DONE)) { + for (v = BMIter_New(&verts, source, BM_VERTS_OF_FACE, f); v; v = BMIter_Step(&verts)) { + if (!BMO_TestFlag(source, (BMHeader*)v, DUPE_DONE)) { copy_vertex(source,v, target, vhash); BMO_SetFlag(source, (BMHeader*)v, DUPE_DONE); } } /*edge pass*/ - for(e = BMIter_New(&edges, source, BM_EDGES_OF_FACE, f); e; e = BMIter_Step(&edges)) { - if(!BMO_TestFlag(source, (BMHeader*)e, DUPE_DONE)) { + for (e = BMIter_New(&edges, source, BM_EDGES_OF_FACE, f); e; e = BMIter_Step(&edges)) { + if (!BMO_TestFlag(source, (BMHeader*)e, DUPE_DONE)) { copy_edge(op, source, e, target, vhash, ehash); BMO_SetFlag(source, (BMHeader*)e, DUPE_DONE); } @@ -370,7 +370,7 @@ void splitop_exec(BMesh *bm, BMOperator *op) for (e= BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL);e;e=BMIter_Step(&iter)) { found = 0; f = BMIter_New(&iter2, bm, BM_FACES_OF_EDGE, e); - for (; f; f=BMIter_Step(&iter2)) { + for ( ; f; f=BMIter_Step(&iter2)) { if (!BMO_TestFlag(bm, f, SPLIT_INPUT)) { found = 1; break; @@ -382,7 +382,7 @@ void splitop_exec(BMesh *bm, BMOperator *op) for (v= BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);v;v=BMIter_Step(&iter)) { found = 0; e = BMIter_New(&iter2, bm, BM_EDGES_OF_VERT, v); - for (; e; e=BMIter_Step(&iter2)) { + for ( ; e; e=BMIter_Step(&iter2)) { if (!BMO_TestFlag(bm, e, SPLIT_INPUT)) { found = 1; break; @@ -436,13 +436,13 @@ static void delete_verts(BMesh *bm) BMIter edges; BMIter faces; - for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)) { - if(BMO_TestFlag(bm, (BMHeader*)v, DEL_INPUT)) { + for (v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)) { + if (BMO_TestFlag(bm, (BMHeader*)v, DEL_INPUT)) { /*Visit edges*/ - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_VERT, v); e; e = BMIter_Step(&edges)) + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_VERT, v); e; e = BMIter_Step(&edges)) BMO_SetFlag(bm, (BMHeader*)e, DEL_INPUT); /*Visit faces*/ - for(f = BMIter_New(&faces, bm, BM_FACES_OF_VERT, v); f; f = BMIter_Step(&faces)) + for (f = BMIter_New(&faces, bm, BM_FACES_OF_VERT, v); f; f = BMIter_Step(&faces)) BMO_SetFlag(bm, (BMHeader*)f, DEL_INPUT); } } @@ -460,9 +460,9 @@ static void delete_edges(BMesh *bm) BMIter edges; BMIter faces; - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) { - if(BMO_TestFlag(bm, (BMHeader*)e, DEL_INPUT)) { - for(f = BMIter_New(&faces, bm, BM_FACES_OF_EDGE, e); f; f = BMIter_Step(&faces)) { + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) { + if (BMO_TestFlag(bm, (BMHeader*)e, DEL_INPUT)) { + for (f = BMIter_New(&faces, bm, BM_FACES_OF_EDGE, e); f; f = BMIter_Step(&faces)) { BMO_SetFlag(bm, (BMHeader*)f, DEL_INPUT); } } @@ -491,53 +491,54 @@ static void delete_context(BMesh *bm, int type) BMIter edges; BMIter faces; - if(type == DEL_VERTS) delete_verts(bm); - else if(type == DEL_EDGES) { + if (type == DEL_VERTS) delete_verts(bm); + else if (type == DEL_EDGES) { /*flush down to verts*/ - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) { - if(BMO_TestFlag(bm, (BMHeader*)e, DEL_INPUT)) { + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) { + if (BMO_TestFlag(bm, (BMHeader*)e, DEL_INPUT)) { BMO_SetFlag(bm, (BMHeader*)(e->v1), DEL_INPUT); BMO_SetFlag(bm, (BMHeader*)(e->v2), DEL_INPUT); } } delete_edges(bm); /*remove loose vertices*/ - for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)) { - if(BMO_TestFlag(bm, (BMHeader*)v, DEL_INPUT) && (!(v->e))) + for (v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)) { + if (BMO_TestFlag(bm, (BMHeader*)v, DEL_INPUT) && (!(v->e))) BMO_SetFlag(bm, (BMHeader*)v, DEL_WIREVERT); } BM_remove_tagged_verts(bm, DEL_WIREVERT); } - else if(type == DEL_EDGESFACES) delete_edges(bm); - else if(type == DEL_ONLYFACES) BM_remove_tagged_faces(bm, DEL_INPUT); + else if (type == DEL_EDGESFACES) delete_edges(bm); + else if (type == DEL_ONLYFACES) BM_remove_tagged_faces(bm, DEL_INPUT); else if (type == DEL_ONLYTAGGED) { BM_remove_tagged_faces(bm, DEL_INPUT); BM_remove_tagged_edges(bm, DEL_INPUT); BM_remove_tagged_verts(bm, DEL_INPUT); - } else if(type == DEL_FACES) { + } + else if (type == DEL_FACES) { /*go through and mark all edges and all verts of all faces for delete*/ - for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)) { - if(BMO_TestFlag(bm, (BMHeader*)f, DEL_INPUT)) { - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_FACE, f); e; e = BMIter_Step(&edges)) + for (f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)) { + if (BMO_TestFlag(bm, (BMHeader*)f, DEL_INPUT)) { + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_FACE, f); e; e = BMIter_Step(&edges)) BMO_SetFlag(bm, (BMHeader*)e, DEL_INPUT); - for(v = BMIter_New(&verts, bm, BM_VERTS_OF_FACE, f); v; v = BMIter_Step(&verts)) + for (v = BMIter_New(&verts, bm, BM_VERTS_OF_FACE, f); v; v = BMIter_Step(&verts)) BMO_SetFlag(bm, (BMHeader*)v, DEL_INPUT); } } /*now go through and mark all remaining faces all edges for keeping.*/ - for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)) { - if(!BMO_TestFlag(bm, (BMHeader*)f, DEL_INPUT)) { - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_FACE, f); e; e= BMIter_Step(&edges)) { + for (f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)) { + if (!BMO_TestFlag(bm, (BMHeader*)f, DEL_INPUT)) { + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_FACE, f); e; e= BMIter_Step(&edges)) { BMO_ClearFlag(bm, (BMHeader*)e, DEL_INPUT); } - for(v = BMIter_New(&verts, bm, BM_VERTS_OF_FACE, f); v; v= BMIter_Step(&verts)) { + for (v = BMIter_New(&verts, bm, BM_VERTS_OF_FACE, f); v; v= BMIter_Step(&verts)) { BMO_ClearFlag(bm, (BMHeader*)v, DEL_INPUT); } } } /*also mark all the vertices of remaining edges for keeping.*/ - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) { - if(!BMO_TestFlag(bm, (BMHeader*)e, DEL_INPUT)) { + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) { + if (!BMO_TestFlag(bm, (BMHeader*)e, DEL_INPUT)) { BMO_ClearFlag(bm, (BMHeader*)e->v1, DEL_INPUT); BMO_ClearFlag(bm, (BMHeader*)e->v2, DEL_INPUT); } @@ -550,12 +551,12 @@ static void delete_context(BMesh *bm, int type) BM_remove_tagged_verts(bm, DEL_INPUT); } /*does this option even belong in here?*/ - else if(type == DEL_ALL) { - for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)) + else if (type == DEL_ALL) { + for (f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)) BMO_SetFlag(bm, (BMHeader*)f, DEL_INPUT); - for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) + for (e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) BMO_SetFlag(bm, (BMHeader*)e, DEL_INPUT); - for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)) + for (v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)) BMO_SetFlag(bm, (BMHeader*)v, DEL_INPUT); BM_remove_tagged_faces(bm, DEL_INPUT); @@ -598,15 +599,16 @@ void spinop_exec(BMesh *bm, BMOperator *op) quat_to_mat3(rmat, q); BMO_CopySlot(op, op, "geom", "lastout"); - for(a=0; a<steps; a++) { - if(dupli) { + for (a=0; a<steps; a++) { + if (dupli) { BMO_InitOpf(bm, &dupop, "dupe geom=%s", op, "lastout"); BMO_Exec_Op(bm, &dupop); BMO_CallOpf(bm, "rotate cent=%v mat=%m3 verts=%s", cent, rmat, &dupop, "newout"); BMO_CopySlot(&dupop, op, "newout", "lastout"); BMO_Finish_Op(bm, &dupop); - } else { + } + else { BMO_InitOpf(bm, &extop, "extrudefaceregion edgefacein=%s", op, "lastout"); BMO_Exec_Op(bm, &extop); @@ -616,7 +618,7 @@ void spinop_exec(BMesh *bm, BMOperator *op) BMO_Finish_Op(bm, &extop); } - if(usedvec) + if (usedvec) BMO_CallOpf(bm, "translate vec=%v verts=%s", dvec, op, "lastout"); } } diff --git a/source/blender/bmesh/operators/connectops.c b/source/blender/bmesh/operators/connectops.c index 73592985f2a..a24fdbe901e 100644 --- a/source/blender/bmesh/operators/connectops.c +++ b/source/blender/bmesh/operators/connectops.c @@ -38,7 +38,7 @@ void connectverts_exec(BMesh *bm, BMOperator *op) l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f); lastl = NULL; - for (; l; l=BMIter_Step(&liter)) { + for ( ; l; l=BMIter_Step(&liter)) { if (BMO_TestFlag(bm, l->v, VERT_INPUT)) { if (!lastl) { lastl = l; @@ -207,7 +207,8 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) if (c==0) { BLI_array_append(ee1, e2); BLI_array_append(vv1, v); - } else { + } + else { BLI_array_append(ee2, e2); BLI_array_append(vv2, v); } @@ -230,7 +231,8 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) printf("%s: internal state waning *TODO DESCRIPTION!*\n", __func__); } BLI_array_append(vv1, v); - } else { + } + else { BLI_array_append(vv2, v); } } diff --git a/source/blender/bmesh/operators/createops.c b/source/blender/bmesh/operators/createops.c index 8f608d4196e..d81122e42fb 100644 --- a/source/blender/bmesh/operators/createops.c +++ b/source/blender/bmesh/operators/createops.c @@ -78,7 +78,8 @@ static int rotsys_append_edge(struct BMEdge *e, struct BMVert *v, vd->e = e; e1->next = e1->prev = (Link*)e; - } else { + } + else { Link *e1, *e2, *e3; EdgeData *ved = &edata[BM_GetIndex(vd->e)]; @@ -448,7 +449,8 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) i = 0; k++; continue; - } else { + } + else { k++; continue; } @@ -499,7 +501,8 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) if (dot_v3v3(n1, n2) < 0.0f) { if (dot_v3v3(n1, n3) >= 0.0f + FLT_EPSILON*10) { SWAP(BMEdge*, edges[i], edges[(i+1)%totedge]); - } else { + } + else { SWAP(BMEdge*, edges[(i+totedge-1)%totedge], edges[(i+1)%totedge]) SWAP(BMEdge*, edges[i], edges[(i+1)%totedge]) } @@ -742,7 +745,8 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E while (1) { if (!last->cure) { last->cure = e = vdata[BM_GetIndex(last->v)].e; - } else { + } + else { last->cure = e = rotsys_nextedge(last->cure, last->v, edata, vdata); if (last->cure == vdata[BM_GetIndex(last->v)].e) { v2 = NULL; @@ -1083,7 +1087,8 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) if (!count) { edges1 = edges; BLI_array_set_length(edges1, BLI_array_count(edges)); - } else { + } + else { edges2 = edges; BLI_array_set_length(edges2, BLI_array_count(edges)); } @@ -1097,7 +1102,8 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) BLI_array_free(edges1); BLI_array_free(edges2); return; - } else { + } + else { edges1 = edges2; edges2 = NULL; } @@ -1114,7 +1120,8 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) if (BLI_array_count(edges1)==1) { v1 = edges1[0]->v1; v2 = edges1[0]->v2; - } else { + } + else { if (BM_Vert_In_Edge(edges1[1], edges1[0]->v1)) v1 = edges1[0]->v2; else v1 = edges1[0]->v1; @@ -1128,7 +1135,8 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) if (BLI_array_count(edges2)==1) { v3 = edges2[0]->v1; v4 = edges2[0]->v2; - } else { + } + else { if (BM_Vert_In_Edge(edges2[1], edges2[0]->v1)) v3 = edges2[0]->v2; else v3 = edges2[0]->v1; @@ -1153,7 +1161,8 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) BMO_SetFlag(bm, e, ELE_NEW); e = BM_Make_Edge(bm, v2, v4, NULL, 1); BMO_SetFlag(bm, e, ELE_NEW); - } else if (edges1) { + } + else if (edges1) { BMVert *v1, *v2; if (BLI_array_count(edges1) > 1) { @@ -1317,29 +1326,31 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) /*create edge*/ e = BM_Make_Edge(bm, verts[0], verts[1], NULL, 1); BMO_SetFlag(bm, e, ELE_OUT); - } else if (amount == 3) { + } + else if (amount == 3) { /*create triangle*/ BM_Make_Face_QuadTri(bm, verts[0], verts[1], verts[2], NULL, NULL, 1); - } else if (amount == 4) { + } + else if (amount == 4) { f = NULL; /* the order of vertices can be anything, 6 cases to check */ - if( is_quad_convex_v3(verts[0]->co, verts[1]->co, verts[2]->co, verts[3]->co) ) { + if (is_quad_convex_v3(verts[0]->co, verts[1]->co, verts[2]->co, verts[3]->co)) { f= BM_Make_Face_QuadTri(bm, verts[0], verts[1], verts[2], verts[3], NULL, 1); } - else if( is_quad_convex_v3(verts[0]->co, verts[2]->co, verts[3]->co, verts[1]->co) ) { + else if (is_quad_convex_v3(verts[0]->co, verts[2]->co, verts[3]->co, verts[1]->co)) { f= BM_Make_Face_QuadTri(bm, verts[0], verts[2], verts[3], verts[1], NULL, 1); } - else if( is_quad_convex_v3(verts[0]->co, verts[2]->co, verts[1]->co, verts[3]->co) ) { + else if (is_quad_convex_v3(verts[0]->co, verts[2]->co, verts[1]->co, verts[3]->co)) { f= BM_Make_Face_QuadTri(bm, verts[0], verts[2], verts[1], verts[3], NULL, 1); } - else if( is_quad_convex_v3(verts[0]->co, verts[1]->co, verts[3]->co, verts[2]->co) ) { + else if (is_quad_convex_v3(verts[0]->co, verts[1]->co, verts[3]->co, verts[2]->co)) { f= BM_Make_Face_QuadTri(bm, verts[0], verts[1], verts[3], verts[2], NULL, 1); } - else if( is_quad_convex_v3(verts[0]->co, verts[3]->co, verts[2]->co, verts[1]->co) ) { + else if (is_quad_convex_v3(verts[0]->co, verts[3]->co, verts[2]->co, verts[1]->co)) { f= BM_Make_Face_QuadTri(bm, verts[0], verts[3], verts[2], verts[1], NULL, 1); } - else if( is_quad_convex_v3(verts[0]->co, verts[3]->co, verts[1]->co, verts[2]->co) ) { + else if (is_quad_convex_v3(verts[0]->co, verts[3]->co, verts[1]->co, verts[2]->co)) { f= BM_Make_Face_QuadTri(bm, verts[0], verts[3], verts[1], verts[2], NULL, 1); } else { diff --git a/source/blender/bmesh/operators/dissolveops.c b/source/blender/bmesh/operators/dissolveops.c index dce3fe554e3..f247c89b0af 100644 --- a/source/blender/bmesh/operators/dissolveops.c +++ b/source/blender/bmesh/operators/dissolveops.c @@ -30,9 +30,9 @@ static int UNUSED_FUNCTION(check_hole_in_region)(BMesh *bm, BMFace *f) BMW_Init(®walker, bm, BMW_ISLAND, 0,0,0,FACE_MARK, BMW_NIL_LAY); f2 = BMW_Begin(®walker, f); - for (; f2; f2=BMW_Step(®walker)) { + for ( ; f2; f2=BMW_Step(®walker)) { l2 = BMIter_New(&liter2, bm, BM_LOOPS_OF_FACE, f2); - for (; l2; l2=BMIter_Step(&liter2)) { + for ( ; l2; l2=BMIter_Step(&liter2)) { l3 = bmesh_radial_nextloop(l2); if (BMO_TestFlag(bm, l3->f, FACE_MARK) != BMO_TestFlag(bm, l2->f, FACE_MARK)) @@ -71,7 +71,7 @@ void dissolvefaces_exec(BMesh *bm, BMOperator *op) /*yay, walk!*/ BMW_Init(®walker, bm, BMW_ISLAND, 0,0,0,FACE_MARK, BMW_NIL_LAY); f2 = BMW_Begin(®walker, f); - for (; f2; f2=BMW_Step(®walker)) { + for ( ; f2; f2=BMW_Step(®walker)) { BLI_array_append(faces, f2); } BMW_End(®walker); @@ -253,9 +253,9 @@ static int test_extra_verts(BMesh *bm, BMVert *v) /*test faces around verts for verts that would be wronly killed by dissolve faces.*/ f = BMIter_New(&iter, bm, BM_FACES_OF_VERT, v); - for (; f; f=BMIter_Step(&iter)) { + for ( ; f; f=BMIter_Step(&iter)) { l=BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f); - for (; l; l=BMIter_Step(&liter)) { + for ( ; l; l=BMIter_Step(&liter)) { if (!BMO_TestFlag(bm, l->v, VERT_MARK)) { /*if an edge around a vert is a boundary edge, then dissolve faces won't destroy it. @@ -263,10 +263,10 @@ static int test_extra_verts(BMesh *bm, BMVert *v) of the face regions*/ found = 0; e = BMIter_New(&iter2, bm, BM_EDGES_OF_VERT, l->v); - for (; e; e=BMIter_Step(&iter2)) { + for ( ; e; e=BMIter_Step(&iter2)) { if (BM_Edge_FaceCount(e)==1) found = 1; f2 = BMIter_New(&iter3, bm, BM_FACES_OF_EDGE, e); - for (; f2; f2=BMIter_Step(&iter3)) { + for ( ; f2; f2=BMIter_Step(&iter3)) { if (!BMO_TestFlag(bm, f2, FACE_MARK)) { found = 1; break; @@ -303,7 +303,7 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) } f=BMIter_New(&fiter, bm, BM_FACES_OF_VERT, v); - for (; f; f=BMIter_Step(&fiter)) { + for ( ; f; f=BMIter_Step(&fiter)) { BMO_SetFlag(bm, f, FACE_ORIG); BMO_SetFlag(bm, f, FACE_MARK); } @@ -312,15 +312,16 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) will destroy nonmarked vertices.*/ if (!test_extra_verts(bm, v)) { f=BMIter_New(&fiter, bm, BM_FACES_OF_VERT, v); - for (; f; f=BMIter_Step(&fiter)) { + for ( ; f; f=BMIter_Step(&fiter)) { if (BMO_TestFlag(bm, f, FACE_ORIG)) { BMO_ClearFlag(bm, f, FACE_MARK); BMO_ClearFlag(bm, f, FACE_ORIG); } } - } else { + } + else { f=BMIter_New(&fiter, bm, BM_FACES_OF_VERT, v); - for (; f; f=BMIter_Step(&fiter)) { + for ( ; f; f=BMIter_Step(&fiter)) { BMO_ClearFlag(bm, f, FACE_ORIG); } } @@ -373,10 +374,10 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) found2 = 0; l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f); fe = l->e; - for (; l; l=BMIter_Step(&liter)) { + for ( ; l; l=BMIter_Step(&liter)) { f2 = BMIter_New(&fiter, bm, BM_FACES_OF_EDGE, l->e); - for (; f2; f2=BMIter_Step(&fiter)) { + for ( ; f2; f2=BMIter_Step(&fiter)) { if (f2 != f) { BM_Join_TwoFaces(bm, f, f2, l->e); found2 = 1; @@ -398,7 +399,7 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) //check for duplicate edges l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f); - for (; l; l=BMIter_Step(&liter)) { + for ( ; l; l=BMIter_Step(&liter)) { ed[i] = l->e; lp[i] = l; vt[i++] = l->v; diff --git a/source/blender/bmesh/operators/edgesplitop.c b/source/blender/bmesh/operators/edgesplitop.c index 6c35fa92452..3d9acb98b50 100644 --- a/source/blender/bmesh/operators/edgesplitop.c +++ b/source/blender/bmesh/operators/edgesplitop.c @@ -94,7 +94,7 @@ static BMFace *remake_face(BMesh *bm, EdgeTag *etags, BMFace *f, BMVert **verts, l = BMIter_New(&liter1, bm, BM_LOOPS_OF_FACE, f); l2 = BMIter_New(&liter2, bm, BM_LOOPS_OF_FACE, f2); - for (; l && l2; l=BMIter_Step(&liter1), l2=BMIter_Step(&liter2)) { + for ( ; l && l2; l=BMIter_Step(&liter1), l2=BMIter_Step(&liter2)) { BM_Copy_Attributes(bm, bm, l, l2); if (l->e != l2->e) { /*set up data for figuring out the two sides of @@ -368,14 +368,14 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op) /* debugging code, quick way to find the face/vert combination * which is failing assuming quads start planer - campbell */ #if 0 - if(f->len == 4) { + if (f->len == 4) { float no1[3]; float no2[3]; float angle_error; printf(" ** found QUAD\n"); normal_tri_v3(no1, verts[0]->co, verts[1]->co, verts[2]->co); normal_tri_v3(no2, verts[0]->co, verts[2]->co, verts[3]->co); - if((angle_error= angle_v3v3(no1, no2)) > 0.05) { + if ((angle_error= angle_v3v3(no1, no2)) > 0.05) { printf(" ERROR %.4f\n", angle_error); print_v3("0", verts[0]->co); print_v3("1", verts[1]->co); diff --git a/source/blender/bmesh/operators/extrudeops.c b/source/blender/bmesh/operators/extrudeops.c index fde240d70de..6d454ac34ac 100644 --- a/source/blender/bmesh/operators/extrudeops.c +++ b/source/blender/bmesh/operators/extrudeops.c @@ -114,7 +114,7 @@ void bmesh_extrude_onlyedge_exec(BMesh *bm, BMOperator *op) BMO_Exec_Op(bm, &dupeop); e = BMO_IterNew(&siter, bm, &dupeop, "boundarymap", 0); - for (; e; e=BMO_IterStep(&siter)) { + for ( ; e; e=BMO_IterStep(&siter)) { e2 = BMO_IterMapVal(&siter); e2 = *(BMEdge**)e2; @@ -123,7 +123,8 @@ void bmesh_extrude_onlyedge_exec(BMesh *bm, BMOperator *op) v2 = e->v2; v3 = e2->v2; v4 = e2->v1; - } else { + } + else { v1 = e2->v1; v2 = e2->v2; v3 = e->v2; @@ -154,7 +155,7 @@ void extrude_vert_indiv_exec(BMesh *bm, BMOperator *op) BMEdge *e; v = BMO_IterNew(&siter, bm, op, "verts", BM_VERT); - for (; v; v=BMO_IterStep(&siter)) { + for ( ; v; v=BMO_IterStep(&siter)) { dupev = BM_Make_Vert(bm, v->co, v); e = BM_Make_Edge(bm, v, dupev, NULL, 0); @@ -255,7 +256,7 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) BMO_CopySlot(&dupeop, op, "newout", "geomout"); e = BMO_IterNew(&siter, bm, &dupeop, "boundarymap", 0); - for (; e; e=BMO_IterStep(&siter)) { + for ( ; e; e=BMO_IterStep(&siter)) { if (BMO_InMap(bm, op, "exclude", e)) continue; newedge = BMO_IterMapVal(&siter); @@ -276,7 +277,8 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) verts[1] = e->v2; verts[2] = newedge->v2; verts[3] = newedge->v1; - } else { + } + else { verts[3] = e->v1; verts[2] = e->v2; verts[1] = newedge->v2; @@ -288,7 +290,7 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) /*copy attributes*/ l=BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); - for (; l; l=BMIter_Step(&iter)) { + for ( ; l; l=BMIter_Step(&iter)) { if (l->e != e && l->e != newedge) continue; l2 = l->radial_next; @@ -300,7 +302,8 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) l2 = l2->next; l = l->next; BM_Copy_Attributes(bm, bm, l2, l); - } else { + } + else { BM_Copy_Attributes(bm, bm, l2->f, l->f); /*copy data*/ @@ -309,7 +312,8 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) l2 = l2->next; l = l->next; BM_Copy_Attributes(bm, bm, l2, l); - } else { + } + else { l2 = l2->next; BM_Copy_Attributes(bm, bm, l2, l); l2 = l2->prev; @@ -322,7 +326,7 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) /*link isolated verts*/ v = BMO_IterNew(&siter, bm, &dupeop, "isovertmap", 0); - for (; v; v=BMO_IterStep(&siter)) { + for ( ; v; v=BMO_IterStep(&siter)) { v2 = *((void**)BMO_IterMapVal(&siter)); BM_Make_Edge(bm, v, v2, v->e, 1); } @@ -507,7 +511,7 @@ static void solidify_add_thickness(BMesh *bm, float dist) BM_ElemIndex_Ensure(bm, BM_VERT); BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { - if(!BMO_TestFlag(bm, f, FACE_MARK)) { + if (!BMO_TestFlag(bm, f, FACE_MARK)) { continue; } @@ -534,7 +538,7 @@ static void solidify_add_thickness(BMesh *bm, float dist) BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { index = BM_GetIndex(v); - if(vert_accum[index]) { /* zero if unselected */ + if (vert_accum[index]) { /* zero if unselected */ float vdist = MIN2(maxdist, dist * vert_angles[index] / vert_accum[index]); madd_v3_v3fl(v->co, v->no, vdist); } diff --git a/source/blender/bmesh/operators/join_triangles.c b/source/blender/bmesh/operators/join_triangles.c index e27d1ecec29..49fb6967965 100644 --- a/source/blender/bmesh/operators/join_triangles.c +++ b/source/blender/bmesh/operators/join_triangles.c @@ -55,17 +55,17 @@ static float measure_facepair(BMesh *UNUSED(bm), BMVert *v1, BMVert *v2, normal_tri_v3(n1, v1->co, v2->co, v3->co); normal_tri_v3(n2, v1->co, v3->co, v4->co); - if(n1[0] == n2[0] && n1[1] == n2[1] && n1[2] == n2[2]) angle1 = 0.0f; + if (n1[0] == n2[0] && n1[1] == n2[1] && n1[2] == n2[2]) angle1 = 0.0f; else angle1 = angle_v3v3(n1, n2); normal_tri_v3(n1, v2->co, v3->co, v4->co); normal_tri_v3(n2, v4->co, v1->co, v2->co); - if(n1[0] == n2[0] && n1[1] == n2[1] && n1[2] == n2[2]) angle2 = 0.0f; + if (n1[0] == n2[0] && n1[1] == n2[1] && n1[2] == n2[2]) angle2 = 0.0f; else angle2 = angle_v3v3(n1, n2); measure += (angle1 + angle2) * 0.5f; - if(measure > limit) return measure; + if (measure > limit) return measure; /*Second test: Colinearity*/ sub_v3_v3v3(edgeVec1, v1->co, v2->co); @@ -79,22 +79,22 @@ static float measure_facepair(BMesh *UNUSED(bm), BMVert *v1, BMVert *v2, fabsf(angle_v3v3(edgeVec2, edgeVec3) - (float)M_PI_2) + fabsf(angle_v3v3(edgeVec3, edgeVec4) - (float)M_PI_2) + fabsf(angle_v3v3(edgeVec4, edgeVec1) - (float)M_PI_2)); - if(!diff) return 0.0; + if (!diff) return 0.0; measure += diff; - if(measure > limit) return measure; + if (measure > limit) return measure; /*Third test: Concavity*/ areaA = area_tri_v3(v1->co, v2->co, v3->co) + area_tri_v3(v1->co, v3->co, v4->co); areaB = area_tri_v3(v2->co, v3->co, v4->co) + area_tri_v3(v4->co, v1->co, v2->co); - if(areaA <= areaB) minarea = areaA; + if (areaA <= areaB) minarea = areaA; else minarea = areaB; - if(areaA >= areaB) maxarea = areaA; + if (areaA >= areaB) maxarea = areaA; else maxarea = areaB; - if(!maxarea) measure += 1; + if (!maxarea) measure += 1; else measure += (1 - (minarea / maxarea)); return measure; @@ -118,7 +118,8 @@ static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols) if (l1->v == l3->v) { l2 = l1->next; l4 = l2->next; - } else { + } + else { l2 = l1->next; l4 = l3; @@ -147,7 +148,7 @@ static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols) /*compare faceedges for each face attribute. Additional per face attributes can be added later*/ /*do VCOLs*/ - if(lcol1 && dovcols) { + if (lcol1 && dovcols) { char *cols[4] = {(char*)lcol1, (char*)lcol2, (char*)lcol3, (char*)lcol4}; int i; @@ -164,15 +165,15 @@ static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols) /*do UVs*/ if (luv1 && douvs) { - if(tp1->tpage != tp2->tpage); /*do nothing*/ + if (tp1->tpage != tp2->tpage); /*do nothing*/ else { int i; - for(i = 0; i < 2; i++) { - if(luv1->uv[0] + T2QUV_LIMIT > luv3->uv[0] && luv1->uv[0] - T2QUV_LIMIT < luv3->uv[0] && + for (i = 0; i < 2; i++) { + if (luv1->uv[0] + T2QUV_LIMIT > luv3->uv[0] && luv1->uv[0] - T2QUV_LIMIT < luv3->uv[0] && luv1->uv[1] + T2QUV_LIMIT > luv3->uv[1] && luv1->uv[1] - T2QUV_LIMIT < luv3->uv[1]) { - if(luv2->uv[0] + T2QUV_LIMIT > luv4->uv[0] && luv2->uv[0] - T2QUV_LIMIT < luv4->uv[0] && + if (luv2->uv[0] + T2QUV_LIMIT > luv4->uv[0] && luv2->uv[0] - T2QUV_LIMIT < luv4->uv[0] && luv2->uv[1] + T2QUV_LIMIT > luv4->uv[1] && luv2->uv[1] - T2QUV_LIMIT < luv4->uv[1]) { mergeok_uvs = 1; @@ -202,8 +203,8 @@ static int fplcmp(const void *v1, const void *v2) { const JoinEdge *e1= ((JoinEdge*)v1), *e2=((JoinEdge*)v2); - if( e1->weight > e2->weight) return 1; - else if( e1->weight < e2->weight) return -1; + if (e1->weight > e2->weight) return 1; + else if (e1->weight < e2->weight) return -1; return 0; } @@ -281,7 +282,7 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) continue; measure = measure_facepair(bm, v1, v2, v3, v4, limit); - if(measure < limit) { + if (measure < limit) { BLI_array_growone(jedges); jedges[i].e = e; diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c index 39f312c72f8..6bc9fdda116 100644 --- a/source/blender/bmesh/operators/mesh_conv.c +++ b/source/blender/bmesh/operators/mesh_conv.c @@ -94,7 +94,7 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) } actkey = ob_get_keyblock(ob); - if(actkey && actkey->totelem == me->totvert) { + if (actkey && actkey->totelem == me->totvert) { CustomData_add_layer(&bm->vdata, CD_SHAPE_KEYINDEX, CD_ASSIGN, NULL, 0); /*check if we need to generate unique ids for the shapekeys. @@ -117,7 +117,8 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) j = CustomData_get_layer_index_n(&bm->vdata, CD_SHAPEKEY, i); bm->vdata.layers[j].uid = block->uid; } - } else if (actkey) { + } + else if (actkey) { printf("shapekey<->mesh mismatch!\n"); } @@ -296,31 +297,33 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) BMFace **face_array = MEM_callocN(sizeof(BMFace *) * bm->totface, "Selection Conversion Face Pointer Array"); - for(i = 0, vertex = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); + for (i = 0, vertex = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); vertex; i++, vertex = BMIter_Step(&iter)) { vertex_array[i] = vertex; } - for(i = 0, edge = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL); + for (i = 0, edge = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL); edge; i++, edge = BMIter_Step(&iter)) { edge_array[i] = edge; } - for(i = 0, face = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); + for (i = 0, face = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); face; i++, face = BMIter_Step(&iter)) { face_array[i] = face; } - if(me->mselect) { - for(i = 0; i < me->totselect; i++) { - if(me->mselect[i].type == ME_VSEL) { + if (me->mselect) { + for (i = 0; i < me->totselect; i++) { + if (me->mselect[i].type == ME_VSEL) { BM_store_selection(bm, vertex_array[me->mselect[i].index]); - }else if(me->mselect[i].type == ME_ESEL) { + } + else if (me->mselect[i].type == ME_ESEL) { BM_store_selection(bm, edge_array[me->mselect[i].index]); - }else if(me->mselect[i].type == ME_FSEL) { + } + else if (me->mselect[i].type == ME_FSEL) { BM_store_selection(bm, face_array[me->mselect[i].index]); } } @@ -370,17 +373,17 @@ static BMVert **bmesh_to_mesh_vertex_map(BMesh *bm, int ototvert) BLI_assert(ototvert > 0); vertMap = MEM_callocN(sizeof(*vertMap)*ototvert, "vertMap"); - if(CustomData_has_layer(&bm->vdata, CD_SHAPE_KEYINDEX)) { + if (CustomData_has_layer(&bm->vdata, CD_SHAPE_KEYINDEX)) { int *keyi; BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX); - if(keyi) { + if (keyi) { if (((index= *keyi) != ORIGINDEX_NONE) && (index < ototvert)) { vertMap[index] = eve; } } else { - if(i < ototvert) { + if (i < ototvert) { vertMap[i] = eve; } } @@ -389,7 +392,7 @@ static BMVert **bmesh_to_mesh_vertex_map(BMesh *bm, int ototvert) } else { BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { - if(i < ototvert) { + if (i < ototvert) { vertMap[i] = eve; } else { @@ -436,16 +439,16 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) ototvert = me->totvert; /* new Vertex block */ - if(bm->totvert==0) mvert= NULL; + if (bm->totvert==0) mvert= NULL; else mvert= MEM_callocN(bm->totvert*sizeof(MVert), "loadeditbMesh vert"); /* new Edge block */ - if(bm->totedge==0) medge= NULL; + if (bm->totedge==0) medge= NULL; else medge= MEM_callocN(bm->totedge*sizeof(MEdge), "loadeditbMesh edge"); /*build ngon data*/ /* new Ngon Face block */ - if(bm->totface==0) mpoly = NULL; + if (bm->totface==0) mpoly = NULL; else mpoly= MEM_callocN(bm->totface*sizeof(MPoly), "loadeditbMesh poly"); /*find number of loops to allocate*/ @@ -587,17 +590,17 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) vertMap= bmesh_to_mesh_vertex_map(bm, ototvert); } - if(ob->par1 < ototvert) { + if (ob->par1 < ototvert) { eve = vertMap[ob->par1]; - if(eve) ob->par1= BM_GetIndex(eve); + if (eve) ob->par1= BM_GetIndex(eve); } - if(ob->par2 < ototvert) { + if (ob->par2 < ototvert) { eve = vertMap[ob->par2]; - if(eve) ob->par2= BM_GetIndex(eve); + if (eve) ob->par2= BM_GetIndex(eve); } - if(ob->par3 < ototvert) { + if (ob->par3 < ototvert) { eve = vertMap[ob->par3]; - if(eve) ob->par3= BM_GetIndex(eve); + if (eve) ob->par3= BM_GetIndex(eve); } } @@ -611,7 +614,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) } for (i=j=0; i<hmd->totindex; i++) { - if(hmd->indexar[i] < ototvert) { + if (hmd->indexar[i] < ototvert) { eve = vertMap[hmd->indexar[i]]; if (eve) { @@ -640,19 +643,21 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) BMEditSelection *selected; me->totselect = BLI_countlist(&(bm->selected)); - if(me->mselect) MEM_freeN(me->mselect); + if (me->mselect) MEM_freeN(me->mselect); me->mselect = MEM_callocN(sizeof(MSelect) * me->totselect, "Mesh selection history"); - for(i = 0, selected = bm->selected.first; selected; i++, selected = selected->next) { - if(selected->htype == BM_VERT) { + for (i = 0, selected = bm->selected.first; selected; i++, selected = selected->next) { + if (selected->htype == BM_VERT) { me->mselect[i].type = ME_VSEL; - }else if(selected->htype == BM_EDGE) { + } + else if (selected->htype == BM_EDGE) { me->mselect[i].type = ME_ESEL; - }else if(selected->htype == BM_FACE) { + } + else if (selected->htype == BM_FACE) { me->mselect[i].type = ME_FSEL; } @@ -696,17 +701,17 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) /* editing the base key should update others */ - if(me->key->type==KEY_RELATIVE && oldverts) { + if (me->key->type==KEY_RELATIVE && oldverts) { int act_is_basis = 0; /* find if this key is a basis for any others */ - for(currkey = me->key->block.first; currkey; currkey= currkey->next) { - if(bm->shapenr-1 == currkey->relative) { + for (currkey = me->key->block.first; currkey; currkey= currkey->next) { + if (bm->shapenr-1 == currkey->relative) { act_is_basis = 1; break; } } - if(act_is_basis) { /* active key is a base */ + if (act_is_basis) { /* active key is a base */ float (*fp)[3]= actkey->data; int *keyi; i=0; @@ -714,7 +719,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) mvert = me->mvert; BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX); - if(keyi && *keyi != ORIGINDEX_NONE) { + if (keyi && *keyi != ORIGINDEX_NONE) { sub_v3_v3v3(ofs[i], mvert->co, fp[*keyi]); } i++; @@ -747,7 +752,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) copy_v3_v3(fp, co); /* propagate edited basis offsets to other shapes */ - if(apply_offset) { + if (apply_offset) { add_v3_v3(fp, *ofs_pt++); } @@ -766,7 +771,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) } } - if(ofs) MEM_freeN(ofs); + if (ofs) MEM_freeN(ofs); } /* XXX, code below is from trunk and a duplicate functionality @@ -777,7 +782,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) /* old method of reconstructing keys via vertice's original key indices, currently used if the new method above fails (which is theoretically possible in certain cases of undo).*/ - if(me->key) { + if (me->key) { float *fp, *newkey, *oldkey; KeyBlock *currkey; KeyBlock *actkey= BLI_findlink(&me->key->block, bm->shapenr-1); @@ -785,17 +790,17 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) float (*ofs)[3] = NULL; /* editing the base key should update others */ - if(me->key->type==KEY_RELATIVE && oldverts) { + if (me->key->type==KEY_RELATIVE && oldverts) { int act_is_basis = 0; /* find if this key is a basis for any others */ - for(currkey = me->key->block.first; currkey; currkey= currkey->next) { - if(bm->shapenr-1 == currkey->relative) { + for (currkey = me->key->block.first; currkey; currkey= currkey->next) { + if (bm->shapenr-1 == currkey->relative) { act_is_basis = 1; break; } } - if(act_is_basis) { /* active key is a base */ + if (act_is_basis) { /* active key is a base */ float (*fp)[3]= actkey->data; int *keyi; i=0; @@ -803,7 +808,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) mvert = me->mvert; BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX); - if(keyi && *keyi != ORIGINDEX_NONE) { + if (keyi && *keyi != ORIGINDEX_NONE) { sub_v3_v3v3(ofs[i], mvert->co, fp[*keyi]); } i++; @@ -815,7 +820,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) /* Lets reorder the key data so that things line up roughly * with the way things were before editmode */ currkey = me->key->block.first; - while(currkey) { + while (currkey) { int apply_offset = (ofs && (currkey != actkey) && (bm->shapenr-1 == currkey->relative)); if (!(currkey->flag & KEYBLOCK_MISSING)) { @@ -835,25 +840,25 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) i = 0; mvert = me->mvert; - while(eve) { + while (eve) { keyi = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX); if (!keyi) { break; } if (*keyi >= 0 && *keyi < currkey->totelem) { // valid old vertex - if(currkey == actkey) { - if(actkey == me->key->refkey) { + if (currkey == actkey) { + if (actkey == me->key->refkey) { copy_v3_v3(fp, mvert->co); } else { copy_v3_v3(fp, mvert->co); - if(oldverts) { + if (oldverts) { copy_v3_v3(mvert->co, oldverts[*keyi].co); } } } else { - if(oldkey) { + if (oldkey) { copy_v3_v3(fp, oldkey + 3 * *keyi); } } @@ -863,7 +868,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) } /* propagate edited basis offsets to other shapes */ - if(apply_offset) { + if (apply_offset) { add_v3_v3(fp, ofs[i]); } @@ -873,14 +878,14 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) eve= BMIter_Step(&iter); } currkey->totelem= bm->totvert; - if(currkey->data) MEM_freeN(currkey->data); + if (currkey->data) MEM_freeN(currkey->data); currkey->data = newkey; currkey= currkey->next; } - if(ofs) MEM_freeN(ofs); + if (ofs) MEM_freeN(ofs); } - if(oldverts) MEM_freeN(oldverts); + if (oldverts) MEM_freeN(oldverts); } diff --git a/source/blender/bmesh/operators/primitiveops.c b/source/blender/bmesh/operators/primitiveops.c index d78e0e1c18a..10d8319fda5 100644 --- a/source/blender/bmesh/operators/primitiveops.c +++ b/source/blender/bmesh/operators/primitiveops.c @@ -230,7 +230,7 @@ void bmesh_create_grid_exec(BMesh *bm, BMOperator *op) /* one segment first: the X axis */ phi= 1.0f; phid= 2.0f/((float)tot-1); - for(a=0;a<tot;a++) { + for (a=0;a<tot;a++) { vec[0]= dia*phi; vec[1]= - dia; vec[2]= 0.0f; @@ -253,14 +253,15 @@ void bmesh_create_grid_exec(BMesh *bm, BMOperator *op) vec[1]= dia*phid; mul_mat3_m4_v3(mat, vec); - for(a=0;a<seg-1;a++) { + for (a=0;a<seg-1;a++) { if (a) { BMO_InitOpf(bm, &bmop, "extrude_edge_only edges=%s", &prevop, "geomout"); BMO_Exec_Op(bm, &bmop); BMO_Finish_Op(bm, &prevop); BMO_Flag_Buffer(bm, &bmop, "geomout", VERT_MARK, BM_VERT); - } else { + } + else { BMO_InitOpf(bm, &bmop, "extrude_edge_only edges=%fe", EDGE_ORIG); BMO_Exec_Op(bm, &bmop); BMO_Flag_Buffer(bm, &bmop, "geomout", VERT_MARK, BM_VERT); @@ -289,12 +290,12 @@ void bmesh_create_uvsphere_exec(BMesh *bm, BMOperator *op) BMO_Get_Mat4(op, "mat", mat); phid= 2.0f*(float)M_PI/tot; - phi= .25f*(float)M_PI; + phi= 0.25f*(float)M_PI; /* one segment first */ phi= 0; phid/=2; - for(a=0; a<=tot; a++) { + for (a=0; a<=tot; a++) { /* Going in this direction, then edge extruding, makes normals face outward */ vec[0]= -dia*sinf(phi); vec[1]= 0.0; @@ -302,7 +303,7 @@ void bmesh_create_uvsphere_exec(BMesh *bm, BMOperator *op) eve= BM_Make_Vert(bm, vec, NULL); BMO_SetFlag(bm, eve, VERT_MARK); - if(a != 0) { + if (a != 0) { e = BM_Make_Edge(bm, preveve, eve, NULL, 0); BMO_SetFlag(bm, e, EDGE_ORIG); } @@ -318,12 +319,13 @@ void bmesh_create_uvsphere_exec(BMesh *bm, BMOperator *op) q[1]=q[2]= 0; quat_to_mat3(cmat, q); - for(a=0; a<seg; a++) { + for (a=0; a<seg; a++) { if (a) { BMO_InitOpf(bm, &bmop, "extrude_edge_only edges=%s", &prevop, "geomout"); BMO_Exec_Op(bm, &bmop); BMO_Finish_Op(bm, &prevop); - } else { + } + else { BMO_InitOpf(bm, &bmop, "extrude_edge_only edges=%fe", EDGE_ORIG); BMO_Exec_Op(bm, &bmop); } @@ -341,7 +343,7 @@ void bmesh_create_uvsphere_exec(BMesh *bm, BMOperator *op) /* and now do imat */ BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { - if(BMO_TestFlag(bm, eve, VERT_MARK)) { + if (BMO_TestFlag(bm, eve, VERT_MARK)) { mul_m4_v3(mat, eve->co); } } @@ -364,7 +366,7 @@ void bmesh_create_icosphere_exec(BMesh *bm, BMOperator *op) /* phi= .25f*(float)M_PI; */ /* UNUSED */ dia/=200; - for(a=0;a<12;a++) { + for (a=0;a<12;a++) { vec[0]= dia*icovert[a][0]; vec[1]= dia*icovert[a][1]; vec[2]= dia*icovert[a][2]; @@ -374,7 +376,7 @@ void bmesh_create_icosphere_exec(BMesh *bm, BMOperator *op) BM_Select(bm, eva[a], TRUE); } - for(a=0;a<20;a++) { + for (a=0;a<20;a++) { BMFace *eftemp; BMVert *v1, *v2, *v3; @@ -393,7 +395,7 @@ void bmesh_create_icosphere_exec(BMesh *bm, BMOperator *op) dia*=200; - for(a=1; a<subdiv; a++) { + for (a=1; a<subdiv; a++) { BMOperator bmop; BMO_InitOpf(bm, &bmop, @@ -575,7 +577,8 @@ void bmesh_create_cone_exec(BMesh *bm, BMOperator *op) BMO_SetFlag(bm, f, FACE_NEW); } BM_Make_Face_QuadTri(bm, lastv1, lastv2, v2, v1, NULL, 0); - } else { + } + else { firstv1 = v1; firstv2 = v2; } diff --git a/source/blender/bmesh/operators/removedoubles.c b/source/blender/bmesh/operators/removedoubles.c index a6dd09752de..00aaaf0527a 100644 --- a/source/blender/bmesh/operators/removedoubles.c +++ b/source/blender/bmesh/operators/removedoubles.c @@ -66,11 +66,11 @@ int remdoubles_face_overlaps(BMesh *bm, BMVert **varr, if (overlapface) *overlapface = NULL; - for(i=0; i < len; i++) { - f = BMIter_New(&vertfaces, bm, BM_FACES_OF_VERT, varr[i] ); - while(f) { + for (i=0; i < len; i++) { + f = BMIter_New(&vertfaces, bm, BM_FACES_OF_VERT, varr[i]); + while (f) { amount = BM_Verts_In_Face(bm, f, varr, len); - if(amount >= len) { + if (amount >= len) { if (overlapface) *overlapface = f; return 1; } @@ -323,7 +323,8 @@ void bmesh_pointmerge_exec(BMesh *bm, BMOperator *op) if (!snapv) { snapv = v; copy_v3_v3(snapv->co, vec); - } else { + } + else { BMO_Insert_MapPointer(bm, &weldop, "targetmap", v, snapv); } } diff --git a/source/blender/bmesh/operators/subdivideop.c b/source/blender/bmesh/operators/subdivideop.c index 5d8eb668876..97e4e34059f 100644 --- a/source/blender/bmesh/operators/subdivideop.c +++ b/source/blender/bmesh/operators/subdivideop.c @@ -96,9 +96,11 @@ NOTE: beauty has been renamed to flag! while (1) { if (d > dp) { d -= wid; - } else if (d < dp) { + } + else if (d < dp) { d += wid; - } else { + } + else { break; } @@ -176,7 +178,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const subdpar co = CustomData_bmesh_get_n(&bm->vdata, v->head.data, CD_SHAPEKEY, params->origkey); copy_v3_v3(prev_co, co); - if(params->beauty & B_SMOOTH) { + if (params->beauty & B_SMOOTH) { /* we calculate an offset vector vec1[], to be added to *co */ float len, nor[3], nor1[3], nor2[3], smooth=params->smooth; @@ -201,12 +203,12 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const subdpar add_v3_v3(co, tvec); } - else if(params->beauty & B_SPHERE) { /* subdivide sphere */ + else if (params->beauty & B_SPHERE) { /* subdivide sphere */ normalize_v3(co); mul_v3_fl(co, params->smooth); } - if(params->beauty & B_FRACTAL) { + if (params->beauty & B_FRACTAL) { float len = len_v3v3(vsta->co, vend->co); float vec2[3] = {0.0f, 0.0f, 0.0f}, co2[3]; @@ -263,13 +265,13 @@ static BMVert *bm_subdivide_edge_addvert(BMesh *bm, BMEdge *edge,BMEdge *oedge, #if 0 //BMESH_TODO /* clip if needed by mirror modifier */ if (edge->v1->f2) { - if ( edge->v1->f2 & edge->v2->f2 & 1) { + if (edge->v1->f2 & edge->v2->f2 & 1) { co[0]= 0.0f; } - if ( edge->v1->f2 & edge->v2->f2 & 2) { + if (edge->v1->f2 & edge->v2->f2 & 2) { co[1]= 0.0f; } - if ( edge->v1->f2 & edge->v2->f2 & 4) { + if (edge->v1->f2 & edge->v2->f2 & 4) { co[2]= 0.0f; } } @@ -309,7 +311,7 @@ static void bm_subdivide_multicut(BMesh *bm, BMEdge *edge, const subdparams *par temp.v1 = &ov1; temp.v2 = &ov2; - for(i=0;i<numcuts;i++) { + for (i=0;i<numcuts;i++) { v = subdivideedgenum(bm, eed, &temp, i, params->numcuts, params, &newe, vsta, vend); @@ -358,7 +360,8 @@ static void quad_1edge_split(BMesh *bm, BMFace *UNUSED(face), connect_smallest_face(bm, verts[i], verts[numcuts+add], &nf); } - } else { + } + else { add = 2; for (i=0; i<numcuts; i++) { connect_smallest_face(bm, verts[i], verts[numcuts+add], @@ -802,7 +805,8 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) if (singleedge) { patterns[0] = &quad_1edge; patterns[2] = &tri_1edge; - } else { + } + else { patterns[0] = NULL; patterns[2] = NULL; } @@ -810,7 +814,8 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) if (gridfill) { patterns[3] = &quad_4edge; patterns[5] = &tri_3edge; - } else { + } + else { patterns[3] = NULL; patterns[5] = NULL; } @@ -1004,7 +1009,8 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) if (BMO_TestFlag(bmesh, loops[(a+numcuts+1)%vlen]->v, ELE_INNER)) { b = (a+numcuts+1)%vlen; - } else { + } + else { /*find the boundary of the other edge.*/ for (j=0; j<vlen; j++) { b = (j + a + numcuts + 1) % vlen; @@ -1037,7 +1043,8 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) } continue; - } else if (!pat) { + } + else if (!pat) { continue; } @@ -1112,10 +1119,11 @@ void BM_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float smooth // int i; ele = BMO_IterNew(&iter, bm, &op, "outinner", BM_EDGE|BM_VERT); - for (; ele; ele=BMO_IterStep(&iter)) { + for ( ; ele; ele=BMO_IterStep(&iter)) { BM_Select(bm, ele, TRUE); } - } else if (seltype == SUBDIV_SELECT_LOOPCUT) { + } + else if (seltype == SUBDIV_SELECT_LOOPCUT) { BMOIter iter; BMHeader *ele; // int i; @@ -1124,7 +1132,7 @@ void BM_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float smooth BM_clear_flag_all(bm, BM_SELECT); ele = BMO_IterNew(&iter, bm, &op, "outinner", BM_EDGE|BM_VERT); - for (; ele; ele=BMO_IterStep(&iter)) { + for ( ; ele; ele=BMO_IterStep(&iter)) { BM_Select(bm, ele, TRUE); if (ele->htype == BM_VERT) { @@ -1136,7 +1144,8 @@ void BM_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float smooth && BM_TestHFlag(e->v2, BM_SELECT)) { BM_Select(bm, e, TRUE); bm->totedgesel += 1; - } else if (BM_TestHFlag(e, BM_SELECT) && (!BM_TestHFlag(e->v1, BM_SELECT) + } + else if (BM_TestHFlag(e, BM_SELECT) && (!BM_TestHFlag(e->v1, BM_SELECT) || !BM_TestHFlag(e->v2, BM_SELECT))) { BM_Select(bm, e, FALSE); bm->totedgesel -= 1; diff --git a/source/blender/bmesh/operators/triangulateop.c b/source/blender/bmesh/operators/triangulateop.c index 5fb5ceddb63..c1f31bcbd79 100644 --- a/source/blender/bmesh/operators/triangulateop.c +++ b/source/blender/bmesh/operators/triangulateop.c @@ -32,7 +32,7 @@ void triangulate_exec(BMesh *bm, BMOperator *op) int i, lastlen=0 /* , count = 0 */; face = BMO_IterNew(&siter, bm, op, "faces", BM_FACE); - for (; face; face=BMO_IterStep(&siter)) { + for ( ; face; face=BMO_IterStep(&siter)) { if (lastlen < face->len) { BLI_array_empty(projectverts); BLI_array_empty(newfaces); diff --git a/source/blender/bmesh/operators/utils.c b/source/blender/bmesh/operators/utils.c index b4de92a3088..b535fa1eb4b 100644 --- a/source/blender/bmesh/operators/utils.c +++ b/source/blender/bmesh/operators/utils.c @@ -154,7 +154,8 @@ static void bmesh_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces) } } } - } else { + } + else { BMIter liter, fiter; BMFace *f, *f2; BMLoop *l; @@ -192,7 +193,8 @@ static void bmesh_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces } } } - } else { + } + else { BMIter liter, fiter; BMFace *f, *f2; BMLoop *l; @@ -331,7 +333,8 @@ void bmesh_righthandfaces_exec(BMesh *bm, BMOperator *op) BMO_ToggleFlag(bm, l2->f, FACE_FLIP); if (flagflip) BM_ToggleHFlag(l2->f, BM_TMP_TAG); - } else if (BM_TestHFlag(l2->f, BM_TMP_TAG) || BM_TestHFlag(l->f, BM_TMP_TAG)) { + } + else if (BM_TestHFlag(l2->f, BM_TMP_TAG) || BM_TestHFlag(l->f, BM_TMP_TAG)) { if (flagflip) { BM_ClearHFlag(l->f, BM_TMP_TAG); BM_ClearHFlag(l2->f, BM_TMP_TAG); @@ -429,10 +432,11 @@ static float ngon_perimeter(BMesh *bm, BMFace *f) float perimeter = 0.0f; BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { - if( num_verts == 0 ) { + if (num_verts == 0) { copy_v3_v3(v, l->v->co); copy_v3_v3(sv, l->v->co); - } else { + } + else { perimeter += len_v3v3(v, l->v->co); copy_v3_v3(v, l->v->co); } @@ -462,11 +466,12 @@ static float ngon_fake_area(BMesh *bm, BMFace *f) BM_Compute_Face_CenterMean(bm, f, c); BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { - if( num_verts == 0 ) { + if (num_verts == 0) { copy_v3_v3(v, l->v->co); copy_v3_v3(sv, l->v->co); num_verts++; - } else { + } + else { area += area_tri_v3(v, c, l->v->co); copy_v3_v3(v, l->v->co); num_verts++; @@ -543,9 +548,9 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) ** Save us some computation burden: In case of perimeter/area/coplanar selection we compute ** only once. */ - if( type == SIMFACE_PERIMETER || type == SIMFACE_AREA || type == SIMFACE_COPLANAR || type == SIMFACE_IMAGE ) { - for( i = 0; i < num_total; i++ ) { - switch( type ) { + if (type == SIMFACE_PERIMETER || type == SIMFACE_AREA || type == SIMFACE_COPLANAR || type == SIMFACE_IMAGE) { + for (i = 0; i < num_total; i++) { + switch (type) { case SIMFACE_PERIMETER: /* set the perimeter */ f_ext[i].perim = ngon_perimeter(bm, f_ext[i].f); @@ -569,7 +574,7 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) case SIMFACE_IMAGE: f_ext[i].t = NULL; - if( CustomData_has_layer(&(bm->pdata), CD_MTEXPOLY) ) { + if (CustomData_has_layer(&(bm->pdata), CD_MTEXPOLY)) { MTexPoly *mtpoly = CustomData_bmesh_get(&bm->pdata, f_ext[i].f->head.data, CD_MTEXPOLY); f_ext[i].t = mtpoly->tpage; } @@ -579,22 +584,22 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) } /* now select the rest (if any) */ - for( i = 0; i < num_total; i++ ) { + for (i = 0; i < num_total; i++) { fm = f_ext[i].f; - if( !BMO_TestFlag(bm, fm, FACE_MARK) && !BM_TestHFlag(fm, BM_HIDDEN) ) { + if (!BMO_TestFlag(bm, fm, FACE_MARK) && !BM_TestHFlag(fm, BM_HIDDEN)) { int cont = 1; - for( idx = 0; idx < num_sels && cont == 1; idx++ ) { + for (idx = 0; idx < num_sels && cont == 1; idx++) { fs = f_ext[indices[idx]].f; - switch( type ) { + switch (type) { case SIMFACE_MATERIAL: - if( fm->mat_nr == fs->mat_nr ) { + if (fm->mat_nr == fs->mat_nr) { BMO_SetFlag(bm, fm, FACE_MARK); cont = 0; } break; case SIMFACE_IMAGE: - if( f_ext[i].t == f_ext[indices[idx]].t ) { + if (f_ext[i].t == f_ext[indices[idx]].t) { BMO_SetFlag(bm, fm, FACE_MARK); cont = 0; } @@ -602,7 +607,7 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) case SIMFACE_NORMAL: angle = RAD2DEGF(angle_v3v3(fs->no, fm->no)); /* if the angle between the normals -> 0 */ - if( angle / 180.0f <= thresh ) { + if (angle / 180.0f <= thresh) { BMO_SetFlag(bm, fm, FACE_MARK); cont = 0; } @@ -610,8 +615,8 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) case SIMFACE_COPLANAR: angle = RAD2DEGF(angle_v3v3(fs->no, fm->no)); /* angle -> 0 */ - if( angle / 180.0f <= thresh ) { /* and dot product difference -> 0 */ - if( fabsf(f_ext[i].d - f_ext[indices[idx]].d) <= thresh ) { + if (angle / 180.0f <= thresh) { /* and dot product difference -> 0 */ + if (fabsf(f_ext[i].d - f_ext[indices[idx]].d) <= thresh) { BMO_SetFlag(bm, fm, FACE_MARK); cont = 0; } @@ -619,14 +624,14 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) break; case SIMFACE_AREA: - if( fabsf(f_ext[i].area - f_ext[indices[idx]].area) <= thresh ) { + if (fabsf(f_ext[i].area - f_ext[indices[idx]].area) <= thresh) { BMO_SetFlag(bm, fm, FACE_MARK); cont = 0; } break; case SIMFACE_PERIMETER: - if( fabsf(f_ext[i].perim - f_ext[indices[idx]].perim) <= thresh ) { + if (fabsf(f_ext[i].perim - f_ext[indices[idx]].perim) <= thresh) { BMO_SetFlag(bm, fm, FACE_MARK); cont = 0; } @@ -659,7 +664,7 @@ static float edge_angle(BMesh *bm, BMEdge *e) /* first edge faces, dont account for 3+ */ BM_ITER(f, &fiter, bm, BM_FACES_OF_EDGE, e) { - if(f_prev == NULL) { + if (f_prev == NULL) { f_prev= f; } else { @@ -728,10 +733,9 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) } /* save us some computation time by doing heavy computation once */ - if( type == SIMEDGE_LENGTH || type == SIMEDGE_FACE || type == SIMEDGE_DIR || - type == SIMEDGE_FACE_ANGLE ) { - for( i = 0; i < num_total; i++ ) { - switch( type ) { + if (type == SIMEDGE_LENGTH || type == SIMEDGE_FACE || type == SIMEDGE_DIR || type == SIMEDGE_FACE_ANGLE) { + for (i = 0; i < num_total; i++) { + switch (type) { case SIMEDGE_LENGTH: /* compute the length of the edge */ e_ext[i].length = len_v3v3(e_ext[i].e->v1->co, e_ext[i].e->v2->co); break; @@ -746,7 +750,7 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) case SIMEDGE_FACE_ANGLE: e_ext[i].faces = BM_Edge_FaceCount(e_ext[i].e); - if( e_ext[i].faces == 2 ) + if (e_ext[i].faces == 2) e_ext[i].angle = edge_angle(bm, e_ext[i].e); break; } @@ -754,15 +758,15 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) } /* select the edges if any */ - for( i = 0; i < num_total; i++ ) { + for (i = 0; i < num_total; i++) { e = e_ext[i].e; - if( !BMO_TestFlag(bm, e, EDGE_MARK) && !BM_TestHFlag(e, BM_HIDDEN) ) { + if (!BMO_TestFlag(bm, e, EDGE_MARK) && !BM_TestHFlag(e, BM_HIDDEN)) { int cont = 1; - for( idx = 0; idx < num_sels && cont == 1; idx++ ) { + for (idx = 0; idx < num_sels && cont == 1; idx++) { es = e_ext[indices[idx]].e; - switch( type ) { + switch (type) { case SIMEDGE_LENGTH: - if( fabsf(e_ext[i].length - e_ext[indices[idx]].length) <= thresh ) { + if (fabsf(e_ext[i].length - e_ext[indices[idx]].length) <= thresh) { BMO_SetFlag(bm, e, EDGE_MARK); cont = 0; } @@ -772,31 +776,34 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) /* compute the angle between the two edges */ angle = RAD2DEGF(angle_v3v3(e_ext[i].dir, e_ext[indices[idx]].dir)); - if( angle > 90.0f ) /* use the smallest angle between the edges */ + if (angle > 90.0f) /* use the smallest angle between the edges */ angle = fabsf(angle - 180.0f); - if( angle / 90.0f <= thresh ) { + if (angle / 90.0f <= thresh) { BMO_SetFlag(bm, e, EDGE_MARK); cont = 0; } break; case SIMEDGE_FACE: - if( e_ext[i].faces == e_ext[indices[idx]].faces ) { + if (e_ext[i].faces == e_ext[indices[idx]].faces) { BMO_SetFlag(bm, e, EDGE_MARK); cont = 0; } break; case SIMEDGE_FACE_ANGLE: - if( e_ext[i].faces == 2 ) { - if( e_ext[indices[idx]].faces == 2 ) { - if( fabsf(e_ext[i].angle - e_ext[indices[idx]].angle) <= thresh ) { + if (e_ext[i].faces == 2) { + if (e_ext[indices[idx]].faces == 2) { + if (fabsf(e_ext[i].angle - e_ext[indices[idx]].angle) <= thresh) { BMO_SetFlag(bm, e, EDGE_MARK); cont = 0; } } - } else cont = 0; + } + else { + cont = 0; + } break; case SIMEDGE_CREASE: @@ -806,7 +813,7 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) c1 = CustomData_bmesh_get(&bm->edata, e->head.data, CD_CREASE); c2 = CustomData_bmesh_get(&bm->edata, es->head.data, CD_CREASE); - if( c1&&c2 && fabsf(*c1 - *c2) <= thresh ) { + if (c1 && c2 && fabsf(*c1 - *c2) <= thresh) { BMO_SetFlag(bm, e, EDGE_MARK); cont = 0; } @@ -814,14 +821,14 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) break; case SIMEDGE_SEAM: - if( BM_TestHFlag(e, BM_SEAM) == BM_TestHFlag(es, BM_SEAM) ) { + if (BM_TestHFlag(e, BM_SEAM) == BM_TestHFlag(es, BM_SEAM)) { BMO_SetFlag(bm, e, EDGE_MARK); cont = 0; } break; case SIMEDGE_SHARP: - if( BM_TestHFlag(e, BM_SHARP) == BM_TestHFlag(es, BM_SHARP) ) { + if (BM_TestHFlag(e, BM_SHARP) == BM_TestHFlag(es, BM_SHARP)) { BMO_SetFlag(bm, e, EDGE_MARK); cont = 0; } @@ -887,16 +894,19 @@ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op) idx++; } - switch( type ) { + switch (type) { case SIMVERT_FACE: /* calling BM_Vert_FaceCount every time is time consumming, so call it only once per vertex */ v_ext[i].num_faces = BM_Vert_FaceCount(v); break; case SIMVERT_VGROUP: - if( CustomData_has_layer(&(bm->vdata),CD_MDEFORMVERT) ) { + if (CustomData_has_layer(&(bm->vdata),CD_MDEFORMVERT)) { v_ext[i].dvert = CustomData_bmesh_get(&bm->vdata, v_ext[i].v->head.data, CD_MDEFORMVERT); - } else v_ext[i].dvert = NULL; + } + else { + v_ext[i].dvert = NULL; + } break; } @@ -904,34 +914,34 @@ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op) } /* select the vertices if any */ - for( i = 0; i < num_total; i++ ) { + for (i = 0; i < num_total; i++) { v = v_ext[i].v; - if( !BMO_TestFlag(bm, v, VERT_MARK) && !BM_TestHFlag(v, BM_HIDDEN) ) { + if (!BMO_TestFlag(bm, v, VERT_MARK) && !BM_TestHFlag(v, BM_HIDDEN)) { int cont = 1; - for( idx = 0; idx < num_sels && cont == 1; idx++ ) { + for (idx = 0; idx < num_sels && cont == 1; idx++) { vs = v_ext[indices[idx]].v; - switch( type ) { + switch (type) { case SIMVERT_NORMAL: /* compare the angle between the normals */ - if( RAD2DEGF(angle_v3v3(v->no, vs->no)) / 180.0f <= thresh ) { + if (RAD2DEGF(angle_v3v3(v->no, vs->no)) / 180.0f <= thresh) { BMO_SetFlag(bm, v, VERT_MARK); cont = 0; } break; case SIMVERT_FACE: /* number of adjacent faces */ - if( v_ext[i].num_faces == v_ext[indices[idx]].num_faces ) { + if (v_ext[i].num_faces == v_ext[indices[idx]].num_faces) { BMO_SetFlag(bm, v, VERT_MARK); cont = 0; } break; case SIMVERT_VGROUP: - if( v_ext[i].dvert != NULL && v_ext[indices[idx]].dvert != NULL ) { + if (v_ext[i].dvert != NULL && v_ext[indices[idx]].dvert != NULL) { int v1, v2; - for( v1 = 0; v1 < v_ext[i].dvert->totweight && cont == 1; v1++ ) { - for( v2 = 0; v2 < v_ext[indices[idx]].dvert->totweight; v2++ ) { - if( v_ext[i].dvert->dw[v1].def_nr == v_ext[indices[idx]].dvert->dw[v2].def_nr ) { + for (v1 = 0; v1 < v_ext[i].dvert->totweight && cont == 1; v1++) { + for (v2 = 0; v2 < v_ext[indices[idx]].dvert->totweight; v2++) { + if (v_ext[i].dvert->dw[v1].def_nr == v_ext[indices[idx]].dvert->dw[v2].def_nr) { BMO_SetFlag(bm, v, VERT_MARK); cont = 0; break; @@ -965,8 +975,8 @@ void bmesh_rotateuvs_exec(BMesh *bm, BMOperator *op) int dir = BMO_Get_Int(op, "dir"); BMO_ITER(fs, &fs_iter, bm, op, "faces", BM_FACE) { - if( CustomData_has_layer(&(bm->ldata), CD_MLOOPUV) ) { - if( dir == DIRECTION_CW ) { /* same loops direction */ + if (CustomData_has_layer(&(bm->ldata), CD_MLOOPUV)) { + if (dir == DIRECTION_CW) { /* same loops direction */ BMLoop *lf; /* current face loops */ MLoopUV *f_luv; /* first face loop uv */ float p_uv[2]; /* previous uvs */ @@ -976,24 +986,21 @@ void bmesh_rotateuvs_exec(BMesh *bm, BMOperator *op) BM_ITER(lf, &l_iter, bm, BM_LOOPS_OF_FACE, fs) { /* current loop uv is the previous loop uv */ MLoopUV *luv = CustomData_bmesh_get(&bm->ldata, lf->head.data, CD_MLOOPUV); - if( n == 0 ) { + if (n == 0) { f_luv = luv; - p_uv[0] = luv->uv[0]; - p_uv[1] = luv->uv[1]; - } else { - t_uv[0] = luv->uv[0]; - t_uv[1] = luv->uv[1]; - luv->uv[0] = p_uv[0]; - luv->uv[1] = p_uv[1]; - p_uv[0] = t_uv[0]; - p_uv[1] = t_uv[1]; + copy_v2_v2(p_uv, luv->uv); + } + else { + copy_v2_v2(t_uv, luv->uv); + copy_v2_v2(luv->uv, p_uv); + copy_v2_v2(p_uv, t_uv); } n++; } - f_luv->uv[0] = p_uv[0]; - f_luv->uv[1] = p_uv[1]; - } else if( dir == DIRECTION_CCW ) { /* counter loop direction */ + copy_v2_v2(f_luv->uv, p_uv); + } + else if (dir == DIRECTION_CCW) { /* counter loop direction */ BMLoop *lf; /* current face loops */ MLoopUV *p_luv; /*previous loop uv */ MLoopUV *luv; @@ -1003,20 +1010,18 @@ void bmesh_rotateuvs_exec(BMesh *bm, BMOperator *op) BM_ITER(lf, &l_iter, bm, BM_LOOPS_OF_FACE, fs) { /* previous loop uv is the current loop uv */ luv = CustomData_bmesh_get(&bm->ldata, lf->head.data, CD_MLOOPUV); - if( n == 0 ) { + if (n == 0) { p_luv = luv; - t_uv[0] = luv->uv[0]; - t_uv[1] = luv->uv[1]; - } else { - p_luv->uv[0] = luv->uv[0]; - p_luv->uv[1] = luv->uv[1]; + copy_v2_v2(t_uv, luv->uv); + } + else { + copy_v2_v2(p_luv->uv, luv->uv); p_luv = luv; } n++; } - luv->uv[0] = t_uv[0]; - luv->uv[1] = t_uv[1]; + copy_v2_v2(luv->uv, t_uv); } } } @@ -1036,7 +1041,7 @@ void bmesh_reverseuvs_exec(BMesh *bm, BMOperator *op) float (*uvs)[2] = NULL; BMO_ITER(fs, &fs_iter, bm, op, "faces", BM_FACE) { - if( CustomData_has_layer(&(bm->ldata), CD_MLOOPUV) ) { + if (CustomData_has_layer(&(bm->ldata), CD_MLOOPUV)) { BMLoop *lf; /* current face loops */ int i = 0; @@ -1080,8 +1085,8 @@ void bmesh_rotatecolors_exec(BMesh *bm, BMOperator *op) int dir = BMO_Get_Int(op, "dir"); BMO_ITER(fs, &fs_iter, bm, op, "faces", BM_FACE) { - if( CustomData_has_layer(&(bm->ldata), CD_MLOOPCOL) ) { - if( dir == DIRECTION_CW ) { /* same loops direction */ + if (CustomData_has_layer(&(bm->ldata), CD_MLOOPCOL)) { + if (dir == DIRECTION_CW) { /* same loops direction */ BMLoop *lf; /* current face loops */ MLoopCol *f_lcol; /* first face loop color */ MLoopCol p_col; /* previous color */ @@ -1091,10 +1096,11 @@ void bmesh_rotatecolors_exec(BMesh *bm, BMOperator *op) BM_ITER(lf, &l_iter, bm, BM_LOOPS_OF_FACE, fs) { /* current loop color is the previous loop color */ MLoopCol *luv = CustomData_bmesh_get(&bm->ldata, lf->head.data, CD_MLOOPCOL); - if( n == 0 ) { + if (n == 0) { f_lcol = luv; p_col = *luv; - } else { + } + else { t_col = *luv; *luv = p_col; p_col = t_col; @@ -1103,7 +1109,8 @@ void bmesh_rotatecolors_exec(BMesh *bm, BMOperator *op) } *f_lcol = p_col; - } else if( dir == DIRECTION_CCW ) { /* counter loop direction */ + } + else if (dir == DIRECTION_CCW) { /* counter loop direction */ BMLoop *lf; /* current face loops */ MLoopCol *p_lcol; /*previous loop color */ MLoopCol *lcol; @@ -1113,10 +1120,11 @@ void bmesh_rotatecolors_exec(BMesh *bm, BMOperator *op) BM_ITER(lf, &l_iter, bm, BM_LOOPS_OF_FACE, fs) { /* previous loop color is the current loop color */ lcol = CustomData_bmesh_get(&bm->ldata, lf->head.data, CD_MLOOPCOL); - if( n == 0 ) { + if (n == 0) { p_lcol = lcol; t_col = *lcol; - } else { + } + else { *p_lcol = *lcol; p_lcol = lcol; } @@ -1142,7 +1150,7 @@ void bmesh_reversecolors_exec(BMesh *bm, BMOperator *op) MLoopCol *cols = NULL; BMO_ITER(fs, &fs_iter, bm, op, "faces", BM_FACE) { - if( CustomData_has_layer(&(bm->ldata), CD_MLOOPCOL) ) { + if (CustomData_has_layer(&(bm->ldata), CD_MLOOPCOL)) { BMLoop *lf; /* current face loops */ int i = 0; @@ -1226,10 +1234,10 @@ void bmesh_vertexshortestpath_exec(BMesh *bm, BMOperator *op) h = BLI_heap_new(); - for( i = 0; i < num_total; i++ ) + for (i = 0; i < num_total; i++ ) vert_list[i].hn = BLI_heap_insert(h, vert_list[i].weight, vert_list[i].v); - while( !BLI_heap_empty(h) ) { + while (!BLI_heap_empty(h)) { BMEdge *e; BMIter e_i; float v_weight; @@ -1237,7 +1245,7 @@ void bmesh_vertexshortestpath_exec(BMesh *bm, BMOperator *op) /* take the vertex with the lowest weight out of the heap */ BMVert *v = (BMVert*)BLI_heap_popmin(h); - if( vert_list[BM_GetIndex(v)].weight == FLT_MAX ) /* this means that there is no path */ + if (vert_list[BM_GetIndex(v)].weight == FLT_MAX) /* this means that there is no path */ break; v_weight = vert_list[BM_GetIndex(v)].weight; @@ -1246,13 +1254,13 @@ void bmesh_vertexshortestpath_exec(BMesh *bm, BMOperator *op) BMVert *u; float e_weight = v_weight; - if( type == VPATH_SELECT_EDGE_LENGTH ) + if (type == VPATH_SELECT_EDGE_LENGTH) e_weight += len_v3v3(e->v1->co, e->v2->co); else e_weight += 1.0f; u = ( e->v1 == v ) ? e->v2 : e->v1; - if( e_weight < vert_list[BM_GetIndex(u)].weight ) { /* is this path shorter ? */ + if (e_weight < vert_list[BM_GetIndex(u)].weight) { /* is this path shorter ? */ /* add it if so */ vert_list[BM_GetIndex(u)].parent = v; vert_list[BM_GetIndex(u)].weight = e_weight; @@ -1267,7 +1275,7 @@ void bmesh_vertexshortestpath_exec(BMesh *bm, BMOperator *op) /* now we trace the path (if it exists) */ v = ev; - while( vert_list[BM_GetIndex(v)].parent != NULL ) { + while (vert_list[BM_GetIndex(v)].parent != NULL) { BMO_SetFlag(bm, v, VERT_MARK); v = vert_list[BM_GetIndex(v)].parent; } diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index 97e4132482d..1f0eef78e32 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -98,7 +98,7 @@ BMEditMesh_mods.c, UI level access, no geometry changes static void EDBM_select_mirrored(Object *obedit, BMEditMesh *em) { - if(em->selectmode & SCE_SELECT_VERTEX) { + if (em->selectmode & SCE_SELECT_VERTEX) { BMVert *eve, *v1; BMIter iter; int i; @@ -107,7 +107,7 @@ static void EDBM_select_mirrored(Object *obedit, BMEditMesh *em) BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if (BM_TestHFlag(eve, BM_SELECT) && !BM_TestHFlag(eve, BM_HIDDEN)) { v1= editbmesh_get_x_mirror_vert(obedit, em, eve, eve->co, i); - if(v1) { + if (v1) { BM_Select(em->bm, eve, FALSE); BM_Select(em->bm, v1, TRUE); } @@ -168,7 +168,7 @@ static void draw_triangulated(int mcords[][2], short tot) /* do the draw */ dl= lb.first; /* filldisplist adds in head of list */ - if(dl->type==DL_INDEX3) { + if (dl->type==DL_INDEX3) { int *index; a= dl->parts; @@ -196,11 +196,11 @@ int EDBM_init_backbuf_border(ViewContext *vc, short xmin, short ymin, short xmax unsigned int *dr; int a; - if(vc->obedit==NULL || vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; + if (vc->obedit==NULL || vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; buf= view3d_read_backbuf(vc, xmin, ymin, xmax, ymax); - if(buf==NULL) return 0; - if(bm_vertoffs==0) return 0; + if (buf==NULL) return 0; + if (bm_vertoffs==0) return 0; dr = buf->rect; @@ -209,7 +209,7 @@ int EDBM_init_backbuf_border(ViewContext *vc, short xmin, short ymin, short xmax a= (xmax-xmin+1)*(ymax-ymin+1); while(a--) { - if(*dr>0 && *dr<=bm_vertoffs) + if (*dr>0 && *dr<=bm_vertoffs) selbuf[*dr]= 1; dr++; } @@ -219,15 +219,15 @@ int EDBM_init_backbuf_border(ViewContext *vc, short xmin, short ymin, short xmax int EDBM_check_backbuf(unsigned int index) { - if(selbuf==NULL) return 1; - if(index>0 && index<=bm_vertoffs) + if (selbuf==NULL) return 1; + if (index>0 && index<=bm_vertoffs) return selbuf[index]; return 0; } void EDBM_free_backbuf(void) { - if(selbuf) MEM_freeN(selbuf); + if (selbuf) MEM_freeN(selbuf); selbuf= NULL; } @@ -244,16 +244,16 @@ int EDBM_mask_init_backbuf_border(ViewContext *vc, int mcords[][2], short tot, s int a; /* method in use for face selecting too */ - if(vc->obedit==NULL) { - if(paint_facesel_test(vc->obact)); - else if(paint_vertsel_test(vc->obact)); + if (vc->obedit==NULL) { + if (paint_facesel_test(vc->obact)); + else if (paint_vertsel_test(vc->obact)); else return 0; } - else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; + else if (vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; buf= view3d_read_backbuf(vc, xmin, ymin, xmax, ymax); - if(buf==NULL) return 0; - if(bm_vertoffs==0) return 0; + if (buf==NULL) return 0; + if (bm_vertoffs==0) return 0; dr = buf->rect; @@ -275,14 +275,14 @@ int EDBM_mask_init_backbuf_border(ViewContext *vc, int mcords[][2], short tot, s /* grab mask */ bufmask= view3d_read_backbuf(vc, xmin, ymin, xmax, ymax); drm = bufmask->rect; - if(bufmask==NULL) return 0; /* only when mem alloc fails, go crash somewhere else! */ + if (bufmask==NULL) return 0; /* only when mem alloc fails, go crash somewhere else! */ /* build selection lookup */ selbuf= MEM_callocN(bm_vertoffs+1, "selbuf"); a= (xmax-xmin+1)*(ymax-ymin+1); while(a--) { - if(*dr>0 && *dr<=bm_vertoffs && *drm==0) selbuf[*dr]= 1; + if (*dr>0 && *dr<=bm_vertoffs && *drm==0) selbuf[*dr]= 1; dr++; drm++; } IMB_freeImBuf(buf); @@ -300,18 +300,18 @@ int EDBM_init_backbuf_circle(ViewContext *vc, short xs, short ys, short rads) int radsq; /* method in use for face selecting too */ - if(vc->obedit==NULL) { - if(paint_facesel_test(vc->obact)); - else if(paint_vertsel_test(vc->obact)); + if (vc->obedit==NULL) { + if (paint_facesel_test(vc->obact)); + else if (paint_vertsel_test(vc->obact)); else return 0; } - else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; + else if (vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0; xmin= xs-rads; xmax= xs+rads; ymin= ys-rads; ymax= ys+rads; buf= view3d_read_backbuf(vc, xmin, ymin, xmax, ymax); - if(bm_vertoffs==0) return 0; - if(buf==NULL) return 0; + if (bm_vertoffs==0) return 0; + if (buf==NULL) return 0; dr = buf->rect; @@ -320,8 +320,8 @@ int EDBM_init_backbuf_circle(ViewContext *vc, short xs, short ys, short rads) radsq= rads*rads; for(yc= -rads; yc<=rads; yc++) { for(xc= -rads; xc<=rads; xc++, dr++) { - if(xc*xc + yc*yc < radsq) { - if(*dr>0 && *dr<=bm_vertoffs) selbuf[*dr]= 1; + if (xc*xc + yc*yc < radsq) { + if (*dr>0 && *dr<=bm_vertoffs) selbuf[*dr]= 1; } } } @@ -338,7 +338,8 @@ static void findnearestvert__doClosest(void *userData, BMVert *eve, int x, int y if (data->pass==0) { if (index<=data->lastIndex) return; - } else { + } + else { if (index>data->lastIndex) return; } @@ -368,7 +369,7 @@ static unsigned int findnearestvert__backbufIndextest(void *handle, unsigned int BMEditMesh *em= (BMEditMesh *)handle; BMVert *eve = BM_Vert_AtIndex(em->bm, index-1); - if(eve && BM_TestHFlag(eve, BM_SELECT)) return 0; + if (eve && BM_TestHFlag(eve, BM_SELECT)) return 0; return 1; } /** @@ -382,20 +383,21 @@ static unsigned int findnearestvert__backbufIndextest(void *handle, unsigned int */ BMVert *EDBM_findnearestvert(ViewContext *vc, int *dist, short sel, short strict) { - if(vc->v3d->drawtype>OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) { + if (vc->v3d->drawtype>OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) { int distance; unsigned int index; BMVert *eve; - if(strict) index = view3d_sample_backbuf_rect(vc, vc->mval, 50, bm_wireoffs, 0xFFFFFF, &distance, strict, vc->em, findnearestvert__backbufIndextest); + if (strict) index = view3d_sample_backbuf_rect(vc, vc->mval, 50, bm_wireoffs, 0xFFFFFF, &distance, strict, vc->em, findnearestvert__backbufIndextest); else index = view3d_sample_backbuf_rect(vc, vc->mval, 50, bm_wireoffs, 0xFFFFFF, &distance, 0, NULL, NULL); eve = BM_Vert_AtIndex(vc->em->bm, index-1); - if(eve && distance < *dist) { + if (eve && distance < *dist) { *dist = distance; return eve; - } else { + } + else { return NULL; } @@ -446,7 +448,7 @@ float labda_PdistVL2Dfl(const float v1[3], const float v2[3], const float v3[3]) rc[0]= v3[0]-v2[0]; rc[1]= v3[1]-v2[1]; len= rc[0]*rc[0]+ rc[1]*rc[1]; - if(len==0.0f) + if (len==0.0f) return 0.0f; return ( rc[0]*(v1[0]-v2[0]) + rc[1]*(v1[1]-v2[1]) )/len; @@ -466,9 +468,9 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, int x0, int distance= dist_to_line_segment_v2(data->mval, v1, v2); - if(BM_TestHFlag(eed, BM_SELECT)) distance+=5; - if(distance < data->dist) { - if(data->vc.rv3d->rflag & RV3D_CLIPPING) { + if (BM_TestHFlag(eed, BM_SELECT)) distance+=5; + if (distance < data->dist) { + if (data->vc.rv3d->rflag & RV3D_CLIPPING) { float labda= labda_PdistVL2Dfl(data->mval, v1, v2); float vec[3]; @@ -477,7 +479,7 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, int x0, int vec[2]= eed->v1->co[2] + labda*(eed->v2->co[2] - eed->v1->co[2]); mul_m4_v3(data->vc.obedit->obmat, vec); - if(ED_view3d_test_clipping(data->vc.rv3d, vec, 1)==0) { + if (ED_view3d_test_clipping(data->vc.rv3d, vec, 1)==0) { data->dist = distance; data->closest = eed; } @@ -491,7 +493,7 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, int x0, int BMEdge *EDBM_findnearestedge(ViewContext *vc, int *dist) { - if(vc->v3d->drawtype>OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) { + if (vc->v3d->drawtype>OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) { int distance; unsigned int index; BMEdge *eed; @@ -504,7 +506,8 @@ BMEdge *EDBM_findnearestedge(ViewContext *vc, int *dist) if (eed && distance<*dist) { *dist = distance; return eed; - } else { + } + else { return NULL; } } @@ -543,7 +546,8 @@ static void findnearestface__doClosest(void *userData, BMFace *efa, int x, int y if (data->pass==0) { if (index<=data->lastIndex) return; - } else { + } + else { if (index>data->lastIndex) return; } @@ -562,7 +566,7 @@ static void findnearestface__doClosest(void *userData, BMFace *efa, int x, int y BMFace *EDBM_findnearestface(ViewContext *vc, int *dist) { - if(vc->v3d->drawtype>OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) { + if (vc->v3d->drawtype>OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) { unsigned int index; BMFace *efa; @@ -581,7 +585,7 @@ BMFace *EDBM_findnearestface(ViewContext *vc, int *dist) mesh_foreachScreenFace(vc, findnearestface__getDistance, &data); - if(vc->em->selectmode == SCE_SELECT_FACE || data.dist<*dist) { /* only faces, no dist check */ + if (vc->em->selectmode == SCE_SELECT_FACE || data.dist<*dist) { /* only faces, no dist check */ *dist= data.dist; return efa; } @@ -641,20 +645,20 @@ static int unified_findnearest(ViewContext *vc, BMVert **eve, BMEdge **eed, BMFa /* no afterqueue (yet), so we check it now, otherwise the em_xxxofs indices are bad */ view3d_validate_backbuf(vc); - if(em->selectmode & SCE_SELECT_VERTEX) + if (em->selectmode & SCE_SELECT_VERTEX) *eve= EDBM_findnearestvert(vc, &dist, BM_SELECT, 0); - if(em->selectmode & SCE_SELECT_FACE) + if (em->selectmode & SCE_SELECT_FACE) *efa= EDBM_findnearestface(vc, &dist); dist-= 20; /* since edges select lines, we give dots advantage of 20 pix */ - if(em->selectmode & SCE_SELECT_EDGE) + if (em->selectmode & SCE_SELECT_EDGE) *eed= EDBM_findnearestedge(vc, &dist); /* return only one of 3 pointers, for frontbuffer redraws */ - if(*eed) { + if (*eed) { *efa= NULL; *eve= NULL; } - else if(*efa) { + else if (*efa) { *eve= NULL; } @@ -712,7 +716,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) BMO_HeaderFlag_Buffer(em->bm, &bmop, "faceout", BM_SELECT, BM_ALL); /* finish the operator */ - if( !EDBM_FinishOp(em, &bmop, op, 1) ) + if ( !EDBM_FinishOp(em, &bmop, op, 1) ) return OPERATOR_CANCELLED; /* dependencies graph and notification stuff */ @@ -753,7 +757,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) EDBM_selectmode_flush(em); /* finish the operator */ - if( !EDBM_FinishOp(em, &bmop, op, 1) ) + if ( !EDBM_FinishOp(em, &bmop, op, 1) ) return OPERATOR_CANCELLED; /* dependencies graph and notification stuff */ @@ -796,7 +800,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) BMO_HeaderFlag_Buffer(em->bm, &bmop, "vertout", BM_SELECT, BM_ALL); /* finish the operator */ - if( !EDBM_FinishOp(em, &bmop, op, 1) ) + if ( !EDBM_FinishOp(em, &bmop, op, 1) ) return OPERATOR_CANCELLED; EDBM_selectmode_flush(em); @@ -813,9 +817,9 @@ static int select_similar_exec(bContext *C, wmOperator *op) { int type= RNA_enum_get(op->ptr, "type"); - if(type < 100) + if (type < 100) return similar_vert_select_exec(C, op); - else if(type < 200) + else if (type < 200) return similar_edge_select_exec(C, op); else return similar_face_select_exec(C, op); @@ -825,20 +829,22 @@ static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUS { Object *obedit = CTX_data_edit_object(C); - if(obedit && obedit->type == OB_MESH) { + if (obedit && obedit->type == OB_MESH) { EnumPropertyItem *item= NULL; int a, totitem= 0; BMEditMesh *em= ((Mesh*)obedit->data)->edit_btmesh; - if(em->selectmode & SCE_SELECT_VERTEX) { + if (em->selectmode & SCE_SELECT_VERTEX) { for (a=SIMVERT_NORMAL; a<SIMEDGE_LENGTH; a++) { RNA_enum_items_add_value(&item, &totitem, prop_similar_types, a); } - } else if(em->selectmode & SCE_SELECT_EDGE) { + } + else if (em->selectmode & SCE_SELECT_EDGE) { for (a=SIMEDGE_LENGTH; a<SIMFACE_MATERIAL; a++) { RNA_enum_items_add_value(&item, &totitem, prop_similar_types, a); } - } else if(em->selectmode & SCE_SELECT_FACE) { + } + else if (em->selectmode & SCE_SELECT_FACE) { for (a=SIMFACE_MATERIAL; a<=SIMFACE_COPLANAR; a++) { RNA_enum_items_add_value(&item, &totitem, prop_similar_types, a); } @@ -910,7 +916,7 @@ static int loop_multiselect(bContext *C, wmOperator *op) for(eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); eed; eed = BMIter_Step(&iter)) { - if(BM_TestHFlag(eed, BM_SELECT)) { + if (BM_TestHFlag(eed, BM_SELECT)) { totedgesel++; } } @@ -922,13 +928,13 @@ static int loop_multiselect(bContext *C, wmOperator *op) for(eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); eed; eed = BMIter_Step(&iter)) { - if(BM_TestHFlag(eed, BM_SELECT)) { + if (BM_TestHFlag(eed, BM_SELECT)) { edarray[edindex] = eed; edindex++; } } - if(looptype) { + if (looptype) { for(edindex = 0; edindex < totedgesel; edindex +=1) { eed = edarray[edindex]; walker_select(em, BMW_EDGERING, eed, 1); @@ -992,7 +998,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) eed = EDBM_findnearestedge(&vc, &dist); if (eed) { - if(extend==0) EDBM_clear_flag_all(em, BM_SELECT); + if (extend==0) EDBM_clear_flag_all(em, BM_SELECT); if (BM_TestHFlag(eed, BM_SELECT)==0) { select=1; @@ -1001,17 +1007,17 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) select=0; } - if(em->selectmode & SCE_SELECT_FACE) { + if (em->selectmode & SCE_SELECT_FACE) { walker_select(em, BMW_FACELOOP, eed, select); } - else if(em->selectmode & SCE_SELECT_EDGE) { - if(ring) + else if (em->selectmode & SCE_SELECT_EDGE) { + if (ring) walker_select(em, BMW_EDGERING, eed, select); else walker_select(em, BMW_LOOP, eed, select); } - else if(em->selectmode & SCE_SELECT_VERTEX) { - if(ring) + else if (em->selectmode & SCE_SELECT_VERTEX) { + if (ring) walker_select(em, BMW_EDGERING, eed, select); else @@ -1029,7 +1035,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) of arbitrarily selecting the first one */ EDBM_store_selection(em, eed->v1); } - else if(em->selectmode & SCE_SELECT_EDGE) { + else if (em->selectmode & SCE_SELECT_EDGE) { EDBM_store_selection(em, eed); } /* TODO: would be nice if the nearest face that @@ -1348,14 +1354,14 @@ static void mouse_mesh_shortest_path(bContext *C, int mval[2]) em= vc.em; e= EDBM_findnearestedge(&vc, &dist); - if(e) { + if (e) { Mesh *me= vc.obedit->data; int path = 0; if (em->bm->selected.last) { BMEditSelection *ese= em->bm->selected.last; - if(ese && ese->htype == BM_EDGE) { + if (ese && ese->htype == BM_EDGE) { BMEdge *e_act; e_act = (BMEdge *)ese->data; if (e_act != e) { @@ -1374,7 +1380,7 @@ static void mouse_mesh_shortest_path(bContext *C, int mval[2]) EDBM_selectmode_flush(em); /* even if this is selected it may not be in the selection list */ - if(edgetag_context_check(vc.scene, em, e)==0) + if (edgetag_context_check(vc.scene, em, e)==0) EDBM_remove_selection(em, e); else EDBM_store_selection(em, e); @@ -1445,39 +1451,39 @@ int mouse_mesh(bContext *C, const int mval[2], short extend) vc.mval[0]= mval[0]; vc.mval[1]= mval[1]; - if(unified_findnearest(&vc, &eve, &eed, &efa)) { + if (unified_findnearest(&vc, &eve, &eed, &efa)) { - if(extend==0) EDBM_clear_flag_all(vc.em, BM_SELECT); + if (extend==0) EDBM_clear_flag_all(vc.em, BM_SELECT); - if(efa) { + if (efa) { /* set the last selected face */ BM_set_actFace(vc.em->bm, efa); - if(!BM_TestHFlag(efa, BM_SELECT)) { + if (!BM_TestHFlag(efa, BM_SELECT)) { EDBM_store_selection(vc.em, efa); BM_Select(vc.em->bm, efa, TRUE); } - else if(extend) { + else if (extend) { EDBM_remove_selection(vc.em, efa); BM_Select(vc.em->bm, efa, FALSE); } } - else if(eed) { - if(!BM_TestHFlag(eed, BM_SELECT)) { + else if (eed) { + if (!BM_TestHFlag(eed, BM_SELECT)) { EDBM_store_selection(vc.em, eed); BM_Select(vc.em->bm, eed, TRUE); } - else if(extend) { + else if (extend) { EDBM_remove_selection(vc.em, eed); BM_Select(vc.em->bm, eed, FALSE); } } - else if(eve) { - if(!BM_TestHFlag(eve, BM_SELECT)) { + else if (eve) { + if (!BM_TestHFlag(eve, BM_SELECT)) { EDBM_store_selection(vc.em, eve); BM_Select(vc.em->bm, eve, TRUE); } - else if(extend) { + else if (extend) { EDBM_remove_selection(vc.em, eve); BM_Select(vc.em->bm, eve, FALSE); } @@ -1504,27 +1510,27 @@ static void EDBM_strip_selections(BMEditMesh *em) { BMEditSelection *ese, *nextese; - if(!(em->selectmode & SCE_SELECT_VERTEX)) { + if (!(em->selectmode & SCE_SELECT_VERTEX)) { ese = em->bm->selected.first; while(ese) { nextese = ese->next; - if(ese->htype == BM_VERT) BLI_freelinkN(&(em->bm->selected),ese); + if (ese->htype == BM_VERT) BLI_freelinkN(&(em->bm->selected),ese); ese = nextese; } } - if(!(em->selectmode & SCE_SELECT_EDGE)) { + if (!(em->selectmode & SCE_SELECT_EDGE)) { ese=em->bm->selected.first; while(ese) { nextese = ese->next; - if(ese->htype == BM_EDGE) BLI_freelinkN(&(em->bm->selected), ese); + if (ese->htype == BM_EDGE) BLI_freelinkN(&(em->bm->selected), ese); ese = nextese; } } - if(!(em->selectmode & SCE_SELECT_FACE)) { + if (!(em->selectmode & SCE_SELECT_FACE)) { ese=em->bm->selected.first; while(ese) { nextese = ese->next; - if(ese->htype == BM_FACE) BLI_freelinkN(&(em->bm->selected), ese); + if (ese->htype == BM_FACE) BLI_freelinkN(&(em->bm->selected), ese); ese = nextese; } } @@ -1543,7 +1549,7 @@ void EDBM_selectmode_set(BMEditMesh *em) EDBM_strip_selections(em); /*strip BMEditSelections from em->selected that are not relevant to new mode*/ - if(em->selectmode & SCE_SELECT_VERTEX) { + if (em->selectmode & SCE_SELECT_VERTEX) { /*BMIter iter; eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); @@ -1554,7 +1560,7 @@ void EDBM_selectmode_set(BMEditMesh *em) EDBM_selectmode_flush(em); } - else if(em->selectmode & SCE_SELECT_EDGE) { + else if (em->selectmode & SCE_SELECT_EDGE) { /* deselect vertices, and select again based on edge select */ eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL); for ( ; eve; eve=BMIter_Step(&iter)) BM_Select(em->bm, eve, FALSE); @@ -1569,7 +1575,7 @@ void EDBM_selectmode_set(BMEditMesh *em) /* selects faces based on edge status */ EDBM_selectmode_flush(em); } - else if(em->selectmode & SCE_SELECT_FACE) { + else if (em->selectmode & SCE_SELECT_FACE) { /* deselect eges, and select again based on face select */ eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); for ( ; eed; eed=BMIter_Step(&iter)) BM_Select(em->bm, eed, FALSE); @@ -1590,8 +1596,8 @@ void EDBM_convertsel(BMEditMesh *em, short oldmode, short selectmode) BMIter iter; /*have to find out what the selectionmode was previously*/ - if(oldmode == SCE_SELECT_VERTEX) { - if(selectmode == SCE_SELECT_EDGE) { + if (oldmode == SCE_SELECT_VERTEX) { + if (selectmode == SCE_SELECT_EDGE) { /*select all edges associated with every selected vertex*/ eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); for ( ; eed; eed=BMIter_Step(&iter)) { @@ -1602,7 +1608,7 @@ void EDBM_convertsel(BMEditMesh *em, short oldmode, short selectmode) } } } - else if(selectmode == SCE_SELECT_FACE) { + else if (selectmode == SCE_SELECT_FACE) { BMIter liter; BMLoop *l; @@ -1620,8 +1626,8 @@ void EDBM_convertsel(BMEditMesh *em, short oldmode, short selectmode) } } - if(oldmode == SCE_SELECT_EDGE) { - if(selectmode == SCE_SELECT_FACE) { + if (oldmode == SCE_SELECT_EDGE) { + if (selectmode == SCE_SELECT_FACE) { BMIter liter; BMLoop *l; @@ -1649,7 +1655,7 @@ void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const s BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (BM_TestHFlag(efa, BM_HIDDEN)) continue; - if(efa->mat_nr == index) { + if (efa->mat_nr == index) { BM_Select(em->bm, efa, select); } } @@ -1663,14 +1669,14 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */ BMEdge *eed; BMFace *efa; - if(em->bm->selectmode & SCE_SELECT_VERTEX) { + if (em->bm->selectmode & SCE_SELECT_VERTEX) { BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if (BM_TestHFlag(eve, BM_HIDDEN)) continue; BM_Select(em->bm, eve, !BM_TestHFlag(eve, BM_SELECT)); } } - else if(em->selectmode & SCE_SELECT_EDGE) { + else if (em->selectmode & SCE_SELECT_EDGE) { BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { if (BM_TestHFlag(eed, BM_HIDDEN)) continue; @@ -1707,7 +1713,7 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event em_setup_viewcontext(C, &vc); em = vc.em; - if(em->bm->totedge==0) + if (em->bm->totedge==0) return OPERATOR_CANCELLED; bm= em->bm; @@ -1717,13 +1723,13 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event /* return warning! */ - /*if(limit) { + /*if (limit) { int retval= select_linked_limited_invoke(&vc, 0, sel); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit); return retval; }*/ - if( unified_findnearest(&vc, &eve, &eed, &efa)==0 ) { + if ( unified_findnearest(&vc, &eve, &eed, &efa)==0 ) { WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit); return OPERATOR_CANCELLED; @@ -1751,7 +1757,8 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event else { if (efa) { eed = bm_firstfaceloop(efa)->e; - } else if (!eed) { + } + else if (!eed) { if (!eve || !eve->e) return OPERATOR_CANCELLED; @@ -1964,7 +1971,7 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h short mask_vert=0, mask_edge=0, mask_loop=0, mask_face=0; /* No active element from which to start - nothing to do */ - if(h_act==NULL) { + if (h_act==NULL) { return; } @@ -2032,7 +2039,7 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **v_p, BMEdge **e_p, BMFa EDBM_selectmode_flush(em); ese= (BMEditSelection*)em->bm->selected.last; - if(ese) { + if (ese) { switch(ese->htype) { case BM_VERT: *v_p= (BMVert *)ese->data; @@ -2046,7 +2053,7 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **v_p, BMEdge **e_p, BMFa } } - if(em->selectmode & SCE_SELECT_VERTEX) { + if (em->selectmode & SCE_SELECT_VERTEX) { BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if (BM_TestHFlag(v, BM_SELECT)) { *v_p = v; @@ -2054,7 +2061,7 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **v_p, BMEdge **e_p, BMFa } } } - else if(em->selectmode & SCE_SELECT_EDGE) { + else if (em->selectmode & SCE_SELECT_EDGE) { BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { if (BM_TestHFlag(e, BM_SELECT)) { *e_p = e; @@ -2062,9 +2069,9 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **v_p, BMEdge **e_p, BMFa } } } - else if(em->selectmode & SCE_SELECT_FACE) { + else if (em->selectmode & SCE_SELECT_FACE) { f= BM_get_actFace(em->bm, 1); - if(f) { + if (f) { *f_p= f; return; } @@ -2083,11 +2090,11 @@ static int EM_deselect_nth(BMEditMesh *em, int nth, int offset) walker_deselect_nth(em, nth, offset, &v->head); return 1; } - else if(e) { + else if (e) { walker_deselect_nth(em, nth, offset, &e->head); return 1; } - else if(f) { + else if (f) { walker_deselect_nth(em, nth, offset, &f->head); return 1; } @@ -2104,7 +2111,7 @@ static int mesh_select_nth_exec(bContext *C, wmOperator *op) offset = MIN2(nth, offset); - if(EM_deselect_nth(em, nth, offset) == 0) { + if (EM_deselect_nth(em, nth, offset) == 0) { BKE_report(op->reports, RPT_ERROR, "Mesh has no active vert/edge/face"); return OPERATOR_CANCELLED; } @@ -2138,7 +2145,7 @@ void em_setup_viewcontext(bContext *C, ViewContext *vc) { view3d_set_viewcontext(C, vc); - if(vc->obedit) { + if (vc->obedit) { Mesh *me= vc->obedit->data; vc->em= me->edit_btmesh; } @@ -2147,7 +2154,7 @@ void em_setup_viewcontext(bContext *C, ViewContext *vc) /* poll call for mesh operators requiring a view3d context */ int EM_view3d_poll(bContext *C) { - if(ED_operator_editmesh(C) && ED_operator_view3d_active(C)) + if (ED_operator_editmesh(C) && ED_operator_view3d_active(C)) return 1; return 0; } @@ -2303,7 +2310,7 @@ static int select_non_manifold_exec(bContext *C, wmOperator *op) * faces */ - if(em->selectmode==SCE_SELECT_FACE) { + if (em->selectmode==SCE_SELECT_FACE) { BKE_report(op->reports, RPT_ERROR, "Doesn't work in face selection mode"); return OPERATOR_CANCELLED; } @@ -2352,10 +2359,10 @@ static int mesh_select_random_exec(bContext *C, wmOperator *op) BLI_srand( BLI_rand() ); /* random seed */ - if(!RNA_boolean_get(op->ptr, "extend")) + if (!RNA_boolean_get(op->ptr, "extend")) EDBM_clear_flag_all(em, BM_SELECT); - if(em->selectmode & SCE_SELECT_VERTEX) { + if (em->selectmode & SCE_SELECT_VERTEX) { BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if (!BM_TestHFlag(eve, BM_HIDDEN) && BLI_frand() < randfac) { BM_Select(em->bm, eve, TRUE); @@ -2363,7 +2370,7 @@ static int mesh_select_random_exec(bContext *C, wmOperator *op) } EDBM_selectmode_flush(em); } - else if(em->selectmode & SCE_SELECT_EDGE) { + else if (em->selectmode & SCE_SELECT_EDGE) { BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { if (!BM_TestHFlag(eed, BM_HIDDEN) && BLI_frand() < randfac) { BM_Select(em->bm, eed, TRUE); @@ -2593,7 +2600,8 @@ static int loop_find_regions(BMEditMesh *em, int selbigger) if (BM_TestHFlag(e, BM_SELECT)) { BLI_array_append(edges, e); BM_SetHFlag(e, BM_TMP_TAG); - } else { + } + else { BM_ClearHFlag(e, BM_TMP_TAG); } } diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 8861f94ca9b..a01b0593487 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -100,7 +100,7 @@ static void add_normal_aligned(float nor[3], const float add[3]) { - if(dot_v3v3(nor, add) < -0.9999f) + if (dot_v3v3(nor, add) < -0.9999f) sub_v3_v3(nor, add); else sub_v3_v3(nor, add); @@ -117,9 +117,9 @@ static int subdivide_exec(bContext *C, wmOperator *op) float fractal= RNA_float_get(op->ptr, "fractal")/2.5; int flag= 0; - if(smooth != 0.0f) + if (smooth != 0.0f) flag |= B_SMOOTH; - if(fractal != 0.0f) + if (fractal != 0.0f) flag |= B_FRACTAL; if (RNA_boolean_get(op->ptr, "quadtri") && @@ -188,7 +188,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, Object *obedit, BMEditMes int dist_dummy; mul_v3_m4v3(vec, obedit->obmat, eve->co); project_float_noclip(ar, vec, mval); - if(snapObjectsContext(C, mval, &dist_dummy, vec, no_dummy, SNAP_NOT_OBEDIT)) { + if (snapObjectsContext(C, mval, &dist_dummy, vec, no_dummy, SNAP_NOT_OBEDIT)) { mul_v3_m4v3(eve->co, obedit->imat, vec); } } @@ -286,7 +286,7 @@ static short EDBM_Extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, if ((md->type==eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) { MirrorModifierData *mmd = (MirrorModifierData*) md; - if(mmd->flag & MOD_MIR_CLIPPING) { + if (mmd->flag & MOD_MIR_CLIPPING) { float mtx[4][4]; if (mmd->mirror_ob) { float imtx[4][4]; @@ -347,7 +347,7 @@ static short EDBM_Extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, BMO_Finish_Op(bm, &extop); - if(nor[0]==0.0 && nor[1]==0.0 && nor[2]==0.0) return 'g'; // grab + if (nor[0]==0.0 && nor[1]==0.0 && nor[2]==0.0) return 'g'; // grab return 'n'; // normal constraint } @@ -367,7 +367,8 @@ static short EDBM_Extrude_vert(Object *obedit, BMEditMesh *em, const char hflag, BM_SetHFlag(eed->v1, hflag & ~BM_SELECT); BM_SetHFlag(eed->v2, hflag & ~BM_SELECT); - } else { + } + else { if (BM_TestHFlag(eed->v1, hflag) && BM_TestHFlag(eed->v2, hflag)) { if (hflag & BM_SELECT) { BM_Select(em->bm, eed, TRUE); @@ -451,24 +452,24 @@ static int EDBM_Extrude_Mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe nor[0] = nor[1] = nor[2] = 0.0f; - if(em->selectmode & SCE_SELECT_VERTEX) { - if(em->bm->totvertsel==0) nr= 0; - else if(em->bm->totvertsel==1) nr= 4; - else if(em->bm->totedgesel==0) nr= 4; - else if(em->bm->totfacesel==0) + if (em->selectmode & SCE_SELECT_VERTEX) { + if (em->bm->totvertsel==0) nr= 0; + else if (em->bm->totvertsel==1) nr= 4; + else if (em->bm->totedgesel==0) nr= 4; + else if (em->bm->totfacesel==0) nr= 3; // pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4"); - else if(em->bm->totfacesel==1) + else if (em->bm->totfacesel==1) nr= 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4"); else nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4"); } - else if(em->selectmode & SCE_SELECT_EDGE) { + else if (em->selectmode & SCE_SELECT_EDGE) { if (em->bm->totedgesel==0) nr = 0; nr = 1; /*else if (em->totedgesel==1) nr = 3; - else if(em->totfacesel==0) nr = 3; - else if(em->totfacesel==1) + else if (em->totfacesel==0) nr = 3; + else if (em->totfacesel==1) nr= 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3"); else nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3"); @@ -481,16 +482,16 @@ static int EDBM_Extrude_Mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2"); } - if(nr<1) return 'g'; + if (nr<1) return 'g'; - if(nr==1 && em->selectmode & SCE_SELECT_VERTEX) + if (nr==1 && em->selectmode & SCE_SELECT_VERTEX) transmode= EDBM_Extrude_vert(obedit, em, BM_SELECT, nor); else if (nr == 1) transmode= EDBM_Extrude_edge(obedit, em, BM_SELECT, nor); - else if(nr==4) transmode= EDBM_Extrude_verts_indiv(em, op, BM_SELECT, nor); - else if(nr==3) transmode= EDBM_Extrude_edges_indiv(em, op, BM_SELECT, nor); + else if (nr==4) transmode= EDBM_Extrude_verts_indiv(em, op, BM_SELECT, nor); + else if (nr==3) transmode= EDBM_Extrude_edges_indiv(em, op, BM_SELECT, nor); else transmode= EDBM_Extrude_face_indiv(em, op, BM_SELECT, nor); - if(transmode==0) { + if (transmode==0) { BKE_report(op->reports, RPT_ERROR, "Not a valid selection for extrude"); } else { @@ -506,13 +507,13 @@ static int EDBM_Extrude_Mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe /* individual faces? */ // BIF_TransformSetUndo("Extrude"); - if(nr==2) { + if (nr==2) { // initTransform(TFM_SHRINKFATTEN, CTX_NO_PET|CTX_NO_MIRROR); // Transform(); } else { // initTransform(TFM_TRANSLATION, CTX_NO_PET|CTX_NO_MIRROR); - if(transmode=='n') { + if (transmode=='n') { mul_m4_v3(obedit->obmat, nor); sub_v3_v3v3(nor, nor, obedit->obmat[3]); // BIF_setSingleAxisConstraint(nor, "along normal"); @@ -654,7 +655,7 @@ void MESH_OT_extrude_faces_indiv(wmOperatorType *ot) void EDBM_toggle_select_all(BMEditMesh *em) /* exported for UV */ { - if(em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel) + if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel) EDBM_clear_flag_all(em, BM_SELECT); else EDBM_set_flag_all(em, BM_SELECT); @@ -728,7 +729,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) } /* call extrude? */ - if(done) { + if (done) { const short rot_src= RNA_boolean_get(op->ptr, "rotate_source"); BMEdge *eed; float vec[3], cent[3], mat[3][3]; @@ -755,7 +756,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) * * accumulate the screenspace normal in 2D, * with screenspace edge length weighting the result. */ - if(line_point_side_v2(co1, co2, mval_f) >= 0.0f) { + if (line_point_side_v2(co1, co2, mval_f) >= 0.0f) { nor[0] += (co1[1] - co2[1]); nor[1] += -(co1[0] - co2[0]); } @@ -767,7 +768,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) done= 1; } - if(done) { + if (done) { float view_vec[3], cross[3]; /* convert the 2D nomal into 3D */ @@ -794,14 +795,14 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) /* calculate rotation */ unit_m3(mat); - if(done) { + if (done) { float dot; copy_v3_v3(vec, min); normalize_v3(vec); dot= dot_v3v3(vec, nor); - if( fabs(dot)<0.999) { + if ( fabs(dot)<0.999) { float cross[3], si, q1[4]; cross_v3_v3v3(cross, nor, vec); @@ -809,7 +810,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) dot= 0.5f*saacos(dot); /* halve the rotation if its applied twice */ - if(rot_src) dot *= 0.5f; + if (rot_src) dot *= 0.5f; si= (float)sin(dot); q1[0]= (float)cos(dot); @@ -820,12 +821,12 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) } } - if(rot_src) { + if (rot_src) { EDBM_CallOpf(vc.em, op, "rotate verts=%hv cent=%v mat=%m3", BM_SELECT, cent, mat); /* also project the source, for retopo workflow */ - if(use_proj) + if (use_proj) EMBM_project_snap_verts(C, vc.ar, vc.obedit, vc.em); } @@ -857,7 +858,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } - if(use_proj) + if (use_proj) EMBM_project_snap_verts(C, vc.ar, vc.obedit, vc.em); /*This normally happens when pushing undo but modal operators @@ -893,48 +894,50 @@ static int delete_mesh(bContext *C, Object *obedit, wmOperator *op, int event, S { BMEditMesh *bem = ((Mesh*)obedit->data)->edit_btmesh; - if(event<1) return OPERATOR_CANCELLED; + if (event<1) return OPERATOR_CANCELLED; - if(event==10 ) { + if (event==10 ) { //"Erase Vertices"; if (!EDBM_CallOpf(bem, op, "del geom=%hv context=%i", BM_SELECT, DEL_VERTS)) return OPERATOR_CANCELLED; } - else if(event==11) { + else if (event==11) { //"Edge Loop" if (!EDBM_CallOpf(bem, op, "dissolveedgeloop edges=%he", BM_SELECT)) return OPERATOR_CANCELLED; } - else if(event==7) { + else if (event==7) { //"Dissolve" if (bem->selectmode & SCE_SELECT_FACE) { if (!EDBM_CallOpf(bem, op, "dissolvefaces faces=%hf",BM_SELECT)) return OPERATOR_CANCELLED; - } else if (bem->selectmode & SCE_SELECT_EDGE) { + } + else if (bem->selectmode & SCE_SELECT_EDGE) { if (!EDBM_CallOpf(bem, op, "dissolveedges edges=%he",BM_SELECT)) return OPERATOR_CANCELLED; - } else if (bem->selectmode & SCE_SELECT_VERTEX) { + } + else if (bem->selectmode & SCE_SELECT_VERTEX) { if (!EDBM_CallOpf(bem, op, "dissolveverts verts=%hv",BM_SELECT)) return OPERATOR_CANCELLED; } } - else if(event==4) { + else if (event==4) { //Edges and Faces if (!EDBM_CallOpf(bem, op, "del geom=%hef context=%i", BM_SELECT, DEL_EDGESFACES)) return OPERATOR_CANCELLED; } - else if(event==1) { + else if (event==1) { //"Erase Edges" if (!EDBM_CallOpf(bem, op, "del geom=%he context=%i", BM_SELECT, DEL_EDGES)) return OPERATOR_CANCELLED; } - else if(event==2) { + else if (event==2) { //"Erase Faces"; if (!EDBM_CallOpf(bem, op, "del geom=%hf context=%i", BM_SELECT, DEL_FACES)) return OPERATOR_CANCELLED; } - else if(event==5) { + else if (event==5) { //"Erase Only Faces"; if (!EDBM_CallOpf(bem, op, "del geom=%hf context=%d", BM_SELECT, DEL_ONLYFACES)) @@ -971,7 +974,8 @@ static int delete_mesh_exec(bContext *C, wmOperator *op) if (delete_mesh(C, obedit, op, type, scene) == OPERATOR_CANCELLED) return OPERATOR_CANCELLED; EDBM_clear_flag_all(em, BM_SELECT); - } else { + } + else { if (!EDBM_CallOpf(em, op, "collapse edges=%he", BM_SELECT)) return OPERATOR_CANCELLED; DAG_id_tag_update(obedit->data, OB_RECALC_DATA); @@ -1108,11 +1112,11 @@ static int editbmesh_mark_seam(bContext *C, wmOperator *op) int clear = RNA_boolean_get(op->ptr, "clear"); /* auto-enable seams drawing */ - if(clear==0) { + if (clear==0) { me->drawflag |= ME_DRAWSEAMS; } - if(clear) { + if (clear) { BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (!BM_TestHFlag(eed, BM_SELECT) || BM_TestHFlag(eed, BM_HIDDEN)) continue; @@ -1162,18 +1166,19 @@ static int editbmesh_mark_sharp(bContext *C, wmOperator *op) int clear = RNA_boolean_get(op->ptr, "clear"); /* auto-enable sharp edge drawing */ - if(clear == 0) { + if (clear == 0) { me->drawflag |= ME_DRAWSHARP; } - if(!clear) { + if (!clear) { BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (!BM_TestHFlag(eed, BM_SELECT) || BM_TestHFlag(eed, BM_HIDDEN)) continue; BM_SetHFlag(eed, BM_SHARP); } - } else { + } + else { BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (!BM_TestHFlag(eed, BM_SELECT) || BM_TestHFlag(eed, BM_HIDDEN)) continue; @@ -1428,7 +1433,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op) /* avoid adding to the selection if we start off with only a selected edge, * we could also just deselect the single edge easily but use the BMO api * since it seems this is more 'correct' */ - if(do_deselect) BMO_UnHeaderFlag_Buffer(em->bm, &bmop, "edges", BM_SELECT, BM_EDGE); + if (do_deselect) BMO_UnHeaderFlag_Buffer(em->bm, &bmop, "edges", BM_SELECT, BM_EDGE); BMO_Exec_Op(em->bm, &bmop); BMO_HeaderFlag_Buffer(em->bm, &bmop, "edgeout", BM_SELECT, BM_EDGE); @@ -1467,7 +1472,7 @@ void EDBM_hide_mesh(BMEditMesh *em, int swap) BMHeader *h; int itermode; - if(em==NULL) return; + if (em==NULL) return; if (em->selectmode & SCE_SELECT_VERTEX) itermode = BM_VERTS_OF_MESH; @@ -1650,10 +1655,10 @@ static int do_smooth_vertex(bContext *C, wmOperator *op) * are within tolerance of the plane(s) of reflection */ for(md=obedit->modifiers.first; md; md=md->next) { - if(md->type==eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) { + if (md->type==eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) { MirrorModifierData *mmd = (MirrorModifierData*) md; - if(mmd->flag & MOD_MIR_CLIPPING) { + if (mmd->flag & MOD_MIR_CLIPPING) { if (mmd->flag & MOD_MIR_AXIS_X) mirrx = 1; if (mmd->flag & MOD_MIR_AXIS_Y) @@ -1787,7 +1792,7 @@ static void mesh_set_smooth_faces(BMEditMesh *em, short smooth) BMIter iter; BMFace *efa; - if(em==NULL) return; + if (em==NULL) return; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (BM_TestHFlag(efa, BM_SELECT)) { @@ -1880,7 +1885,7 @@ static int mesh_rotate_uvs(bContext *C, wmOperator *op) BMO_Exec_Op(em->bm, &bmop); /* finish the operator */ - if( !EDBM_FinishOp(em, &bmop, op, 1) ) + if ( !EDBM_FinishOp(em, &bmop, op, 1) ) return OPERATOR_CANCELLED; @@ -1905,7 +1910,7 @@ static int mesh_reverse_uvs(bContext *C, wmOperator *op) BMO_Exec_Op(em->bm, &bmop); /* finish the operator */ - if( !EDBM_FinishOp(em, &bmop, op, 1) ) + if ( !EDBM_FinishOp(em, &bmop, op, 1) ) return OPERATOR_CANCELLED; /* dependencies graph and notification stuff */ @@ -1932,7 +1937,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op) BMO_Exec_Op(em->bm, &bmop); /* finish the operator */ - if( !EDBM_FinishOp(em, &bmop, op, 1) ) + if ( !EDBM_FinishOp(em, &bmop, op, 1) ) return OPERATOR_CANCELLED; @@ -1960,7 +1965,7 @@ static int mesh_reverse_colors(bContext *C, wmOperator *op) BMO_Exec_Op(em->bm, &bmop); /* finish the operator */ - if( !EDBM_FinishOp(em, &bmop, op, 1) ) + if ( !EDBM_FinishOp(em, &bmop, op, 1) ) return OPERATOR_CANCELLED; DAG_id_tag_update(ob->data, OB_RECALC_DATA); @@ -2046,7 +2051,7 @@ static int merge_firstlast(BMEditMesh *em, int first, int uvmerge, wmOperator *w BMEditSelection *ese; /* do sanity check in mergemenu in edit.c ?*/ - if(first == 0) { + if (first == 0) { ese = em->bm->selected.last; mergevert= (BMVert*)ese->data; } @@ -2142,7 +2147,7 @@ static int merge_exec(bContext *C, wmOperator *op) break; } - if(!status) + if (!status) return OPERATOR_CANCELLED; DAG_id_tag_update(obedit->data, OB_RECALC_DATA); @@ -2165,22 +2170,22 @@ static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), EnumPropertyItem *item= NULL; int totitem= 0; - if(!C) /* needed for docs */ + if (!C) /* needed for docs */ return merge_type_items; obedit= CTX_data_edit_object(C); - if(obedit && obedit->type == OB_MESH) { + if (obedit && obedit->type == OB_MESH) { BMEditMesh *em= ((Mesh*)obedit->data)->edit_btmesh; - if(em->selectmode & SCE_SELECT_VERTEX) { - if(em->bm->selected.first && em->bm->selected.last && + if (em->selectmode & SCE_SELECT_VERTEX) { + if (em->bm->selected.first && em->bm->selected.last && ((BMEditSelection*)em->bm->selected.first)->htype == BM_VERT && ((BMEditSelection*)em->bm->selected.last)->htype == BM_VERT) { RNA_enum_items_add_value(&item, &totitem, merge_type_items, 6); RNA_enum_items_add_value(&item, &totitem, merge_type_items, 1); } - else if(em->bm->selected.first && ((BMEditSelection*)em->bm->selected.first)->htype == BM_VERT) + else if (em->bm->selected.first && ((BMEditSelection*)em->bm->selected.first)->htype == BM_VERT) RNA_enum_items_add_value(&item, &totitem, merge_type_items, 1); - else if(em->bm->selected.last && ((BMEditSelection*)em->bm->selected.last)->htype == BM_VERT) + else if (em->bm->selected.last && ((BMEditSelection*)em->bm->selected.last)->htype == BM_VERT) RNA_enum_items_add_value(&item, &totitem, merge_type_items, 6); } @@ -2241,7 +2246,7 @@ static int removedoublesflag_exec(bContext *C, wmOperator *op) /*we need a better way of reporting this, since this doesn't work with the last operator panel correctly. - if(count) + if (count) { sprintf(msg, "Removed %d vertices", count); BKE_report(op->reports, RPT_INFO, msg); @@ -2299,13 +2304,13 @@ static int select_vertex_path_exec(bContext *C, wmOperator *op) int type = RNA_enum_get(op->ptr, "type"); sv = em->bm->selected.last; - if( sv != NULL ) + if ( sv != NULL ) ev = sv->prev; else return OPERATOR_CANCELLED; - if( ev == NULL ) + if ( ev == NULL ) return OPERATOR_CANCELLED; - if((sv->htype != BM_VERT) || (ev->htype != BM_VERT)) + if ((sv->htype != BM_VERT) || (ev->htype != BM_VERT)) return OPERATOR_CANCELLED; /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ @@ -2321,7 +2326,7 @@ static int select_vertex_path_exec(bContext *C, wmOperator *op) BMO_HeaderFlag_Buffer(em->bm, &bmop, "vertout", BM_SELECT, BM_ALL); /* finish the operator */ - if( !EDBM_FinishOp(em, &bmop, op, 1) ) + if ( !EDBM_FinishOp(em, &bmop, op, 1) ) return OPERATOR_CANCELLED; EDBM_selectmode_flush(em); @@ -2448,7 +2453,8 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) if (!ripvert) { return OPERATOR_CANCELLED; } - } else if (BM_Edge_FaceCount(e2) == 2) { + } + else if (BM_Edge_FaceCount(e2) == 2) { l = e2->l; e = BM_OtherFaceLoop(e2, l->f, v)->e; BM_SetHFlag(e, BM_TMP_TAG); @@ -2461,7 +2467,8 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) } dist = FLT_MAX; - } else { + } + else { /*expand edge selection*/ BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { e2 = NULL; @@ -2631,7 +2638,7 @@ static void shape_propagate(Object *obedit, BMEditMesh *em, wmOperator *op) #if 0 //TAG Mesh Objects that share this data for(base = scene->base.first; base; base = base->next) { - if(base->object && base->object->data == me) { + if (base->object && base->object->data == me) { base->object->recalc = OB_RECALC_DATA; } } @@ -2698,7 +2705,7 @@ static int blend_from_shape_exec(bContext *C, wmOperator *op) copy_v3_v3(co, sco); - if(add) { + if (add) { mul_v3_fl(co, blend); add_v3_v3v3(eve->co, eve->co, co); } @@ -2722,7 +2729,7 @@ static EnumPropertyItem *shape_itemf(bContext *C, PointerRNA *UNUSED(ptr), Prop EnumPropertyItem *item= NULL; int totitem= 0; - if(obedit && obedit->type == OB_MESH && CustomData_has_layer(&em->bm->vdata, CD_SHAPEKEY)) { + if (obedit && obedit->type == OB_MESH && CustomData_has_layer(&em->bm->vdata, CD_SHAPEKEY)) { EnumPropertyItem tmp= {0, "", 0, "", ""}; int a; @@ -2789,24 +2796,24 @@ static int select_axis_exec(bContext *C, wmOperator *op) float value= act_vert->co[axis]; float limit= CTX_data_tool_settings(C)->doublimit; // XXX - if(mode==0) + if (mode==0) value -= limit; else if (mode==1) value += limit; BM_ITER(ev, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - if(!BM_TestHFlag(ev, BM_HIDDEN)) { + if (!BM_TestHFlag(ev, BM_HIDDEN)) { switch(mode) { case -1: /* aligned */ - if(fabs(ev->co[axis] - value) < limit) + if (fabs(ev->co[axis] - value) < limit) BM_Select(em->bm, ev, TRUE); break; case 0: /* neg */ - if(ev->co[axis] > value) + if (ev->co[axis] > value) BM_Select(em->bm, ev, TRUE); break; case 1: /* pos */ - if(ev->co[axis] < value) + if (ev->co[axis] < value) BM_Select(em->bm, ev, TRUE); break; } @@ -2987,7 +2994,7 @@ static float bm_seg_intersect(BMEdge *e, CutCurve *c, int len, char mode, *isected = 0; /*check for *exact* vertex intersection first*/ - if(mode!=KNIFE_MULTICUT) { + if (mode!=KNIFE_MULTICUT) { for (i=0; i<len; i++) { if (i>0) { x11=x12; @@ -3001,13 +3008,13 @@ static float bm_seg_intersect(BMEdge *e, CutCurve *c, int len, char mode, y12=c[i].y; /*test e->v1*/ - if((x11 == x21 && y11 == y21) || (x12 == x21 && y12 == y21)) { + if ((x11 == x21 && y11 == y21) || (x12 == x21 && y12 == y21)) { perc = 0; *isected = 1; return(perc); } /*test e->v2*/ - else if((x11 == x22 && y11 == y22) || (x12 == x22 && y12 == y22)) { + else if ((x11 == x22 && y11 == y22) || (x12 == x22 && y12 == y22)) { perc = 0; *isected = 2; return(perc); @@ -3078,16 +3085,16 @@ static float bm_seg_intersect(BMEdge *e, CutCurve *c, int len, char mode, /* Intersect inside bounding box of edge?*/ if ((xi>=x2min)&&(xi<=x2max)&&(yi<=y2max)&&(yi>=y2min)) { /*test for vertex intersect that may be 'close enough'*/ - if(mode!=KNIFE_MULTICUT) { - if(xi <= (x21 + threshold) && xi >= (x21 - threshold)) { - if(yi <= (y21 + threshold) && yi >= (y21 - threshold)) { + if (mode!=KNIFE_MULTICUT) { + if (xi <= (x21 + threshold) && xi >= (x21 - threshold)) { + if (yi <= (y21 + threshold) && yi >= (y21 - threshold)) { *isected = 1; perc = 0; break; } } - if(xi <= (x22 + threshold) && xi >= (x22 - threshold)) { - if(yi <= (y22 + threshold) && yi >= (y22 - threshold)) { + if (xi <= (x22 + threshold) && xi >= (x22 - threshold)) { + if (yi <= (y22 + threshold) && yi >= (y22 - threshold)) { *isected = 2; perc = 0; break; @@ -3139,11 +3146,11 @@ static int knife_cut_exec(bContext *C, wmOperator *op) RNA_float_get_array(&itemptr, "loc", (float *)&curve[len]); len++; - if(len>= MAX_CUTS) break; + if (len>= MAX_CUTS) break; } RNA_END; - if(len<2) { + if (len<2) { return OPERATOR_CANCELLED; } @@ -3164,7 +3171,7 @@ static int knife_cut_exec(bContext *C, wmOperator *op) /*store percentage of edge cut for KNIFE_EXACT here.*/ for (be=BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL); be; be=BMIter_Step(&iter)) { - if( BM_Selected(bm, be) ) { + if ( BM_Selected(bm, be) ) { isect= bm_seg_intersect(be, curve, len, mode, gh, &isected); if (isect != 0.0f) { @@ -3175,8 +3182,14 @@ static int knife_cut_exec(bContext *C, wmOperator *op) } BMO_SetFlag(bm, be, 1); - } else BMO_ClearFlag(bm, be, 1); - } else BMO_ClearFlag(bm, be, 1); + } + else { + BMO_ClearFlag(bm, be, 1); + } + } + else { + BMO_ClearFlag(bm, be, 1); + } } BMO_Flag_To_Slot(bm, &bmop, "edges", 1, BM_EDGE); @@ -3382,14 +3395,14 @@ static int mesh_separate_exec(bContext *C, wmOperator *op) Base *base= CTX_data_active_base(C); int retval= 0, type= RNA_enum_get(op->ptr, "type"); - if(type == 0) + if (type == 0) retval= mesh_separate_selected(bmain, scene, base, op); - else if(type == 1) + else if (type == 1) retval= mesh_separate_material (bmain, scene, base, op); - else if(type == 2) + else if (type == 2) retval= mesh_separate_loose(bmain, scene, base, op); - if(retval) { + if (retval) { DAG_id_tag_update(base->object->data, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, base->object->data); return OPERATOR_FINISHED; @@ -3657,7 +3670,7 @@ static int spin_mesh_exec(bContext *C, wmOperator *op) RNA_float_get_array(op->ptr, "axis", axis); steps = RNA_int_get(op->ptr, "steps"); degr = RNA_float_get(op->ptr, "degrees"); - if(ts->editbutflag & B_CLOCKWISE) degr= -degr; + if (ts->editbutflag & B_CLOCKWISE) degr= -degr; dupli = RNA_boolean_get(op->ptr, "dupli"); /* undo object transformation */ @@ -3759,15 +3772,15 @@ static int screw_mesh_exec(bContext *C, wmOperator *op) for(eed = BMIter_New(&eiter, em->bm, BM_EDGES_OF_VERT, eve); eed; eed = BMIter_Step(&eiter)) { - if(BM_TestHFlag(eed, BM_SELECT)) { + if (BM_TestHFlag(eed, BM_SELECT)) { valence++; } } - if(valence == 1) { - if(v1==NULL) v1 = eve; - else if(v2==NULL) v2= eve; + if (valence == 1) { + if (v1==NULL) v1 = eve; + else if (v2==NULL) v2= eve; else { v1= NULL; break; @@ -3775,7 +3788,7 @@ static int screw_mesh_exec(bContext *C, wmOperator *op) } } - if(v1==NULL || v2==NULL) { + if (v1==NULL || v2==NULL) { BKE_report(op->reports, RPT_ERROR, "You have to select a string of connected vertices too"); return OPERATOR_CANCELLED; } @@ -3784,7 +3797,7 @@ static int screw_mesh_exec(bContext *C, wmOperator *op) sub_v3_v3v3(dvec, v1->co, v2->co); mul_v3_fl(dvec, 1.0f/steps); - if(dot_v3v3(nor, dvec)>0.000) + if (dot_v3v3(nor, dvec)>0.000) negate_v3(dvec); if (!EDBM_InitOpf(em, &spinop, op, @@ -3854,15 +3867,15 @@ static int select_by_number_vertices_exec(bContext *C, wmOperator *op) int select = 0; - if(type == 0 && efa->len < numverts) { + if (type == 0 && efa->len < numverts) { select = 1; - }else if(type == 1 && efa->len == numverts) { + }else if (type == 1 && efa->len == numverts) { select = 1; - }else if(type == 2 && efa->len > numverts) { + }else if (type == 2 && efa->len > numverts) { select = 1; } - if(select) { + if (select) { BM_Select(em->bm, efa, TRUE); } } @@ -3910,7 +3923,7 @@ static int select_loose_verts_exec(bContext *C, wmOperator *UNUSED(op)) for(eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL); eve; eve = BMIter_Step(&iter)) { - if(!eve->e) { + if (!eve->e) { BM_Select(em->bm, eve, TRUE); } } @@ -3918,7 +3931,7 @@ static int select_loose_verts_exec(bContext *C, wmOperator *UNUSED(op)) for(eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL); eed; eed = BMIter_Step(&iter)) { - if(!eed->l) { + if (!eed->l) { BM_Select(em->bm, eed, TRUE); } } @@ -4018,8 +4031,8 @@ static int vergxco(const void *v1, const void *v2) { const xvertsort *x1=v1, *x2=v2; - if( x1->x > x2->x ) return 1; - else if( x1->x < x2->x) return -1; + if ( x1->x > x2->x ) return 1; + else if ( x1->x < x2->x) return -1; return 0; } @@ -4032,8 +4045,8 @@ static int vergface(const void *v1, const void *v2) { const struct facesort *x1=v1, *x2=v2; - if( x1->x > x2->x ) return 1; - else if( x1->x < x2->x) return -1; + if ( x1->x > x2->x ) return 1; + else if ( x1->x < x2->x) return -1; return 0; } #endif @@ -4068,7 +4081,7 @@ static void xsortvert_flag(bContext *UNUSED(C), int UNUSED(flag)) amount = em->bm->totvert; sortblock = MEM_callocN(sizeof(xvertsort)*amount,"xsort"); BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - if(BM_TestHFlag(eve, BM_SELECT)) + if (BM_TestHFlag(eve, BM_SELECT)) sortblock[i].v1 = eve; } @@ -4145,8 +4158,8 @@ static int float_sort(const void *v1, const void *v2) x1 = face_sort_floats[((int *) v1)[0]]; x2 = face_sort_floats[((int *) v2)[0]]; - if( x1 > x2 ) return 1; - else if( x1 < x2 ) return -1; + if ( x1 > x2 ) return 1; + else if ( x1 < x2 ) return -1; return 0; } @@ -4172,7 +4185,7 @@ static int sort_faces_exec(bContext *C, wmOperator *op) ED_object_exit_editmode(C, EM_FREEDATA); me= ob->data; - if(me->totpoly==0) { + if (me->totpoly==0) { ED_object_enter_editmode(C, 0); return OPERATOR_FINISHED; } @@ -4180,7 +4193,7 @@ static int sort_faces_exec(bContext *C, wmOperator *op) event= RNA_enum_get(op->ptr, "type"); // XXX - //if(ctrl) + //if (ctrl) // reverse = -1; /* create index list */ @@ -4200,7 +4213,8 @@ static int sort_faces_exec(bContext *C, wmOperator *op) face_sort_floats[i] = BLI_frand(); } qsort(index, me->totpoly, sizeof(int), float_sort); - } else { + } + else { MPoly *mp; MLoop *ml; MVert *mv; @@ -4211,9 +4225,10 @@ static int sort_faces_exec(bContext *C, wmOperator *op) if (event == 1) mult_m4_m4m4(mat, rv3d->viewmat, OBACT->obmat); /* apply the view matrix to the object matrix */ else if (event == 2) { /* sort from cursor */ - if( v3d && v3d->localvd ) { + if ( v3d && v3d->localvd ) { copy_v3_v3(cur, v3d->cursor); - } else { + } + else { copy_v3_v3(cur, scene->cursor); } invert_m4_m4(mat, OBACT->obmat); @@ -4225,13 +4240,15 @@ static int sort_faces_exec(bContext *C, wmOperator *op) for(i=0; i<me->totpoly; i++, mp++) { if (event==3) { face_sort_floats[i] = ((float)mp->mat_nr)*reverse; - } else if (event==4) { + } + else if (event==4) { /*selected first*/ if (mp->flag & ME_FACE_SEL) face_sort_floats[i] = 0.0; else face_sort_floats[i] = reverse; - } else { + } + else { /* find the face's center */ ml = me->mloop+mp->loopstart; zero_v3(vec); @@ -4244,7 +4261,8 @@ static int sort_faces_exec(bContext *C, wmOperator *op) if (event == 1) { /* sort on view axis */ mul_m4_v3(mat, vec); face_sort_floats[i] = vec[2] * reverse; - } else if(event == 2) { /* distance from cursor*/ + } + else if (event == 2) { /* distance from cursor*/ face_sort_floats[i] = len_v3v3(cur, vec) * reverse; /* back to front */ } } @@ -4308,16 +4326,16 @@ static void hashvert_flag(EditMesh *em, int flag) eve= em->verts.first; amount= 0; while(eve) { - if(eve->f & flag) amount++; + if (eve->f & flag) amount++; eve= eve->next; } - if(amount==0) return; + if (amount==0) return; /* allocate memory */ sb= sortblock= (struct xvertsort *)MEM_mallocN(sizeof(struct xvertsort)*amount,"sortremovedoub"); eve= em->verts.first; while(eve) { - if(eve->f & flag) { + if (eve->f & flag) { sb->v1= eve; sb++; } @@ -4329,7 +4347,7 @@ static void hashvert_flag(EditMesh *em, int flag) sb= sortblock; for(a=0; a<amount; a++, sb++) { b= (int)(amount*BLI_drand()); - if(b>=0 && b<amount) { + if (b>=0 && b<amount) { newsort= sortblock+b; onth= *sb; *sb= *newsort; @@ -4395,22 +4413,22 @@ static int mesh_noise_exec(bContext *C, wmOperator *op) BMIter iter; float fac= RNA_float_get(op->ptr, "factor"); - if(em==NULL) return OPERATOR_FINISHED; + if (em==NULL) return OPERATOR_FINISHED; ma= give_current_material(obedit, obedit->actcol); - if(ma==0 || ma->mtex[0]==0 || ma->mtex[0]->tex==0) { + if (ma==0 || ma->mtex[0]==0 || ma->mtex[0]->tex==0) { BKE_report(op->reports, RPT_WARNING, "Mesh has no material or texture assigned"); return OPERATOR_FINISHED; } tex= give_current_material_texture(ma); - if(tex->type==TEX_STUCCI) { + if (tex->type==TEX_STUCCI) { float b2, vec[3]; float ofs= tex->turbul/200.0; BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if (BM_TestHFlag(eve, BM_SELECT) && !BM_TestHFlag(eve, BM_HIDDEN)) { b2= BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2]); - if(tex->stype) ofs*=(b2*b2); + if (tex->stype) ofs*=(b2*b2); vec[0]= fac*(b2-BLI_hnoise(tex->noisesize, eve->co[0]+ofs, eve->co[1], eve->co[2])); vec[1]= fac*(b2-BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1]+ofs, eve->co[2])); vec[2]= fac*(b2-BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2]+ofs)); @@ -4480,7 +4498,7 @@ static int mesh_bevel_exec(bContext *C, wmOperator *op) *dv = d; } - if(em==NULL) return OPERATOR_CANCELLED; + if (em==NULL) return OPERATOR_CANCELLED; /*ugh, stupid math depends somewhat on angles!*/ /* dfac = 1.0/(float)(recursion+1); */ /* UNUSED */ @@ -4595,12 +4613,14 @@ static int mesh_export_obj_exec(bContext *C, wmOperator *op) if (!RNA_boolean_get(op->ptr, "apply_modifiers")) { dm = CDDM_from_mesh(me, ob); free = 1; - } else { + } + else { dm = mesh_get_derived_final(scene, ob, CD_MASK_DERIVEDMESH); if (!CDDM_Check(dm)) { dm = CDDM_copy(dm); free = 1; - } else { + } + else { free = 0; } } @@ -4640,7 +4660,8 @@ static int mesh_export_obj_exec(bContext *C, wmOperator *op) found = 1; break; } - } else { + } + else { found = 1; break; } @@ -4657,7 +4678,8 @@ static int mesh_export_obj_exec(bContext *C, wmOperator *op) if (ob->matbits && ob->matbits[mp->mat_nr]) { matlists[mp->mat_nr][j].mat = ob->mat[mp->mat_nr]; - } else { + } + else { matlists[mp->mat_nr][j].mat = me->mat[mp->mat_nr]; } @@ -4696,7 +4718,8 @@ static int mesh_export_obj_exec(bContext *C, wmOperator *op) if (mp->flag & ME_SMOOTH) { fprintf(file, "s 1\n"); - } else { + } + else { fprintf(file, "s off\n"); } @@ -4704,11 +4727,14 @@ static int mesh_export_obj_exec(bContext *C, wmOperator *op) if (matlists[mp->mat_nr][face_mat_group[i]].mat && matlists[mp->mat_nr][face_mat_group[i]].poly.tpage) { sprintf(matname, "%s__%s", matlists[mp->mat_nr][face_mat_group[i]].mat->id.name+2, matlists[mp->mat_nr][face_mat_group[i]].poly.tpage->id.name+2); - } else if (matlists[mp->mat_nr][face_mat_group[i]].mat) { + } + else if (matlists[mp->mat_nr][face_mat_group[i]].mat) { sprintf(matname, "%s", matlists[mp->mat_nr][face_mat_group[i]].mat->id.name+2); - } else if (matlists[mp->mat_nr][face_mat_group[i]].poly.tpage != NULL) { + } + else if (matlists[mp->mat_nr][face_mat_group[i]].poly.tpage != NULL) { sprintf(matname, "texture_%s", matlists[mp->mat_nr][face_mat_group[i]].poly.tpage->id.name+2); - } else { + } + else { sprintf(matname, "__null_material_%d_%d", mp->mat_nr, face_mat_group[mp->mat_nr]); } @@ -4722,7 +4748,8 @@ static int mesh_export_obj_exec(bContext *C, wmOperator *op) for (j=0; j<mp->totloop; j++, ml++, (luv ? luv++ : NULL), c++) { if (luv) { fprintf(file, "%d/%d ", ml->v+1, c+1); - } else { + } + else { fprintf(file, "%d ", ml->v+1); } } @@ -4744,11 +4771,14 @@ static int mesh_export_obj_exec(bContext *C, wmOperator *op) if (mat && matlists[i][j].poly.tpage) { fprintf(matfile, "newmtl %s__%s\n", mat->id.name+2, matlists[i][j].poly.tpage->id.name+2); - } else if (mat) { + } + else if (mat) { fprintf(matfile, "newmtl %s\n", mat->id.name+2); - } else if (matlists[i][j].poly.tpage != NULL) { + } + else if (matlists[i][j].poly.tpage != NULL) { fprintf(matfile, "newmtl texture_%s\n", matlists[i][j].poly.tpage->id.name+2); - } else { + } + else { fprintf(matfile, "newmtl __null_material_%d_%d\n", i, j); } @@ -4756,7 +4786,8 @@ static int mesh_export_obj_exec(bContext *C, wmOperator *op) fprintf(matfile, "Kd %.6f %.6f %.6f\n", mat->r, mat->g, mat->b); fprintf(matfile, "Ks %.6f %.6f %.6f\n", mat->specr, mat->specg, mat->specb); fprintf(matfile, "Ns %.6f\n", mat->spec*1000.0f); - } else { + } + else { fprintf(matfile, "Kd %.6f %.6f %.6f\n", 0.45f, 0.45f, 0.45f); fprintf(matfile, "Ks %.6f %.6f %.6f\n", 1.0f, 0.4f, 0.1f); fprintf(matfile, "Ns %.6f\n", 300.0f); @@ -4827,7 +4858,7 @@ static int export_obj_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) BLI_strncpy(filename, "//untitled.obj", FILE_MAX); - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return mesh_export_obj_exec(C, op); export_obj_filesel(C, op, filename); diff --git a/source/blender/editors/mesh/bmeshutils.c b/source/blender/editors/mesh/bmeshutils.c index f495626a4c3..05a1d96753c 100644 --- a/source/blender/editors/mesh/bmeshutils.c +++ b/source/blender/editors/mesh/bmeshutils.c @@ -185,7 +185,8 @@ int EDBM_FinishOp(BMEditMesh *em, BMOperator *bmop, wmOperator *op, int report) em->emcopyusers = 0; em->emcopy = NULL; return 0; - } else { + } + else { em->emcopyusers--; if (em->emcopyusers < 0) { printf("warning: em->emcopyusers was less then zero.\n"); @@ -300,7 +301,8 @@ void EDBM_MakeEditBMesh(ToolSettings *ts, Scene *UNUSED(scene), Object *ob) /*BMESH_TODO need to write smarter code here*/ bm = BKE_mesh_to_bmesh(me, ob); - } else { + } + else { bm = BKE_mesh_to_bmesh(me, ob); } @@ -475,7 +477,8 @@ int EDBM_get_actSelection(BMEditMesh *em, BMEditSelection *ese) if (ese_last->htype == BM_FACE) { /* if there is an active face, use it over the last selected face */ if (efa) { ese->data = (void *)efa; - } else { + } + else { ese->data = ese_last->data; } ese->htype = BM_FACE; @@ -541,7 +544,7 @@ void EDBM_set_flag_all(BMEditMesh *em, const char hflag) static void *getEditMesh(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_MESH) { + if (obedit && obedit->type==OB_MESH) { Mesh *me= obedit->data; return me->edit_btmesh; } @@ -648,11 +651,11 @@ UvVertMap *EDBM_make_uv_vert_map(BMEditMesh *em, int selected, int do_face_idx_a /* generate UvMapVert array */ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(!selected || ((!BM_TestHFlag(efa, BM_HIDDEN)) && BM_TestHFlag(efa, BM_SELECT))) + if (!selected || ((!BM_TestHFlag(efa, BM_HIDDEN)) && BM_TestHFlag(efa, BM_SELECT))) totuv += efa->len; } - if(totuv==0) { + if (totuv==0) { if (do_face_idx_array) EDBM_free_index_arrays(em); return NULL; @@ -676,7 +679,7 @@ UvVertMap *EDBM_make_uv_vert_map(BMEditMesh *em, int selected, int do_face_idx_a a = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(!selected || ((!BM_TestHFlag(efa, BM_HIDDEN)) && BM_TestHFlag(efa, BM_SELECT))) { + if (!selected || ((!BM_TestHFlag(efa, BM_HIDDEN)) && BM_TestHFlag(efa, BM_SELECT))) { i = 0; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { buf->tfindex= i; @@ -728,8 +731,8 @@ UvVertMap *EDBM_make_uv_vert_map(BMEditMesh *em, int selected, int do_face_idx_a sub_v2_v2v2(uvdiff, uv2, uv); - if(fabs(uv[0]-uv2[0]) < limit[0] && fabs(uv[1]-uv2[1]) < limit[1]) { - if(lastv) lastv->next= next; + if (fabs(uv[0]-uv2[0]) < limit[0] && fabs(uv[1]-uv2[1]) < limit[1]) { + if (lastv) lastv->next= next; else vlist= next; iterv->next= newvlist; newvlist= iterv; @@ -787,20 +790,20 @@ UvElementMap *EDBM_make_uv_element_map(EditMesh *em, int selected, int do_island totuv = 0; for(efa = em->faces.first; efa; efa = efa->next) - if(!selected || ((!efa->h) && (efa->f & SELECT))) + if (!selected || ((!efa->h) && (efa->f & SELECT))) totuv += (efa->v4)? 4: 3; - if(totuv == 0) + if (totuv == 0) return NULL; vmap = (UvElementMap *)MEM_callocN(sizeof(*vmap), "UvVertElementMap"); - if(!vmap) + if (!vmap) return NULL; vmap->vert = (UvElement**)MEM_callocN(sizeof(*vmap->vert)*em->totvert, "UvElementVerts"); buf = vmap->buf = (UvElement*)MEM_callocN(sizeof(*vmap->buf)*totuv, "UvElement"); - if(!vmap->vert || !vmap->buf) { + if (!vmap->vert || !vmap->buf) { EDBM_free_uv_element_map(vmap); return NULL; } @@ -808,7 +811,7 @@ UvElementMap *EDBM_make_uv_element_map(EditMesh *em, int selected, int do_island vmap->totalUVs = totuv; for(efa = em->faces.first; efa; a++, efa = efa->next) { - if(!selected || ((!efa->h) && (efa->f & SELECT))) { + if (!selected || ((!efa->h) && (efa->f & SELECT))) { nverts = (efa->v4)? 4: 3; for(i = 0; i<nverts; i++) { @@ -852,8 +855,8 @@ UvElementMap *EDBM_make_uv_element_map(EditMesh *em, int selected, int do_island tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); uv2 = tf->uv[iterv->tfindex]; - if(fabsf(uv[0]-uv2[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1]-uv2[1]) < STD_UV_CONNECT_LIMIT) { - if(lastv) lastv->next = next; + if (fabsf(uv[0]-uv2[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1]-uv2[1]) < STD_UV_CONNECT_LIMIT) { + if (lastv) lastv->next = next; else vlist = next; iterv->next = newvlist; newvlist = iterv; @@ -870,7 +873,7 @@ UvElementMap *EDBM_make_uv_element_map(EditMesh *em, int selected, int do_island vmap->vert[a] = newvlist; } - if(do_islands) { + if (do_islands) { /* at this point, every UvElement in vert points to a UvElement sharing the same vertex. Now we should sort uv's in islands. */ /* map holds the map from current vmap->buf to the new, sorted map*/ @@ -879,7 +882,7 @@ UvElementMap *EDBM_make_uv_element_map(EditMesh *em, int selected, int do_island islandbuf = MEM_callocN(sizeof(*islandbuf)*totuv, "uvelement_island_buffer"); for(i = 0; i < totuv; i++) { - if(vmap->buf[i].island == INVALID_ISLAND) { + if (vmap->buf[i].island == INVALID_ISLAND) { vmap->buf[i].island = nislands; stack[0] = vmap->buf[i].face; stack[0]->tmp.l = nislands; @@ -893,10 +896,10 @@ UvElementMap *EDBM_make_uv_element_map(EditMesh *em, int selected, int do_island UvElement *element, *initelement = vmap->vert[(*(&efa->v1 + j))->tmp.l]; for(element = initelement; element; element = element->next) { - if(element->separate) + if (element->separate) initelement = element; - if(element->face == efa) { + if (element->face == efa) { /* found the uv corresponding to our face and vertex. Now fill it to the buffer */ element->island = nislands; map[element - vmap->buf] = islandbufsize; @@ -907,10 +910,10 @@ UvElementMap *EDBM_make_uv_element_map(EditMesh *em, int selected, int do_island islandbufsize++; for(element = initelement; element; element = element->next) { - if(element->separate && element != initelement) + if (element->separate && element != initelement) break; - if(element->face->tmp.l == INVALID_ISLAND) { + if (element->face->tmp.l == INVALID_ISLAND) { stack[stacksize++] = element->face; element->face->tmp.l = nislands; } @@ -928,12 +931,12 @@ UvElementMap *EDBM_make_uv_element_map(EditMesh *em, int selected, int do_island /* remap */ for(i = 0; i < em->totvert; i++) { /* important since we may do selection only. Some of these may be NULL */ - if(vmap->vert[i]) + if (vmap->vert[i]) vmap->vert[i] = &islandbuf[map[vmap->vert[i] - vmap->buf]]; } vmap->islandIndices = MEM_callocN(sizeof(*vmap->islandIndices)*nislands,"UvVertMap2_island_indices"); - if(!vmap->islandIndices) { + if (!vmap->islandIndices) { MEM_freeN(islandbuf); MEM_freeN(stack); MEM_freeN(map); @@ -943,12 +946,12 @@ UvElementMap *EDBM_make_uv_element_map(EditMesh *em, int selected, int do_island j = 0; for(i = 0; i < totuv; i++) { UvElement *element = vmap->buf[i].next; - if(element == NULL) + if (element == NULL) islandbuf[map[i]].next = NULL; else islandbuf[map[i]].next = &islandbuf[map[element - vmap->buf]]; - if(islandbuf[i].island != j) { + if (islandbuf[i].island != j) { j++; vmap->islandIndices[j] = i; } @@ -1008,7 +1011,7 @@ MTexPoly *EDBM_get_active_mtexpoly(BMEditMesh *em, BMFace **act_efa, int sloppy) { BMFace *efa = NULL; - if(!EDBM_texFaceCheck(em)) + if (!EDBM_texFaceCheck(em)) return NULL; efa = BM_get_actFace(em->bm, sloppy); |