diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 644a4f00a3f..64453f3aeee 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -55,7 +55,7 @@ #define SELECT 1 -/*prototypes*/ +/* prototypes */ static void bm_copy_loop_attributes(BMesh *source_mesh, BMesh *target_mesh, const BMLoop *source_loop, BMLoop *target_loop); #if 0 @@ -66,7 +66,7 @@ static void bm_copy_loop_attributes(BMesh *source_mesh, BMesh *target_mesh, * This file contains functions for making and destroying * individual elements like verts, edges and faces. * -*/ + */ /* * BMESH MAKE VERT @@ -76,7 +76,7 @@ static void bm_copy_loop_attributes(BMesh *source_mesh, BMesh *target_mesh, * passed in, it's custom data and properties * will be copied to the new vertex. * -*/ + */ BMVert *BM_Make_Vert(BMesh *bm, float co[3], BMVert *example) { @@ -100,13 +100,13 @@ BMVert *BM_Make_Vert(BMesh *bm, float co[3], BMVert *example) * provided, it's custom data and properties will be copied to the * new edge. * -*/ + */ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge *example, int nodouble) { 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) { @@ -135,21 +135,20 @@ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge *example, int nod * * Note that the winding of the face is determined * by the order of the vertices in the vertex array - * -*/ + */ BMFace *BM_Make_Face_QuadTri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, const BMFace *example, const int nodouble) { - BMVert *vtar[4]= {v1, v2, v3, v4}; + BMVert *vtar[4] = {v1, v2, v3, v4}; return BM_Make_Face_QuadTri_v(bm, vtar, v4 ? 4 : 3, example, nodouble); } -/*remove the edge array bits from this. Its not really needed?*/ +/* remove the edge array bits from this. Its not really needed? */ BMFace *BM_Make_Face_QuadTri_v(BMesh *bm, BMVert **verts, int len, const BMFace *example, const int nodouble) { - BMEdge *edar[4]= {NULL}; + BMEdge *edar[4] = {NULL}; BMFace *f = NULL; int overlap = 0; @@ -164,7 +163,7 @@ BMFace *BM_Make_Face_QuadTri_v(BMesh *bm, BMVert **verts, int len, const BMFace } if (nodouble) { - /*check if face exists or overlaps*/ + /* check if face exists or overlaps */ if (len == 4) { overlap = BM_Exist_Face_Overlaps(bm, verts, len, &f); } @@ -173,7 +172,7 @@ BMFace *BM_Make_Face_QuadTri_v(BMesh *bm, BMVert **verts, int len, const BMFace } } - /*make new face*/ + /* 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); @@ -196,7 +195,7 @@ BMFace *BM_Make_Face_QuadTri_v(BMesh *bm, BMVert **verts, int len, const BMFace } -/*copies face data from shared adjacent faces*/ +/* copies face data from shared adjacent faces */ void BM_Face_CopyShared(BMesh *bm, BMFace *f) { BMIter iter; @@ -204,8 +203,8 @@ 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)) { + l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); + for ( ; l; l = BMIter_Step(&iter)) { l2 = l->radial_next; if (l2 && l2 != l) { @@ -233,7 +232,7 @@ void BM_Face_CopyShared(BMesh *bm, BMFace *f) * are already sorted, if the edges are always going to be sorted, * BM_Make_Face should be considered over this function as it * avoids some unnecessary work. -*/ + */ BMFace *BM_Make_Ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, int nodouble) { BMEdge **edges2 = NULL; @@ -243,18 +242,18 @@ BMFace *BM_Make_Ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, BMFace *f = NULL; BMEdge *e; BMVert *ev1, *ev2; - int i, /* j,*/ v1found, reverse; + int i, /* j, */ v1found, reverse; - /*this code is hideous, yeek. I'll have to think about ways of - cleaning it up. basically, it now combines the old BM_Make_Ngon - *and* the old bmesh_mf functions, so its kindof smashed together - - joeedh*/ + /* this code is hideous, yeek. I'll have to think about ways of + * cleaning it up. basically, it now combines the old BM_Make_Ngon + * _and_ the old bmesh_mf functions, so its kindof smashed together + * - joeedh */ if (!len || !v1 || !v2 || !edges || !bm) return NULL; - /*put edges in correct order*/ - for (i=0; imat_nr = source_face->mat_nr; } -/*BMESH_TODO: Special handling for hide flags?*/ +/* BMESH_TODO: Special handling for hide flags? */ void BM_Copy_Attributes(BMesh *source_mesh, BMesh *target_mesh, const void *source, void *target) { @@ -446,21 +447,21 @@ void BM_Copy_Attributes(BMesh *source_mesh, BMesh *target_mesh, const void *sour if (sheader->htype != theader->htype) return; - /*First we copy select*/ + /* First we copy select */ if (BM_Selected(source_mesh, source)) BM_Select(target_mesh, target, TRUE); - /*Now we copy flags*/ + /* Now we copy flags */ theader->hflag = sheader->hflag; - /*Copy specific attributes*/ + /* Copy specific attributes */ if (theader->htype == BM_VERT) - bm_copy_vert_attributes(source_mesh, target_mesh, (const BMVert*)source, (BMVert*)target); + bm_copy_vert_attributes(source_mesh, target_mesh, (const BMVert *)source, (BMVert *)target); else if (theader->htype == BM_EDGE) - bm_copy_edge_attributes(source_mesh, target_mesh, (const BMEdge*)source, (BMEdge*)target); + bm_copy_edge_attributes(source_mesh, target_mesh, (const BMEdge *)source, (BMEdge *)target); else if (theader->htype == BM_LOOP) - bm_copy_loop_attributes(source_mesh, target_mesh, (const BMLoop*)source, (BMLoop*)target); + bm_copy_loop_attributes(source_mesh, target_mesh, (const BMLoop *)source, (BMLoop *)target); else if (theader->htype == BM_FACE) - bm_copy_face_attributes(source_mesh, target_mesh, (const BMFace*)source, (BMFace*)target); + bm_copy_face_attributes(source_mesh, target_mesh, (const BMFace *)source, (BMFace *)target); } BMesh *BM_Copy_Mesh(BMesh *bmold) @@ -469,15 +470,15 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) BMVert *v, *v2, **vtable = NULL; BMEdge *e, *e2, **edges = NULL, **etable = NULL; BLI_array_declare(edges); - BMLoop *l, /* *l2,*/ **loops = NULL; + BMLoop *l, /* *l2, */ **loops = NULL; BLI_array_declare(loops); BMFace *f, *f2, **ftable = NULL; BMEditSelection *ese; BMIter iter, liter; - int allocsize[4] = {512,512,2048,512}; + int allocsize[4] = {512, 512, 2048, 512}; int i, j; - /*allocate a bmesh*/ + /* allocate a bmesh */ bm = BM_Make_Mesh(bmold->ob, allocsize); CustomData_copy(&bmold->vdata, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0); @@ -490,12 +491,12 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) CustomData_bmesh_init_pool(&bm->ldata, allocsize[2]); CustomData_bmesh_init_pool(&bm->pdata, allocsize[3]); - vtable= MEM_mallocN(sizeof(BMVert *) * bmold->totvert, "BM_Copy_Mesh vtable"); - etable= MEM_mallocN(sizeof(BMEdge *) * bmold->totedge, "BM_Copy_Mesh etable"); - ftable= MEM_mallocN(sizeof(BMFace *) * bmold->totface, "BM_Copy_Mesh ftable"); + vtable = MEM_mallocN(sizeof(BMVert *) * bmold->totvert, "BM_Copy_Mesh vtable"); + etable = MEM_mallocN(sizeof(BMEdge *) * bmold->totedge, "BM_Copy_Mesh etable"); + ftable = MEM_mallocN(sizeof(BMFace *) * bmold->totface, "BM_Copy_Mesh ftable"); v = BMIter_New(&iter, bmold, BM_VERTS_OF_MESH, NULL); - for (i=0; v; v=BMIter_Step(&iter), i++) { + for (i = 0; v; v = BMIter_Step(&iter), i++) { v2 = BM_Make_Vert(bm, v->co, NULL); /* copy between meshes so cant use 'example' argument */ BM_Copy_Attributes(bmold, bm, v, v2); vtable[i] = v2; @@ -509,7 +510,7 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) BLI_assert(i == bmold->totvert); e = BMIter_New(&iter, bmold, BM_EDGES_OF_MESH, NULL); - for (i=0; e; e=BMIter_Step(&iter), i++) { + for (i = 0; e; e = BMIter_Step(&iter), i++) { e2 = BM_Make_Edge(bm, vtable[BM_GetIndex(e->v1)], vtable[BM_GetIndex(e->v2)], e, 0); @@ -525,7 +526,7 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) BLI_assert(i == bmold->totedge); f = BMIter_New(&iter, bmold, BM_FACES_OF_MESH, NULL); - for (i=0; f; f=BMIter_Step(&iter), i++) { + for (i = 0; f; f = BMIter_Step(&iter), i++) { BM_SetIndex(f, i); /* set_inline */ BLI_array_empty(loops); @@ -534,7 +535,7 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) BLI_array_growitems(edges, f->len); l = BMIter_New(&liter, bmold, BM_LOOPS_OF_FACE, f); - for (j=0; jlen; j++, l = BMIter_Step(&liter)) { + for (j = 0; j < f->len; j++, l = BMIter_Step(&liter)) { loops[j] = l; edges[j] = etable[BM_GetIndex(l->e)]; } @@ -543,7 +544,7 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) v2 = vtable[BM_GetIndex(loops[1]->v)]; if (!bmesh_verts_in_edge(v, v2, edges[0])) { - v = vtable[BM_GetIndex(loops[BLI_array_count(loops)-1]->v)]; + v = vtable[BM_GetIndex(loops[BLI_array_count(loops) - 1]->v)]; v2 = vtable[BM_GetIndex(loops[0]->v)]; } @@ -551,7 +552,7 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) if (!f2) continue; /* use totface incase adding some faces fails */ - BM_SetIndex(f2, (bm->totface-1)); /* set_inline */ + BM_SetIndex(f2, (bm->totface - 1)); /* set_inline */ ftable[i] = f2; @@ -559,7 +560,7 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) copy_v3_v3(f2->no, f->no); l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f2); - for (j=0; jlen; j++, l = BMIter_Step(&liter)) { + for (j = 0; j < f->len; j++, l = BMIter_Step(&liter)) { BM_Copy_Attributes(bmold, bm, loops[j], l); } @@ -571,16 +572,16 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) /* safety check */ BLI_assert(i == bmold->totface); - /*copy over edit selection history*/ - for (ese=bmold->selected.first; ese; ese=ese->next) { + /* copy over edit selection history */ + for (ese = bmold->selected.first; ese; ese = ese->next) { void *ele = NULL; if (ese->htype == BM_VERT) - ele= vtable[BM_GetIndex(ese->data)]; + ele = vtable[BM_GetIndex(ese->data)]; else if (ese->htype == BM_EDGE) - ele= etable[BM_GetIndex(ese->data)]; + ele = etable[BM_GetIndex(ese->data)]; else if (ese->htype == BM_FACE) { - ele= ftable[BM_GetIndex(ese->data)]; + ele = ftable[BM_GetIndex(ese->data)]; } else { BLI_assert(0); @@ -626,7 +627,7 @@ char BM_Face_Flag_From_MEFlag(const char meflag) /* BM -> ME */ char BM_Vert_Flag_To_MEFlag(BMVert *eve) { - const char hflag= eve->head.hflag; + const char hflag = eve->head.hflag; return ( ((hflag & BM_SELECT) ? SELECT : 0) | ((hflag & BM_HIDDEN) ? ME_HIDE : 0) @@ -634,7 +635,7 @@ char BM_Vert_Flag_To_MEFlag(BMVert *eve) } short BM_Edge_Flag_To_MEFlag(BMEdge *eed) { - const char hflag= eed->head.hflag; + const char hflag = eed->head.hflag; return ( ((hflag & BM_SELECT) ? SELECT : 0) | ((hflag & BM_SEAM) ? ME_SEAM : 0) | @@ -646,7 +647,7 @@ short BM_Edge_Flag_To_MEFlag(BMEdge *eed) } char BM_Face_Flag_To_MEFlag(BMFace *efa) { - const char hflag= efa->head.hflag; + const char hflag = efa->head.hflag; return ( ((hflag & BM_SELECT) ? ME_FACE_SEL : 0) | ((hflag & BM_SMOOTH) ? ME_SMOOTH : 0) | @@ -662,10 +663,10 @@ char BM_Face_Flag_To_MEFlag(BMFace *efa) Returns the flags stored in element, which much be either a BMVert, BMEdge, or BMFace, converted to mesh flags. -*/ + */ short BMFlags_To_MEFlags(void *element) { - const char src_htype= ((BMHeader *)element)->htype; + const char src_htype = ((BMHeader *)element)->htype; if (src_htype == BM_FACE) { return BM_Face_Flag_To_MEFlag(element); @@ -689,7 +690,7 @@ short BMFlags_To_MEFlags(void *element) or MPoly, converted to mesh flags. type must be either BM_VERT, BM_EDGE, or BM_FACE. -*/ + */ char MEFlags_To_BMFlags(const short hflag, const char htype) { if (htype == BM_FACE) { diff --git a/source/blender/bmesh/intern/bmesh_inline.c b/source/blender/bmesh/intern/bmesh_inline.c index d53c42a336e..54339610a9f 100644 --- a/source/blender/bmesh/intern/bmesh_inline.c +++ b/source/blender/bmesh/intern/bmesh_inline.c @@ -68,5 +68,5 @@ BM_INLINE int BM_GetIndex(const void *element) return ((BMHeader *)element)->index; } -#endif /*BM_INLINE_C*/ +#endif /* BM_INLINE_C */ diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index c9c17a738ab..1ce71539198 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -77,8 +77,8 @@ void BM_Data_Interp_From_Verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, flo void *src[2]; float w[2]; - src[0]= v1->head.data; - src[1]= v2->head.data; + src[0] = v1->head.data; + src[1] = v2->head.data; w[0] = 1.0f-fac; w[1] = fac; CustomData_bmesh_interp(&bm->vdata, src, w, NULL, 2, v->head.data); @@ -87,11 +87,11 @@ void BM_Data_Interp_From_Verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, flo } /* - BM Data Vert Average - - Sets all the customdata (e.g. vert, loop) associated with a vert - to the average of the face regions surrounding it. -*/ + * BM Data Vert Average + * + * Sets all the customdata (e.g. vert, loop) associated with a vert + * to the average of the face regions surrounding it. + */ static void UNUSED_FUNCTION(BM_Data_Vert_Average)(BMesh *UNUSED(bm), BMFace *UNUSED(f)) @@ -107,13 +107,13 @@ static void UNUSED_FUNCTION(BM_Data_Vert_Average)(BMesh *UNUSED(bm), BMFace *UNU * * Returns - * Nothing -*/ + */ void BM_Data_Facevert_Edgeinterp(BMesh *bm, BMVert *v1, BMVert *UNUSED(v2), BMVert *v, BMEdge *e1, float fac) { void *src[2]; float w[2]; - BMLoop *l=NULL, *v1loop = NULL, *vloop = NULL, *v2loop = NULL; + BMLoop *l = NULL, *v1loop = NULL, *vloop = NULL, *v2loop = NULL; w[1] = 1.0f - fac; w[0] = fac; @@ -138,9 +138,9 @@ void BM_Data_Facevert_Edgeinterp(BMesh *bm, BMVert *v1, BMVert *UNUSED(v2), BMVe src[0] = v1loop->head.data; src[1] = v2loop->head.data; - CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, vloop->head.data); + 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; @@ -200,14 +200,14 @@ void BM_loops_to_corners(BMesh *bm, Mesh *me, int findex, * * Returns - * Nothing -*/ + */ void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source) { BMLoop *l1, *l2; BMLoop *l_first; - void **blocks=NULL; - float (*cos)[3]=NULL, *w=NULL; + void **blocks = NULL; + float (*cos)[3] = NULL, *w = NULL; BLI_array_fixedstack_declare(cos, BM_NGON_STACK_SIZE, source->len, __func__); BLI_array_fixedstack_declare(w, BM_NGON_STACK_SIZE, source->len, __func__); BLI_array_fixedstack_declare(blocks, BM_NGON_STACK_SIZE, source->len, __func__); @@ -236,22 +236,22 @@ void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source) BLI_array_fixedstack_free(blocks); } -/****some math stuff for dealing with doubles, put here to - avoid merge errors - joeedh ****/ +/* some math stuff for dealing with doubles, put here to + * avoid merge errors - joeedh */ #define VECMUL(a, b) (((a)[0] = (a)[0] * (b)), ((a)[1] = (a)[1] * (b)), ((a)[2] = (a)[2] * (b))) #define VECADD2(a, b) (((a)[0] = (a)[0] + (b)[0]), ((a)[1] = (a)[1] + (b)[1]), ((a)[2] = (a)[2] + (b)[2])) #define VECSUB2(a, b) (((a)[0] = (a)[0] - (b)[0]), ((a)[1] = (a)[1] - (b)[1]), ((a)[2] = (a)[2] - (b)[2])) -/* find closest point to p on line through l1,l2 and return lambda, - * where (0 <= lambda <= 1) when cp is in the line segement l1,l2 +/* find closest point to p on line through l1, l2 and return lambda, + * where (0 <= lambda <= 1) when cp is in the line segement l1, l2 */ static double closest_to_line_v3_d(double cp[3], const double p[3], const double l1[3], const double l2[3]) { - double h[3],u[3],lambda; + double h[3], u[3], lambda; VECSUB(u, l2, l1); VECSUB(h, p, l1); - lambda =INPR(u,h)/INPR(u,u); + lambda = INPR(u, h) / INPR(u, u); cp[0] = l1[0] + u[0] * lambda; cp[1] = l1[1] + u[1] * lambda; cp[2] = l1[2] + u[2] * lambda; @@ -263,7 +263,7 @@ static void UNUSED_FUNCTION(closest_to_line_segment_v3_d)(double *closest, doubl { double lambda, cp[3]; - lambda= closest_to_line_v3_d(cp,v1, v2, v3); + lambda = closest_to_line_v3_d(cp, v1, v2, v3); if (lambda <= 0.0) { VECCOPY(closest, v2); @@ -291,23 +291,23 @@ static double UNUSED_FUNCTION(len_v3v3_d)(const double a[3], const double b[3]) static void cent_quad_v3_d(double *cent, double *v1, double *v2, double *v3, double *v4) { - cent[0]= 0.25*(v1[0]+v2[0]+v3[0]+v4[0]); - cent[1]= 0.25*(v1[1]+v2[1]+v3[1]+v4[1]); - cent[2]= 0.25*(v1[2]+v2[2]+v3[2]+v4[2]); + cent[0] = 0.25 * (v1[0] + v2[0] + v3[0] + v4[0]); + cent[1] = 0.25 * (v1[1] + v2[1] + v3[1] + v4[1]); + cent[2] = 0.25 * (v1[2] + v2[2] + v3[2] + v4[2]); } static void UNUSED_FUNCTION(cent_tri_v3_d)(double *cent, double *v1, double *v2, double *v3) { - cent[0]= 0.33333*(v1[0]+v2[0]+v3[0]); - cent[1]= 0.33333*(v1[1]+v2[1]+v3[1]); - cent[2]= 0.33333*(v1[2]+v2[2]+v3[2]); + cent[0] = 0.33333 * (v1[0] + v2[0] + v3[0]); + cent[1] = 0.33333 * (v1[1] + v2[1] + v3[1]); + cent[2] = 0.33333 * (v1[2] + v2[2] + v3[2]); } static void UNUSED_FUNCTION(cross_v3_v3v3_d)(double r[3], const double a[3], const double b[3]) { - r[0]= a[1]*b[2] - a[2]*b[1]; - r[1]= a[2]*b[0] - a[0]*b[2]; - r[2]= a[0]*b[1] - a[1]*b[0]; + r[0] = a[1] * b[2] - a[2] * b[1]; + r[1] = a[2] * b[0] - a[0] * b[2]; + r[2] = a[0] * b[1] - a[1] * b[0]; } /* distance v1 to line-piece v2-v3 */ @@ -315,31 +315,31 @@ static double UNUSED_FUNCTION(dist_to_line_segment_v2_d)(double v1[3], double v2 { double labda, rc[2], pt[2], len; - 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) { - rc[0]= v1[0]-v2[0]; - rc[1]= v1[1]-v2[1]; - return sqrt(rc[0]*rc[0]+ rc[1]*rc[1]); + 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) { + 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) { - pt[0]= v2[0]; - pt[1]= v2[1]; + labda = (rc[0]*(v1[0]-v2[0]) + rc[1]*(v1[1]-v2[1])) / len; + if (labda <= 0.0) { + pt[0] = v2[0]; + pt[1] = v2[1]; } - else if (labda>=1.0) { - pt[0]= v3[0]; - pt[1]= v3[1]; + else if (labda >= 1.0) { + pt[0] = v3[0]; + pt[1] = v3[1]; } else { - pt[0]= labda*rc[0]+v2[0]; - pt[1]= labda*rc[1]+v2[1]; + pt[0] = labda*rc[0]+v2[0]; + pt[1] = labda*rc[1]+v2[1]; } - rc[0]= pt[0]-v1[0]; - rc[1]= pt[1]-v1[1]; + rc[0] = pt[0]-v1[0]; + rc[1] = pt[1]-v1[1]; return sqrt(rc[0]*rc[0]+ rc[1]*rc[1]); } @@ -353,19 +353,19 @@ MINLINE double line_point_side_v2_d(const double *l1, const double *l2, const do /* point in quad - only convex quads */ static int isect_point_quad_v2_d(double pt[2], double v1[2], double v2[2], double v3[2], double v4[2]) { - if (line_point_side_v2_d(v1,v2,pt)>=0.0) { - 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) { + if (line_point_side_v2_d(v1, v2, pt) >= 0.0) { + 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) { return 1; } } } } 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)) { + 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)) { return -1; } } @@ -386,14 +386,14 @@ mdisps is a grid of displacements, ordered thus: | V y -*/ + */ static int compute_mdisp_quad(BMLoop *l, double v1[3], double v2[3], double v3[3], double v4[3], double e1[3], double e2[3]) { double cent[3] = {0.0, 0.0, 0.0}, n[3], p[3]; BMLoop *l2; - /*computer center*/ + /* computer center */ l2 = bm_firstfaceloop(l->f); do { cent[0] += (double)l2->v->co[0]; @@ -402,7 +402,7 @@ static int compute_mdisp_quad(BMLoop *l, double v1[3], double v2[3], double v3[3 l2 = l2->next; } while (l2 != bm_firstfaceloop(l->f)); - VECMUL(cent, (1.0/(double)l->f->len)); + VECMUL(cent, (1.0 / (double)l->f->len)); VECADD(p, l->prev->v->co, l->v->co); VECMUL(p, 0.5); @@ -420,38 +420,38 @@ static int compute_mdisp_quad(BMLoop *l, double v1[3], double v2[3], double v3[3 return 1; } -/*funnily enough, I think this is identical to face_to_crn_interp, heh*/ +/* funnily enough, I think this is identical to face_to_crn_interp, heh */ static double quad_coord(double aa[3], double bb[3], double cc[3], double dd[3], int a1, int a2) { double x, y, z, f1; - x = aa[a1]*cc[a2]-cc[a1]*aa[a2]; - y = aa[a1]*dd[a2]+bb[a1]*cc[a2]-cc[a1]*bb[a2]-dd[a1]*aa[a2]; - z = bb[a1]*dd[a2]-dd[a1]*bb[a2]; + x = aa[a1] * cc[a2] - cc[a1] * aa[a2]; + y = aa[a1] * dd[a2] + bb[a1] * cc[a2] - cc[a1] * bb[a2] - dd[a1] * aa[a2]; + z = bb[a1] * dd[a2] - dd[a1] * bb[a2]; - if (fabs(2*(x-y+z)) > DBL_EPSILON*10.0) { + if (fabs(2 * (x - y + z)) > DBL_EPSILON * 10.0) { double f2; - f1 = (sqrt(y*y-4.0*x*z) - y + 2.0*z) / (2.0*(x-y+z)); - f2 = (-sqrt(y*y-4.0*x*z) - y + 2.0*z) / (2.0*(x-y+z)); + f1 = (sqrt(y * y - 4.0 * x * z) - y + 2.0 * z) / (2.0 * (x - y + z)); + f2 = (-sqrt(y * y - 4.0 * x * z) - y + 2.0 * z) / (2.0 * (x - y + z)); - f1= fabs(f1); - f2= fabs(f2); + f1 = fabs(f1); + f2 = fabs(f2); f1 = MIN2(f1, f2); - CLAMP(f1, 0.0, 1.0+DBL_EPSILON); + CLAMP(f1, 0.0, 1.0 + DBL_EPSILON); } else { - f1 = -z/(y - 2*z); - CLAMP(f1, 0.0, 1.0+DBL_EPSILON); + f1 = -z / (y - 2 * z); + CLAMP(f1, 0.0, 1.0 + DBL_EPSILON); if (isnan(f1) || f1 > 1.0 || f1 < 0.0) { int i; - for (i=0; i<2; i++) { - if (fabsf(aa[i]) < FLT_EPSILON*100) - return aa[(i+1)%2] / fabs(bb[(i+1)%2] - aa[(i+1)%2]); - if (fabsf(cc[i]) < FLT_EPSILON*100) - return cc[(i+1)%2] / fabs(dd[(i+1)%2] - cc[(i+1)%2]); + for (i = 0; i < 2; i++) { + if (fabsf(aa[i]) < FLT_EPSILON * 100) + return aa[(i + 1) % 2] / fabs(bb[(i + 1) % 2] - aa[(i + 1) % 2]); + if (fabsf(cc[i]) < FLT_EPSILON * 100) + return cc[(i + 1) % 2] / fabs(dd[(i + 1) % 2] - cc[(i + 1) % 2]); } } } @@ -462,10 +462,10 @@ static double quad_coord(double aa[3], double bb[3], double cc[3], double dd[3], static int quad_co(double *x, double *y, double v1[3], double v2[3], double v3[3], double v4[3], double p[3], float n[3]) { float projverts[5][3], n2[3]; - double dprojverts[4][3], origin[3]={0.0f, 0.0f, 0.0f}; + double dprojverts[4][3], origin[3] = {0.0f, 0.0f, 0.0f}; int i; - /*project points into 2d along normal*/ + /* project points into 2d along normal */ VECCOPY(projverts[0], v1); VECCOPY(projverts[1], v2); VECCOPY(projverts[2], v3); @@ -474,17 +474,20 @@ static int quad_co(double *x, double *y, double v1[3], double v2[3], double v3[3 normal_quad_v3(n2, projverts[0], projverts[1], projverts[2], projverts[3]); - if (INPR(n, n2) < -FLT_EPSILON) + if (INPR(n, n2) < -FLT_EPSILON) { return 0; + } - /*rotate*/ + /* rotate */ poly_rotate_plane(n, projverts, 5); - /*flatten*/ - for (i=0; i<5; i++) projverts[i][2] = 0.0f; + /* flatten */ + for (i = 0; i < 5; i++) { + projverts[i][2] = 0.0f; + } - /*subtract origin*/ - for (i=0; i<4; i++) { + /* subtract origin */ + for (i = 0; i < 4; i++) { VECSUB2(projverts[i], projverts[4]); } @@ -493,8 +496,9 @@ static int quad_co(double *x, double *y, double v1[3], double v2[3], double v3[3 VECCOPY(dprojverts[2], projverts[2]); VECCOPY(dprojverts[3], projverts[3]); - if (!isect_point_quad_v2_d(origin, dprojverts[0], dprojverts[1], dprojverts[2], dprojverts[3])) + if (!isect_point_quad_v2_d(origin, dprojverts[0], dprojverts[1], dprojverts[2], dprojverts[3])) { return 0; + } *y = quad_coord(dprojverts[1], dprojverts[0], dprojverts[2], dprojverts[3], 0, 1); *x = quad_coord(dprojverts[2], dprojverts[1], dprojverts[3], dprojverts[0], 0, 1); @@ -503,12 +507,12 @@ static int quad_co(double *x, double *y, double v1[3], double v2[3], double v3[3 } -/*tl is loop to project onto, l is loop whose internal displacement, co, is being - projected. x and y are location in loop's mdisps grid of point co.*/ +/* tl is loop to project onto, l is loop whose internal displacement, co, is being + * projected. x and y are location in loop's mdisps grid of point co. */ static int mdisp_in_mdispquad(BMesh *bm, BMLoop *l, BMLoop *tl, double p[3], double *x, double *y, int res) { double v1[3], v2[3], c[3], v3[3], v4[3], e1[3], e2[3]; - double eps = FLT_EPSILON*4000; + double eps = FLT_EPSILON * 4000; if (len_v3(l->v->no) == 0.0f) BM_Vert_UpdateAllNormals(bm, l->v); @@ -517,21 +521,21 @@ static int mdisp_in_mdispquad(BMesh *bm, BMLoop *l, BMLoop *tl, double p[3], dou compute_mdisp_quad(tl, v1, v2, v3, v4, e1, e2); - /*expand quad a bit*/ + /* expand quad a bit */ cent_quad_v3_d(c, v1, v2, v3, v4); VECSUB2(v1, c); VECSUB2(v2, c); VECSUB2(v3, c); VECSUB2(v4, c); - VECMUL(v1, 1.0+eps); VECMUL(v2, 1.0+eps); - VECMUL(v3, 1.0+eps); VECMUL(v4, 1.0+eps); + VECMUL(v1, 1.0 + eps); VECMUL(v2, 1.0 + eps); + VECMUL(v3, 1.0 + eps); VECMUL(v4, 1.0 + eps); VECADD2(v1, c); VECADD2(v2, c); VECADD2(v3, c); VECADD2(v4, c); if (!quad_co(x, y, v1, v2, v3, v4, p, l->v->no)) return 0; - *x *= res-1; - *y *= res-1; + *x *= res - 1; + *y *= res - 1; return 1; } @@ -543,7 +547,7 @@ static void bmesh_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source) double x, y, d, v1[3], v2[3], v3[3], v4[3] = {0.0f, 0.0f, 0.0f}, e1[3], e2[3]; int ix, iy, res; - /*ignore 2-edged faces*/ + /* ignore 2-edged faces */ if (target->f->len < 3) return; @@ -553,28 +557,30 @@ static void bmesh_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source) mdisps = CustomData_bmesh_get(&bm->ldata, target->head.data, CD_MDISPS); compute_mdisp_quad(target, v1, v2, v3, v4, e1, e2); - /*if no disps data allocate a new grid, the size of the first grid in source.*/ + /* if no disps data allocate a new grid, the size of the first grid in source. */ if (!mdisps->totdisp) { MDisps *md2 = CustomData_bmesh_get(&bm->ldata, bm_firstfaceloop(source)->head.data, CD_MDISPS); mdisps->totdisp = md2->totdisp; - if (mdisps->totdisp) - mdisps->disps = MEM_callocN(sizeof(float)*3*mdisps->totdisp, "mdisp->disps in bmesh_loop_intern_mdisps"); - else + if (mdisps->totdisp) { + mdisps->disps = MEM_callocN(sizeof(float) * 3 * mdisps->totdisp, "mdisp->disps in bmesh_loop_intern_mdisps"); + } + else { return; + } } res = (int)sqrt(mdisps->totdisp); - d = 1.0/(double)(res-1); - for (x=0.0f, ix=0; ixdisps[iy*res+ix], md2->disps, res, (float)x2, (float)y2); + old_mdisps_bilinear(md1->disps[iy * res + ix], md2->disps, res, (float)x2, (float)y2); } l2 = l2->next; } while (l2 != bm_firstfaceloop(source)); @@ -626,22 +632,22 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f) int sides; int y; - /***** - mdisps is a grid of displacements, ordered thus: - - v4/next - | - | v1/cent-----mid2 ---> x - | | | - | | | - v2/prev---mid1-----v3/cur - | - V - y - *****/ + /* + * mdisps is a grid of displacements, ordered thus: + * + * v4/next + * | + * | v1/cent-----mid2 ---> x + * | | | + * | | | + * v2/prev---mid1-----v3/cur + * | + * V + * y + */ sides = (int)sqrt(mdp->totdisp); - for (y=0; ydisps[y*sides], mdl->disps[y]); mul_v3_fl(co1, 0.5); @@ -657,19 +663,19 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f) int sides; int y; - /***** - mdisps is a grid of displacements, ordered thus: - - v4/next - | - | v1/cent-----mid2 ---> x - | | | - | | | - v2/prev---mid1-----v3/cur - | - V - y - *****/ + /* + * mdisps is a grid of displacements, ordered thus: + * + * v4/next + * | + * | v1/cent-----mid2 ---> x + * | | | + * | | | + * v2/prev---mid1-----v3/cur + * | + * V + * y + */ if (l->radial_next == l) continue; @@ -680,24 +686,24 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f) mdl2 = CustomData_bmesh_get(&bm->ldata, l->radial_next->next->head.data, CD_MDISPS); sides = (int)sqrt(mdl1->totdisp); - for (y=0; yv != l->radial_next->v) { a1 = sides*y + sides-2; a2 = (sides-2)*sides + y; - o1 = sides*y + sides-1; - o2 = (sides-1)*sides + y; + o1 = sides * y + sides - 1; + o2 = (sides - 1) * sides + y; } else { - a1 = sides*y + sides-2; - a2 = sides*y + sides-2; - o1 = sides*y + sides-1; - o2 = sides*y + sides-1; + a1 = sides * y + sides - 2; + a2 = sides * y + sides - 2; + o1 = sides * y + sides - 1; + o2 = sides * y + sides - 1; } - /*magic blending numbers, hardcoded!*/ + /* magic blending numbers, hardcoded! */ add_v3_v3v3(co1, mdl1->disps[a1], mdl2->disps[a2]); mul_v3_fl(co1, 0.18); @@ -707,7 +713,7 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f) add_v3_v3v3(co, co1, co2); copy_v3_v3(mdl1->disps[o1], co); - copy_v3_v3(mdl2->disps[o2], co); //*/ + copy_v3_v3(mdl2->disps[o2], co); } } } @@ -722,9 +728,9 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source, { BMLoop *l; BMLoop *l_first; - void **blocks=NULL; - void **vblocks=NULL; - float (*cos)[3]=NULL, co[3], *w=NULL, cent[3] = {0.0f, 0.0f, 0.0f}; + void **blocks = NULL; + void **vblocks = NULL; + float (*cos)[3] = NULL, co[3], *w = NULL, cent[3] = {0.0f, 0.0f, 0.0f}; BLI_array_fixedstack_declare(cos, BM_NGON_STACK_SIZE, source->len, __func__); BLI_array_fixedstack_declare(w, BM_NGON_STACK_SIZE, source->len, __func__); BLI_array_fixedstack_declare(blocks, BM_NGON_STACK_SIZE, source->len, __func__); @@ -755,9 +761,9 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source, axis_dominant_v3(&ax, &ay, source->no); /* scale source face coordinates a bit, so points sitting directonly on an - edge will work.*/ - mul_v3_fl(cent, 1.0f/(float)source->len); - for (i=0; ilen; i++) { + edge will work. */ + mul_v3_fl(cent, 1.0f / (float)source->len); + for (i = 0; i < source->len; i++) { float vec[3], tmp[3]; sub_v3_v3v3(vec, cent, cos[i]); mul_v3_fl(vec, 0.001f); @@ -770,7 +776,7 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source, } - /*interpolate*/ + /* interpolate */ co[0] = target->v->co[ax]; co[1] = target->v->co[ay]; co[2] = 0.0f; @@ -798,8 +804,8 @@ void BM_vert_interp_from_face(BMesh *bm, BMVert *v, BMFace *source) { BMLoop *l; BMLoop *l_first; - void **blocks=NULL; - float (*cos)[3]=NULL, *w=NULL, cent[3] = {0.0f, 0.0f, 0.0f}; + void **blocks = NULL; + float (*cos)[3] = NULL, *w = NULL, cent[3] = {0.0f, 0.0f, 0.0f}; BLI_array_fixedstack_declare(cos, BM_NGON_STACK_SIZE, source->len, __func__); BLI_array_fixedstack_declare(w, BM_NGON_STACK_SIZE, source->len, __func__); BLI_array_fixedstack_declare(blocks, BM_NGON_STACK_SIZE, source->len, __func__); @@ -817,8 +823,8 @@ void BM_vert_interp_from_face(BMesh *bm, BMVert *v, BMFace *source) } while ((l = l->next) != l_first); /* scale source face coordinates a bit, so points sitting directonly on an - * edge will work.*/ - mul_v3_fl(cent, 1.0f/(float)source->len); + * edge will work. */ + mul_v3_fl(cent, 1.0f / (float)source->len); for (i = 0; i < source->len; i++) { float vec[3]; sub_v3_v3v3(vec, cent, cos[i]); @@ -826,7 +832,7 @@ void BM_vert_interp_from_face(BMesh *bm, BMVert *v, BMFace *source) add_v3_v3(cos[i], vec); } - /*interpolate*/ + /* interpolate */ interp_weights_poly_v3(w, cos, source->len, v->co); CustomData_bmesh_interp(&bm->vdata, blocks, w, NULL, source->len, v->head.data); @@ -841,7 +847,7 @@ static void update_data_blocks(BMesh *bm, CustomData *olddata, CustomData *data) BLI_mempool *oldpool = olddata->pool; void *block; - CustomData_bmesh_init_pool(data, data==&bm->ldata ? 2048 : 512); + CustomData_bmesh_init_pool(data, data == &bm->ldata ? 2048 : 512); if (data == &bm->vdata) { BMVert *eve; @@ -851,7 +857,7 @@ static void update_data_blocks(BMesh *bm, CustomData *olddata, CustomData *data) CustomData_bmesh_set_default(data, &block); CustomData_bmesh_copy_data(olddata, data, eve->head.data, &block); CustomData_bmesh_free_block(olddata, &eve->head.data); - eve->head.data= block; + eve->head.data = block; } } else if (data == &bm->edata) { @@ -862,7 +868,7 @@ static void update_data_blocks(BMesh *bm, CustomData *olddata, CustomData *data) CustomData_bmesh_set_default(data, &block); CustomData_bmesh_copy_data(olddata, data, eed->head.data, &block); CustomData_bmesh_free_block(olddata, &eed->head.data); - eed->head.data= block; + eed->head.data = block; } } else if (data == &bm->pdata || data == &bm->ldata) { @@ -876,7 +882,7 @@ static void update_data_blocks(BMesh *bm, CustomData *olddata, CustomData *data) CustomData_bmesh_set_default(data, &block); CustomData_bmesh_copy_data(olddata, data, efa->head.data, &block); CustomData_bmesh_free_block(olddata, &efa->head.data); - efa->head.data= block; + efa->head.data = block; } if (data == &bm->ldata) { @@ -885,7 +891,7 @@ static void update_data_blocks(BMesh *bm, CustomData *olddata, CustomData *data) CustomData_bmesh_set_default(data, &block); CustomData_bmesh_copy_data(olddata, data, l->head.data, &block); CustomData_bmesh_free_block(olddata, &l->head.data); - l->head.data= block; + l->head.data = block; } } } @@ -903,8 +909,8 @@ void BM_add_data_layer(BMesh *bm, CustomData *data, int type) { CustomData olddata; - olddata= *data; - olddata.layers= (olddata.layers)? MEM_dupallocN(olddata.layers): NULL; + olddata = *data; + olddata.layers = (olddata.layers) ? MEM_dupallocN(olddata.layers): NULL; /* the pool is now owned by olddata and must not be shared */ data->pool = NULL; @@ -919,8 +925,8 @@ void BM_add_data_layer_named(BMesh *bm, CustomData *data, int type, const char * { CustomData olddata; - olddata= *data; - olddata.layers= (olddata.layers)? MEM_dupallocN(olddata.layers): NULL; + olddata = *data; + olddata.layers = (olddata.layers) ? MEM_dupallocN(olddata.layers): NULL; /* the pool is now owned by olddata and must not be shared */ data->pool = NULL; @@ -935,8 +941,8 @@ void BM_free_data_layer(BMesh *bm, CustomData *data, int type) { CustomData olddata; - olddata= *data; - olddata.layers= (olddata.layers)? MEM_dupallocN(olddata.layers): NULL; + olddata = *data; + olddata.layers = (olddata.layers) ? MEM_dupallocN(olddata.layers): NULL; /* the pool is now owned by olddata and must not be shared */ data->pool = NULL; @@ -951,8 +957,8 @@ void BM_free_data_layer_n(BMesh *bm, CustomData *data, int type, int n) { CustomData olddata; - olddata= *data; - olddata.layers= (olddata.layers)? MEM_dupallocN(olddata.layers): NULL; + olddata = *data; + olddata.layers = (olddata.layers) ? MEM_dupallocN(olddata.layers): NULL; /* the pool is now owned by olddata and must not be shared */ data->pool = NULL; @@ -965,12 +971,12 @@ void BM_free_data_layer_n(BMesh *bm, CustomData *data, int type, int n) float BM_GetCDf(CustomData *cd, void *element, int type) { - float *f = CustomData_bmesh_get(cd, ((BMHeader*)element)->data, type); + float *f = CustomData_bmesh_get(cd, ((BMHeader *)element)->data, type); return f ? *f : 0.0f; } void BM_SetCDf(CustomData *cd, void *element, int type, float val) { - float *f = CustomData_bmesh_get(cd, ((BMHeader*)element)->data, type); + float *f = CustomData_bmesh_get(cd, ((BMHeader *)element)->data, type); if (f) *f = val; } diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index 9f446eec1f8..43e2a160cae 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -42,14 +42,16 @@ void *BMIter_AtIndex(struct BMesh *bm, const char itype, void *data, int index) void *val; int i; - /*sanity check*/ - if (index < 0) return NULL; + /* sanity check */ + if (index < 0) { + return NULL; + } - val=BMIter_New(&iter, bm, itype, data); + val = BMIter_New(&iter, bm, itype, data); i = 0; while (i < index) { - val=BMIter_Step(&iter); + val = BMIter_Step(&iter); i++; } @@ -66,16 +68,16 @@ void *BMIter_AtIndex(struct BMesh *bm, const char itype, void *data, int index) int BMIter_AsArray(struct BMesh *bm, const char type, void *data, void **array, const int len) { - int i= 0; + int i = 0; - /*sanity check*/ + /* sanity check */ if (len > 0) { BMIter iter; void *val; BM_ITER(val, &iter, bm, type, data) { - array[i]= val; + array[i] = val; i++; if (i == len) { return len; @@ -93,7 +95,7 @@ int BMIter_AsArray(struct BMesh *bm, const char type, void *data, void **array, * Clears the internal state of an iterator * For begin() callbacks. * -*/ + */ static void init_iterator(BMIter *iter) { @@ -124,7 +126,7 @@ static void init_iterator(BMIter *iter) /* * VERT OF MESH CALLBACKS * -*/ + */ void bmiter__vert_of_mesh_begin(BMIter *iter) { @@ -162,7 +164,7 @@ void *bmiter__face_of_mesh_step(BMIter *iter) /* * EDGE OF VERT CALLBACKS * -*/ + */ void bmiter__edge_of_vert_begin(BMIter *iter) { @@ -188,7 +190,7 @@ void *bmiter__edge_of_vert_step(BMIter *iter) /* * FACE OF VERT CALLBACKS * -*/ + */ void bmiter__face_of_vert_begin(BMIter *iter) { @@ -219,16 +221,14 @@ void *bmiter__face_of_vert_step(BMIter *iter) if (!iter->count) iter->nextloop = NULL; - - if (current) return current->f; - return NULL; + return current ? current->f : NULL; } /* * LOOP OF VERT CALLBACKS * -*/ + */ void bmiter__loop_of_vert_begin(BMIter *iter) { @@ -271,7 +271,7 @@ void bmiter__loops_of_edge_begin(BMIter *iter) l = iter->edata->l; - /*note sure why this sets ldata. . .*/ + /* note sure why this sets ldata ... */ init_iterator(iter); iter->firstloop = iter->nextloop = l; @@ -297,7 +297,7 @@ void bmiter__loops_of_loop_begin(BMIter *iter) l = iter->ldata; - /*note sure why this sets ldata. . .*/ + /* note sure why this sets ldata ... */ init_iterator(iter); iter->firstloop = l; @@ -321,7 +321,7 @@ void *bmiter__loops_of_loop_step(BMIter *iter) /* * FACE OF EDGE CALLBACKS * -*/ + */ void bmiter__face_of_edge_begin(BMIter *iter) { @@ -340,19 +340,19 @@ void *bmiter__face_of_edge_step(BMIter *iter) if (iter->nextloop) iter->nextloop = bmesh_radial_nextloop(iter->nextloop); if (iter->nextloop == iter->firstloop) iter->nextloop = NULL; - if (current) return current->f; - return NULL; + + return current ? current->f : NULL; } /* * VERT OF FACE CALLBACKS * -*/ + */ void bmiter__vert_of_face_begin(BMIter *iter) { init_iterator(iter); - iter->firstloop = iter->nextloop = ((BMLoopList*)iter->pdata->loops.first)->first; + iter->firstloop = iter->nextloop = ((BMLoopList *)iter->pdata->loops.first)->first; } void *bmiter__vert_of_face_step(BMIter *iter) @@ -362,19 +362,18 @@ void *bmiter__vert_of_face_step(BMIter *iter) if (iter->nextloop) iter->nextloop = iter->nextloop->next; if (iter->nextloop == iter->firstloop) iter->nextloop = NULL; - if (current) return current->v; - return NULL; + return current ? current->v : NULL; } /* * EDGE OF FACE CALLBACKS * -*/ + */ void bmiter__edge_of_face_begin(BMIter *iter) { init_iterator(iter); - iter->firstloop = iter->nextloop = ((BMLoopList*)iter->pdata->loops.first)->first; + iter->firstloop = iter->nextloop = ((BMLoopList *)iter->pdata->loops.first)->first; } void *bmiter__edge_of_face_step(BMIter *iter) @@ -384,14 +383,13 @@ void *bmiter__edge_of_face_step(BMIter *iter) if (iter->nextloop) iter->nextloop = iter->nextloop->next; if (iter->nextloop == iter->firstloop) iter->nextloop = NULL; - if (current) return current->e; - return NULL; + return current ? current->e : NULL; } /* * LOOP OF FACE CALLBACKS * -*/ + */ void bmiter__loop_of_face_begin(BMIter *iter) { diff --git a/source/blender/bmesh/intern/bmesh_iterators_inline.c b/source/blender/bmesh/intern/bmesh_iterators_inline.c index cf621ee938f..eb04fe068a7 100644 --- a/source/blender/bmesh/intern/bmesh_iterators_inline.c +++ b/source/blender/bmesh/intern/bmesh_iterators_inline.c @@ -39,7 +39,7 @@ * * Calls an iterators step fucntion to return * the next element. -*/ + */ BM_INLINE void *BMIter_Step(BMIter *iter) { @@ -55,7 +55,7 @@ BM_INLINE void *BMIter_Step(BMIter *iter) * upon its type and then calls BMeshIter_step() * to return the first element of the iterator. * -*/ + */ BM_INLINE void *BMIter_New(BMIter *iter, BMesh *bm, const char itype, void *data) { /* int argtype; */ diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 7275648fd22..8913f833973 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -52,7 +52,7 @@ * should only be called by system and not * tool authors. * -*/ + */ static void recount_totsels(BMesh *bm) { @@ -62,15 +62,15 @@ static void recount_totsels(BMesh *bm) int *tots[3]; int i; - /*recount tot*sel variables*/ + /* recount tot*sel variables */ bm->totvertsel = bm->totedgesel = bm->totfacesel = 0; tots[0] = &bm->totvertsel; tots[1] = &bm->totedgesel; tots[2] = &bm->totfacesel; - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { ele = BMIter_New(&iter, bm, itypes[i], NULL); - for ( ; ele; ele=BMIter_Step(&iter)) { + for ( ; ele; ele = BMIter_Step(&iter)) { if (BM_TestHFlag(ele, BM_SELECT)) *tots[i] += 1; } } @@ -88,7 +88,7 @@ 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)) { + 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); } @@ -96,9 +96,9 @@ void BM_SelectMode_Flush(BMesh *bm) 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); + l = (BMLoop *) bm_firstfaceloop(f); do { if (BM_TestHFlag(l->v, BM_SELECT)) totsel++; @@ -114,14 +114,14 @@ 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)) { + 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)) totsel++; l = l->next; - } while (l!=bm_firstfaceloop(f)); + } while (l != bm_firstfaceloop(f)); if (totsel == f->len && !BM_TestHFlag(f, BM_HIDDEN)) { BM_SetHFlag(f, BM_SELECT); @@ -132,7 +132,7 @@ void BM_SelectMode_Flush(BMesh *bm) } } - /*Remove any deselected elements from the BMEditSelection*/ + /* Remove any deselected elements from the BMEditSelection */ BM_validate_selections(bm); recount_totsels(bm); @@ -144,7 +144,7 @@ void BM_SelectMode_Flush(BMesh *bm) * Changes selection state of a single vertex * in a mesh * -*/ + */ void BM_Select_Vert(BMesh *bm, BMVert *v, int select) { @@ -175,7 +175,7 @@ void BM_Select_Vert(BMesh *bm, BMVert *v, int select) * Changes selection state of a single edge * in a mesh. * -*/ + */ void BM_Select_Edge(BMesh *bm, BMEdge *e, int select) { @@ -236,7 +236,7 @@ void BM_Select_Edge(BMesh *bm, BMEdge *e, int select) * Changes selection state of a single * face in a mesh. * -*/ + */ void BM_Select_Face(BMesh *bm, BMFace *f, int select) { @@ -250,7 +250,7 @@ void BM_Select_Face(BMesh *bm, BMFace *f, int select) if (!BM_TestHFlag(f, BM_SELECT)) bm->totfacesel += 1; BM_SetHFlag(&(f->head), BM_SELECT); - l=(BMLoop*) bm_firstfaceloop(f); + l = (BMLoop *) bm_firstfaceloop(f); do { BM_Select_Vert(bm, l->v, TRUE); BM_Select_Edge(bm, l->e, TRUE); @@ -264,7 +264,7 @@ void BM_Select_Face(BMesh *bm, BMFace *f, int select) if (BM_TestHFlag(f, BM_SELECT)) bm->totfacesel -= 1; BM_ClearHFlag(&(f->head), BM_SELECT); - /*flush down to edges*/ + /* flush down to edges */ BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { BMIter fiter; BMFace *f2; @@ -279,7 +279,7 @@ void BM_Select_Face(BMesh *bm, BMFace *f, int select) } } - /*flush down to verts*/ + /* flush down to verts */ BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { BMIter eiter; BMEdge *e; @@ -300,7 +300,7 @@ void BM_Select_Face(BMesh *bm, BMFace *f, int select) * * Sets the selection mode for the bmesh * -*/ + */ void BM_Selectmode_Set(BMesh *bm, int selectmode) { @@ -315,16 +315,16 @@ 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)) + 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)) + 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)) { + 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); } @@ -332,9 +332,9 @@ void BM_Selectmode_Set(BMesh *bm, int selectmode) 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)) + 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)) { if (BM_TestHFlag(&(f->head), BM_SELECT)) { BM_Select_Face(bm, f, TRUE); } @@ -351,19 +351,19 @@ int BM_CountFlag(struct BMesh *bm, const char htype, const char hflag, int respe int tot = 0; if (htype & BM_VERT) { - for (head = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); head; head=BMIter_Step(&iter)) { + for (head = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); head; head = BMIter_Step(&iter)) { if (respecthide && BM_TestHFlag(head, BM_HIDDEN)) continue; if (BM_TestHFlag(head, hflag)) tot++; } } if (htype & BM_EDGE) { - for (head = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL); head; head=BMIter_Step(&iter)) { + for (head = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL); head; head = BMIter_Step(&iter)) { if (respecthide && BM_TestHFlag(head, BM_HIDDEN)) continue; if (BM_TestHFlag(head, hflag)) tot++; } } if (htype & BM_FACE) { - for (head = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); head; head=BMIter_Step(&iter)) { + for (head = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); head; head = BMIter_Step(&iter)) { if (respecthide && BM_TestHFlag(head, BM_HIDDEN)) continue; if (BM_TestHFlag(head, hflag)) tot++; } @@ -372,14 +372,14 @@ int BM_CountFlag(struct BMesh *bm, const char htype, const char hflag, int respe return tot; } -/*note: by design, this will not touch the editselection history stuff*/ +/* note: by design, this will not touch the editselection history stuff */ 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); + 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); } int BM_Selected(BMesh *UNUSED(bm), const void *element) @@ -403,17 +403,17 @@ BMFace *BM_get_actFace(BMesh *bm, int sloppy) } else if (sloppy) { BMIter iter; - BMFace *f= NULL; + BMFace *f = NULL; BMEditSelection *ese; /* Find the latest non-hidden face from the BMEditSelection */ ese = bm->selected.last; - for ( ; ese; ese=ese->prev) { + for ( ; ese; ese = ese->prev) { if (ese->htype == BM_FACE) { - f= (BMFace *)ese->data; + f = (BMFace *)ese->data; if (BM_TestHFlag(f, BM_HIDDEN)) { - f= NULL; + f = NULL; } else { break; @@ -421,7 +421,7 @@ BMFace *BM_get_actFace(BMesh *bm, int sloppy) } } /* Last attempt: try to find any selected face */ - if (f==NULL) { + if (f == NULL) { BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { if (BM_TestHFlag(f, BM_SELECT)) { break; @@ -440,20 +440,20 @@ BMFace *BM_get_actFace(BMesh *bm, int sloppy) * - EM_editselection_center * - EM_editselection_normal * - EM_editselection_plane -*/ + */ void BM_editselection_center(BMesh *bm, float r_center[3], BMEditSelection *ese) { if (ese->htype == BM_VERT) { - BMVert *eve= ese->data; + BMVert *eve = ese->data; copy_v3_v3(r_center, eve->co); } else if (ese->htype == BM_EDGE) { - BMEdge *eed= ese->data; + BMEdge *eed = ese->data; add_v3_v3v3(r_center, eed->v1->co, eed->v2->co); mul_v3_fl(r_center, 0.5); } else if (ese->htype == BM_FACE) { - BMFace *efa= ese->data; + BMFace *efa = ese->data; BM_Compute_Face_CenterBounds(bm, efa, r_center); } } @@ -461,11 +461,11 @@ void BM_editselection_center(BMesh *bm, float r_center[3], BMEditSelection *ese) void BM_editselection_normal(float r_normal[3], BMEditSelection *ese) { if (ese->htype == BM_VERT) { - BMVert *eve= ese->data; + BMVert *eve = ese->data; copy_v3_v3(r_normal, eve->no); } else if (ese->htype == BM_EDGE) { - BMEdge *eed= ese->data; + BMEdge *eed = ese->data; float plane[3]; /* need a plane to correct the normal */ float vec[3]; /* temp vec storage */ @@ -473,16 +473,16 @@ void BM_editselection_normal(float r_normal[3], BMEditSelection *ese) sub_v3_v3v3(plane, eed->v2->co, eed->v1->co); /* the 2 vertex normals will be close but not at rightangles to the edge - for rotate about edge we want them to be at right angles, so we need to - do some extra colculation to correct the vert normals, - we need the plane for this */ + * for rotate about edge we want them to be at right angles, so we need to + * do some extra colculation to correct the vert normals, + * we need the plane for this */ cross_v3_v3v3(vec, r_normal, plane); cross_v3_v3v3(r_normal, plane, vec); normalize_v3(r_normal); } else if (ese->htype == BM_FACE) { - BMFace *efa= ese->data; + BMFace *efa = ese->data; copy_v3_v3(r_normal, efa->no); } } @@ -490,62 +490,64 @@ void BM_editselection_normal(float r_normal[3], BMEditSelection *ese) /* ref - editmesh_lib.cL:EM_editselection_plane() */ /* Calculate a plane that is rightangles to the edge/vert/faces normal -also make the plane run along an axis that is related to the geometry, -because this is used for the manipulators Y axis.*/ + * also make the plane run along an axis that is related to the geometry, + * because this is used for the manipulators Y axis. */ void BM_editselection_plane(BMesh *bm, float r_plane[3], BMEditSelection *ese) { if (ese->htype == BM_VERT) { - BMVert *eve= ese->data; - float vec[3]={0,0,0}; + BMVert *eve = ese->data; + float vec[3] = {0.0f, 0.0f, 0.0f}; - if (ese->prev) { /*use previously selected data to make a useful vertex plane */ + 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 { /* 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) - that vec isnt the same or in the same direction even.*/ - if (eve->no[0] < 0.5f) vec[0]= 1.0f; - else if (eve->no[1] < 0.5f) vec[1]= 1.0f; - else vec[2]= 1.0f; + * 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) + * that vec isnt the same or in the same direction even. */ + if (eve->no[0] < 0.5f) vec[0] = 1.0f; + else if (eve->no[1] < 0.5f) vec[1] = 1.0f; + else vec[2] = 1.0f; cross_v3_v3v3(r_plane, eve->no, vec); } } else if (ese->htype == BM_EDGE) { - BMEdge *eed= ese->data; + BMEdge *eed = ese->data; /* the plane is simple, it runs along the edge - however selecting different edges can swap the direction of the y axis. - this makes it less likely for the y axis of the manipulator - (running along the edge).. to flip less often. - at least its more pradictable */ - if (eed->v2->co[1] > eed->v1->co[1]) /*check which to do first */ + * however selecting different edges can swap the direction of the y axis. + * this makes it less likely for the y axis of the manipulator + * (running along the edge).. to flip less often. + * at least its more pradictable */ + if (eed->v2->co[1] > eed->v1->co[1]) { /* check which to do first */ sub_v3_v3v3(r_plane, eed->v2->co, eed->v1->co); - else + } + else { sub_v3_v3v3(r_plane, eed->v1->co, eed->v2->co); + } } else if (ese->htype == BM_FACE) { - BMFace *efa= ese->data; + BMFace *efa = ese->data; float vec[3] = {0.0f, 0.0f, 0.0f}; - /*for now, use face normal*/ + /* for now, use face normal */ /* 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) - that vec isnt the same or in the same direction even.*/ + * 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) + * that vec isnt the same or in the same direction even. */ if (efa->len < 3) { /* crappy fallback method */ - if (efa->no[0] < 0.5f) vec[0]= 1.0f; - else if (efa->no[1] < 0.5f) vec[1]= 1.0f; - else vec[2]= 1.0f; + if (efa->no[0] < 0.5f) vec[0] = 1.0f; + else if (efa->no[1] < 0.5f) vec[1] = 1.0f; + else vec[2] = 1.0f; cross_v3_v3v3(r_plane, efa->no, vec); } else { - BMVert *verts[4]= {NULL}; + BMVert *verts[4] = {NULL}; BMIter_AsArray(bm, BM_VERTS_OF_FACE, efa, (void **)verts, 4); @@ -558,7 +560,7 @@ void BM_editselection_plane(BMesh *bm, float r_plane[3], BMEditSelection *ese) sub_v3_v3v3(vecA, verts[0]->co, verts[3]->co); sub_v3_v3v3(vecB, verts[1]->co, verts[2]->co); add_v3_v3v3(vec, vecA, vecB); - /*use the biggest edge length*/ + /* use the biggest edge length */ if (dot_v3v3(r_plane, r_plane) < dot_v3v3(vec, vec)) { copy_v3_v3(r_plane, vec); } @@ -566,15 +568,15 @@ void BM_editselection_plane(BMesh *bm, float r_plane[3], BMEditSelection *ese) else { /* BMESH_TODO (not urgent, use longest ngon edge for alignment) */ - /*start with v1-2 */ + /* start with v1-2 */ sub_v3_v3v3(r_plane, verts[0]->co, verts[1]->co); - /*test the edge between v2-3, use if longer */ + /* test the edge between v2-3, use if longer */ sub_v3_v3v3(vec, verts[1]->co, verts[2]->co); if (dot_v3v3(r_plane, r_plane) < dot_v3v3(vec, vec)) copy_v3_v3(r_plane, vec); - /*test the edge between v1-3, use if longer */ + /* test the edge between v1-3, use if longer */ sub_v3_v3v3(vec, verts[2]->co, verts[0]->co); if (dot_v3v3(r_plane, r_plane) < dot_v3v3(vec, vec)) { copy_v3_v3(r_plane, vec); @@ -591,18 +593,20 @@ 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; + if (ese->data == data) { + return TRUE; + } } - return 0; + return FALSE; } void BM_remove_selection(BMesh *bm, void *data) { BMEditSelection *ese; - for (ese=bm->selected.first; ese; ese = ese->next) { + for (ese = bm->selected.first; ese; ese = ese->next) { if (ese->data == data) { - BLI_freelinkN(&(bm->selected),ese); + BLI_freelinkN(&(bm->selected), ese); break; } } @@ -618,10 +622,10 @@ void BM_store_selection(BMesh *bm, void *data) { BMEditSelection *ese; if (!BM_check_selection(bm, data)) { - ese = (BMEditSelection*) MEM_callocN(sizeof(BMEditSelection), "BMEdit Selection"); - ese->htype = ((BMHeader*)data)->htype; + ese = (BMEditSelection *) MEM_callocN(sizeof(BMEditSelection), "BMEdit Selection"); + ese->htype = ((BMHeader *)data)->htype; ese->data = data; - BLI_addtail(&(bm->selected),ese); + BLI_addtail(&(bm->selected), ese); } } @@ -647,12 +651,13 @@ void BM_clear_flag_all(BMesh *bm, const char hflag) BMHeader *ele; int i; - if (hflag & BM_SELECT) + if (hflag & BM_SELECT) { BM_clear_selection_history(bm); + } - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { ele = BMIter_New(&iter, bm, itypes[i], NULL); - for ( ; ele; ele=BMIter_Step(&iter)) { + for ( ; ele; ele = BMIter_Step(&iter)) { if (hflag & BM_SELECT) BM_Select(bm, ele, FALSE); BM_ClearHFlag(ele, hflag); } @@ -660,7 +665,7 @@ void BM_clear_flag_all(BMesh *bm, const char hflag) } -/***************** Mesh Hiding stuff *************/ +/***************** Mesh Hiding stuff *********** */ #define SETHIDE(ele) hide ? BM_SetHFlag(ele, BM_HIDDEN) : BM_ClearHFlag(ele, BM_HIDDEN); @@ -692,7 +697,7 @@ static void edge_flush_hide(BMesh *bm, BMEdge *e) void BM_Hide_Vert(BMesh *bm, BMVert *v, int hide) { - /*vert hiding: vert + surrounding edges and faces*/ + /* vert hiding: vert + surrounding edges and faces */ BMIter iter, fiter; BMEdge *e; BMFace *f; @@ -714,14 +719,14 @@ void BM_Hide_Edge(BMesh *bm, BMEdge *e, int hide) BMFace *f; /* BMVert *v; */ - /*edge hiding: faces around the edge*/ + /* edge hiding: faces around the edge */ BM_ITER(f, &iter, bm, BM_FACES_OF_EDGE, e) { SETHIDE(f); } SETHIDE(e); - /*hide vertices if necassary*/ + /* hide vertices if necassary */ vert_flush_hide(bm, e->v1); vert_flush_hide(bm, e->v2); } @@ -731,7 +736,6 @@ void BM_Hide_Face(BMesh *bm, BMFace *f, int hide) BMIter iter; BMLoop *l; - /**/ SETHIDE(f); BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) { @@ -747,10 +751,11 @@ void BM_Hide(BMesh *bm, void *element, int hide) { BMHeader *h = element; - /*Follow convention of always deselecting before - hiding an element*/ - if (hide) + /* Follow convention of always deselecting before + * hiding an element */ + if (hide) { BM_Select(bm, element, FALSE); + } switch (h->htype) { case BM_VERT: diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 202a2fe7cfa..3fab6d6a5aa 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -49,14 +49,14 @@ #include "bmesh.h" #include "bmesh_private.h" -/*bmesh_error stub*/ +/* bmesh_error stub */ void bmesh_error(void) { printf("BM modelling error!\n"); /* This placeholder assert makes modelling errors easier to catch - in the debugger, until bmesh_error is replaced with something - better. */ + * in the debugger, until bmesh_error is replaced with something + * better. */ BLI_assert(0); } @@ -67,12 +67,12 @@ void bmesh_error(void) * Returns - * Pointer to a BM * -*/ + */ BMesh *BM_Make_Mesh(struct Object *ob, int allocsize[4]) { - /*allocate the structure*/ - BMesh *bm = MEM_callocN(sizeof(BMesh),"BM"); + /* allocate the structure */ + BMesh *bm = MEM_callocN(sizeof(BMesh), __func__); int vsize, esize, lsize, fsize, lstsize; vsize = sizeof(BMVert); @@ -83,14 +83,14 @@ BMesh *BM_Make_Mesh(struct Object *ob, int allocsize[4]) bm->ob = ob; - /*allocate the memory pools for the mesh elements*/ + /* allocate the memory pools for the mesh elements */ bm->vpool = BLI_mempool_create(vsize, allocsize[0], allocsize[0], FALSE, TRUE); bm->epool = BLI_mempool_create(esize, allocsize[1], allocsize[1], FALSE, TRUE); bm->lpool = BLI_mempool_create(lsize, allocsize[2], allocsize[2], FALSE, FALSE); bm->looplistpool = BLI_mempool_create(lstsize, allocsize[3], allocsize[3], FALSE, FALSE); bm->fpool = BLI_mempool_create(fsize, allocsize[3], allocsize[3], FALSE, TRUE); - /*allocate one flag pool that we dont get rid of.*/ + /* allocate one flag pool that we dont get rid of. */ bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), 512, 512, FALSE, FALSE); bm->stackdepth = 1; bm->totflags = 1; @@ -102,7 +102,7 @@ BMesh *BM_Make_Mesh(struct Object *ob, int allocsize[4]) * BMESH FREE MESH * * Frees a BMesh structure. -*/ + */ void BM_Free_Mesh_Data(BMesh *bm) { @@ -124,25 +124,25 @@ void BM_Free_Mesh_Data(BMesh *bm) 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?*/ + /* 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); - /*free custom data*/ - CustomData_free(&bm->vdata,0); - CustomData_free(&bm->edata,0); - CustomData_free(&bm->ldata,0); - CustomData_free(&bm->pdata,0); + /* free custom data */ + CustomData_free(&bm->vdata, 0); + CustomData_free(&bm->edata, 0); + CustomData_free(&bm->ldata, 0); + CustomData_free(&bm->pdata, 0); - /*destroy element pools*/ + /* destroy element pools */ BLI_mempool_destroy(bm->vpool); BLI_mempool_destroy(bm->epool); BLI_mempool_destroy(bm->lpool); BLI_mempool_destroy(bm->fpool); - /*destroy flag pool*/ + /* destroy flag pool */ BLI_mempool_destroy(bm->toolflagpool); BLI_mempool_destroy(bm->looplistpool); @@ -159,18 +159,18 @@ void BM_Free_Mesh_Data(BMesh *bm) void BM_Clear_Mesh(BMesh *bm) { - /*allocate the structure*/ + /* allocate the structure */ int vsize, esize, lsize, fsize, lstsize; - /*I really need to make the allocation sizes defines, there's no reason why the API - should allow client code to mess around with this - joeedh*/ + /* I really need to make the allocation sizes defines, there's no reason why the API + * should allow client code to mess around with this - joeedh */ int allocsize[5] = {512, 512, 512, 2048, 512}; Object *ob = bm->ob; - /*free old mesh*/ + /* free old mesh */ BM_Free_Mesh_Data(bm); memset(bm, 0, sizeof(BMesh)); - /*re-initialize mesh*/ + /* re-initialize mesh */ vsize = sizeof(BMVert); esize = sizeof(BMEdge); lsize = sizeof(BMLoop); @@ -179,14 +179,14 @@ void BM_Clear_Mesh(BMesh *bm) bm->ob = ob; - /*allocate the memory pools for the mesh elements*/ + /* allocate the memory pools for the mesh elements */ bm->vpool = BLI_mempool_create(vsize, allocsize[0], allocsize[0], FALSE, TRUE); bm->epool = BLI_mempool_create(esize, allocsize[1], allocsize[1], FALSE, TRUE); bm->lpool = BLI_mempool_create(lsize, allocsize[2], allocsize[2], FALSE, FALSE); bm->looplistpool = BLI_mempool_create(lstsize, allocsize[3], allocsize[3], FALSE, FALSE); bm->fpool = BLI_mempool_create(fsize, allocsize[4], allocsize[4], FALSE, TRUE); - /*allocate one flag pool that we dont get rid of.*/ + /* allocate one flag pool that we dont get rid of. */ bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), 512, 512, FALSE, FALSE); bm->stackdepth = 1; bm->totflags = 1; @@ -196,7 +196,7 @@ void BM_Clear_Mesh(BMesh *bm) * BMESH FREE MESH * * Frees a BMesh structure. -*/ + */ void BM_Free_Mesh(BMesh *bm) { @@ -210,7 +210,7 @@ void BM_Free_Mesh(BMesh *bm) * Updates the normals of a mesh. * Note that this can only be called * -*/ + */ void BM_Compute_Normals(BMesh *bm) { @@ -227,7 +227,7 @@ void BM_Compute_Normals(BMesh *bm) float (*projectverts)[3]; float (*edgevec)[3]; - /*first, find out the largest face in mesh*/ + /* first, find out the largest face in mesh */ BM_ITER(f, &faces, bm, BM_FACES_OF_MESH, NULL) { if (BM_TestHFlag(f, BM_HIDDEN)) continue; @@ -235,13 +235,13 @@ void BM_Compute_Normals(BMesh *bm) if (f->len > maxlength) maxlength = f->len; } - /*make sure we actually have something to do*/ + /* make sure we actually have something to do */ if (maxlength < 3) return; - /*allocate projectverts array*/ + /* allocate projectverts array */ projectverts = MEM_callocN(sizeof(float) * maxlength * 3, "BM normal computation array"); - /*calculate all face normals*/ + /* calculate all face normals */ BM_ITER(f, &faces, bm, BM_FACES_OF_MESH, NULL) { if (BM_TestHFlag(f, BM_HIDDEN)) continue; @@ -253,7 +253,7 @@ void BM_Compute_Normals(BMesh *bm) bmesh_update_face_normal(bm, f, f->no, projectverts); } - /*Zero out vertex normals*/ + /* Zero out vertex normals */ BM_ITER(v, &verts, bm, BM_VERTS_OF_MESH, NULL) { if (BM_TestHFlag(v, BM_HIDDEN)) continue; @@ -281,7 +281,7 @@ void BM_Compute_Normals(BMesh *bm) } bm->elem_index_dirty &= ~BM_EDGE; - /*add weighted face normals to vertices*/ + /* add weighted face normals to vertices */ BM_ITER(f, &faces, bm, BM_FACES_OF_MESH, NULL) { if (BM_TestHFlag(f, BM_HIDDEN)) @@ -293,16 +293,16 @@ void BM_Compute_Normals(BMesh *bm) float fac; /* calculate the dot product of the two edges that - meet at the loop's vertex */ + * meet at the loop's vertex */ e1diff = edgevec[BM_GetIndex(l->prev->e)]; e2diff = edgevec[BM_GetIndex(l->e)]; dotprod = dot_v3v3(e1diff, e2diff); /* edge vectors are calculated from e->v1 to e->v2, so - adjust the dot product if one but not both loops - actually runs from from e->v2 to e->v1 */ + * adjust the dot product if one but not both loops + * actually runs from from e->v2 to e->v1 */ if ((l->prev->e->v1 == l->prev->v) ^ (l->e->v1 == l->v)) { - dotprod= -dotprod; + dotprod = -dotprod; } fac = saacos(-dotprod); @@ -333,7 +333,7 @@ void BM_Compute_Normals(BMesh *bm) if undo is 0: calculate right normals if undo is 1: restore original normals -*/ + */ //keep in sycn with utils.c! #define FACE_FLIP 8 static void bmesh_rationalize_normals(BMesh *bm, int undo) @@ -370,7 +370,7 @@ static void bmesh_rationalize_normals(BMesh *bm, int undo) static void bmesh_set_mdisps_space(BMesh *bm, int from, int to) { - /*switch multires data out of tangent space*/ + /* switch multires data out of tangent space */ if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) { Object *ob = bm->ob; BMEditMesh *em = BMEdit_Create(bm, FALSE); @@ -378,7 +378,7 @@ static void bmesh_set_mdisps_space(BMesh *bm, int from, int to) MDisps *mdisps; BMFace *f; BMIter iter; - // int i= 0; // UNUSED + // int i = 0; // UNUSED multires_set_space(dm, ob, from, to); @@ -395,7 +395,7 @@ 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); + memcpy(lmd->disps, mdisps->disps, sizeof(float) * 3 * lmd->totdisp); } else if (mdisps->disps) { if (lmd->disps) @@ -413,7 +413,7 @@ static void bmesh_set_mdisps_space(BMesh *bm, int from, int to) dm->needsFree = 1; dm->release(dm); - /*setting this to NULL prevents BMEdit_Free from freeing it*/ + /* setting this to NULL prevents BMEdit_Free from freeing it */ em->bm = NULL; BMEdit_Free(em); MEM_freeN(em); @@ -430,7 +430,7 @@ static void bmesh_set_mdisps_space(BMesh *bm, int from, int to) * Returns - * Nothing * -*/ + */ void bmesh_begin_edit(BMesh *bm, int flag) { bm->opflag = flag; @@ -441,11 +441,11 @@ void bmesh_begin_edit(BMesh *bm, int flag) the mesh at all, which doesn't seem right. Turning off completely for now, until this is shown to be better for certain types of mesh edits. */ #if BMOP_UNTAN_MULTIRES_ENABLED - /*switch multires data out of tangent space*/ + /* switch multires data out of tangent space */ if ((flag & BMOP_UNTAN_MULTIRES) && CustomData_has_layer(&bm->ldata, CD_MDISPS)) { bmesh_set_mdisps_space(bm, MULTIRES_SPACE_TANGENT, MULTIRES_SPACE_ABSOLUTE); - /*ensure correct normals, if possible*/ + /* ensure correct normals, if possible */ bmesh_rationalize_normals(bm, 0); BM_Compute_Normals(bm); } @@ -463,9 +463,9 @@ void bmesh_end_edit(BMesh *bm, int flag) { /* BMOP_UNTAN_MULTIRES disabled for now, see comment above in bmesh_begin_edit. */ #if BMOP_UNTAN_MULTIRES_ENABLED - /*switch multires data into tangent space*/ + /* switch multires data into tangent space */ if ((flag & BMOP_UNTAN_MULTIRES) && CustomData_has_layer(&bm->ldata, CD_MDISPS)) { - /*set normals to their previous winding*/ + /* set normals to their previous winding */ bmesh_rationalize_normals(bm, 1); bmesh_set_mdisps_space(bm, MULTIRES_SPACE_ABSOLUTE, MULTIRES_SPACE_TANGENT); } @@ -480,7 +480,7 @@ void bmesh_end_edit(BMesh *bm, int flag) bm->opflag = 0; - /*compute normals, clear temp flags and flush selections*/ + /* compute normals, clear temp flags and flush selections */ BM_Compute_Normals(bm); BM_SelectMode_Flush(bm); } @@ -496,7 +496,7 @@ void BM_ElemIndex_Ensure(BMesh *bm, const char hflag) if (hflag & BM_VERT) { if (bm->elem_index_dirty & BM_VERT) { - int index= 0; + int index = 0; BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) { BM_SetIndex(ele, index); /* set_ok */ index++; @@ -511,7 +511,7 @@ void BM_ElemIndex_Ensure(BMesh *bm, const char hflag) if (hflag & BM_EDGE) { if (bm->elem_index_dirty & BM_EDGE) { - int index= 0; + int index = 0; BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) { BM_SetIndex(ele, index); /* set_ok */ index++; @@ -526,7 +526,7 @@ void BM_ElemIndex_Ensure(BMesh *bm, const char hflag) if (hflag & BM_FACE) { if (bm->elem_index_dirty & BM_FACE) { - int index= 0; + int index = 0; BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) { BM_SetIndex(ele, index); /* set_ok */ index++; @@ -556,24 +556,24 @@ void BM_ElemIndex_Validate(BMesh *bm, const char *location, const char *func, co BMIter iter; BMHeader *ele; int types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, BM_FACES_OF_MESH}; - const char *type_names[3]= {"vert", "edge", "face"}; - const char type_flags[3]= {BM_VERT, BM_EDGE, BM_FACE}; + const char *type_names[3] = {"vert", "edge", "face"}; + const char type_flags[3] = {BM_VERT, BM_EDGE, BM_FACE}; int i; - int is_any_error= 0; + int is_any_error = 0; - for (i=0; i<3; i++) { - const int is_dirty= (type_flags[i] & bm->elem_index_dirty); - int index= 0; - int is_error= FALSE; - int err_val= 0; - int err_idx= 0; + for (i = 0; i < 3; i++) { + const int is_dirty = (type_flags[i] & bm->elem_index_dirty); + int index = 0; + int is_error = FALSE; + int err_val = 0; + int err_idx = 0; BM_ITER(ele, &iter, bm, types[i], NULL) { if (!is_dirty) { if (BM_GetIndex(ele) != index) { - err_val= BM_GetIndex(ele); - err_idx= index; - is_error= TRUE; + err_val = BM_GetIndex(ele); + err_idx = index; + is_error = TRUE; } } @@ -582,7 +582,7 @@ void BM_ElemIndex_Validate(BMesh *bm, const char *location, const char *func, co } if ((is_error == TRUE) && (is_dirty == FALSE)) { - is_any_error= TRUE; + is_any_error = TRUE; fprintf(stderr, "Invalid Index: at %s, %s, %s[%d] invalid index %d, '%s', '%s'\n", location, func, type_names[i], err_idx, err_val, msg_a, msg_b); diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 09cdc80a76e..03d064edaec 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -68,12 +68,14 @@ int BM_Dissolve_Vert(BMesh *bm, BMVert *v) { BMIter iter; BMEdge *e; - int len=0; + int len = 0; - if (!v) return 0; + 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++; } @@ -103,18 +105,18 @@ int BM_Dissolve_Vert(BMesh *bm, BMVert *v) int BM_Dissolve_Disk(BMesh *bm, BMVert *v) { BMFace *f, *f2; - BMEdge *e, *keepedge=NULL, *baseedge=NULL; - int len= 0; + BMEdge *e, *keepedge = NULL, *baseedge = NULL; + int len = 0; if (BM_Nonmanifold_Vert(bm, v)) { return 0; } if (v->e) { - /*v->e we keep, what else?*/ + /* v->e we keep, what else */ e = v->e; do { - e = bmesh_disk_nextedge(e,v); + e = bmesh_disk_nextedge(e, v); if (!(BM_Edge_Share_Faces(e, v->e))) { keepedge = e; baseedge = v->e; @@ -124,12 +126,12 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) } while (e != v->e); } - /*this code for handling 2 and 3-valence verts - may be totally bad.*/ + /* this code for handling 2 and 3-valence verts + * may be totally bad */ if (keepedge == NULL && len == 3) { - /*handle specific case for three-valence. solve it by - increasing valence to four. this may be hackish. . .*/ - BMLoop *loop= e->l; + /* handle specific case for three-valence. solve it by + * increasing valence to four. this may be hackish. . */ + BMLoop *loop = e->l; if (loop->v == v) loop = loop->next; if (!BM_Split_Face(bm, loop->f, v, loop->v, NULL, NULL)) return 0; @@ -140,14 +142,14 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) return 1; } else if (keepedge == NULL && len == 2) { - /*collapse the vertex*/ + /* collapse the verte */ e = BM_Collapse_Vert_Faces(bm, v->e, v, 1.0, TRUE); if (!e) { return 0; } - /*handle two-valence*/ + /* handle two-valenc */ f = e->l->f; f2 = e->l->radial_next->f; @@ -167,12 +169,14 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) 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.*/ + /* return if couldn't join faces in manifold + * conditions */ //!disabled for testing why bad things happen - if (!f) return 0; + if (!f) { + return 0; + } } if (f) { @@ -183,19 +187,19 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) } while (e != v->e); } - /*collapse the vertex*/ + /* collapse the verte */ e = BM_Collapse_Vert_Faces(bm, baseedge, v, 1.0, TRUE); if (!e) { return 0; } - /*get remaining two faces*/ + /* get remaining two face */ f = e->l->f; f2 = e->l->radial_next->f; if (f != f2) { - /*join two remaining faces*/ + /* join two remaining face */ if (!BM_Join_TwoFaces(bm, f, f2, e)) { return 0; } @@ -217,15 +221,13 @@ void BM_Dissolve_Disk(BMesh *bm, BMVert *v) while (!done) { done = 1; - /*loop the edges looking for an edge to dissolve*/ - for (e=BMIter_New(&iter, bm, BM_EDGES_OF_VERT, v); e; + /* loop the edges looking for an edge to dissolv */ + for (e = BMIter_New(&iter, bm, BM_EDGES_OF_VERT, v); e; e = BMIter_Step(&iter)) { f = NULL; len = bmesh_cycle_length(&(e->l->radial)); if (len == 2) { - f = BM_Join_TwoFaces(bm,e->l->f,((BMLoop*) - (e->l->radial_next))->f, - e); + f = BM_Join_TwoFaces(bm, e->l->f, ((BMLoop *)(e->l->radial_next))->f, e); } if (f) { done = 0; @@ -258,12 +260,12 @@ void BM_Dissolve_Disk(BMesh *bm, BMVert *v) BMFace *BM_Join_TwoFaces(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) { BMLoop *l1, *l2; - BMEdge *jed=NULL; + BMEdge *jed = NULL; BMFace *faces[2] = {f1, f2}; jed = e; if (!jed) { - /*search for an edge that has both these faces in its radial cycle*/ + /* search for an edge that has both these faces in its radial cycl */ l1 = bm_firstfaceloop(f1); do { if (l1->radial_next->f == f2) { @@ -271,7 +273,7 @@ BMFace *BM_Join_TwoFaces(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) break; } l1 = l1->next; - } while (l1!=bm_firstfaceloop(f1)); + } while (l1 != bm_firstfaceloop(f1)); } if (!jed) { @@ -296,14 +298,14 @@ BMFace *BM_Join_TwoFaces(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) return f1; } -/*connects two verts together, automatically (if very naively) finding the - face they both share (if there is one) and splittling it. use this at your - own risk, as it doesn't handle the many complex cases it should (like zero-area faces, - multiple faces, etc). - - this is really only meant for cases where you don't know before hand the face - the two verts belong to for splitting (e.g. the subdivision operator). -*/ +/* connects two verts together, automatically (if very naively) finding the + * face they both share (if there is one) and splittling it. use this at your + * own risk, as it doesn't handle the many complex cases it should (like zero-area faces, + * multiple faces, etc). + * + * this is really only meant for cases where you don't know before hand the face + * the two verts belong to for splitting (e.g. the subdivision operator). + */ BMEdge *BM_Connect_Verts(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **nf) { @@ -312,9 +314,9 @@ BMEdge *BM_Connect_Verts(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **nf) BMLoop *nl; BMFace *face; - /*be warned: this can do weird things in some ngon situation, see BM_LegalSplits*/ - for (face = BMIter_New(&iter, bm, BM_FACES_OF_VERT, v1); face; face=BMIter_Step(&iter)) { - for (v=BMIter_New(&iter2, bm, BM_VERTS_OF_FACE, face); v; v=BMIter_Step(&iter2)) { + /* be warned: this can do weird things in some ngon situation, see BM_LegalSplit */ + for (face = BMIter_New(&iter, bm, BM_FACES_OF_VERT, v1); face; face = BMIter_Step(&iter)) { + for (v = BMIter_New(&iter2, bm, BM_VERTS_OF_FACE, face); v; v = BMIter_Step(&iter2)) { if (v == v2) { face = BM_Split_Face(bm, face, v1, v2, &nl, NULL); @@ -350,7 +352,7 @@ BMFace *BM_Split_Face(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **nl, const int has_mdisp = CustomData_has_layer(&bm->ldata, CD_MDISPS); BMFace *nf, *of; - /*do we have a multires layer?*/ + /* do we have a multires layer */ if (has_mdisp) { of = BM_Copy_Face(bm, f, 0, 0); } @@ -418,7 +420,7 @@ BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, con BMVert *tv2; BMIter iter; - BMLoop *l=NULL, *kvloop=NULL, *tvloop=NULL; + BMLoop *l = NULL, *kvloop = NULL, *tvloop = NULL; void *src[2]; float w[2]; @@ -440,9 +442,9 @@ BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, con src[0] = kvloop->head.data; src[1] = tvloop->head.data; - CustomData_bmesh_interp(&bm->ldata, src,w, NULL, 2, kvloop->head.data); + CustomData_bmesh_interp(&bm->ldata, src, w, NULL, 2, kvloop->head.data); } - l= l->radial_next; + l = l->radial_next; } while (l != ke->l); } @@ -497,7 +499,7 @@ BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, con BMEdge *BM_Collapse_Vert_Edges(BMesh *bm, BMEdge *ke, BMVert *kv) { /* nice example implimentation but we want loops to have their customdata - * accounted for.*/ + * accounted for */ #if 0 BMEdge *ne = NULL; @@ -514,7 +516,7 @@ BMEdge *BM_Collapse_Vert_Edges(BMesh *bm, BMEdge *ke, BMVert *kv) /* only action, other calls here only get the edge to return */ bmesh_jekv(bm, ke, kv); - ne= BM_Edge_Exist(tv, tv2); + ne = BM_Edge_Exist(tv, tv2); } } } @@ -548,11 +550,11 @@ BMVert *BM_Split_Edge(BMesh *bm, BMVert *v, BMEdge *e, BMEdge **ne, float percen BLI_array_staticdeclare(oldfaces, 32); SmallHash hash; - /*we need this for handling multires*/ + /* we need this for handling multire */ if (!ne) ne = &dummy; - /*do we have a multires layer?*/ + /* do we have a multires layer */ if (CustomData_has_layer(&bm->ldata, CD_MDISPS) && e->l) { BMLoop *l; int i; @@ -563,17 +565,17 @@ BMVert *BM_Split_Edge(BMesh *bm, BMVert *v, BMEdge *e, BMEdge **ne, float percen l = l->radial_next; } while (l != e->l); - /*create a hash so we can differentiate oldfaces from new faces*/ + /* create a hash so we can differentiate oldfaces from new face */ BLI_smallhash_init(&hash); - for (i=0; ico, v2->co, v->co); @@ -584,16 +586,16 @@ BMVert *BM_Split_Edge(BMesh *bm, BMVert *v, BMEdge *e, BMEdge **ne, float percen BM_Copy_Attributes(bm, bm, e, *ne); } - /*v->nv->v2*/ + /* v->nv->v2 */ BM_Data_Facevert_Edgeinterp(bm, v2, v, nv, e, percent); BM_Data_Interp_From_Verts(bm, v, v2, nv, percent); if (CustomData_has_layer(&bm->ldata, CD_MDISPS) && e->l && nv) { int i, j; - /*interpolate new/changed loop data from copied old faces*/ - for (j=0; j<2; j++) { - for (i=0; iv2, e, NULL, percent); } @@ -673,9 +675,9 @@ int BM_Validate_Face(BMesh *bm, BMFace *face, FILE *err) fflush(err); } - for (l=BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, face);l;l=BMIter_Step(&iter)) { + for (l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, face); l; l = BMIter_Step(&iter)) { BLI_array_growone(verts); - verts[BLI_array_count(verts)-1] = l->v; + verts[BLI_array_count(verts) - 1] = l->v; if (l->e->v1 == l->e->v2) { fprintf(err, "Found bmesh edge with identical verts!\n"); @@ -685,9 +687,12 @@ int BM_Validate_Face(BMesh *bm, BMFace *face, FILE *err) } } - for (i=0; ino' is handled by BM_Copy_Attributes */ if (co) copy_v3_v3(v->co, co); - /*allocate flags*/ + /* allocate flag */ v->head.flags = BLI_mempool_calloc(bm->toolflagpool); CustomData_bmesh_set_default(&bm->vdata, &v->head.data); if (example) { - BM_Copy_Attributes(bm, bm, (BMVert*)example, (BMVert*)v); + BM_Copy_Attributes(bm, bm, (BMVert *)example, (BMVert *)v); } BM_CHECK_ELEMENT(bm, v); - return (BMVert*) v; + return (BMVert *) v; } /** @@ -122,8 +122,8 @@ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, i { BMEdge *e; - if (nodouble && (e= BM_Edge_Exist(v1, v2))) - return (BMEdge*)e; + if (nodouble && (e = BM_Edge_Exist(v1, v2))) + return (BMEdge *)e; e = BLI_mempool_calloc(bm->epool); @@ -139,11 +139,11 @@ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, i e->head.htype = BM_EDGE; - /*allocate flags*/ + /* allocate flag */ e->head.flags = BLI_mempool_calloc(bm->toolflagpool); - e->v1 = (BMVert*) v1; - e->v2 = (BMVert*) v2; + e->v1 = (BMVert *) v1; + e->v2 = (BMVert *) v2; CustomData_bmesh_set_default(&bm->edata, &e->head.data); @@ -152,16 +152,16 @@ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, i bmesh_disk_append_edge(e, e->v2); if (example) - BM_Copy_Attributes(bm, bm, (BMEdge*)example, (BMEdge*)e); + BM_Copy_Attributes(bm, bm, (BMEdge *)example, (BMEdge *)e); BM_CHECK_ELEMENT(bm, e); - return (BMEdge*) e; + return (BMEdge *) e; } static BMLoop *bmesh_create_loop(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f, const BMLoop *example) { - BMLoop *l=NULL; + BMLoop *l = NULL; l = BLI_mempool_calloc(bm->lpool); l->next = l->prev = NULL; @@ -228,11 +228,11 @@ 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]; + v2 = verts[(i + 1) % f->len]; } else { v2 = verts[i]; - v1 = verts[(i+1)%f->len]; + v1 = verts[(i + 1) % f->len]; } e = BM_Make_Edge(bm, v1, v2, l->e, 0); @@ -268,7 +268,7 @@ BMFace *BM_Make_Face(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, i int i, overlap; if (len == 0) { - /*just return NULL for now*/ + /* just return NULL for no */ return NULL; } @@ -297,14 +297,14 @@ BMFace *BM_Make_Face(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, i f->head.htype = BM_FACE; - startl = lastl = BM_Add_FaceBoundary(bm, (BMFace*)f, verts[0], edges[0]); + startl = lastl = BM_Add_FaceBoundary(bm, (BMFace *)f, verts[0], edges[0]); - startl->v = (BMVert*) verts[0]; - startl->e = (BMEdge*) edges[0]; - for (i=1; iv = (BMVert *) verts[0]; + startl->e = (BMEdge *) edges[0]; + for (i = 1; i < len; i++) { l = bmesh_create_loop(bm, verts[i], edges[i], (BMFace *)f, edges[i]->l); - l->f = (BMFace*) f; + l->f = (BMFace *) f; bmesh_radial_append(edges[i], l); l->prev = lastl; @@ -312,7 +312,7 @@ BMFace *BM_Make_Face(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, i lastl = l; } - /*allocate flags*/ + /* allocate flag */ f->head.flags = BLI_mempool_calloc(bm->toolflagpool); CustomData_bmesh_set_default(&bm->pdata, &f->head.data); @@ -325,7 +325,7 @@ BMFace *BM_Make_Face(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, i BM_CHECK_ELEMENT(bm, f); - return (BMFace*) f; + return (BMFace *) f; } int bmesh_check_element(BMesh *UNUSED(bm), void *element, const char htype) @@ -377,12 +377,12 @@ int bmesh_check_element(BMesh *UNUSED(bm), void *element, const char htype) } if (l->radial_next == NULL || l->radial_prev == NULL) - err |= (1<<12); + err |= (1 << 12); if (l->f->len <= 0) - err |= (1<<13); + err |= (1 << 13); - /*validate boundary loop--invalid for hole loops, of course, - but we won't be allowing those for a while yet*/ + /* validate boundary loop--invalid for hole loops, of course, + but we won't be allowing those for a while ye */ l2 = l; i = 0; do { @@ -394,47 +394,47 @@ int bmesh_check_element(BMesh *UNUSED(bm), void *element, const char htype) } while (l2 != l); if (i != l->f->len || l2 != l) - err |= (1<<14); + err |= (1 << 14); if (!bmesh_radial_validate(bmesh_radial_length(l), l)) - err |= (1<<15); + err |= (1 << 15); break; } case BM_FACE: { BMFace *f = element; BMLoop *l; - int len=0; + int len = 0; if (!f->loops.first) - err |= (1<<16); + err |= (1 << 16); l = bm_firstfaceloop(f); do { if (l->f != f) { fprintf(stderr, "%s: loop inside one face points to another! (bmesh internal error)\n", __func__); - err |= (1<<17); + err |= (1 << 17); } if (!l->e) - err |= (1<<18); + err |= (1 << 18); if (!l->v) - err |= (1<<19); + err |= (1 << 19); if (!BM_Vert_In_Edge(l->e, l->v) || !BM_Vert_In_Edge(l->e, l->next->v)) { - err |= (1<<20); + err |= (1 << 20); } if (!bmesh_radial_validate(bmesh_radial_length(l), l)) - err |= (1<<21); + err |= (1 << 21); if (!bmesh_disk_count(l->v) || !bmesh_disk_count(l->next->v)) - err |= (1<<22); + err |= (1 << 22); len++; l = l->next; } while (l != bm_firstfaceloop(f)); if (len != f->len) - err |= (1<<23); + err |= (1 << 23); } } @@ -515,7 +515,7 @@ void BM_Kill_Face_Edges(BMesh *bm, BMFace *f) l = l->next; } while (l != bm_firstfaceloop(f)); - for (i=0; inext; } while (l != bm_firstfaceloop(f)); - for (i=0; iloops.first; ls; ls=lsnext) { + for (ls = f->loops.first; ls; ls = lsnext) { BMLoop *l, *lnext; lsnext = ls->next; @@ -575,7 +575,7 @@ void BM_Kill_Edge(BMesh *bm, BMEdge *e) bmesh_disk_remove_edge(e, e->v2); if (e->l) { - BMLoop *l = e->l, *lnext, *startl=e->l; + BMLoop *l = e->l, *lnext, *startl = e->l; do { lnext = l->radial_next; @@ -611,7 +611,7 @@ void BM_Kill_Vert(BMesh *bm, BMVert *v) bmesh_kill_only_vert(bm, v); } -/********** private disk and radial cycle functions ************/ +/********** private disk and radial cycle functions ********** */ /** * bmesh_loop_reverse @@ -651,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++) { + /* actually reverse the loop */ + for (i = 0, curloop = l; i < len; i++) { oldnext = curloop->next; oldprev = curloop->prev; curloop->next = oldprev; @@ -673,12 +673,12 @@ static int bmesh_loop_reverse_loop(BMesh *bm, BMFace *f, BMLoopList *lst) if (!md->totdisp || !md->disps) continue; - sides= (int)sqrt(md->totdisp); + sides = (int)sqrt(md->totdisp); co = md->disps; - for (x=0; xnext->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) { curloop->e = edar[j]; @@ -701,12 +701,12 @@ 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) + /* rebuild radia */ + 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) { + /* validate radia */ + 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); @@ -730,7 +730,7 @@ static void bmesh_systag_elements(BMesh *UNUSED(bm), void *veles, int tot, int f BMHeader **eles = veles; int i; - for (i=0; ie; - int i=0; + int i = 0; if (!e) return 0; @@ -844,10 +844,10 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE); BLI_array_staticdeclare(deledges, BM_NGON_STACK_SIZE); BLI_array_staticdeclare(delverts, BM_NGON_STACK_SIZE); - BMVert *v1=NULL, *v2=NULL; + BMVert *v1 = NULL, *v2 = NULL; ListBase holes = {NULL, NULL}; const char *err = NULL; - int i, tote=0; + int i, tote = 0; if (!totface) { bmesh_error(); @@ -859,7 +859,7 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) bmesh_systag_elements(bm, faces, totface, _FLAG_JF); - for (i=0; inext; } while (l != bm_firstfaceloop(f)); - for (lst=f->loops.first; lst; lst=lst->next) { + for (lst = f->loops.first; lst; lst = lst->next) { if (lst == f->loops.first) continue; BLI_remlink(&f->loops, lst); @@ -912,7 +912,7 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) } } - /*create region face*/ + /* create region fac */ newf = BM_Make_Ngon(bm, v1, v2, edges, tote, 0); if (!newf || BMO_HasError(bm)) { if (!BMO_HasError(bm)) @@ -920,7 +920,7 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) goto error; } - /*copy over loop data*/ + /* copy over loop dat */ l = bm_firstfaceloop(newf); do { BMLoop *l2 = l->radial_next; @@ -932,7 +932,7 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) } while (l2 != l); if (l2 != l) { - /*I think this is correct?*/ + /* I think this is correct */ if (l2->v != l->v) { l2 = l2->next; } @@ -945,11 +945,11 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) BM_Copy_Attributes(bm, bm, faces[0], newf); - /*add holes*/ + /* add hole */ BLI_movelisttolist(&newf->loops, &holes); - /*update loop face pointers*/ - for (lst=newf->loops.first; lst; lst=lst->next) { + /* update loop face pointer */ + for (lst = newf->loops.first; lst; lst = lst->next) { l = lst->first; do { l->f = newf; @@ -960,11 +960,11 @@ BMFace *BM_Join_Faces(BMesh *bm, BMFace **faces, int totface) bmesh_clear_systag_elements(bm, faces, totface, _FLAG_JF); bmesh_api_clearflag(newf, _FLAG_JF); - /* handle multires data*/ + /* handle multires dat */ if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) { l = bm_firstfaceloop(newf); do { - for (i=0; itotface++; - /*allocate flags*/ + /* allocate flag */ f->head.flags = BLI_mempool_calloc(bm->toolflagpool); CustomData_bmesh_set_default(&bm->pdata, &f->head.data); @@ -1028,7 +1028,7 @@ static BMFace *bmesh_addpolylist(BMesh *bm, BMFace *UNUSED(example)) f->len = 0; f->totbounds = 1; - return (BMFace*) f; + return (BMFace *) f; } /** @@ -1073,12 +1073,12 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, { BMFace *f2; - BMLoop *v1loop = NULL, *v2loop = NULL, *curloop, *f1loop=NULL, *f2loop=NULL; + BMLoop *v1loop = NULL, *v2loop = NULL, *curloop, *f1loop = NULL, *f2loop = NULL; BMEdge *e; BMLoopList *lst, *lst2; int i, len, f1len, f2len; - /*verify that v1 and v2 are in face.*/ + /* 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; @@ -1087,12 +1087,12 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, if (!v1loop || !v2loop) return NULL; - /*allocate new edge between v1 and v2*/ + /* allocate new edge between v1 and v2 */ e = BM_Make_Edge(bm, v1, v2, NULL, 0); - f2 = bmesh_addpolylist(bm,f); - f1loop = bmesh_create_loop(bm,v2,e,f,v2loop); - f2loop = bmesh_create_loop(bm,v1,e,f2,v1loop); + f2 = bmesh_addpolylist(bm, f); + f1loop = bmesh_create_loop(bm, v2, e, f, v2loop); + f2loop = bmesh_create_loop(bm, v1, e, f2, v1loop); f1loop->prev = v2loop->prev; f2loop->prev = v1loop->prev; @@ -1110,10 +1110,10 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, lst2->first = lst2->last = f2loop; lst->first = lst->last = f1loop; - /*validate both loops*/ - /*I dont know how many loops are supposed to be in each face at this point! FIXME!*/ + /* validate both loop */ + /* I dont know how many loops are supposed to be in each face at this point! FIXME */ - /*go through all of f2's loops and make sure they point to it properly.*/ + /* go through all of f2's loops and make sure they point to it properly */ curloop = lst2->first; f2len = 0; do { @@ -1123,7 +1123,7 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, f2len++; } while (curloop != lst2->first); - /*link up the new loops into the new edges radial*/ + /* link up the new loops into the new edges radia */ bmesh_radial_append(e, f1loop); bmesh_radial_append(e, f2loop); @@ -1144,9 +1144,9 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BLI_movelisttolist(&f2->loops, holes); } else { - /* this code is not significant until holes actually work ;) */ + /* 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) { + for (lst = f->loops.last; lst != f->loops.first; lst = lst2) { lst2 = lst->prev; BLI_mempool_free(bm->looplistpool, lst); } @@ -1172,22 +1172,24 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, * Returns - * BMVert pointer. * -*/ + */ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) { BMLoop *nextl; BMEdge *ne; BMVert *nv, *ov; - int i, edok, valence1=0, valence2=0; + int i, edok, valence1 = 0, valence2 = 0; - if (bmesh_vert_in_edge(e,tv) == 0) return NULL; - ov = bmesh_edge_getothervert(e,tv); + if (bmesh_vert_in_edge(e, tv) == 0) { + return NULL; + } + ov = bmesh_edge_getothervert(e, tv); - /*count valence of v1*/ + /* count valence of v1 */ valence1 = bmesh_disk_count(ov); - /*count valence of v2*/ + /* count valence of v2 */ valence2 = bmesh_disk_count(tv); nv = BM_Make_Vert(bm, tv->co, tv); @@ -1196,22 +1198,22 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) bmesh_disk_remove_edge(ne, tv); bmesh_disk_remove_edge(ne, nv); - /*remove e from v2's disk cycle*/ + /* remove e from v2's disk cycle */ bmesh_disk_remove_edge(e, tv); - /*swap out tv for nv in e*/ + /* swap out tv for nv in e */ bmesh_edge_swapverts(e, tv, nv); - /*add e to nv's disk cycle*/ + /* add e to nv's disk cycl */ bmesh_disk_append_edge(e, nv); - /*add ne to nv's disk cycle*/ + /* add ne to nv's disk cycl */ bmesh_disk_append_edge(ne, nv); - /*add ne to tv's disk cycle*/ + /* add ne to tv's disk cycl */ bmesh_disk_append_edge(ne, tv); - /*verify disk cycles*/ + /* verify disk cycle */ edok = bmesh_disk_validate(valence1, ov->e, ov); if (!edok) bmesh_error(); edok = bmesh_disk_validate(valence2, tv->e, tv); @@ -1219,34 +1221,34 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) edok = bmesh_disk_validate(2, nv->e, nv); if (!edok) bmesh_error(); - /*Split the radial cycle if present*/ + /* Split the radial cycle if presen */ nextl = e->l; e->l = NULL; if (nextl) { BMLoop *nl, *l; int radlen = bmesh_radial_length(nextl); - int first1=0, first2=0; + int first1 = 0, first2 = 0; - /*Take the next loop. Remove it from radial. Split it. Append to appropriate radials.*/ + /* Take the next loop. Remove it from radial. Split it. Append to appropriate radials */ while (nextl) { - l=nextl; + l = nextl; l->f->len++; - nextl = nextl!=nextl->radial_next ? nextl->radial_next : NULL; + nextl = nextl != nextl->radial_next ? nextl->radial_next : NULL; bmesh_radial_remove_loop(l, NULL); - nl = bmesh_create_loop(bm,NULL,NULL,l->f,l); + nl = bmesh_create_loop(bm, NULL, NULL, l->f, l); nl->prev = l; nl->next = (l->next); nl->prev->next = nl; nl->next->prev = nl; nl->v = nv; - /*assign the correct edge to the correct loop*/ + /* assign the correct edge to the correct loo */ if (bmesh_verts_in_edge(nl->v, nl->next->v, e)) { nl->e = e; l->e = ne; - /*append l into ne's rad cycle*/ + /* append l into ne's rad cycl */ if (!first1) { first1 = 1; l->radial_next = l->radial_prev = NULL; @@ -1264,7 +1266,7 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) nl->e = ne; l->e = e; - /*append l into ne's rad cycle*/ + /* append l into ne's rad cycl */ if (!first1) { first1 = 1; l->radial_next = l->radial_prev = NULL; @@ -1281,14 +1283,14 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) } - /*verify length of radial cycle*/ + /* verify length of radial cycl */ edok = bmesh_radial_validate(radlen, e->l); if (!edok) bmesh_error(); edok = bmesh_radial_validate(radlen, ne->l); 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) { + /* verify loop->v and loop->next->v pointers for */ + 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(); @@ -1297,14 +1299,14 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **re) if (l->v == l->next->v) bmesh_error(); if (l->e == l->next->e) bmesh_error(); - /*verify loop cycle for kloop->f*/ + /* verify loop cycle for kloop-> */ BM_CHECK_ELEMENT(bm, l); BM_CHECK_ELEMENT(bm, l->v); BM_CHECK_ELEMENT(bm, l->e); 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) { + /* verify loop->v and loop->next->v pointers for n */ + 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(); @@ -1366,40 +1368,43 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) BMEdge *oe; BMVert *ov, *tv; BMLoop *killoop, *l; - int len,radlen=0, halt = 0, i, valence1, valence2,edok; + 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) { 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*/ + halt = bmesh_verts_in_edge(kv, tv, oe); /* check for double edge */ if (halt) { return 0; } else { - /*For verification later, count valence of ov and tv*/ + /* For verification later, count valence of ov and t */ valence1 = bmesh_disk_count(ov); valence2 = bmesh_disk_count(tv); - /*remove oe from kv's disk cycle*/ - bmesh_disk_remove_edge(oe,kv); - /*relink oe->kv to be oe->tv*/ + /* remove oe from kv's disk cycl */ + bmesh_disk_remove_edge(oe, kv); + /* relink oe->kv to be oe->t */ bmesh_edge_swapverts(oe, kv, tv); - /*append oe to tv's disk cycle*/ + /* append oe to tv's disk cycl */ bmesh_disk_append_edge(oe, tv); - /*remove ke from tv's disk cycle*/ + /* remove ke from tv's disk cycl */ bmesh_disk_remove_edge(ke, tv); - /*deal with radial cycle of ke*/ + /* deal with radial cycle of k */ radlen = bmesh_radial_length(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; il; i < radlen; i++, killoop = bmesh_radial_nextloop(killoop)) { + /* relink loops and fix vertex pointer */ if (killoop->next->v == kv) killoop->next->v = tv; killoop->next->prev = killoop->prev; @@ -1409,10 +1414,10 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) killoop->next = NULL; killoop->prev = NULL; - /*fix len attribute of face*/ + /* fix len attribute of fac */ killoop->f->len--; } - /*second step, remove all the hanging loops attached to ke*/ + /* second step, remove all the hanging loops attached to k */ radlen = bmesh_radial_length(ke->l); if (LIKELY(radlen)) { @@ -1421,7 +1426,7 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) killoop = ke->l; - /*this should be wrapped into a bme_free_radial function to be used by bmesh_KF as well...*/ + /* this should be wrapped into a bme_free_radial function to be used by bmesh_KF as well.. */ for (i = 0; i < radlen; i++) { loops[i] = killoop; killoop = bmesh_radial_nextloop(killoop); @@ -1433,26 +1438,27 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) BLI_array_fixedstack_free(loops); } - /*Validate radial cycle of oe*/ - edok = bmesh_radial_validate(radlen,oe->l); - if (!edok) bmesh_error(); - + /* Validate radial cycle of o */ + edok = bmesh_radial_validate(radlen, oe->l); + if (!edok) { + bmesh_error(); + } } - /*deallocate edge*/ + /* deallocate edg */ bmesh_kill_only_edge(bm, ke); - /*deallocate vertex*/ + /* deallocate verte */ bmesh_kill_only_vert(bm, kv); - /*Validate disk cycle lengths of ov,tv are unchanged*/ + /* Validate disk cycle lengths of ov, tv are unchange */ edok = bmesh_disk_validate(valence1, ov->e, ov); if (!edok) bmesh_error(); edok = bmesh_disk_validate(valence2, tv->e, tv); if (!edok) bmesh_error(); - /*Validate loop cycle of all faces attached to oe*/ - for (i=0,l = oe->l; il; 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(); @@ -1505,16 +1511,19 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) * * Returns - * A BMFace pointer -*/ + */ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) { - BMLoop *curloop, *f1loop=NULL, *f2loop=NULL; - int newlen = 0,i, f1len=0, f2len=0, radlen=0, edok, shared; + BMLoop *curloop, *f1loop = NULL, *f2loop = NULL; + int newlen = 0, i, f1len = 0, f2len = 0, radlen = 0, edok, shared; BMIter iter; - /*can't join a face to itself*/ - if (f1 == f2) return NULL; - /*verify that e is in both f1 and f2*/ + /* can't join a face to itsel */ + 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) { @@ -1529,77 +1538,90 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) break; } } - if (!(f1loop && f2loop)) return NULL; + if (!(f1loop && f2loop)) { + return NULL; + } - /*validate that edge is 2-manifold edge*/ + /* validate that edge is 2-manifold edg */ radlen = bmesh_radial_length(f1loop); - if (radlen != 2) return NULL; + if (radlen != 2) { + return NULL; + } - /*validate direction of f2's loop cycle is compatible.*/ + /* validate direction of f2's loop cycle is compatible */ 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; - - /*validate only one shared edge*/ - shared = BM_Face_Share_Edges(f1,f2); - if (shared > 1) return NULL; - - /*validate no internal joins*/ - 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) - bmesh_api_setindex(curloop->v, 0); - - 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) { - if (curloop != f2loop) - bmesh_api_setindex(curloop->v, bmesh_api_getindex(curloop->v) + 1); + /* 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) || + bmesh_radial_find_face(f1loop->prev->e, f2) || + bmesh_radial_find_face(f2loop->next->e, f1) || + bmesh_radial_find_face(f2loop->prev->e, f1) ) + { + return NULL; } - for (i=0, curloop = bm_firstfaceloop(f1); i < f1len; i++, curloop = curloop->next) { - if (bmesh_api_getindex(curloop->v) > 1) + /* validate only one shared edg */ + shared = BM_Face_Share_Edges(f1, f2); + if (shared > 1) { + return NULL; + } + + /* validate no internal join */ + 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) { + bmesh_api_setindex(curloop->v, 0); + } + + 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) { + 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) { + if (bmesh_api_getindex(curloop->v) > 1) { return NULL; + } } - for (i=0, curloop = bm_firstfaceloop(f2); i < f2len; i++, curloop = curloop->next) { - if (bmesh_api_getindex(curloop->v) > 1) + for (i = 0, curloop = bm_firstfaceloop(f2); i < f2len; i++, curloop = curloop->next) { + if (bmesh_api_getindex(curloop->v) > 1) { return NULL; + } } - /*join the two loops*/ + /* join the two loop */ f1loop->prev->next = f2loop->next; f2loop->next->prev = f1loop->prev; f1loop->next->prev = f2loop->prev; f2loop->prev->next = f1loop->next; - /*if f1loop was baseloop, make f1loop->next the base.*/ + /* if f1loop was baseloop, make f1loop->next the base. */ if (bm_firstfaceloop(f1) == f1loop) bm_firstfaceloop(f1) = f1loop->next; - /*increase length of f1*/ + /* increase length of f1 */ f1->len += (f2->len - 2); - /*make sure each loop points to the proper face*/ + /* make sure each loop points to the proper fac */ newlen = f1->len; 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.*/ + /* remove edge from the disk cycle of its two vertices */ bmesh_disk_remove_edge(f1loop->e, f1loop->e->v1); bmesh_disk_remove_edge(f1loop->e, f1loop->e->v2); - /*deallocate edge and its two loops as well as f2*/ + /* deallocate edge and its two loops as well as f2 */ BLI_mempool_free(bm->toolflagpool, f1loop->e->head.flags); BLI_mempool_free(bm->epool, f1loop->e); bm->totedge--; @@ -1615,7 +1637,7 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) BM_CHECK_ELEMENT(bm, f1); - /*validate the new loop cycle*/ + /* validate the new loop cycle */ edok = bmesh_loop_validate(f1); if (!edok) bmesh_error(); diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index d0d85f7fb0d..eae81ab6954 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -59,45 +59,44 @@ #include -/* -ok, I'm going to write a little docgen script. so all -bmop comments must conform to the following template/rules: - -template (py quotes used because nested comments don't work -on all C compilers): - -""" -Region Extend. - -paragraph1, Extends bleh bleh bleh. -Bleh Bleh bleh. - -Another paragraph. - -Another paragraph. -""" - -so the first line is the "title" of the bmop. -subsequent line blocks seperated by blank lines -are paragraphs. individual descriptions of slots -would be extracted from comments -next to them, e.g. - -{BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, //output slot, boundary region - -the doc generator would automatically detect the presence of "output slot" -and flag the slot as an output. the same happens for "input slot". also -note that "edges", "faces", "verts", "loops", and "geometry" are valid -substitutions for "slot". - -note that slots default to being input slots. -*/ +/* ok, I'm going to write a little docgen script. so all + * bmop comments must conform to the following template/rules: + * + * template (py quotes used because nested comments don't work + * on all C compilers): + * + * """ + * Region Extend. + * + * paragraph1, Extends bleh bleh bleh. + * Bleh Bleh bleh. + * + * Another paragraph. + * + * Another paragraph. + * """ + * + * so the first line is the "title" of the bmop. + * subsequent line blocks seperated by blank lines + * are paragraphs. individual descriptions of slots + * would be extracted from comments + * next to them, e.g. + * + * {BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, //output slot, boundary region + * + * the doc generator would automatically detect the presence of "output slot" + * and flag the slot as an output. the same happens for "input slot". also + * note that "edges", "faces", "verts", "loops", and "geometry" are valid + * substitutions for "slot". + * + * note that slots default to being input slots. + */ /* - Vertex Smooth - - Smoothes vertices by using a basic vertex averaging scheme. -*/ + * Vertex Smooth + * + * Smoothes vertices by using a basic vertex averaging scheme. + */ static BMOpDefine def_vertexsmooth = { "vertexsmooth", {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, //input vertices @@ -105,106 +104,106 @@ static BMOpDefine def_vertexsmooth = { {BMOP_OPSLOT_INT, "mirror_clip_y"}, //set vertices close to the y axis before the operation to 0 {BMOP_OPSLOT_INT, "mirror_clip_z"}, //set vertices close to the z axis before the operation to 0 {BMOP_OPSLOT_FLT, "clipdist"}, //clipping threshod for the above three slots - {0} /*null-terminating sentinel*/, + {0} /* null-terminating sentine */, }, bmesh_vertexsmooth_exec, 0 }; /* - Right-Hand Faces - - Computes an "outside" normal for the specified input faces. -*/ + * Right-Hand Faces + * + * Computes an "outside" normal for the specified input faces. + */ static BMOpDefine def_righthandfaces = { "righthandfaces", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, {BMOP_OPSLOT_INT, "doflip"}, //internal flag, used by bmesh_rationalize_normals - {0} /*null-terminating sentinel*/, + {0} /* null-terminating sentine */, }, bmesh_righthandfaces_exec, BMOP_UNTAN_MULTIRES, }; /* - Region Extend - - used to implement the select more/less tools. - this puts some geometry surrounding regions of - geometry in geom into geomout. - - if usefaces is 0 then geomout spits out verts and edges, - otherwise it spits out faces. - */ + * Region Extend + * + * used to implement the select more/less tools. + * this puts some geometry surrounding regions of + * geometry in geom into geomout. + * + * if usefaces is 0 then geomout spits out verts and edges, + * otherwise it spits out faces. + */ static BMOpDefine def_regionextend = { "regionextend", {{BMOP_OPSLOT_ELEMENT_BUF, "geom"}, //input geometry {BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, //output slot, computed boundary geometry. {BMOP_OPSLOT_INT, "constrict"}, //find boundary inside the regions, not outside. {BMOP_OPSLOT_INT, "usefaces"}, //extend from faces instead of edges - {0} /*null-terminating sentinel*/, + {0} /* null-terminating sentine */, }, bmesh_regionextend_exec, 0 }; /* - Edge Rotate - - Rotates edges topologically. Also known as "spin edge" to some people. - Simple example: [/] becomes [|] then [\]. -*/ + * Edge Rotate + * + * Rotates edges topologically. Also known as "spin edge" to some people. + * Simple example: [/] becomes [|] then [\]. + */ static BMOpDefine def_edgerotate = { "edgerotate", {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, //input edges {BMOP_OPSLOT_ELEMENT_BUF, "edgeout"}, //newly spun edges {BMOP_OPSLOT_INT, "ccw"}, //rotate edge counter-clockwise if true, othewise clockwise - {0} /*null-terminating sentinel*/, + {0} /* null-terminating sentine */, }, bmesh_edgerotate_exec, BMOP_UNTAN_MULTIRES }; /* - Reverse Faces - - Reverses the winding (vertex order) of faces. This has the effect of - flipping the normal. -*/ + * Reverse Faces + * + * Reverses the winding (vertex order) of faces. This has the effect of + * flipping the normal. + */ static BMOpDefine def_reversefaces = { "reversefaces", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, //input faces - {0} /*null-terminating sentinel*/, + {0} /* null-terminating sentine */, }, bmesh_reversefaces_exec, BMOP_UNTAN_MULTIRES, }; /* - Edge Bisect - - Splits input edges (but doesn't do anything else). - This creates a 2-valence vert. -*/ + * Edge Bisect + * + * Splits input edges (but doesn't do anything else). + * This creates a 2-valence vert. + */ static BMOpDefine def_edgebisect = { "edgebisect", {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, //input edges {BMOP_OPSLOT_INT, "numcuts"}, //number of cuts {BMOP_OPSLOT_ELEMENT_BUF, "outsplit"}, //newly created vertices and edges - {0} /*null-terminating sentinel*/, + {0} /* null-terminating sentine */, }, esplit_exec, BMOP_UNTAN_MULTIRES }; /* - Mirror - - Mirrors geometry along an axis. The resulting geometry is welded on using - mergedist. Pairs of original/mirrored vertices are welded using the mergedist - parameter (which defines the minimum distance for welding to happen). -*/ + * Mirror + * + * Mirrors geometry along an axis. The resulting geometry is welded on using + * mergedist. Pairs of original/mirrored vertices are welded using the mergedist + * parameter (which defines the minimum distance for welding to happen). + */ static BMOpDefine def_mirror = { "mirror", @@ -215,167 +214,166 @@ static BMOpDefine def_mirror = { {BMOP_OPSLOT_INT, "axis"}, //the axis to use, 0, 1, or 2 for x, y, z {BMOP_OPSLOT_INT, "mirror_u"}, //mirror UVs across the u axis {BMOP_OPSLOT_INT, "mirror_v"}, //mirror UVs across the v axis - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_mirror_exec, 0, }; /* - Find Doubles - - Takes input verts and find vertices they should weld to. Outputs a - mapping slot suitable for use with the weld verts bmop. -*/ + * Find Doubles + * + * Takes input verts and find vertices they should weld to. Outputs a + * mapping slot suitable for use with the weld verts bmop. + */ static BMOpDefine def_finddoubles = { "finddoubles", {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, //input vertices {BMOP_OPSLOT_ELEMENT_BUF, "keepverts"}, //list of verts to keep {BMOP_OPSLOT_FLT, "dist"}, //minimum distance {BMOP_OPSLOT_MAPPING, "targetmapout"}, - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_finddoubles_exec, 0, }; /* - Remove Doubles - - Finds groups of vertices closer then dist and merges them together, - using the weld verts bmop. -*/ + * Remove Doubles + * + * Finds groups of vertices closer then dist and merges them together, + * using the weld verts bmop. + */ static BMOpDefine def_removedoubles = { "removedoubles", {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, //input verts {BMOP_OPSLOT_FLT, "dist"}, //minimum distance - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_removedoubles_exec, BMOP_UNTAN_MULTIRES, }; /* - Auto Merge - - Finds groups of vertices closer then dist and merges them together, - using the weld verts bmop. The merges must go from a vert not in - verts to one in verts. -*/ + * Auto Merge + * + * Finds groups of vertices closer then dist and merges them together, + * using the weld verts bmop. The merges must go from a vert not in + * verts to one in verts. + */ static BMOpDefine def_automerge = { "automerge", {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, //input verts {BMOP_OPSLOT_FLT, "dist"}, //minimum distance - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_automerge_exec, BMOP_UNTAN_MULTIRES, }; /* - Collapse Connected - - Collapses connected vertices -*/ + * Collapse Connected + * + * Collapses connected vertices + */ static BMOpDefine def_collapse = { "collapse", - {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /*input edges*/ - {0, /*null-terminating sentinel*/}}, + {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /* input edge */ + {0, /* null-terminating sentine */}}, bmesh_collapse_exec, BMOP_UNTAN_MULTIRES, }; /* - Facedata point Merge - - Merge uv/vcols at a specific vertex. -*/ + * Facedata point Merge + * + * Merge uv/vcols at a specific vertex. + */ static BMOpDefine def_pointmerge_facedata = { "pointmerge_facedata", - {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, /*input vertices*/ - {BMOP_OPSLOT_ELEMENT_BUF, "snapv"}, /*snap vertex*/ - {0, /*null-terminating sentinel*/}}, + {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, /* input vertice */ + {BMOP_OPSLOT_ELEMENT_BUF, "snapv"}, /* snap verte */ + {0, /* null-terminating sentine */}}, bmesh_pointmerge_facedata_exec, 0, }; /* - Average Vertices Facevert Data - - Merge uv/vcols associated with the input vertices at - the bounding box center. (I know, it's not averaging but - the vert_snap_to_bb_center is just too long). -*/ + * Average Vertices Facevert Data + * + * Merge uv/vcols associated with the input vertices at + * the bounding box center. (I know, it's not averaging but + * the vert_snap_to_bb_center is just too long). + */ static BMOpDefine def_vert_average_facedata = { "vert_average_facedata", - {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, /*input vertices*/ - {0, /*null-terminating sentinel*/}}, + {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, /* input vertice */ + {0, /* null-terminating sentine */}}, bmesh_vert_average_facedata_exec, 0, }; /* - Point Merge - - Merge verts together at a point. -*/ + * Point Merge + * + * Merge verts together at a point. + */ static BMOpDefine def_pointmerge = { "pointmerge", - {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, /*input vertices*/ + {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, /* input vertice */ {BMOP_OPSLOT_VEC, "mergeco"}, - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_pointmerge_exec, BMOP_UNTAN_MULTIRES, }; /* - Collapse Connected UVs - - Collapses connected UV vertices. -*/ + * Collapse Connected UVs + * + * Collapses connected UV vertices. + */ static BMOpDefine def_collapse_uvs = { "collapse_uvs", - {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /*input edges*/ - {0, /*null-terminating sentinel*/}}, + {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /* input edge */ + {0, /* null-terminating sentine */}}, bmesh_collapsecon_exec, 0, }; /* - Weld Verts - - Welds verts together (kindof like remove doubles, merge, etc, all of which - use or will use this bmop). You pass in mappings from vertices to the vertices - they weld with. -*/ + * Weld Verts + * + * Welds verts together (kindof like remove doubles, merge, etc, all of which + * use or will use this bmop). You pass in mappings from vertices to the vertices + * they weld with. + */ static BMOpDefine def_weldverts = { "weldverts", - {{BMOP_OPSLOT_MAPPING, "targetmap"}, /*maps welded vertices to verts they should weld to.*/ - {0, /*null-terminating sentinel*/}}, + {{BMOP_OPSLOT_MAPPING, "targetmap"}, /* maps welded vertices to verts they should weld to */ + {0, /* null-terminating sentine */}}, bmesh_weldverts_exec, BMOP_UNTAN_MULTIRES, }; /* - Make Vertex - - Creates a single vertex; this bmop was necassary - for click-create-vertex. -*/ + * Make Vertex + * + * Creates a single vertex; this bmop was necassary + * for click-create-vertex. + */ static BMOpDefine def_makevert = { "makevert", {{BMOP_OPSLOT_VEC, "co"}, //the coordinate of the new vert {BMOP_OPSLOT_ELEMENT_BUF, "newvertout"}, //the new vert - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_makevert_exec, 0, }; /* - Join Triangles - - Tries to intelligently join triangles according - to various settings and stuff. - - */ -static BMOpDefine def_join_triangles= { + * Join Triangles + * + * Tries to intelligently join triangles according + * to various settings and stuff. + */ +static BMOpDefine def_join_triangles = { "join_triangles", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, //input geometry. {BMOP_OPSLOT_ELEMENT_BUF, "faceout"}, //joined faces @@ -384,225 +382,224 @@ static BMOpDefine def_join_triangles= { {BMOP_OPSLOT_INT, "compare_vcols"}, {BMOP_OPSLOT_INT, "compare_materials"}, {BMOP_OPSLOT_FLT, "limit"}, - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_jointriangles_exec, BMOP_UNTAN_MULTIRES, }; /* - Contextual Create - - This is basically fkey, it creates - new faces from vertices, makes stuff from edge nets, - makes wire edges, etc. It also dissolves - faces. - - Three verts become a triangle, four become a quad. Two - become a wire edge. - */ -static BMOpDefine def_contextual_create= { + * Contextual Create + * + * This is basically fkey, it creates + * new faces from vertices, makes stuff from edge nets, + * makes wire edges, etc. It also dissolves + * faces. + * + * Three verts become a triangle, four become a quad. Two + * become a wire edge. + */ +static BMOpDefine def_contextual_create = { "contextual_create", {{BMOP_OPSLOT_ELEMENT_BUF, "geom"}, //input geometry. {BMOP_OPSLOT_ELEMENT_BUF, "faceout"}, //newly-made face(s) - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_contextual_create_exec, BMOP_UNTAN_MULTIRES, }; /* - - Bridge edge loops with faces -*/ -static BMOpDefine def_bridge_loops= { + * Bridge edge loops with faces + */ +static BMOpDefine def_bridge_loops = { "bridge_loops", - {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /*input edges*/ - {BMOP_OPSLOT_ELEMENT_BUF, "faceout"}, /*new faces*/ - {0, /*null-terminating sentinel*/}}, + {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /* input edge */ + {BMOP_OPSLOT_ELEMENT_BUF, "faceout"}, /* new face */ + {0, /* null-terminating sentine */}}, bmesh_bridge_loops_exec, 0, }; -static BMOpDefine def_edgenet_fill= { +static BMOpDefine def_edgenet_fill = { "edgenet_fill", - {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /*input edges*/ - {BMOP_OPSLOT_MAPPING, "restrict"}, /*restricts edges to groups. maps edges to integers*/ + {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /* input edge */ + {BMOP_OPSLOT_MAPPING, "restrict"}, /* restricts edges to groups. maps edges to integer */ {BMOP_OPSLOT_INT, "use_restrict"}, - {BMOP_OPSLOT_ELEMENT_BUF, "excludefaces"}, /*list of faces to ignore for manifold checks*/ - {BMOP_OPSLOT_MAPPING, "faceout_groupmap"}, /*maps new faces to the group numbers they came from*/ - {BMOP_OPSLOT_ELEMENT_BUF, "faceout"}, /*new faces*/ - {0, /*null-terminating sentinel*/}}, + {BMOP_OPSLOT_ELEMENT_BUF, "excludefaces"}, /* list of faces to ignore for manifold check */ + {BMOP_OPSLOT_MAPPING, "faceout_groupmap"}, /* maps new faces to the group numbers they came fro */ + {BMOP_OPSLOT_ELEMENT_BUF, "faceout"}, /* new face */ + {0, /* null-terminating sentine */}}, bmesh_edgenet_fill_exec, 0, }; /* - Edgenet Prepare - - Identifies several useful edge loop cases and modifies them so - they'll become a face when edgenet_fill is called. The cases covered are: - - * One single loop; an edge is added to connect the ends - * Two loops; two edges are added to connect the endpoints (based on the - shortest distance between each endpont). -*/ -static BMOpDefine def_edgenet_prepare= { + * Edgenet Prepare + * + * Identifies several useful edge loop cases and modifies them so + * they'll become a face when edgenet_fill is called. The cases covered are: + * + * - One single loop; an edge is added to connect the ends + * - Two loops; two edges are added to connect the endpoints (based on the + * shortest distance between each endpont). + */ +static BMOpDefine def_edgenet_prepare = { "edgenet_prepare", {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, //input edges {BMOP_OPSLOT_ELEMENT_BUF, "edgeout"}, //new edges - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_edgenet_prepare, 0, }; /* - Rotate - - Rotate vertices around a center, using a 3x3 rotation - matrix. Equivilent of the old rotateflag function. -*/ + * Rotate + * + * Rotate vertices around a center, using a 3x3 rotation + * matrix. Equivilent of the old rotateflag function. + */ static BMOpDefine def_rotate = { "rotate", {{BMOP_OPSLOT_VEC, "cent"}, //center of rotation {BMOP_OPSLOT_MAT, "mat"}, //matrix defining rotation {BMOP_OPSLOT_ELEMENT_BUF, "verts"}, //input vertices - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_rotate_exec, 0, }; /* - Translate - - Translate vertices by an offset. Equivelent of the - old translateflag function. -*/ -static BMOpDefine def_translate= { + * Translate + * + * Translate vertices by an offset. Equivelent of the + * old translateflag function. + */ +static BMOpDefine def_translate = { "translate", {{BMOP_OPSLOT_VEC, "vec"}, //translation offset {BMOP_OPSLOT_ELEMENT_BUF, "verts"}, //input vertices - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_translate_exec, 0, }; /* - Scale - - Scales vertices by an offset. -*/ -static BMOpDefine def_scale= { + * Scale + * + * Scales vertices by an offset. + */ +static BMOpDefine def_scale = { "scale", {{BMOP_OPSLOT_VEC, "vec"}, //scale factor {BMOP_OPSLOT_ELEMENT_BUF, "verts"}, //input vertices - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_scale_exec, 0, }; /* - Transform - - Transforms a set of vertices by a matrix. Multiplies - the vertex coordinates with the matrix. -*/ + * Transform + * + * Transforms a set of vertices by a matrix. Multiplies + * the vertex coordinates with the matrix. + */ static BMOpDefine def_transform = { "transform", {{BMOP_OPSLOT_MAT, "mat"}, //transform matrix {BMOP_OPSLOT_ELEMENT_BUF, "verts"}, //input vertices - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_transform_exec, 0, }; /* - Object Load BMesh - - Loads a bmesh into an object/mesh. This is a "private" - bmop. -*/ + * Object Load BMesh + * + * Loads a bmesh into an object/mesh. This is a "private" + * bmop. + */ static BMOpDefine def_object_load_bmesh = { "object_load_bmesh", {{BMOP_OPSLOT_PNT, "scene"}, {BMOP_OPSLOT_PNT, "object"}, - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, object_load_bmesh_exec, 0, }; /* - BMesh to Mesh - - Converts a bmesh to a Mesh. This is reserved for exiting editmode. -*/ + * BMesh to Mesh + * + * Converts a bmesh to a Mesh. This is reserved for exiting editmode. + */ static BMOpDefine def_bmesh_to_mesh = { "bmesh_to_mesh", {{BMOP_OPSLOT_PNT, "mesh"}, //pointer to a mesh structure to fill in {BMOP_OPSLOT_PNT, "object"}, //pointer to an object structure {BMOP_OPSLOT_INT, "notesselation"}, //don't calculate mfaces - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_to_mesh_exec, 0, }; /* - Mesh to BMesh - - Load the contents of a mesh into the bmesh. this bmop is private, it's - reserved exclusively for entering editmode. -*/ + * Mesh to BMesh + * + * Load the contents of a mesh into the bmesh. this bmop is private, it's + * reserved exclusively for entering editmode. + */ static BMOpDefine def_mesh_to_bmesh = { "mesh_to_bmesh", {{BMOP_OPSLOT_PNT, "mesh"}, //pointer to a Mesh structure {BMOP_OPSLOT_PNT, "object"}, //pointer to an Object structure {BMOP_OPSLOT_INT, "set_shapekey"}, //load active shapekey coordinates into verts - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, mesh_to_bmesh_exec, 0 }; /* - Individual Face Extrude - - Extrudes faces individually. -*/ + * Individual Face Extrude + * + * Extrudes faces individually. + */ static BMOpDefine def_extrude_indivface = { "extrude_face_indiv", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, //input faces {BMOP_OPSLOT_ELEMENT_BUF, "faceout"}, //output faces {BMOP_OPSLOT_ELEMENT_BUF, "skirtout"}, //output skirt geometry, faces and edges - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_extrude_face_indiv_exec, 0 }; /* - Extrude Only Edges - - Extrudes Edges into faces, note that this is very simple, there's no fancy - winged extrusion. -*/ + * Extrude Only Edges + * + * Extrudes Edges into faces, note that this is very simple, there's no fancy + * winged extrusion. + */ static BMOpDefine def_extrude_onlyedge = { "extrude_edge_only", {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, //input vertices {BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, //output geometry - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_extrude_onlyedge_exec, 0 }; /* - Individual Vertex Extrude - - Extrudes wire edges from vertices. -*/ + * Individual Vertex Extrude + * + * Extrudes wire edges from vertices. + */ static BMOpDefine def_extrudeverts_indiv = { "extrude_vert_indiv", {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, //input vertices {BMOP_OPSLOT_ELEMENT_BUF, "edgeout"}, //output wire edges {BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output vertices - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, extrude_vert_indiv_exec, 0 }; @@ -611,7 +608,7 @@ static BMOpDefine def_connectverts = { "connectverts", {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, {BMOP_OPSLOT_ELEMENT_BUF, "edgeout"}, - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, connectverts_exec, BMOP_UNTAN_MULTIRES }; @@ -622,7 +619,7 @@ static BMOpDefine def_extrudefaceregion = { {BMOP_OPSLOT_MAPPING, "exclude"}, {BMOP_OPSLOT_INT, "alwayskeeporig"}, {BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, extrude_edge_context_exec, 0 }; @@ -630,7 +627,7 @@ static BMOpDefine def_extrudefaceregion = { static BMOpDefine def_dissolvevertsop = { "dissolveverts", {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, dissolveverts_exec, BMOP_UNTAN_MULTIRES }; @@ -639,7 +636,7 @@ static BMOpDefine def_dissolveedgessop = { "dissolveedges", {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, {BMOP_OPSLOT_ELEMENT_BUF, "regionout"}, - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, dissolveedges_exec, BMOP_UNTAN_MULTIRES }; @@ -648,7 +645,7 @@ static BMOpDefine def_dissolveedgeloopsop = { "dissolveedgeloop", {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, {BMOP_OPSLOT_ELEMENT_BUF, "regionout"}, - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, dissolve_edgeloop_exec, BMOP_UNTAN_MULTIRES }; @@ -657,7 +654,7 @@ static BMOpDefine def_dissolvefacesop = { "dissolvefaces", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, {BMOP_OPSLOT_ELEMENT_BUF, "regionout"}, - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, dissolvefaces_exec, BMOP_UNTAN_MULTIRES }; @@ -669,7 +666,7 @@ static BMOpDefine def_triangop = { {BMOP_OPSLOT_ELEMENT_BUF, "edgeout"}, {BMOP_OPSLOT_ELEMENT_BUF, "faceout"}, {BMOP_OPSLOT_MAPPING, "facemap"}, - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, triangulate_exec, BMOP_UNTAN_MULTIRES }; @@ -685,16 +682,16 @@ static BMOpDefine def_subdop = { {BMOP_OPSLOT_MAPPING, "custompatterns"}, {BMOP_OPSLOT_MAPPING, "edgepercents"}, - /*these next three can have multiple types of elements in them.*/ + /* these next three can have multiple types of elements in them */ {BMOP_OPSLOT_ELEMENT_BUF, "outinner"}, {BMOP_OPSLOT_ELEMENT_BUF, "outsplit"}, - {BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, /*contains all output geometry*/ + {BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, /* contains all output geometr */ {BMOP_OPSLOT_INT, "quadcornertype"}, //quad corner type, see bmesh_operators.h {BMOP_OPSLOT_INT, "gridfill"}, //fill in fully-selected faces with a grid {BMOP_OPSLOT_INT, "singleedge"}, //tesselate the case of one edge selected in a quad or triangle - {0} /*null-terminating sentinel*/, + {0} /* null-terminating sentine */, }, esubdivide_exec, BMOP_UNTAN_MULTIRES @@ -703,7 +700,7 @@ static BMOpDefine def_subdop = { static BMOpDefine def_delop = { "del", {{BMOP_OPSLOT_ELEMENT_BUF, "geom"}, {BMOP_OPSLOT_INT, "context"}, - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, delop_exec, 0 }; @@ -713,13 +710,13 @@ static BMOpDefine def_dupeop = { {{BMOP_OPSLOT_ELEMENT_BUF, "geom"}, {BMOP_OPSLOT_ELEMENT_BUF, "origout"}, {BMOP_OPSLOT_ELEMENT_BUF, "newout"}, - /*facemap maps from source faces to dupe - faces, and from dupe faces to source faces.*/ + /* facemap maps from source faces to dupe + * faces, and from dupe faces to source faces */ {BMOP_OPSLOT_MAPPING, "facemap"}, {BMOP_OPSLOT_MAPPING, "boundarymap"}, {BMOP_OPSLOT_MAPPING, "isovertmap"}, - {BMOP_OPSLOT_PNT, "dest"}, /*destination bmesh, if NULL will use current one*/ - {0} /*null-terminating sentinel*/}, + {BMOP_OPSLOT_PNT, "dest"}, /* destination bmesh, if NULL will use current on */ + {0} /* null-terminating sentine */}, dupeop_exec, 0 }; @@ -730,18 +727,18 @@ static BMOpDefine def_splitop = { {BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, {BMOP_OPSLOT_MAPPING, "boundarymap"}, {BMOP_OPSLOT_MAPPING, "isovertmap"}, - {BMOP_OPSLOT_PNT, "dest"}, /*destination bmesh, if NULL will use current one*/ - {0} /*null-terminating sentinel*/}, + {BMOP_OPSLOT_PNT, "dest"}, /* destination bmesh, if NULL will use current on */ + {0} /* null-terminating sentine */}, splitop_exec, 0 }; /* - Spin - - Extrude or duplicate geometry a number of times, - rotating and possibly translating after each step -*/ + * Spin + * + * Extrude or duplicate geometry a number of times, + * rotating and possibly translating after each step + */ static BMOpDefine def_spinop = { "spin", {{BMOP_OPSLOT_ELEMENT_BUF, "geom"}, @@ -752,146 +749,146 @@ static BMOpDefine def_spinop = { {BMOP_OPSLOT_FLT, "ang"}, /* total rotation angle (degrees) */ {BMOP_OPSLOT_INT, "steps"}, /* number of steps */ {BMOP_OPSLOT_INT, "dupli"}, /* duplicate or extrude? */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, spinop_exec, 0 }; /* - Similar faces search - - Find similar faces (area/material/perimeter....). -*/ + * Similar faces search + * + * Find similar faces (area/material/perimeter, ...). + */ static BMOpDefine def_similarfaces = { "similarfaces", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMOP_OPSLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMOP_OPSLOT_INT, "type"}, /* type of selection */ {BMOP_OPSLOT_FLT, "thresh"}, /* threshold of selection */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_similarfaces_exec, 0 }; /* - Similar edges search - - Find similar edges (length, direction, edge, seam,....). -*/ + * Similar edges search + * + * Find similar edges (length, direction, edge, seam, ...). + */ static BMOpDefine def_similaredges = { "similaredges", {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /* input edges */ {BMOP_OPSLOT_ELEMENT_BUF, "edgeout"}, /* output edges */ {BMOP_OPSLOT_INT, "type"}, /* type of selection */ {BMOP_OPSLOT_FLT, "thresh"}, /* threshold of selection */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_similaredges_exec, 0 }; /* - Similar vertices search - - Find similar vertices (normal, face, vertex group,....). -*/ + * Similar vertices search + * + * Find similar vertices (normal, face, vertex group, ...). + */ static BMOpDefine def_similarverts = { "similarverts", {{BMOP_OPSLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ {BMOP_OPSLOT_INT, "type"}, /* type of selection */ {BMOP_OPSLOT_FLT, "thresh"}, /* threshold of selection */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_similarverts_exec, 0 }; /* -** uv rotation -** cycle the uvs -*/ + * uv rotation + * cycle the uvs + */ static BMOpDefine def_meshrotateuvs = { "meshrotateuvs", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMOP_OPSLOT_INT, "dir"}, /* direction */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_rotateuvs_exec, 0 }; /* -** uv reverse -** reverse the uvs -*/ + * uv reverse + * reverse the uvs + */ static BMOpDefine def_meshreverseuvs = { "meshreverseuvs", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_reverseuvs_exec, 0 }; /* -** color rotation -** cycle the colors -*/ + * color rotation + * cycle the colors + */ static BMOpDefine def_meshrotatecolors = { "meshrotatecolors", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMOP_OPSLOT_INT, "dir"}, /* direction */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_rotatecolors_exec, 0 }; /* -** color reverse -** reverse the colors -*/ + * color reverse + * reverse the colors + */ static BMOpDefine def_meshreversecolors = { "meshreversecolors", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, /* input faces */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_reversecolors_exec, 0 }; /* - Similar vertices search - - Find similar vertices (normal, face, vertex group,....). -*/ + * Similar vertices search + * + * Find similar vertices (normal, face, vertex group, ...). + */ static BMOpDefine def_vertexshortestpath = { "vertexshortestpath", {{BMOP_OPSLOT_ELEMENT_BUF, "startv"}, /* start vertex */ {BMOP_OPSLOT_ELEMENT_BUF, "endv"}, /* end vertex */ {BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ {BMOP_OPSLOT_INT, "type"}, /* type of selection */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_vertexshortestpath_exec, 0 }; /* - Edge Split - - Disconnects faces along input edges. + * Edge Split + * + * Disconnects faces along input edges. */ static BMOpDefine def_edgesplit = { "edgesplit", {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /* input edges */ {BMOP_OPSLOT_ELEMENT_BUF, "edgeout1"}, /* old output disconnected edges */ {BMOP_OPSLOT_ELEMENT_BUF, "edgeout2"}, /* new output disconnected edges */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_edgesplitop_exec, BMOP_UNTAN_MULTIRES }; /* - Create Grid - - Creates a grid with a variable number of subdivisions -*/ + * Create Grid + * + * Creates a grid with a variable number of subdivisions + */ static BMOpDefine def_create_grid = { "create_grid", {{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts @@ -899,16 +896,16 @@ static BMOpDefine def_create_grid = { {BMOP_OPSLOT_INT, "ysegments"}, //number of y segments {BMOP_OPSLOT_FLT, "size"}, //size of the grid {BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_create_grid_exec, 0, }; /* - Create UV Sphere - - Creates a grid with a variable number of subdivisions -*/ + * Create UV Sphere + * + * Creates a grid with a variable number of subdivisions + */ static BMOpDefine def_create_uvsphere = { "create_uvsphere", {{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts @@ -916,46 +913,46 @@ static BMOpDefine def_create_uvsphere = { {BMOP_OPSLOT_INT, "revolutions"}, //number of v segment {BMOP_OPSLOT_FLT, "diameter"}, //diameter {BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_create_uvsphere_exec, 0, }; /* - Create Ico Sphere - - Creates a grid with a variable number of subdivisions -*/ + * Create Ico Sphere + * + * Creates a grid with a variable number of subdivisions + */ static BMOpDefine def_create_icosphere = { "create_icosphere", {{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts {BMOP_OPSLOT_INT, "subdivisions"}, //how many times to recursively subdivide the sphere {BMOP_OPSLOT_FLT, "diameter"}, //diameter {BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_create_icosphere_exec, 0, }; /* - Create Suzanne - - Creates a monkey. Be wary. -*/ + * Create Suzanne + * + * Creates a monkey. Be wary. + */ static BMOpDefine def_create_monkey = { "create_monkey", {{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts {BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_create_monkey_exec, 0, }; /* - Create Cone - - Creates a cone with variable depth at both ends -*/ + * Create Cone + * + * Creates a cone with variable depth at both ends + */ static BMOpDefine def_create_cone = { "create_cone", {{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts @@ -966,14 +963,14 @@ static BMOpDefine def_create_cone = { {BMOP_OPSLOT_FLT, "diameter2"}, //diameter of the opposite {BMOP_OPSLOT_FLT, "depth"}, //distance between ends {BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_create_cone_exec, 0, }; /* -Creates a circle -*/ + * Creates a circle + */ static BMOpDefine def_create_circle = { "create_circle", {{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts @@ -982,81 +979,81 @@ static BMOpDefine def_create_circle = { {BMOP_OPSLOT_INT, "segments"}, {BMOP_OPSLOT_FLT, "diameter"}, //diameter of one end {BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_create_circle_exec, 0, }; /* - Create Cone - - Creates a cone with variable depth at both ends -*/ + * Create Cone + * + * Creates a cone with variable depth at both ends + */ static BMOpDefine def_create_cube = { "create_cube", {{BMOP_OPSLOT_ELEMENT_BUF, "vertout"}, //output verts {BMOP_OPSLOT_FLT, "size"}, //size of the cube {BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with-- - {0, /*null-terminating sentinel*/}}, + {0, /* null-terminating sentine */}}, bmesh_create_cube_exec, 0, }; /* - Bevel - - Bevels edges and vertices + * Bevel + * + * Bevels edges and vertices */ static BMOpDefine def_bevel = { "bevel", {{BMOP_OPSLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */ {BMOP_OPSLOT_ELEMENT_BUF, "face_spans"}, /* new geometry */ {BMOP_OPSLOT_ELEMENT_BUF, "face_holes"}, /* new geometry */ - {BMOP_OPSLOT_INT, "use_lengths"}, /* grab edge lengths from a PROP_FLT customdata layer*/ + {BMOP_OPSLOT_INT, "use_lengths"}, /* grab edge lengths from a PROP_FLT customdata laye */ {BMOP_OPSLOT_INT, "use_even"}, /* corner vert placement: use shell/angle calculations */ {BMOP_OPSLOT_INT, "use_dist"}, /* corner vert placement: evaluate percent as a distance, * modifier uses this. We could do this as another float setting */ - {BMOP_OPSLOT_INT, "lengthlayer"}, /* which PROP_FLT layer to use*/ - {BMOP_OPSLOT_FLT, "percent"}, /* percentage to expand bevelled edges*/ - {0} /*null-terminating sentinel*/}, + {BMOP_OPSLOT_INT, "lengthlayer"}, /* which PROP_FLT layer to us */ + {BMOP_OPSLOT_FLT, "percent"}, /* percentage to expand bevelled edge */ + {0} /* null-terminating sentine */}, bmesh_bevel_exec, BMOP_UNTAN_MULTIRES }; /* - Beautify Fill - - Makes triangle a bit nicer + * Beautify Fill + * + * Makes triangle a bit nicer */ static BMOpDefine def_beautify_fill = { "beautify_fill", {{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMOP_OPSLOT_ELEMENT_BUF, "constrain_edges"}, /* edges that can't be flipped */ {BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, /* new flipped faces and edges */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_beautify_fill_exec, BMOP_UNTAN_MULTIRES }; /* - Triangle Fill - - Fill edges with triangles + * Triangle Fill + * + * Fill edges with triangles */ static BMOpDefine def_triangle_fill = { "triangle_fill", {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /* input edges */ {BMOP_OPSLOT_ELEMENT_BUF, "geomout"}, /* new faces and edges */ - {0} /*null-terminating sentinel*/}, + {0} /* null-terminating sentine */}, bmesh_triangle_fill_exec, BMOP_UNTAN_MULTIRES }; /* - Solidify - - Turns a mesh into a shell with thickness -*/ + * Solidify + * + * Turns a mesh into a shell with thickness + */ static BMOpDefine def_solidify = { "solidify", {{BMOP_OPSLOT_ELEMENT_BUF, "geom"}, @@ -1135,4 +1132,4 @@ BMOpDefine *opdefines[] = { &def_solidify, }; -int bmesh_total_ops = (sizeof(opdefines) / sizeof(void*)); +int bmesh_total_ops = (sizeof(opdefines) / sizeof(void *)); diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 4695cda4a3f..dcc76ba74f5 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -42,7 +42,7 @@ #include -/*forward declarations*/ +/* forward declarations */ static void alloc_flag_layer(BMesh *bm); static void free_flag_layer(BMesh *bm); static void clear_flag_layer(BMesh *bm); @@ -65,16 +65,16 @@ static const char *bmop_error_messages[] = { }; -/*operator slot type information - size of one element of the type given.*/ +/* operator slot type information - size of one element of the type given. */ const int BMOP_OPSLOT_TYPEINFO[] = { 0, sizeof(int), sizeof(float), - sizeof(void*), + sizeof(void *), 0, /* unused */ 0, /* unused */ 0, /* unused */ - sizeof(void*), /* pointer buffer */ + sizeof(void *), /* pointer buffer */ sizeof(element_mapping) }; @@ -102,7 +102,7 @@ void BMO_push(BMesh *bm, BMOperator *UNUSED(op)) { bm->stackdepth++; - /*add flag layer, if appropriate*/ + /* add flag layer, if appropriate */ if (bm->stackdepth > 1) alloc_flag_layer(bm); else @@ -142,23 +142,23 @@ void BMO_Init_Op(BMesh *bm, BMOperator *op, const char *opname) #endif if (opcode == -1) { - opcode= 0; /* error!, already printed, have a better way to handle this? */ + opcode = 0; /* error!, already printed, have a better way to handle this? */ } memset(op, 0, sizeof(BMOperator)); op->type = opcode; op->flag = opdefines[opcode]->flag; - /*initialize the operator slot types*/ + /* initialize the operator slot types */ for (i = 0; opdefines[opcode]->slottypes[i].type; i++) { op->slots[i].slottype = opdefines[opcode]->slottypes[i].type; op->slots[i].index = i; } - /*callback*/ + /* callback */ op->exec = opdefines[opcode]->exec; - /*memarena, used for operator's slot buffers*/ + /* memarena, used for operator's slot buffers */ op->arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "bmesh operator"); BLI_memarena_use_calloc (op->arena); } @@ -198,7 +198,7 @@ void BMO_Finish_Op(BMesh *bm, BMOperator *op) BMOpSlot *slot; int i; - for (i=0; opdefines[op->type]->slottypes[i].type; i++) { + for (i = 0; opdefines[op->type]->slottypes[i].type; i++) { slot = &op->slots[i]; if (slot->slottype == BMOP_OPSLOT_MAPPING) { if (slot->data.ghash) @@ -262,7 +262,7 @@ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, const char *src, c if (dest_slot->slottype > BMOP_OPSLOT_VEC) { if (dest_slot->slottype != BMOP_OPSLOT_MAPPING) { - /*do buffer copy*/ + /* do buffer copy */ dest_slot->data.buf = NULL; dest_slot->len = source_slot->len; if (dest_slot->len) { @@ -274,7 +274,7 @@ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, const char *src, c GHashIterator it; element_mapping *srcmap, *dstmap; - /*sanity check*/ + /* sanity check */ if (!source_slot->data.ghash) return; if (!dest_slot->data.ghash) { @@ -284,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, @@ -292,10 +292,10 @@ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, const char *src, c dstmap->element = srcmap->element; dstmap->len = srcmap->len; - memcpy(dstmap+1, srcmap+1, srcmap->len); - + memcpy(dstmap + 1, srcmap + 1, srcmap->len); + BLI_ghash_insert(dest_slot->data.ghash, - dstmap->element, dstmap); + dstmap->element, dstmap); } } } @@ -309,8 +309,7 @@ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, const char *src, c * * Sets the value of a slot depending on it's type * -*/ - + */ void BMO_Set_Float(BMOperator *op, const char *slotname, float f) { @@ -330,7 +329,7 @@ void BMO_Set_Int(BMOperator *op, const char *slotname, int i) slot->data.i = i; } -/*only supports square mats*/ +/* only supports square mats */ void BMO_Set_Mat(struct BMOperator *op, const char *slotname, float *mat, int size) { BMOpSlot *slot = BMO_GetSlot(op, slotname); @@ -338,10 +337,10 @@ void BMO_Set_Mat(struct BMOperator *op, const char *slotname, float *mat, int si return; slot->len = 4; - slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float)*4*4); + slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float) * 4 * 4); if (size == 4) { - memcpy(slot->data.p, mat, sizeof(float)*4*4); + memcpy(slot->data.p, mat, sizeof(float) * 4 * 4); } else if (size == 3) { copy_m4_m3(slot->data.p, (float (*)[3])mat); @@ -349,7 +348,7 @@ void BMO_Set_Mat(struct BMOperator *op, const char *slotname, float *mat, int si else { fprintf(stderr, "%s: invalid size argument %d (bmesh internal error)\n", __func__, size); - memset(slot->data.p, 0, sizeof(float)*4*4); + memset(slot->data.p, 0, sizeof(float) * 4 * 4); return; } } @@ -360,7 +359,7 @@ void BMO_Get_Mat4(struct BMOperator *op, const char *slotname, float mat[4][4]) if (!(slot->slottype == BMOP_OPSLOT_MAT)) return; - memcpy(mat, slot->data.p, sizeof(float)*4*4); + memcpy(mat, slot->data.p, sizeof(float) * 4 * 4); } void BMO_Get_Mat3(struct BMOperator *op, const char *slotname, float mat[3][3]) @@ -434,7 +433,7 @@ void BMO_Get_Vec(BMOperator *op, const char *slotname, float r_vec[3]) * Counts the number of elements of a certain type that * have a specific flag set. * -*/ + */ int BMO_CountFlag(BMesh *bm, int flag, const char htype) { @@ -468,18 +467,15 @@ void BMO_Clear_Flag_All(BMesh *bm, BMOperator *UNUSED(op), const char htype, int { BMIter iter; BMHeader *ele; - int i=0, types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, BM_FACES_OF_MESH}; + int types[3] = {BM_VERTS_OF_MESH, BM_EDGES_OF_MESH, BM_FACES_OF_MESH}; + int flags[3] = {BM_VERT, BM_EDGE, BM_FACE}; + int i; - for (i=0; i<3; i++) { - if (i==0 && !(htype & BM_VERT)) - continue; - if (i==1 && !(htype & BM_EDGE)) - continue; - if (i==2 && !(htype & BM_FACE)) - continue; - - BM_ITER(ele, &iter, bm, types[i], NULL) { - BMO_ClearFlag(bm, ele, flag); + for (i = 0; i < 3; i++) { + if (htype & flags[i]) { + BM_ITER(ele, &iter, bm, types[i], NULL) { + BMO_ClearFlag(bm, ele, flag); + } } } } @@ -488,7 +484,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*/ + /* check if its actually a buffer */ if (!(slot->slottype > BMOP_OPSLOT_VEC)) return 0; @@ -499,7 +495,7 @@ int BMO_CountSlotMap(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - /*check if its actually a buffer*/ + /* check if its actually a buffer */ if (!(slot->slottype == BMOP_OPSLOT_MAPPING)) return 0; @@ -512,13 +508,13 @@ void *BMO_Grow_Array(BMesh *bm, BMOperator *op, int slotcode, int totadd) BMOpSlot *slot = &op->slots[slotcode]; void *tmp; - /*check if its actually a buffer*/ + /* check if its actually a buffer */ if (!(slot->slottype > BMOP_OPSLOT_VEC)) return NULL; if (slot->flag & BMOS_DYNAMIC_ARRAY) { if (slot->len >= slot->size) { - slot->size = (slot->size+1+totadd)*2; + slot->size = (slot->size + 1 + totadd) * 2; tmp = slot->data.buf; slot->data.buf = MEM_callocN(BMOP_OPSLOT_TYPEINFO[opdefines[op->type]->slottypes[slotcode].type] * slot->size, "opslot dynamic array"); @@ -531,7 +527,7 @@ void *BMO_Grow_Array(BMesh *bm, BMOperator *op, int slotcode, int totadd) else { slot->flag |= BMOS_DYNAMIC_ARRAY; slot->len += totadd; - slot->size = slot->len+2; + slot->size = slot->len + 2; tmp = slot->data.buf; slot->data.buf = MEM_callocN(BMOP_OPSLOT_TYPEINFO[opdefines[op->type]->slottypes[slotcode].type] * slot->len, "opslot dynamic array"); memcpy(slot->data.buf, tmp, BMOP_OPSLOT_TYPEINFO[opdefines[op->type]->slottypes[slotcode].type] * slot->len); @@ -548,12 +544,12 @@ void BMO_Mapping_To_Flag(struct BMesh *bm, struct BMOperator *op, BMOpSlot *slot = BMO_GetSlot(op, slotname); BMHeader *ele; - /*sanity check*/ + /* sanity check */ if (slot->slottype != BMOP_OPSLOT_MAPPING) return; if (!slot->data.ghash) return; BLI_ghashIterator_init(&it, slot->data.ghash); - for ( ; (ele=BLI_ghashIterator_getKey(&it)); BLI_ghashIterator_step(&it)) { + for ( ; (ele = BLI_ghashIterator_getKey(&it)); BLI_ghashIterator_step(&it)) { BMO_SetFlag(bm, ele, flag); } } @@ -562,7 +558,7 @@ static void *alloc_slot_buffer(BMOperator *op, const char *slotname, int len) { BMOpSlot *slot = BMO_GetSlot(op, slotname); - /*check if its actually a buffer*/ + /* check if its actually a buffer */ if (!(slot->slottype > BMOP_OPSLOT_VEC)) return NULL; @@ -572,21 +568,19 @@ static void *alloc_slot_buffer(BMOperator *op, const char *slotname, int len) return slot->data.buf; } - /* - * * BMO_ALL_TO_SLOT * * Copies all elements of a certain type into an operator slot. * -*/ + */ static void BMO_All_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, const char htype) { BMIter elements; BMHeader *e; BMOpSlot *output = BMO_GetSlot(op, slotname); - int totelement=0, i=0; + int totelement = 0, i = 0; if (htype & BM_VERT) totelement += bm->totvert; if (htype & BM_EDGE) totelement += bm->totedge; @@ -597,21 +591,21 @@ static void BMO_All_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, con if (htype & BM_VERT) { for (e = BMIter_New(&elements, bm, BM_VERTS_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - ((BMHeader**)output->data.p)[i] = e; + ((BMHeader **)output->data.p)[i] = e; i++; } } if (htype & BM_EDGE) { for (e = BMIter_New(&elements, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - ((BMHeader**)output->data.p)[i] = e; + ((BMHeader **)output->data.p)[i] = e; i++; } } if (htype & BM_FACE) { for (e = BMIter_New(&elements, bm, BM_FACES_OF_MESH, bm); e; e = BMIter_Step(&elements)) { - ((BMHeader**)output->data.p)[i] = e; + ((BMHeader **)output->data.p)[i] = e; i++; } } @@ -619,13 +613,11 @@ static void BMO_All_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, con } /* - * * BMO_HEADERFLAG_TO_SLOT * * Copies elements of a certain type, which have a certain header flag set * into a slot for an operator. - * -*/ + */ void BMO_HeaderFlag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, const char hflag, const char htype) @@ -633,7 +625,7 @@ void BMO_HeaderFlag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, BMIter elements; BMHeader *e; BMOpSlot *output = BMO_GetSlot(op, slotname); - int totelement=0, i=0; + int totelement = 0, i = 0; totelement = BM_CountFlag(bm, htype, hflag, 1); @@ -643,7 +635,7 @@ void BMO_HeaderFlag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, 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)) { - ((BMHeader**)output->data.p)[i] = e; + ((BMHeader **)output->data.p)[i] = e; i++; } } @@ -652,7 +644,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)) { - ((BMHeader**)output->data.p)[i] = e; + ((BMHeader **)output->data.p)[i] = e; i++; } } @@ -661,7 +653,7 @@ 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)) { - ((BMHeader**)output->data.p)[i] = e; + ((BMHeader **)output->data.p)[i] = e; i++; } } @@ -685,7 +677,7 @@ void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, BMIter elements; BMHeader *e; BMOpSlot *output = BMO_GetSlot(op, slotname); - int totelement = BMO_CountFlag(bm, flag, htype), i=0; + int totelement = BMO_CountFlag(bm, flag, htype), i = 0; if (totelement) { alloc_slot_buffer(op, slotname, totelement); @@ -693,7 +685,7 @@ void BMO_Flag_To_Slot(BMesh *bm, BMOperator *op, const char *slotname, 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)) { - ((BMHeader**)output->data.p)[i] = e; + ((BMHeader **)output->data.p)[i] = e; i++; } } @@ -702,7 +694,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)) { - ((BMHeader**)output->data.p)[i] = e; + ((BMHeader **)output->data.p)[i] = e; i++; } } @@ -711,7 +703,7 @@ 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)) { - ((BMHeader**)output->data.p)[i] = e; + ((BMHeader **)output->data.p)[i] = e; i++; } } @@ -774,14 +766,14 @@ void BMO_UnHeaderFlag_Buffer(BMesh *bm, BMOperator *op, const char *slotname, } int BMO_Vert_CountEdgeFlags(BMesh *bm, BMVert *v, int toolflag) { - int count= 0; + int count = 0; if (v->e) { BMEdge *curedge; - const int len= bmesh_disk_count(v); + const int len = bmesh_disk_count(v); int i; - for (i = 0, curedge=v->e; ie; i < len; i++) { if (BMO_TestFlag(bm, curedge, toolflag)) count++; curedge = bmesh_disk_nextedge(curedge, v); @@ -856,19 +848,19 @@ static void alloc_flag_layer(BMesh *bm) int i; BMIter iter; - BLI_mempool *oldpool = bm->toolflagpool; /*old flag pool*/ + BLI_mempool *oldpool = bm->toolflagpool; /* old flag pool */ BLI_mempool *newpool; void *oldflags; /* store memcpy size for reuse */ - const size_t old_totflags_size= (bm->totflags * sizeof(BMFlagLayer)); + const size_t old_totflags_size = (bm->totflags * sizeof(BMFlagLayer)); bm->totflags++; - /*allocate new flag pool*/ - bm->toolflagpool= newpool= BLI_mempool_create(sizeof(BMFlagLayer)*bm->totflags, 512, 512, FALSE, FALSE); + /* allocate new flag poo */ + bm->toolflagpool = newpool = BLI_mempool_create(sizeof(BMFlagLayer)*bm->totflags, 512, 512, FALSE, FALSE); - /*now go through and memcpy all the flags. Loops don't get a flag layer at this time...*/ + /* now go through and memcpy all the flags. Loops don't get a flag layer at this time.. */ for (ele = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, bm), i = 0; ele; ele = BMIter_Step(&iter), i++) { oldflags = ele->flags; ele->flags = BLI_mempool_calloc(newpool); @@ -906,14 +898,14 @@ static void free_flag_layer(BMesh *bm) void *oldflags; /* store memcpy size for reuse */ - const size_t new_totflags_size= ((bm->totflags-1) * sizeof(BMFlagLayer)); + const size_t new_totflags_size = ((bm->totflags - 1) * sizeof(BMFlagLayer)); - /*de-increment the totflags first...*/ + /* de-increment the totflags first.. */ bm->totflags--; - /*allocate new flag pool*/ - bm->toolflagpool= newpool= BLI_mempool_create(new_totflags_size, 512, 512, TRUE, FALSE); + /* allocate new flag poo */ + bm->toolflagpool = newpool = BLI_mempool_create(new_totflags_size, 512, 512, TRUE, FALSE); - /*now go through and memcpy all the flags*/ + /* now go through and memcpy all the flag */ for (ele = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, bm), i = 0; ele; ele = BMIter_Step(&iter), i++) { oldflags = ele->flags; ele->flags = BLI_mempool_calloc(newpool); @@ -948,15 +940,15 @@ static void clear_flag_layer(BMesh *bm) BMIter edges; BMIter faces; - /*now go through and memcpy all the flags*/ + /* now go through and memcpy all the flag */ 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)); + 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)) { - memset(e->head.flags+(bm->totflags-1), 0, sizeof(BMFlagLayer)); + 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)) { - memset(f->head.flags+(bm->totflags-1), 0, sizeof(BMFlagLayer)); + memset(f->head.flags + (bm->totflags - 1), 0, sizeof(BMFlagLayer)); } } @@ -967,7 +959,7 @@ void *BMO_FirstElem(BMOperator *op, const char *slotname) if (slot->slottype != BMOP_OPSLOT_ELEMENT_BUF) return NULL; - return slot->data.buf ? *(void**)slot->data.buf : NULL; + return slot->data.buf ? *(void **)slot->data.buf : NULL; } void *BMO_IterNew(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, @@ -982,9 +974,12 @@ void *BMO_IterNew(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, iter->restrictmask = restrictmask; if (iter->slot->slottype == BMOP_OPSLOT_MAPPING) { - if (iter->slot->data.ghash) + if (iter->slot->data.ghash) { BLI_ghashIterator_init(&iter->giter, slot->data.ghash); - else return NULL; + } + else { + return NULL; + } } return BMO_IterStep(iter); @@ -995,12 +990,17 @@ void *BMO_IterStep(BMOIter *iter) if (iter->slot->slottype == BMOP_OPSLOT_ELEMENT_BUF) { BMHeader *h; - if (iter->cur >= iter->slot->len) return NULL; + if (iter->cur >= iter->slot->len) { + return NULL; + } - h = ((void**)iter->slot->data.buf)[iter->cur++]; + h = ((void **)iter->slot->data.buf)[iter->cur++]; while (!(iter->restrictmask & h->htype)) { - if (iter->cur >= iter->slot->len) return NULL; - h = ((void**)iter->slot->data.buf)[iter->cur++]; + if (iter->cur >= iter->slot->len) { + return NULL; + } + + h = ((void **)iter->slot->data.buf)[iter->cur++]; } return h; @@ -1020,7 +1020,7 @@ void *BMO_IterStep(BMOIter *iter) return NULL; } -/*used for iterating over mappings*/ +/* used for iterating over mapping */ void *BMO_IterMapVal(BMOIter *iter) { return iter->val; @@ -1028,15 +1028,15 @@ void *BMO_IterMapVal(BMOIter *iter) void *BMO_IterMapValp(BMOIter *iter) { - return *((void**)iter->val); + return *((void **)iter->val); } float BMO_IterMapValf(BMOIter *iter) { - return *((float*)iter->val); + return *((float *)iter->val); } -/*error system*/ +/* error syste */ typedef struct bmop_error { struct bmop_error *next, *prev; int errorcode; @@ -1066,11 +1066,13 @@ int BMO_HasError(BMesh *bm) return bm->errorstack.first != NULL; } -/*returns error code or 0 if no error*/ +/* returns error code or 0 if no erro */ int BMO_GetError(BMesh *bm, const char **msg, BMOperator **op) { bmop_error *err = bm->errorstack.first; - if (!err) return 0; + if (!err) { + return 0; + } if (msg) *msg = err->msg; if (op) *op = err->op; @@ -1092,7 +1094,7 @@ int BMO_PopError(BMesh *bm, const char **msg, BMOperator **op) return errorcode; } -/* +#if 0 typedef struct bflag { const char *str; int flag; @@ -1120,22 +1122,21 @@ int bmesh_str_to_flag(const char *str) return -1; } -*/ +#endif -//example: -//BMO_CallOp(bm, "del %d %hv", DEL_ONLYFACES, BM_SELECT); -/* - d - int - i - int - f - float - hv - header flagged verts - he - header flagged edges - hf - header flagged faces - fv - flagged verts - fe - flagged edges - ff - flagged faces - -*/ +/* example: + * BMO_CallOp(bm, "del %d %hv", DEL_ONLYFACES, BM_SELECT); + * + * d - int + * i - int + * f - float + * hv - header flagged verts + * he - header flagged edges + * hf - header flagged faces + * fv - flagged verts + * fe - flagged edges + * ff - flagged faces + */ #define nextc(fmt) ((fmt)[0] != 0 ? (fmt)[1] : 0) @@ -1143,8 +1144,10 @@ static int bmesh_name_to_slotcode(BMOpDefine *def, const char *name) { int i; - for (i=0; def->slottypes[i].type; i++) { - if (!strncmp(name, def->slottypes[i].name, MAX_SLOTNAME)) return i; + for (i = 0; def->slottypes[i].type; i++) { + if (!strncmp(name, def->slottypes[i].name, MAX_SLOTNAME)) { + return i; + } } return -1; @@ -1164,8 +1167,10 @@ static int bmesh_opname_to_opcode(const char *opname) { int i; - for (i=0; iname)) return i; + for (i = 0; i < bmesh_total_ops; i++) { + if (!strcmp(opname, opdefines[i]->name)) { + return i; + } } fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname); @@ -1177,19 +1182,19 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) BMOpDefine *def; char *opname, *ofmt, *fmt; char slotname[64] = {0}; - int i /*, n=strlen(fmt) */, stop /*, slotcode = -1 */, ret, type, state; - int noslot=0; + int i /*, n = strlen(fmt) */, stop /*, slotcode = -1 */, ret, type, state; + int noslot = 0; /* basic useful info to help find where bmop formatting strings fail */ - int lineno= -1; -# define GOTO_ERROR { lineno= __LINE__; goto error; } + int lineno = -1; +# define GOTO_ERROR { lineno = __LINE__; goto error; } - /*we muck around in here, so dup it*/ + /* we muck around in here, so dup i */ fmt = ofmt = BLI_strdup(_fmt); - /*find operator name*/ + /* find operator nam */ i = strcspn(fmt, " \t"); opname = fmt; @@ -1198,7 +1203,7 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) fmt += i + (noslot ? 0 : 1); - i= bmesh_opname_to_opcode(opname); + i = bmesh_opname_to_opcode(opname); if (i == -1) { MEM_freeN(ofmt); @@ -1213,17 +1218,17 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) while (*fmt) { if (state) { - /*jump past leading whitespace*/ + /* jump past leading whitespac */ i = strspn(fmt, " \t"); fmt += i; - /*ignore trailing whitespace*/ + /* ignore trailing whitespac */ if (!fmt[i]) break; - /*find end of slot name. currently this is - a little flexible, allowing "slot=%f", - "slot %f", "slot%f", and "slot\t%f". */ + /* find end of slot name. currently this is + * a little flexible, allowing "slot=%f", + * "slot %f", "slot%f", and "slot\t%f". */ i = strcspn(fmt, "= \t%"); if (!fmt[i]) GOTO_ERROR; @@ -1253,29 +1258,29 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) else if (c == '4') size = 4; else GOTO_ERROR; - BMO_Set_Mat(op, slotname, va_arg(vlist, void*), size); + BMO_Set_Mat(op, slotname, va_arg(vlist, void *), size); state = 1; break; } case 'v': { - BMO_Set_Vec(op, slotname, va_arg(vlist, float*)); + BMO_Set_Vec(op, slotname, va_arg(vlist, float *)); state = 1; break; } case 'e': { - BMHeader *ele = va_arg(vlist, void*); + BMHeader *ele = va_arg(vlist, void *); BMOpSlot *slot = BMO_GetSlot(op, slotname); - slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(void*)*4); + slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(void *) * 4); slot->len = 1; - *((void**)slot->data.buf) = ele; + *((void **)slot->data.buf) = ele; state = 1; break; } case 's': { - BMOperator *op2 = va_arg(vlist, void*); - const char *slotname2 = va_arg(vlist, char*); + BMOperator *op2 = va_arg(vlist, void *); + const char *slotname2 = va_arg(vlist, char *); BMO_CopySlot(op2, op, slotname2, slotname); state = 1; @@ -1287,7 +1292,7 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) state = 1; break; case 'p': - BMO_Set_Pnt(op, slotname, va_arg(vlist, void*)); + BMO_Set_Pnt(op, slotname, va_arg(vlist, void *)); state = 1; break; case 'f': @@ -1295,19 +1300,17 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) case 'a': type = *fmt; - if (nextc(fmt) == ' ' || nextc(fmt) == '\t' || - nextc(fmt)==0) - { - BMO_Set_Float(op,slotname,va_arg(vlist,double)); + if (nextc(fmt) == ' ' || nextc(fmt) == '\t' || nextc(fmt) == '\0') { + BMO_Set_Float(op, slotname, va_arg(vlist, double)); } else { ret = 0; stop = 0; while (1) { switch (nextc(fmt)) { - case 'f': ret |= BM_FACE;break; - case 'e': ret |= BM_EDGE;break; - case 'v': ret |= BM_VERT;break; + case 'f': ret |= BM_FACE; break; + case 'e': ret |= BM_EDGE; break; + case 'v': ret |= BM_VERT; break; default: stop = 1; break; @@ -1401,7 +1404,7 @@ int BMO_CallOpf(BMesh *bm, const char *fmt, ...) static void BMO_ToggleFlag(BMesh *bm, void *element, int flag) { BMHeader *head = element; - head->flags[bm->stackdepth-1].f ^= flag; + head->flags[bm->stackdepth - 1].f ^= flag; } /* @@ -1414,8 +1417,8 @@ static void BMO_ToggleFlag(BMesh *bm, void *element, int flag) #endif static void BMO_SetFlag(BMesh *bm, void *element, const int flag) { - BMHeader *head= element; - head->flags[bm->stackdepth-1].f |= flag; + BMHeader *head = element; + head->flags[bm->stackdepth - 1].f |= flag; } /* @@ -1428,8 +1431,8 @@ static void BMO_SetFlag(BMesh *bm, void *element, const int flag) #endif static void BMO_ClearFlag(BMesh *bm, void *element, const int flag) { - BMHeader *head= element; - head->flags[bm->stackdepth-1].f &= ~flag; + BMHeader *head = element; + head->flags[bm->stackdepth - 1].f &= ~flag; } /* @@ -1444,7 +1447,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 dd163d3e248..758fceb6c4c 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -56,43 +56,45 @@ * Point in triangle tests stolen from scanfill.c. * Used for tesselator * -*/ + */ static short testedgeside(const double v1[2], const double v2[2], const double v3[2]) -/* is v3 to the right of v1-v2 ? With exception: v3==v1 || v3==v2 */ { + /* is v3 to the right of v1-v2 ? With exception: v3 == v1 || v3 == v2 */ double inp; - //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]); + //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 short testedgesidef(const float v1[2], const float v2[2], const float v3[2]) -/* is v3 to the right of v1-v2 ? With exception: v3==v1 || v3==v2 */ { + /* is v3 to the right of v1-v2 ? With exception: v3 == v1 || v3 == v2 */ double inp; - //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]); + //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; } @@ -104,23 +106,23 @@ static int point_in_triangle(const double v1[2], const double v2[2], const doubl * polygon See Graphics Gems for * computing newell normal. * -*/ + */ static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts) { - float u[3], v[3], w[3];/*, *w, v1[3], v2[3];*/ - float n[3]= {0.0f, 0.0f, 0.0f} /*, l, v1[3], v2[3] */; + float u[3], v[3], w[3]; /*, *w, v1[3], v2[3]; */ + float n[3] = {0.0f, 0.0f, 0.0f} /*, l, v1[3], v2[3] */; /* double l2; */ - int i /*, s=0 */; + int i /*, s = 0 */; - /*this fixes some weird numerical error*/ + /* this fixes some weird numerical erro */ add_v3_fl(verts[0], 0.0001f); 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]); + copy_v3_v3(v, verts[(i + 1) % nverts]); + copy_v3_v3(w, verts[(i + 2) % nverts]); #if 0 sub_v3_v3v3(v1, w, v); @@ -129,7 +131,7 @@ static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts) normalize_v3(v2); l = dot_v3v3(v1, v2); - if (fabsf(l-1.0) < 0.1f) { + if (fabsf(l - 1.0) < 0.1f) { continue; } #endif @@ -156,12 +158,12 @@ static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts) #if 0 l = len_v3(n); - /*fast square root, newton/babylonian method: - l2 = l*0.1; + /* fast square root, newton/babylonian method: + l2 = l * 0.1; - l2 = (l/l2 + l2)*0.5; - l2 = (l/l2 + l2)*0.5; - l2 = (l/l2 + l2)*0.5; + l2 = (l / l2 + l2) * 0.5; + l2 = (l / l2 + l2) * 0.5; + l2 = (l / l2 + l2) * 0.5; */ if (l == 0.0) { @@ -188,19 +190,19 @@ static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts) * area of a polygon in the X/Y * plane. * -*/ + */ static int compute_poly_center(float center[3], float *r_area, float (*verts)[3], int nverts) { int i, j; - float atmp = 0.0, xtmp = 0.0, ytmp = 0.0, ai; + float atmp = 0.0f, xtmp = 0.0f, ytmp = 0.0f, ai; zero_v3(center); if (nverts < 3) return 0; - i = nverts-1; + i = nverts - 1; j = 0; while (j < nverts) { @@ -246,10 +248,10 @@ float BM_Compute_Face_Area(BMesh *bm, BMFace *f) return area; } -/* -computes center of face in 3d. uses center of bounding box. -*/ +/* + * computes center of face in 3d. uses center of bounding box. + */ void BM_Compute_Face_CenterBounds(BMesh *bm, BMFace *f, float r_cent[3]) { BMIter iter; @@ -259,7 +261,7 @@ void BM_Compute_Face_CenterBounds(BMesh *bm, BMFace *f, float r_cent[3]) INIT_MINMAX(min, max); l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); - for (i=0; l; l=BMIter_Step(&iter), i++) { + for (i = 0; l; l = BMIter_Step(&iter), i++) { DO_MINMAX(l->v->co, min, max); } @@ -275,7 +277,7 @@ void BM_Compute_Face_CenterMean(BMesh *bm, BMFace *f, float r_cent[3]) zero_v3(r_cent); l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); - for (i=0; l; l=BMIter_Step(&iter), i++) { + for (i = 0; l; l = BMIter_Step(&iter), i++) { add_v3_v3(r_cent, l->v->co); } @@ -289,7 +291,7 @@ void BM_Compute_Face_CenterMean(BMesh *bm, BMFace *f, float r_cent[3]) * a plane defined by the average * of its edges cross products * -*/ + */ void compute_poly_plane(float (*verts)[3], int nverts) { @@ -306,14 +308,14 @@ void compute_poly_plane(float (*verts)[3], int nverts) 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); + v2 = verts[(i + 1) % nverts]; + v3 = verts[(i + 2) % nverts]; + normal_tri_v3(norm, v1, v2, v3); add_v3_v3(avgn, norm); } - /*what was this bit for?*/ + /* what was this bit for */ if (is_zero_v3(avgn)) { avgn[0] = 0.0f; avgn[1] = 0.0f; @@ -336,12 +338,12 @@ void compute_poly_plane(float (*verts)[3], int nverts) } /* - BM LEGAL EDGES - - takes in a face and a list of edges, and sets to NULL any edge in - the list that bridges a concave region of the face or intersects - any of the faces's edges. -*/ + * BM LEGAL EDGES + * + * takes in a face and a list of edges, and sets to NULL any edge in + * the list that bridges a concave region of the face or intersects + * any of the faces's edges. + */ #if 0 /* needs BLI math double versions of these functions */ static void shrink_edged(double *v1, double *v2, double fac) { @@ -383,12 +385,12 @@ static void shrink_edgef(float v1[3], float v2[3], const float fac) * Rotates a polygon so that it's * normal is pointing towards the mesh Z axis * -*/ + */ void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nverts) { - float up[3] = {0.0f,0.0f,1.0f}, axis[3], q[4]; + float up[3] = {0.0f, 0.0f, 1.0f}, axis[3], q[4]; float mat[3][3]; double angle; int i; @@ -415,7 +417,7 @@ void poly_rotate_plane(const float normal[3], float (*verts)[3], const int nvert * coordinates for all of the face's vertices * is passed in as well. * -*/ + */ void BM_Face_UpdateNormal(BMesh *bm, BMFace *f) { @@ -449,7 +451,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); } @@ -463,7 +465,7 @@ void BM_Vert_UpdateNormal(BMesh *bm, BMVert *v) BMEdge *e; BMLoop *l; float vec1[3], vec2[3], fac; - int len=0; + int len = 0; zero_v3(v->no); @@ -494,10 +496,10 @@ void BM_Vert_UpdateAllNormals(BMesh *bm, BMVert *v) { BMIter iter; BMFace *f; - int len=0; + 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); } @@ -606,7 +608,7 @@ void bmesh_update_face_normal_vertex_cos(BMesh *bm, BMFace *f, float no[3], * Reverses the winding of a face. * Note that this updates the calculated * normal. -*/ + */ void BM_flip_normal(BMesh *bm, BMFace *f) { bmesh_loop_reverse(bm, f); @@ -614,41 +616,41 @@ void BM_flip_normal(BMesh *bm, BMFace *f) } /* detects if two line segments cross each other (intersects). - note, there could be more winding cases then there needs to be. */ + * note, there could be more winding cases then there needs to be. */ static int UNUSED_FUNCTION(linecrosses)(const double v1[2], const double v2[2], const double v3[2], const double v4[2]) { int w1, w2, w3, w4, w5; - /*w1 = winding(v1, v3, v4); + /* w1 = winding(v1, v3, v4); w2 = winding(v2, v3, v4); w3 = winding(v3, v1, v2); w4 = winding(v4, v1, v2); - return (w1 == w2) && (w3 == w4);*/ + return (w1 == w2) && (w3 == w4); */ w1 = testedgeside(v1, v3, v2); w2 = testedgeside(v2, v4, v1); w3 = !testedgeside(v1, v2, v3); w4 = testedgeside(v3, v2, v4); w5 = !testedgeside(v3, v1, v4); - return w1 == w2 && w2 == w3 && w3 == w4 && w4==w5; + return w1 == w2 && w2 == w3 && w3 == w4 && w4 == w5; } /* detects if two line segments cross each other (intersects). - note, there could be more winding cases then there needs to be. */ + * note, there could be more winding cases then there needs to be. */ static int linecrossesf(const float v1[2], const float v2[2], const float v3[2], const float v4[2]) { - int w1, w2, w3, w4, w5 /*, ret*/; + int w1, w2, w3, w4, w5 /*, re */; float mv1[2], mv2[2], mv3[2], mv4[2]; - /*now test winding*/ + /* now test windin */ w1 = testedgesidef(v1, v3, v2); w2 = testedgesidef(v2, v4, v1); w3 = !testedgesidef(v1, v2, v3); w4 = testedgesidef(v3, v2, v4); w5 = !testedgesidef(v3, v1, v4); - if (w1 == w2 && w2 == w3 && w3 == w4 && w4==w5) + if (w1 == w2 && w2 == w3 && w3 == w4 && w4 == w5) return 1; #define GETMIN2_AXIS(a, b, ma, mb, axis) ma[axis] = MIN2(a[axis], b[axis]), mb[axis] = MAX2(a[axis], b[axis]) @@ -657,16 +659,16 @@ static int linecrossesf(const float v1[2], const float v2[2], const float v3[2], GETMIN2(v1, v2, mv1, mv2); GETMIN2(v3, v4, mv3, mv4); - /*do an interval test on the x and y axes*/ - /*first do x axis*/ - #define T FLT_EPSILON*15 + /* do an interval test on the x and y axe */ + /* first do x axi */ + #define T FLT_EPSILON * 15 if (ABS(v1[1]-v2[1]) < T && ABS(v3[1]-v4[1]) < T && ABS(v1[1]-v3[1]) < T) { return (mv4[0] >= mv1[0] && mv3[0] <= mv2[0]); } - /*now do y axis*/ + /* now do y axi */ if (ABS(v1[0]-v2[0]) < T && ABS(v3[0]-v4[0]) < T && ABS(v1[0]-v3[0]) < T) { @@ -677,22 +679,22 @@ static int linecrossesf(const float v1[2], const float v2[2], const float v3[2], } /* - BM POINT IN FACE - - Projects co onto face f, and returns true if it is inside - the face bounds. Note that this uses a best-axis projection - test, instead of projecting co directly into f's orientation - space, so there might be accuracy issues. -*/ + * BM POINT IN FACE + * + * Projects co onto face f, and returns true if it is inside + * the face bounds. Note that this uses a best-axis projection + * test, instead of projecting co directly into f's orientation + * space, so there might be accuracy issues. + */ int BM_Point_In_Face(BMesh *bm, BMFace *f, const float co[3]) { int ax, ay; - float co2[3], cent[3] = {0.0f, 0.0f, 0.0f}, out[3] = {FLT_MAX*0.5f, FLT_MAX*0.5f, 0}; + float co2[3], cent[3] = {0.0f, 0.0f, 0.0f}, out[3] = {FLT_MAX * 0.5f, FLT_MAX * 0.5f, 0}; BMLoop *l; int crosses = 0; - float eps = 1.0f+(float)FLT_EPSILON*150.0f; + float eps = 1.0f + (float)FLT_EPSILON * 150.0f; - if (dot_v3v3(f->no, f->no) <= FLT_EPSILON*10) + if (dot_v3v3(f->no, f->no) <= FLT_EPSILON * 10) BM_Face_UpdateNormal(bm, f); /* find best projection of face XY, XZ or YZ: barycentric weights of @@ -714,18 +716,18 @@ int BM_Point_In_Face(BMesh *bm, BMFace *f, const float co[3]) l = l->next; } while (l != bm_firstfaceloop(f)); - mul_v2_fl(cent, 1.0f/(float)f->len); + mul_v2_fl(cent, 1.0f / (float)f->len); l = bm_firstfaceloop(f); do { float v1[3], v2[3]; - v1[0] = (l->prev->v->co[ax] - cent[ax])*eps + cent[ax]; - v1[1] = (l->prev->v->co[ay] - cent[ay])*eps + cent[ay]; + v1[0] = (l->prev->v->co[ax] - cent[ax]) * eps + cent[ax]; + v1[1] = (l->prev->v->co[ay] - cent[ay]) * eps + cent[ay]; v1[2] = 0.0f; - v2[0] = (l->v->co[ax] - cent[ax])*eps + cent[ax]; - v2[1] = (l->v->co[ay] - cent[ay])*eps + cent[ay]; + v2[0] = (l->v->co[ax] - cent[ax]) * eps + cent[ax]; + v2[1] = (l->v->co[ay] - cent[ay]) * eps + cent[ay]; v2[2] = 0.0f; crosses += linecrossesf(v1, v2, co2, out) != 0; @@ -733,7 +735,7 @@ int BM_Point_In_Face(BMesh *bm, BMFace *f, const float co[3]) l = l->next; } while (l != bm_firstfaceloop(f)); - return crosses%2 != 0; + return crosses % 2 != 0; } static int goodline(float (*projectverts)[3], BMFace *f, int v1i, @@ -747,9 +749,11 @@ static int goodline(float (*projectverts)[3], BMFace *f, int v1i, VECCOPY(v2, projectverts[v2i]); VECCOPY(v3, projectverts[v3i]); - if (testedgeside(v1, v2, v3)) return 0; - - //for (i=0; iv); if (i == v1i || i == v2i || i == v3i) { @@ -775,15 +779,15 @@ static int goodline(float (*projectverts)[3], BMFace *f, int v1i, * the next triangle to 'clip off' * of a polygon while tesselating. * -*/ + */ static BMLoop *find_ear(BMesh *UNUSED(bm), BMFace *f, float (*verts)[3], int nvert) { BMVert *v1, *v2, *v3; BMLoop *bestear = NULL, *l; - /*float angle, bestangle = 180.0f;*/ - int isear /*, i=0*/; + /* float angle, bestangle = 180.0f; */ + int isear /*, i = 0 */; l = bm_firstfaceloop(f); do { @@ -800,7 +804,7 @@ static BMLoop *find_ear(BMesh *UNUSED(bm), BMFace *f, float (*verts)[3], isear = 0; if (isear) { - /*angle = angle_v3v3v3(verts[v1->head.eflag2], verts[v2->head.eflag2], verts[v3->head.eflag2]); + /* angle = angle_v3v3v3(verts[v1->head.eflag2], verts[v2->head.eflag2], verts[v3->head.eflag2]); if (!bestear || ABS(angle-45.0f) < bestangle) { bestear = l; bestangle = ABS(45.0f-angle); @@ -808,7 +812,7 @@ static BMLoop *find_ear(BMesh *UNUSED(bm), BMFace *f, float (*verts)[3], if (angle > 20 && angle < 90) break; if (angle < 100 && i > 5) break; - i += 1;*/ + i += 1; */ bestear = l; break; } @@ -834,7 +838,7 @@ static BMLoop *find_ear(BMesh *UNUSED(bm), BMFace *f, float (*verts)[3], * newfaces, if non-null, must be an array of BMFace pointers, * with a length equal to f->len. it will be filled with the new * triangles, and will be NULL-terminated. -*/ + */ void BM_Triangulate_Face(BMesh *bm, BMFace *f, float (*projectverts)[3], int newedgeflag, int newfaceflag, BMFace **newfaces) { @@ -842,7 +846,7 @@ void BM_Triangulate_Face(BMesh *bm, BMFace *f, float (*projectverts)[3], BMLoop *l, *newl, *nextloop; /* BMVert *v; */ /* UNUSED */ - /*copy vertex coordinates to vertspace array*/ + /* copy vertex coordinates to vertspace arra */ i = 0; l = bm_firstfaceloop(f); do { @@ -862,7 +866,7 @@ void BM_Triangulate_Face(BMesh *bm, BMFace *f, float (*projectverts)[3], nvert = f->len; //compute_poly_plane(projectverts, i); - for (i=0; iloopbase; + /* l = f->loopbase; do { if (l->v == v) { f->loopbase = l; break; } l = l->next; - } while (l != f->loopbase);*/ + } while (l != f->loopbase); */ } } @@ -908,7 +912,7 @@ void BM_Triangulate_Face(BMesh *bm, BMFace *f, float (*projectverts)[3], if (!f) { printf("triangle fan step of triangulator failed.\n"); - /*NULL-terminate*/ + /* NULL-terminat */ if (newfaces) newfaces[nf_i] = NULL; return; } @@ -921,39 +925,39 @@ void BM_Triangulate_Face(BMesh *bm, BMFace *f, float (*projectverts)[3], } } - /*NULL-terminate*/ + /* NULL-terminat */ if (newfaces) newfaces[nf_i] = NULL; } -/*each pair of loops defines a new edge, a split. this function goes - through and sets pairs that are geometrically invalid to null. a - split is invalid, if it forms a concave angle or it intersects other - edges in the face, or it intersects another split. in the case of - intersecting splits, only the first of the set of intersecting - splits survives.*/ +/* each pair of loops defines a new edge, a split. this function goes + * through and sets pairs that are geometrically invalid to null. a + * split is invalid, if it forms a concave angle or it intersects other + * edges in the face, or it intersects another split. in the case of + * intersecting splits, only the first of the set of intersecting + * splits survives */ void BM_LegalSplits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len) { BMIter iter; BMLoop *l; - float v1[3], v2[3], v3[3]/*, v4[3]*/, no[3], mid[3], *p1, *p2, *p3, *p4; + float v1[3], v2[3], v3[3]/*, v4[3 */, no[3], mid[3], *p1, *p2, *p3, *p4; float out[3] = {-234324.0f, -234324.0f, 0.0f}; float (*projverts)[3]; float (*edgeverts)[3]; float fac1 = 1.0000001f, fac2 = 0.9f; //9999f; //0.999f; - int i, j, a=0, clen; + int i, j, a = 0, clen; BLI_array_fixedstack_declare(projverts, BM_NGON_STACK_SIZE, f->len, "projvertsb"); BLI_array_fixedstack_declare(edgeverts, BM_NGON_STACK_SIZE * 2, len * 2, "edgevertsb"); 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++; } - for (i=0; iv->co); copy_v3_v3(v2, loops[i][1]->v->co); @@ -967,10 +971,10 @@ void BM_LegalSplits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len) compute_poly_normal(no, projverts, f->len); poly_rotate_plane(no, projverts, f->len); - poly_rotate_plane(no, edgeverts, len*2); + poly_rotate_plane(no, edgeverts, len * 2); l = bm_firstfaceloop(f); - for (i=0; ilen; i++) { + for (i = 0; i < f->len; i++) { p1 = projverts[i]; out[0] = MAX2(out[0], p1[0]) + 0.01f; out[1] = MAX2(out[1], p1[1]) + 0.01f; @@ -982,22 +986,22 @@ void BM_LegalSplits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len) l = l->next; } - for (i=0; ilen; j++) { + for (j = 0; j < f->len; j++) { p1 = projverts[j]; - p2 = projverts[(j+1)%f->len]; + p2 = projverts[(j + 1) % f->len]; copy_v3_v3(v1, p1); copy_v3_v3(v2, p2); @@ -1007,44 +1011,43 @@ void BM_LegalSplits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len) if (linecrossesf(p1, p2, mid, out)) clen++; } - if (clen%2 == 0) { + if (clen % 2 == 0) { loops[i][0] = NULL; } } - /*do line crossing tests*/ - for (i=0; ilen; i++) { + /* do line crossing test */ + for (i = 0; i < f->len; i++) { p1 = projverts[i]; - p2 = projverts[(i+1)%f->len]; + p2 = projverts[(i + 1) % f->len]; copy_v3_v3(v1, p1); copy_v3_v3(v2, p2); shrink_edgef(v1, v2, fac1); - for (j=0; je == e) break; - /*found = 1; */ /* UNUSED */ + /* found = 1; */ /* UNUSED */ l = l->next; } while (l != bm_firstfaceloop(f)); @@ -102,17 +100,20 @@ BMLoop *BM_OtherFaceLoop(BMEdge *e, BMFace *f, BMVert *v) * Returns whether or not a given vertex is * is part of a given face. * -*/ + */ int BM_Vert_In_Face(BMFace *f, BMVert *v) { BMLoopList *lst; BMLoop *l; - for (lst=f->loops.first; lst; lst=lst->next) { + 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); } @@ -126,16 +127,16 @@ int BM_Vert_In_Face(BMFace *f, BMVert *v) * Compares the number of vertices in an array * that appear in a given face * -*/ + */ int BM_Verts_In_Face(BMesh *bm, BMFace *f, BMVert **varr, int len) { BMLoopList *lst; 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) { + for (lst = f->loops.first; lst; lst = lst->next) { curloop = lst->first; do { @@ -146,7 +147,7 @@ int BM_Verts_In_Face(BMesh *bm, BMFace *f, BMVert **varr, int len) } 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; } @@ -157,7 +158,7 @@ int BM_Verts_In_Face(BMesh *bm, BMFace *f, BMVert **varr, int len) * Returns whether or not a given edge is * is part of a given face. * -*/ + */ int BM_Edge_In_Face(BMFace *f, BMEdge *e) { @@ -165,8 +166,10 @@ 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)); @@ -179,11 +182,11 @@ int BM_Edge_In_Face(BMFace *f, BMEdge *e) * Returns whether or not two vertices are in * a given edge * -*/ + */ int BM_Verts_In_Edge(BMVert *v1, BMVert *v2, BMEdge *e) { - return bmesh_verts_in_edge(v1,v2,e); + return bmesh_verts_in_edge(v1, v2, e); } /* @@ -192,11 +195,11 @@ int BM_Verts_In_Edge(BMVert *v1, BMVert *v2, BMEdge *e) * Given a edge and one of its vertices, returns * the other vertex. * -*/ + */ BMVert *BM_OtherEdgeVert(BMEdge *e, BMVert *v) { - return bmesh_edge_getothervert(e,v); + return bmesh_edge_getothervert(e, v); } /* @@ -210,11 +213,11 @@ int BM_Vert_EdgeCount(BMVert *v) return bmesh_disk_count(v); } -/** +/* * BMESH EDGE FACECOUNT * * Returns the number of faces around this edge -*/ + */ int BM_Edge_FaceCount(BMEdge *e) { @@ -232,11 +235,11 @@ int BM_Edge_FaceCount(BMEdge *e) return count; } -/** +/* * BMESH VERT FACECOUNT * * Returns the number of faces around this vert -*/ + */ int BM_Vert_FaceCount(BMVert *v) { @@ -255,14 +258,14 @@ int BM_Vert_FaceCount(BMVert *v) curedge = v->e; do { if (curedge->l) count += BM_Edge_FaceCount(curedge); - curedge = bmesh_disk_nextedge(curedge,v); + curedge = bmesh_disk_nextedge(curedge, v); } while (curedge != v->e); } return count; #endif } -/** +/* * BMESH WIRE VERT * * Tests whether or not the vertex is part of a wire edge. @@ -280,14 +283,17 @@ int BM_Wire_Vert(BMesh *UNUSED(bm), BMVert *v) curedge = v->e; do { - if (curedge->l) return 0; + if (curedge->l) { + return 0; + } + curedge = bmesh_disk_nextedge(curedge, v); } while (curedge != v->e); return 1; } -/** +/* * BMESH WIRE EDGE * * Tests whether or not the edge is part of a wire. @@ -303,7 +309,7 @@ int BM_Wire_Edge(BMesh *UNUSED(bm), BMEdge *e) return 1; } -/** +/* * BMESH NONMANIFOLD VERT * * A vertex is non-manifold if it meets the following conditions: @@ -329,7 +335,7 @@ int BM_Nonmanifold_Vert(BMesh *UNUSED(bm), BMVert *v) /* count edges while looking for non-manifold edges */ oe = v->e; - for (len=0,e=v->e; e != oe || (e == oe && len == 0); len++,e=bmesh_disk_nextedge(e,v)) { + for (len = 0, e = v->e; e != oe || (e == oe && len == 0); len++, e = bmesh_disk_nextedge(e, v)) { if (e->l == NULL) { /* loose edge */ return 1; @@ -376,7 +382,7 @@ int BM_Nonmanifold_Vert(BMesh *UNUSED(bm), BMVert *v) return 0; } -/** +/* * BMESH NONMANIFOLD EDGE * * Tests whether or not this edge is manifold. @@ -394,7 +400,7 @@ int BM_Nonmanifold_Edge(BMesh *UNUSED(bm), BMEdge *e) return 0; } -/** +/* * BMESH BOUNDARY EDGE * * Tests whether or not an edge is on the boundary @@ -411,7 +417,7 @@ int BM_Boundary_Edge(BMEdge *e) return 0; } -/** +/* * BMESH FACE SHAREDEDGES * * Counts the number of edges two faces share (if any) @@ -430,20 +436,20 @@ 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)); return count; } -/** +/* * * BMESH EDGE SHARE FACES * * Tests to see if e1 shares any faces with e2 * -*/ + */ int BM_Edge_Share_Faces(BMEdge *e1, BMEdge *e2) { @@ -454,7 +460,7 @@ int BM_Edge_Share_Faces(BMEdge *e1, BMEdge *e2) 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; @@ -469,7 +475,7 @@ int BM_Edge_Share_Faces(BMEdge *e1, BMEdge *e2) * * Tests to see if e1 shares a vertex with e2 * -*/ + */ int BM_Edge_Share_Vert(struct BMEdge *e1, struct BMEdge *e2) { @@ -490,7 +496,7 @@ int BM_Edge_Share_Vert(struct BMEdge *e1, struct BMEdge *e2) * BM_Make_Ngon() on an arbitrary array of verts, * though be sure to pick an edge which has a face. * -*/ + */ void BM_Edge_OrderedVerts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2) { @@ -499,12 +505,12 @@ void BM_Edge_OrderedVerts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2) ((edge->l->v == edge->v1) && (edge->l->next->v == edge->v2)) ) ) { - *r_v1= edge->v1; - *r_v2= edge->v2; + *r_v1 = edge->v1; + *r_v2 = edge->v2; } else { - *r_v1= edge->v2; - *r_v2= edge->v1; + *r_v1 = edge->v2; + *r_v2 = edge->v1; } } @@ -521,8 +527,8 @@ void BM_Edge_OrderedVerts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2) float BM_Face_Angle(BMesh *UNUSED(bm), BMEdge *e) { if (BM_Edge_FaceCount(e) == 2) { - BMLoop *l1= e->l; - BMLoop *l2= e->l->radial_next; + BMLoop *l1 = e->l; + BMLoop *l2 = e->l->radial_next; return acosf(dot_v3v3(l1->f->no, l2->f->no)); } else { @@ -541,7 +547,7 @@ float BM_Face_Angle(BMesh *UNUSED(bm), BMEdge *e) * 1 for overlap * * -*/ + */ int BM_Exist_Face_Overlaps(BMesh *bm, BMVert **varr, int len, BMFace **overlapface) { @@ -551,7 +557,7 @@ int BM_Exist_Face_Overlaps(BMesh *bm, BMVert **varr, int len, BMFace **overlapfa if (overlapface) *overlapface = NULL; - for (i=0; i < len; i++) { + 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); @@ -575,9 +581,7 @@ int BM_Exist_Face_Overlaps(BMesh *bm, BMVert **varr, int len, BMFace **overlapfa * Returns: * 0 for no face found * 1 for face found - * - * -*/ + */ int BM_Face_Exists(BMesh *bm, BMVert **varr, int len, BMFace **existface) { @@ -587,7 +591,7 @@ int BM_Face_Exists(BMesh *bm, BMVert **varr, int len, BMFace **existface) if (existface) *existface = NULL; - for (i=0; i < len; i++) { + 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); diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c index b022a7f8853..65102a5b085 100644 --- a/source/blender/bmesh/intern/bmesh_structure.c +++ b/source/blender/bmesh/intern/bmesh_structure.c @@ -155,14 +155,14 @@ int bmesh_edge_swapverts(BMEdge *e, BMVert *orig, BMVert *newv) * advantage is that no intrinsic properties of the data structures are dependant upon the * cycle order and all non-manifold conditions are represented trivially. * -*/ + */ int bmesh_disk_append_edge(struct BMEdge *e, struct BMVert *v) { if (!v->e) { Link *e1 = bm_get_edge_link(e, v); v->e = e; - e1->next = e1->prev = (Link*)e; + e1->next = e1->prev = (Link *)e; } else { Link *e1, *e2, *e3; @@ -171,12 +171,12 @@ int bmesh_disk_append_edge(struct BMEdge *e, struct BMVert *v) e2 = bm_get_edge_link(v->e, v); e3 = e2->prev ? bm_get_edge_link(e2->prev, v) : NULL; - e1->next = (Link*)v->e; + e1->next = (Link *)v->e; e1->prev = e2->prev; - e2->prev = (Link*)e; + e2->prev = (Link *)e; if (e3) - e3->next = (Link*)e; + e3->next = (Link *)e; } return 1; @@ -229,7 +229,7 @@ BMEdge *bmesh_disk_existedge(BMVert *v1, BMVert *v2) startedge = v1->e; curedge = startedge; do { - if (bmesh_verts_in_edge(v1,v2,curedge)) return curedge; + if (bmesh_verts_in_edge(v1, v2, curedge)) return curedge; curedge = bmesh_disk_nextedge(curedge, v1); } while (curedge != startedge); } @@ -240,7 +240,7 @@ BMEdge *bmesh_disk_existedge(BMVert *v1, BMVert *v2) int bmesh_disk_count(struct BMVert *v) { BMEdge *e = v->e; - int i=0; + int i = 0; if (!e) return 0; @@ -250,7 +250,7 @@ int bmesh_disk_count(struct BMVert *v) return 0; e = bmesh_disk_nextedge(e, v); - if (i >= (1<<20)) { + if (i >= (1 << 20)) { printf("bmesh error: infinite loop in disk cycle!\n"); return 0; } @@ -272,7 +272,7 @@ int bmesh_disk_validate(int len, BMEdge *e, BMVert *v) e2 = e; do { - if (len!=1 && bmesh_disk_prevedge(e2, v) == e2) + if (len != 1 && bmesh_disk_prevedge(e2, v) == e2) return 0; e2 = bmesh_disk_nextedge(e2, v); @@ -288,19 +288,18 @@ int bmesh_disk_validate(int len, BMEdge *e, BMVert *v) * for this vertex. Note that this is * equivalent to counting the number of * faces incident upon this vertex - * -*/ + */ int bmesh_disk_count_facevert(BMVert *v) { BMEdge *curedge; int count = 0; - /*is there an edge on this vert at all?*/ + /* is there an edge on this vert at all */ if (!v->e) return count; - /*first, loop around edges*/ + /* first, loop around edge */ curedge = v->e; do { if (curedge->l) count += bmesh_radial_count_facevert(curedge->l, v); @@ -315,8 +314,8 @@ 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; - searchedge = bmesh_disk_nextedge(searchedge,v); + if (searchedge->l && bmesh_radial_count_facevert(searchedge->l, v)) return searchedge; + searchedge = bmesh_disk_nextedge(searchedge, v); } while (searchedge != e); return NULL; @@ -325,19 +324,21 @@ struct BMEdge *bmesh_disk_find_first_faceedge(struct BMEdge *e, struct BMVert *v struct BMEdge *bmesh_disk_find_next_faceedge(struct BMEdge *e, struct BMVert *v) { BMEdge *searchedge = NULL; - searchedge = bmesh_disk_nextedge(e,v); + searchedge = bmesh_disk_nextedge(e, v); do { - if (searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; - searchedge = bmesh_disk_nextedge(searchedge,v); - } while (searchedge !=e); + if (searchedge->l && bmesh_radial_count_facevert(searchedge->l, v)) { + return searchedge; + } + searchedge = bmesh_disk_nextedge(searchedge, v); + } while (searchedge != e); return e; } -/*****radial cycle functions, e.g. loops surrounding edges******/ +/*****radial cycle functions, e.g. loops surrounding edges**** */ int bmesh_radial_validate(int radlen, BMLoop *l) { BMLoop *l2 = l; - int i=0; + int i = 0; if (bmesh_radial_length(l) != radlen) return 0; @@ -410,8 +411,7 @@ void bmesh_radial_remove_loop(BMLoop *l, BMEdge *e) * * Finds the first loop of v around radial * cycle - * -*/ + */ BMLoop *bmesh_radial_find_first_facevert(BMLoop *l, BMVert *v) { BMLoop *curloop; @@ -430,7 +430,7 @@ BMLoop *bmesh_radial_find_next_facevert(BMLoop *l, BMVert *v) do { if (curloop->v == v) return curloop; curloop = bmesh_radial_nextloop(curloop); - } while (curloop !=l); + } while (curloop != l); return l; } @@ -508,7 +508,7 @@ int bmesh_radial_find_face(BMEdge *e, BMFace *f) * Returns the number of times a vertex appears * in a radial cycle * -*/ + */ int bmesh_radial_count_facevert(BMLoop *l, BMVert *v) { @@ -522,7 +522,7 @@ int bmesh_radial_count_facevert(BMLoop *l, BMVert *v) return count; } -/*****loop cycle functions, e.g. loops surrounding a face******/ +/*****loop cycle functions, e.g. loops surrounding a face**** */ int bmesh_loop_validate(BMFace *f) { int i; @@ -555,8 +555,8 @@ void bmesh_cycle_append(void *h, void *nt) { BMNode *oldtail, *head, *newtail; - head = (BMNode*)h; - newtail = (BMNode*)nt; + head = (BMNode *)h; + newtail = (BMNode *)nt; if (head->next == NULL) { head->next = newtail; @@ -588,9 +588,8 @@ int bmesh_cycle_length(BMEdge *e, BMVert *v) BMEdge *next, *prev, *cur; int len, vi = v == e->v1 ? 0 : 1; - /*should skip 2 forward if v is 1, happily reduces to - v*2*/ - prev = *(&e->v1_prev + vi*2); + /* should skip 2 forward if v is 1, happily reduces to (v * 2) */ + prev = *(&e->v1_prev + vi * 2); cur = e; len = 1; @@ -598,7 +597,7 @@ int bmesh_cycle_length(BMEdge *e, BMVert *v) vi = cur->v1 == v ? 0 : 1; len++; - cur = *(&cur->v1_next + vi*2); + cur = *(&cur->v1_next + vi * 2); } return len; @@ -618,8 +617,8 @@ int bmesh_cycle_remove(void *h, void *remn) int i, len; BMNode *head, *remnode, *curnode; - head = (BMNode*)h; - remnode = (BMNode*)remn; + head = (BMNode *)h; + remnode = (BMNode *)remn; len = bmesh_cycle_length(h); if (len == 1 && head == remnode) { @@ -628,11 +627,11 @@ int bmesh_cycle_remove(void *h, void *remn) return 1; } else { - for (i=0, curnode = head; i < len; curnode = curnode->next) { + 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!*/ + /* zero out remnode pointers, important */ //remnode->next = NULL; //remnode->prev = NULL; return 1; @@ -658,20 +657,24 @@ int bmesh_cycle_validate(int len, void *h) { int i; BMNode *curnode, *head; - head = (BMNode*)h; + head = (BMNode *)h; - /*forward validation*/ + /* forward validatio */ for (i = 0, curnode = head; i < len; i++, curnode = curnode->next); - if (curnode != head) return 0; - - /*reverse validation*/ + if (curnode != head) { + return 0; + } + + /* reverse validatio */ for (i = 0, curnode = head; i < len; i++, curnode = curnode->prev); - if (curnode != head) return 0; - + if (curnode != head) { + return 0; + } + return 1; } -/*Begin Disk Cycle routines*/ +/* Begin Disk Cycle routine */ /** * bmesh_disk_nextedge @@ -701,7 +704,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*/ + /* returns pointer to the cycle node for the appropriate vertex in this dis */ if (e->v1 == v) return &(e->d1); else if (e->v2 == v) return &(e->d2); return NULL; @@ -721,17 +724,17 @@ 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 */ - /*check for loose vert first*/ + /* check for loose vert firs */ if (v->e == NULL) { v->e = e; base = tail = bmesh_disk_getpointer(e, v); - bmesh_cycle_append(base, tail); /*circular reference is ok!*/ + bmesh_cycle_append(base, tail); /* circular reference is ok */ return 1; } - /*insert e at the end of disk cycle and make it the new v->e*/ + /* insert e at the end of disk cycle and make it the new v-> */ base = bmesh_disk_getpointer(v->e, v); tail = bmesh_disk_getpointer(e, v); bmesh_cycle_append(base, tail); @@ -758,13 +761,13 @@ void bmesh_disk_remove_edge(BMEdge *e, BMVert *v) base = bmesh_disk_getpointer(v->e, v); remnode = bmesh_disk_getpointer(e, v); - /*first deal with v->e pointer...*/ + /* 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; else newbase = v->e; - /*remove and rebase*/ + /* remove and rebas */ bmesh_cycle_remove(base, remnode); v->e = newbase; } @@ -787,11 +790,11 @@ BMEdge *bmesh_disk_next_edgeflag(BMEdge *e, BMVert *v, int eflag, int tflag) if (eflag && tflag) return NULL; - ok = bmesh_vert_in_edge(e,v); + ok = bmesh_vert_in_edge(e, v); if (ok) { diskbase = bmesh_disk_getpointer(e, v); len = bmesh_cycle_length(diskbase); - curedge = bmesh_disk_nextedge(e,v); + curedge = bmesh_disk_nextedge(e, v); while (curedge != e) { if (eflag) { if (curedge->head.eflag1 == eflag) return curedge; @@ -816,14 +819,14 @@ int bmesh_disk_count_edgeflag(BMVert *v, int eflag, int tflag) { BMNode *diskbase; BMEdge *curedge; - int i, len=0, count=0; + int i, len = 0, count = 0; if (v->e) { - if (eflag && tflag) return 0; /*tflag and eflag are reserved for different functions!*/ + 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; ie; i < len; i++) { if (eflag) { if (curedge->head.eflag1 == eflag) count++; } @@ -838,15 +841,15 @@ int bmesh_disk_hasedge(BMVert *v, BMEdge *e) { BMNode *diskbase; BMEdge *curedge; - int i, len=0; + int i, len = 0; if (v->e) { - diskbase = bmesh_disk_getpointer(v->e,v); + diskbase = bmesh_disk_getpointer(v->e, v); len = bmesh_cycle_length(diskbase); - for (i = 0, curedge=v->e; ie; i < len; i++) { if (curedge == e) return 1; - else curedge=bmesh_disk_nextedge(curedge, v); + else curedge = bmesh_disk_nextedge(curedge, v); } } return 0; @@ -856,21 +859,21 @@ BMEdge *bmesh_disk_existedge(BMVert *v1, BMVert *v2) { BMNode *diskbase; BMEdge *curedge; - int i, len=0; + int i, len = 0; if (v1->e) { - diskbase = bmesh_disk_getpointer(v1->e,v1); + diskbase = bmesh_disk_getpointer(v1->e, v1); len = bmesh_cycle_length(diskbase); - for (i=0,curedge=v1->e;ie; i < len; i++, curedge = bmesh_disk_nextedge(curedge, v1)) { + if (bmesh_verts_in_edge(v1, v2, curedge)) return curedge; } } return NULL; } -/*end disk cycle routines*/ +/* end disk cycle routine */ BMLoop *bmesh_radial_nextloop(BMLoop *l) { return l->radial_next; @@ -887,18 +890,18 @@ void bmesh_radial_remove_loop(BMLoop *l, BMEdge *e) BMLoop *newbase; int len; - /*deal with edge->l pointer*/ + /* deal with edge->l pointe */ len = bmesh_cycle_length(&(e->l->radial)); if (len == 1) newbase = NULL; else if (e->l == l) newbase = e->l->radial_next; else newbase = e->l; - /*remove and rebase*/ + /* remove and rebas */ bmesh_cycle_remove(&(e->l->radial), &(l->radial)); e->l = newbase; } -int bmesh_radial_find_face(BMEdge *e,BMFace *f) +int bmesh_radial_find_face(BMEdge *e, BMFace *f) { BMLoop *curloop; @@ -918,7 +921,7 @@ int bmesh_radial_find_face(BMEdge *e,BMFace *f) * Returns the number of times a vertex appears * in a radial cycle * -*/ + */ int bmesh_radial_count_facevert(BMLoop *l, BMVert *v) { @@ -940,18 +943,18 @@ int bmesh_radial_count_facevert(BMLoop *l, BMVert *v) * equivalent to counting the number of * faces incident upon this vertex * -*/ + */ int bmesh_disk_count_facevert(BMVert *v) { BMEdge *curedge; int count = 0; - /*is there an edge on this vert at all?*/ + /* is there an edge on this vert at all */ if (!v->e) return count; - /*first, loop around edges*/ + /* first, loop around edge */ curedge = v->e; do { if (curedge->l) count += bmesh_radial_count_facevert(curedge->l, v); @@ -967,13 +970,16 @@ int bmesh_disk_count_facevert(BMVert *v) * Finds the first loop of v around radial * cycle * -*/ + */ 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); return NULL; @@ -986,7 +992,7 @@ BMLoop *bmesh_radial_find_next_facevert(BMLoop *l, BMVert *v) do { if (curloop->v == v) return curloop; curloop = bmesh_radial_nextloop(curloop); - } while (curloop !=l); + } while (curloop != l); return l; } @@ -998,17 +1004,17 @@ BMLoop *bmesh_radial_find_next_facevert(BMLoop *l, BMVert *v) * Disk cycle that has one of this * vert's loops attached * to it. - * - * -*/ + */ 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; - searchedge = bmesh_disk_nextedge(searchedge,v); + if (searchedge->l && bmesh_radial_count_facevert(searchedge->l, v)) { + return searchedge; + } + searchedge = bmesh_disk_nextedge(searchedge, v); } while (searchedge != e); return NULL; @@ -1017,11 +1023,13 @@ BMEdge *bmesh_disk_find_first_faceedge(BMEdge *e, BMVert *v) BMEdge *bmesh_disk_find_next_faceedge(BMEdge *e, BMVert *v) { BMEdge *searchedge = NULL; - searchedge = bmesh_disk_nextedge(e,v); + searchedge = bmesh_disk_nextedge(e, v); do { - if (searchedge->l && bmesh_radial_count_facevert(searchedge->l,v)) return searchedge; - searchedge = bmesh_disk_nextedge(searchedge,v); - } while (searchedge !=e); + if (searchedge->l && bmesh_radial_count_facevert(searchedge->l, v)) { + return searchedge; + } + searchedge = bmesh_disk_nextedge(searchedge, v); + } while (searchedge != e); return e; } @@ -1035,8 +1043,10 @@ struct BMLoop *bmesh_loop_find_loop(struct BMFace *f, struct BMVert *v) int i, len; len = bmesh_cycle_length(f->lbase); - for (i = 0, l=f->loopbase; i < len; i++, l= l->next) { - if (l->v == v) return l; + for (i = 0, l = f->loopbase; i < len; i++, l = l->next) { + if (l->v == v) { + return l; + } } return NULL; } diff --git a/source/blender/bmesh/intern/bmesh_walkers.c b/source/blender/bmesh/intern/bmesh_walkers.c index e29b8ccdd79..488f5cfa6b0 100644 --- a/source/blender/bmesh/intern/bmesh_walkers.c +++ b/source/blender/bmesh/intern/bmesh_walkers.c @@ -45,27 +45,26 @@ #include "bmesh_private.h" #include "bmesh_walkers_private.h" -/* - - joeedh - - design notes: - - original desing: walkers directly emulation recursive functions. - functions save their state onto a worklist, and also add new states - to implement recursive or looping behaviour. generally only one - state push per call with a specific state is desired. - - basic design pattern: the walker step function goes through it's - list of possible choices for recursion, and recurses (by pushing a new state) - using the first non-visited one. this choise is the flagged as visited using - the ghash. each step may push multiple new states onto the worklist at once. - - * walkers use tool flags, not header flags - * walkers now use ghash for storing visited elements, - rather then stealing flags. ghash can be rewritten - to be faster if necassary, in the far future :) . - * tools should ALWAYS have necassary error handling - for if walkers fail. -*/ +/* - joeedh - + * design notes: + * + * original desing: walkers directly emulation recursive functions. + * functions save their state onto a worklist, and also add new states + * to implement recursive or looping behaviour. generally only one + * state push per call with a specific state is desired. + * + * basic design pattern: the walker step function goes through it's + * list of possible choices for recursion, and recurses (by pushing a new state) + * using the first non-visited one. this choise is the flagged as visited using + * the ghash. each step may push multiple new states onto the worklist at once. + * + * - walkers use tool flags, not header flags + * - walkers now use ghash for storing visited elements, + * rather then stealing flags. ghash can be rewritten + * to be faster if necassary, in the far future :) . + * - tools should ALWAYS have necassary error handling + * for if walkers fail. + */ void *BMW_Begin(BMWalker *walker, void *start) { @@ -80,8 +79,7 @@ void *BMW_Begin(BMWalker *walker, void *start) * Allocates and returns a new mesh walker of * a given type. The elements visited are filtered * by the bitmask 'searchmask'. - * -*/ + */ void BMW_Init(BMWalker *walker, BMesh *bm, int type, short mask_vert, short mask_edge, short mask_loop, short mask_face, @@ -103,7 +101,7 @@ void BMW_Init(BMWalker *walker, BMesh *bm, int type, bmesh_error(); fprintf(stderr, "Invalid walker type in BMW_Init; type: %d, " - "searchmask: (v:%d,e:%d,l:%d,f:%d), flag: %d\n", + "searchmask: (v:%d, e:%d, l:%d, f:%d), flag: %d\n", type, mask_vert, mask_edge, mask_loop, mask_face, layer); } @@ -118,10 +116,10 @@ void BMW_Init(BMWalker *walker, BMesh *bm, int type, /* safety checks */ /* if this raises an error either the caller is wrong or * 'bm_walker_types' needs updating */ - BLI_assert(mask_vert==0 || (walker->valid_mask & BM_VERT)); - BLI_assert(mask_edge==0 || (walker->valid_mask & BM_EDGE)); - BLI_assert(mask_loop==0 || (walker->valid_mask & BM_LOOP)); - BLI_assert(mask_face==0 || (walker->valid_mask & BM_FACE)); + BLI_assert(mask_vert == 0 || (walker->valid_mask & BM_VERT)); + BLI_assert(mask_edge == 0 || (walker->valid_mask & BM_EDGE)); + BLI_assert(mask_loop == 0 || (walker->valid_mask & BM_LOOP)); + BLI_assert(mask_face == 0 || (walker->valid_mask & BM_FACE)); } walker->worklist = BLI_mempool_create(walker->structsize, 100, 100, TRUE, FALSE); @@ -132,8 +130,7 @@ void BMW_Init(BMWalker *walker, BMesh *bm, int type, * BMW_End * * Frees a walker's worklist. - * -*/ + */ void BMW_End(BMWalker *walker) { @@ -144,8 +141,7 @@ void BMW_End(BMWalker *walker) /* * BMW_Step - * -*/ + */ void *BMW_Step(BMWalker *walker) { @@ -160,8 +156,7 @@ void *BMW_Step(BMWalker *walker) * BMW_CurrentDepth * * Returns the current depth of the walker. - * -*/ + */ int BMW_CurrentDepth(BMWalker *walker) { @@ -175,8 +170,7 @@ int BMW_CurrentDepth(BMWalker *walker) * * BMESH_TODO: * -add searchmask filtering - * -*/ + */ void *BMW_walk(BMWalker *walker) { @@ -184,7 +178,9 @@ void *BMW_walk(BMWalker *walker) while (BMW_currentstate(walker)) { current = walker->step(walker); - if (current) return current; + if (current) { + return current; + } } return NULL; } @@ -195,23 +191,22 @@ void *BMW_walk(BMWalker *walker) * Returns the first state from the walker state * worklist. This state is the the next in the * worklist for processing. - * -*/ + */ void* BMW_currentstate(BMWalker *walker) { bmesh_walkerGeneric *currentstate = walker->states.first; if (currentstate) { /* Automatic update of depth. For most walkers that - follow the standard "Step" pattern of: - - read current state - - remove current state - - push new states - - return walk result from just-removed current state - this simple automatic update should keep track of depth - just fine. Walkers that deviate from that pattern may - need to manually update the depth if they care about - keeping it correct. */ + * follow the standard "Step" pattern of: + * - read current state + * - remove current state + * - push new states + * - return walk result from just-removed current state + * this simple automatic update should keep track of depth + * just fine. Walkers that deviate from that pattern may + * need to manually update the depth if they care about + * keeping it correct. */ walker->depth = currentstate->depth + 1; } return currentstate; @@ -222,8 +217,7 @@ void* BMW_currentstate(BMWalker *walker) * * Remove and free an item from the end of the walker state * worklist. - * -*/ + */ void BMW_removestate(BMWalker *walker) { @@ -241,8 +235,7 @@ void BMW_removestate(BMWalker *walker) * can fill in the state data. The new state will be inserted * at the front for depth-first walks, and at the end for * breadth-first walks. - * -*/ + */ void* BMW_addstate(BMWalker *walker) { @@ -269,8 +262,7 @@ void* BMW_addstate(BMWalker *walker) * * Frees all states from the worklist, resetting the walker * for reuse in a new walk. - * -*/ + */ void BMW_reset(BMWalker *walker) { diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index b8a3ed778ff..0daf9aaabfb 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -52,7 +52,7 @@ * * Add restriction flag/callback for wire edges. * -*/ + */ static void shellWalker_visitEdge(BMWalker *walker, BMEdge *e) { @@ -88,7 +88,7 @@ static void shellWalker_begin(BMWalker *walker, void *data) { /* starting the walk at a vert, add all the edges to the worklist */ - v = (BMVert*)h; + v = (BMVert *)h; BM_ITER(e, &eiter, walker->bm, BM_EDGES_OF_VERT, v) { shellWalker_visitEdge(walker, e); } @@ -99,7 +99,7 @@ static void shellWalker_begin(BMWalker *walker, void *data) { /* starting the walk at an edge, add the single edge to the worklist */ - e = (BMEdge*)h; + e = (BMEdge *)h; shellWalker_visitEdge(walker, e); break; } @@ -123,7 +123,7 @@ static void *shellWalker_step(BMWalker *walker) e = swalk->curedge; BMW_removestate(walker); - for (i=0; i<2; i++) { + for (i = 0; i < 2; i++) { v = i ? e->v2 : e->v1; BM_ITER(e2, &iter, walker->bm, BM_EDGES_OF_VERT, v) { shellWalker_visitEdge(walker, e2); @@ -139,7 +139,7 @@ static void *shellWalker_step(BMWalker *walker) BMEdge *curedge, *next = NULL; BMVert *ov = NULL; int restrictpass = 1; - shellWalker shellWalk = *((shellWalker*)BMW_currentstate(walker)); + shellWalker shellWalk = *((shellWalker *)BMW_currentstate(walker)); if (!BLI_ghash_haskey(walker->visithash, shellWalk.base)) BLI_ghash_insert(walker->visithash, shellWalk.base, NULL); @@ -147,7 +147,7 @@ static void *shellWalker_step(BMWalker *walker) BMW_removestate(walker); - /*find the next edge whose other vertex has not been visited*/ + /* find the next edge whose other vertex has not been visite */ curedge = shellWalk.curedge; do { if (!BLI_ghash_haskey(walker->visithash, curedge)) { @@ -158,11 +158,11 @@ static void *shellWalker_step(BMWalker *walker) ov = BM_OtherEdgeVert(curedge, shellWalk.base); - /*push a new state onto the stack*/ + /* push a new state onto the stac */ newState = BMW_addstate(walker); BLI_ghash_insert(walker->visithash, curedge, NULL); - /*populate the new state*/ + /* populate the new stat */ newState->base = ov; newState->curedge = curedge; @@ -179,7 +179,7 @@ static void *shellWalker_step(BMWalker *walker) * * Similar to shell walker, but visits vertices instead of edges. * -*/ + */ static void connectedVertexWalker_visitVertex(BMWalker *walker, BMVert *v) { @@ -241,7 +241,7 @@ static void *connectedVertexWalker_step(BMWalker *walker) * * Add restriction flag/callback for wire edges. * -*/ + */ static void islandboundWalker_begin(BMWalker *walker, void *data) { @@ -271,7 +271,7 @@ static void *islandboundWalker_step(BMWalker *walker) BMEdge *e = iwalk->curloop->e; BMFace *f; BMLoop *l = iwalk->curloop; - /* int found=0; */ + /* int found = 0; */ owalk = *iwalk; @@ -280,13 +280,13 @@ static void *islandboundWalker_step(BMWalker *walker) if (BM_Nonmanifold_Vert(walker->bm, v)) { BMW_reset(walker); - BMO_RaiseError(walker->bm, NULL,BMERR_WALKER_FAILED, - "Non-manifold vert" - " while searching region boundary"); + BMO_RaiseError(walker->bm, NULL, BMERR_WALKER_FAILED, + "Non-manifold vert " + "while searching region boundary"); return NULL; } - /*pop off current state*/ + /* pop off current stat */ BMW_removestate(walker); f = l->f; @@ -309,8 +309,12 @@ static void *islandboundWalker_step(BMWalker *walker) } } - if (l == owalk.curloop) return NULL; - if (BLI_ghash_haskey(walker->visithash, l)) return owalk.curloop; + if (l == owalk.curloop) { + return NULL; + } + else if (BLI_ghash_haskey(walker->visithash, l)) { + return owalk.curloop; + } BLI_ghash_insert(walker->visithash, l, NULL); iwalk = BMW_addstate(walker); @@ -333,7 +337,7 @@ static void *islandboundWalker_step(BMWalker *walker) * * Add restriction flag/callback for wire edges. * -*/ + */ static void islandWalker_begin(BMWalker *walker, void *data) { @@ -359,7 +363,7 @@ static void *islandWalker_yield(BMWalker *walker) static void *islandWalker_step(BMWalker *walker) { islandWalker *iwalk = BMW_currentstate(walker); - /* islandWalker *owalk= iwalk; */ /* UNUSED */ + /* islandWalker *owalk = iwalk; */ /* UNUSED */ BMIter iter, liter; BMFace *f, *curf = iwalk->cur; BMLoop *l; @@ -367,14 +371,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; } @@ -395,14 +399,14 @@ static void *islandWalker_step(BMWalker *walker) * * Starts at a tool-flagged edge and walks over the edge loop * -*/ + */ static void loopWalker_begin(BMWalker *walker, void *data) { loopWalker *lwalk = NULL, owalk; BMEdge *e = data; BMVert *v; - /* int found=1, val; */ /* UNUSED */ + /* int found = 1, val; */ /* UNUSED */ v = e->v1; @@ -416,9 +420,9 @@ static void loopWalker_begin(BMWalker *walker, void *data) lwalk->stage2 = 0; lwalk->startrad = BM_Edge_FaceCount(e); - /*rewind*/ + /* rewin */ while (BMW_currentstate(walker)) { - owalk = *((loopWalker*)BMW_currentstate(walker)); + owalk = *((loopWalker *)BMW_currentstate(walker)); BMW_walk(walker); } @@ -449,7 +453,7 @@ static void *loopWalker_step(BMWalker *walker) BMEdge *e = lwalk->cur, *nexte = NULL; BMLoop *l, *l2; BMVert *v; - int val, rlen /* , found=0 */, i=0, stopi; + int val, rlen /* , found = 0 */, i = 0, stopi; owalk = *lwalk; BMW_removestate(walker); @@ -460,7 +464,7 @@ static void *loopWalker_step(BMWalker *walker) if (!l) { /* match trunk: mark all connected wire edges */ - for (i=0; i<2; i++) { + for (i = 0; i < 2; i++) { v = i ? e->v2 : e->v1; BM_ITER(nexte, &eiter, walker->bm, BM_EDGES_OF_VERT, v) { @@ -529,41 +533,41 @@ static void *loopWalker_step(BMWalker *walker) * Conditions for starting and stepping the face loop have been * tuned in an attempt to match the face loops built by EditMesh * -*/ + */ -/*Check whether the face loop should includes the face specified - by the given BMLoop*/ +/* Check whether the face loop should includes the face specified + * by the given BMLoop */ static int faceloopWalker_include_face(BMWalker *walker, BMLoop *l) { - /*face must have degree 4*/ + /* face must have degree 4 */ if (l->f->len != 4) return 0; - /*the face must not have been already visited*/ + /* the face must not have been already visite */ if (BLI_ghash_haskey(walker->visithash, l->f)) return 0; return 1; } -/*Check whether the face loop can start from the given edge*/ +/* Check whether the face loop can start from the given edge */ static int faceloopWalker_edge_begins_loop(BMWalker *walker, BMEdge *e) { BMesh *bm = walker->bm; - /*There is no face loop starting from a wire edges*/ + /* There is no face loop starting from a wire edge */ if (BM_Wire_Edge(bm, e)) { return 0; } - /*Don't start a loop from a boundary edge if it cannot - be extended to cover any faces*/ + /* Don't start a loop from a boundary edge if it cannot + * be extended to cover any faces */ if (BM_Edge_FaceCount(e) == 1) { if (!faceloopWalker_include_face(walker, e->l)) return 0; } - /*Don't start a face loop from non-manifold edges*/ + /* Don't start a face loop from non-manifold edges */ if (BM_Nonmanifold_Edge(bm, e)) { return 0; } @@ -586,9 +590,9 @@ static void faceloopWalker_begin(BMWalker *walker, void *data) lwalk->nocalc = 0; BLI_ghash_insert(walker->visithash, lwalk->l->f, NULL); - /*rewind*/ + /* rewin */ while (BMW_currentstate(walker)) { - owalk = *((faceloopWalker*)BMW_currentstate(walker)); + owalk = *((faceloopWalker *)BMW_currentstate(walker)); BMW_walk(walker); } @@ -605,7 +609,9 @@ static void *faceloopWalker_yield(BMWalker *walker) { faceloopWalker *lwalk = BMW_currentstate(walker); - if (!lwalk) return NULL; + if (!lwalk) { + return NULL; + } return lwalk->l->f; } @@ -656,7 +662,7 @@ static void *faceloopWalker_step(BMWalker *walker) * Conditions for starting and stepping the edge ring have been * tuned in an attempt to match the edge rings built by EditMesh * -*/ + */ static void edgeringWalker_begin(BMWalker *walker, void *data) { @@ -676,9 +682,9 @@ static void edgeringWalker_begin(BMWalker *walker, void *data) BLI_ghash_insert(walker->visithash, lwalk->l->e, NULL); - /*rewind*/ + /* rewin */ while (BMW_currentstate(walker)) { - owalk = *((edgeringWalker*)BMW_currentstate(walker)); + owalk = *((edgeringWalker *)BMW_currentstate(walker)); BMW_walk(walker); } @@ -697,7 +703,9 @@ static void *edgeringWalker_yield(BMWalker *walker) { edgeringWalker *lwalk = BMW_currentstate(walker); - if (!lwalk) return NULL; + if (!lwalk) { + return NULL; + } if (lwalk->l) return lwalk->l->e; @@ -719,10 +727,10 @@ static void *edgeringWalker_step(BMWalker *walker) e = l->e; if (BM_Nonmanifold_Edge(bm, e)) { - /*walker won't traverse to a non-manifold edge, but may - be started on one, and should not traverse *away* from - a non-manfold edge (non-manifold edges are never in an - edge ring with manifold edges*/ + /* walker won't traverse to a non-manifold edge, but may + * be started on one, and should not traverse *away* from + * a non-manfold edge (non-manifold edges are never in an + * edge ring with manifold edges */ return e; } @@ -733,7 +741,7 @@ static void *edgeringWalker_step(BMWalker *walker) l = lwalk->l->next->next; } - /*only walk to manifold edges*/ + /* only walk to manifold edge */ if ((l->f->len == 4) && !BM_Nonmanifold_Edge(bm, l->e) && !BLI_ghash_haskey(walker->visithash, l->e)) { lwalk = BMW_addstate(walker); @@ -763,8 +771,10 @@ static void *uvedgeWalker_yield(BMWalker *walker) { uvedgeWalker *lwalk = BMW_currentstate(walker); - if (!lwalk) return NULL; - + if (!lwalk) { + return NULL; + } + return lwalk->l; } @@ -785,16 +795,16 @@ static void *uvedgeWalker_step(BMWalker *walker) if (walker->mask_edge && !BMO_TestFlag(walker->bm, l->e, walker->mask_edge)) return l; - /*go over loops around l->v and nl->v and see which ones share l and nl's - mloopuv's coordinates. in addition, push on l->next if necassary.*/ - for (i=0; i<2; i++) { + /* go over loops around l->v and nl->v and see which ones share l and nl's + mloopuv's coordinates. in addition, push on l->next if necassary */ + for (i = 0; i < 2; i++) { cl = i ? nl : l; BM_ITER(l2, &liter, walker->bm, BM_LOOPS_OF_VERT, cl->v) { d1 = CustomData_bmesh_get_layer_n(&walker->bm->ldata, cl->head.data, walker->layer); rlen = BM_Edge_FaceCount(l2->e); - for (j=0; jvisithash, l2)) continue; if (walker->mask_edge && !(BMO_TestFlag(walker->bm, l2->e, walker->mask_edge))) diff --git a/source/blender/bmesh/operators/bevel.c b/source/blender/bmesh/operators/bevel.c index b3ba6e154fd..c2d83f83b21 100644 --- a/source/blender/bmesh/operators/bevel.c +++ b/source/blender/bmesh/operators/bevel.c @@ -41,12 +41,12 @@ static void calc_corner_co(BMesh *bm, BMLoop *l, const float fac, float r_co[3], copy_v3_v3(l_co, l->v->co); copy_v3_v3(l_co_next, l->next->v->co); - /*calculate normal*/ + /* calculate norma */ sub_v3_v3v3(l_vec_prev, l_co_prev, l_co); sub_v3_v3v3(l_vec_next, l_co_next, l_co); cross_v3_v3v3(no, l_vec_prev, l_vec_next); - is_concave= dot_v3v3(no, l->f->no) > 0.0f; + is_concave = dot_v3v3(no, l->f->no) > 0.0f; } else { BMIter iter; @@ -81,7 +81,7 @@ static void calc_corner_co(BMesh *bm, BMLoop *l, const float fac, float r_co[3], normalize_v3(l_vec_prev); normalize_v3(l_vec_next); - add_v3_v3v3(co_ofs, l_vec_prev,l_vec_next); + add_v3_v3v3(co_ofs, l_vec_prev, l_vec_next); normalize_v3(co_ofs); if (do_even) { @@ -100,8 +100,8 @@ static void calc_corner_co(BMesh *bm, BMLoop *l, const float fac, float r_co[3], * gives nicer, move even output. * * Use the minimum rather then the middle value so skinny faces don't flip along the short axis */ - float min_fac= minf(normalize_v3(l_vec_prev), normalize_v3(l_vec_next)); - float angle= do_even ? angle_normalized_v3v3(l_vec_prev, l_vec_next) : 0.0f; /* get angle while normalized */ + float min_fac = minf(normalize_v3(l_vec_prev), normalize_v3(l_vec_next)); + float angle = do_even ? angle_normalized_v3v3(l_vec_prev, l_vec_next) : 0.0f; /* get angle while normalized */ mul_v3_fl(l_vec_prev, min_fac); mul_v3_fl(l_vec_next, min_fac); @@ -146,7 +146,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) BMEdge *e; BMVert *v; BMFace **faces = NULL, *f; - LoopTag *tags=NULL, *tag; + LoopTag *tags = NULL, *tag; EdgeTag *etags = NULL; BMVert **verts = NULL; BMEdge **edges = NULL; @@ -195,7 +195,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) #if 0 //a bit of cleaner code that, alas, doens't work. - /*build edge tags*/ + /* build edge tag */ BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (BMO_TestFlag(bm, e->v1, BEVEL_FLAG) || BMO_TestFlag(bm, e->v2, BEVEL_FLAG)) { BMIter liter; @@ -237,7 +237,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) } #endif - /*create and assign looptag structures*/ + /* create and assign looptag structure */ BMO_ITER(e, &siter, bm, op, "geom", BM_EDGE) { BMLoop *l; BMIter liter; @@ -253,29 +253,29 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) if (!BLI_smallhash_haskey(&hash, (intptr_t)e)) { BLI_array_growone(etags); - BM_SetIndex(e, BLI_array_count(etags)-1); /* set_dirty! */ + BM_SetIndex(e, BLI_array_count(etags) - 1); /* set_dirty! */ BLI_smallhash_insert(&hash, (intptr_t)e, NULL); BMO_SetFlag(bm, e, EDGE_OLD); } - /*find all faces surrounding e->v1 and, e->v2*/ - for (i=0; i<2; i++) { - BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, i?e->v2:e->v1) { + /* find all faces surrounding e->v1 and, e->v2 */ + for (i = 0; i < 2; i++) { + BM_ITER(l, &liter, bm, BM_LOOPS_OF_VERT, i ? e->v2:e->v1) { BMLoop *l2; BMIter liter2; - /*see if we've already processed this loop's face*/ + /* see if we've already processed this loop's fac */ if (BLI_smallhash_haskey(&hash, (intptr_t)l->f)) continue; - /*create tags for all loops in l->f*/ + /* create tags for all loops in l-> */ BM_ITER(l2, &liter2, bm, BM_LOOPS_OF_FACE, l->f) { BLI_array_growone(tags); - BM_SetIndex(l2, BLI_array_count(tags)-1); /* set_loop */ + BM_SetIndex(l2, BLI_array_count(tags) - 1); /* set_loop */ if (!BLI_smallhash_haskey(&hash, (intptr_t)l2->e)) { BLI_array_growone(etags); - BM_SetIndex(l2->e, BLI_array_count(etags)-1); /* set_dirty! */ + BM_SetIndex(l2->e, BLI_array_count(etags) - 1); /* set_dirty! */ BLI_smallhash_insert(&hash, (intptr_t)l2->e, NULL); BMO_SetFlag(bm, l2->e, EDGE_OLD); } @@ -304,7 +304,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) v2 = BM_OtherEdgeVert(e, v); sub_v3_v3v3(co, v2->co, v->co); if (has_elens) { - float elen = *(float*)CustomData_bmesh_get_n(&bm->edata, e->head.data, CD_PROP_FLT, li); + float elen = *(float *)CustomData_bmesh_get_n(&bm->edata, e->head.data, CD_PROP_FLT, li); normalize_v3(co); mul_v3_fl(co, elen); @@ -319,7 +319,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) } } - for (i=0; inewv) { sub_v3_v3v3(co, l->prev->v->co, l->v->co); if (has_elens) { - float elen = *(float*)CustomData_bmesh_get_n(&bm->edata, l->prev->e->head.data, CD_PROP_FLT, li); + float elen = *(float *)CustomData_bmesh_get_n(&bm->edata, l->prev->e->head.data, CD_PROP_FLT, li); normalize_v3(co); mul_v3_fl(co, elen); @@ -364,7 +364,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) if (!tag->newv) { sub_v3_v3v3(co, l->next->v->co, l->v->co); if (has_elens) { - float elen = *(float*)CustomData_bmesh_get_n(&bm->edata, l->e->head.data, CD_PROP_FLT, li); + float elen = *(float *)CustomData_bmesh_get_n(&bm->edata, l->e->head.data, CD_PROP_FLT, li); normalize_v3(co); mul_v3_fl(co, elen); @@ -387,12 +387,12 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) } } - /*create new faces inset from original faces*/ - for (i=0; iprev->e, e); BLI_array_append(edges, e); } - lastv=tag->newv; + lastv = tag->newv; v2 = ETAG_GET(l->e, l->next->v); @@ -443,14 +443,14 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) BMO_SetFlag(bm, f, FACE_NEW); } - for (i=0; ie, BEVEL_FLAG)) continue; @@ -468,11 +468,11 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) } } else { - /*the loop is on a boundary*/ + /* the loop is on a boundar */ v3 = l->next->v; v4 = l->v; - for (j=0; j<2; j++) { + for (j = 0; j < 2; j++) { BMIter eiter; BMVert *v = j ? v4 : v3; @@ -513,7 +513,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) BM_Copy_Attributes(bm, bm, l->e, e1); BM_Copy_Attributes(bm, bm, l->e, e2); - /*set edge lengths of cross edges as the average of the cross edges they're based on*/ + /* set edge lengths of cross edges as the average of the cross edges they're based o */ if (has_elens) { #if 0 /* angle happens not to be used. why? - not sure it just isnt - campbell. leave this in incase we need to use it later */ float ang; @@ -531,20 +531,20 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) } d3 = CustomData_bmesh_get_n(&bm->edata, e1->head.data, CD_PROP_FLT, li); - d1 = *(float*)CustomData_bmesh_get_n(&bm->edata, l->prev->e->head.data, CD_PROP_FLT, li); - d2 = *(float*)CustomData_bmesh_get_n(&bm->edata, l2->e->head.data, CD_PROP_FLT, li); + d1 = *(float *)CustomData_bmesh_get_n(&bm->edata, l->prev->e->head.data, CD_PROP_FLT, li); + d2 = *(float *)CustomData_bmesh_get_n(&bm->edata, l2->e->head.data, CD_PROP_FLT, li); #if 0 ang = angle_v3v3v3(l->prev->v->co, l->v->co, BM_OtherEdgeVert(l2->e, l->v)->co); #endif - *d3 = (d1+d2)*0.5f; + *d3 = (d1 + d2) * 0.5f; d3 = CustomData_bmesh_get_n(&bm->edata, e2->head.data, CD_PROP_FLT, li); - d1 = *(float*)CustomData_bmesh_get_n(&bm->edata, l->next->e->head.data, CD_PROP_FLT, li); - d2 = *(float*)CustomData_bmesh_get_n(&bm->edata, l3->e->head.data, CD_PROP_FLT, li); + d1 = *(float *)CustomData_bmesh_get_n(&bm->edata, l->next->e->head.data, CD_PROP_FLT, li); + d2 = *(float *)CustomData_bmesh_get_n(&bm->edata, l3->e->head.data, CD_PROP_FLT, li); #if 0 ang = angle_v3v3v3(BM_OtherEdgeVert(l->next->e, l->next->v)->co, l->next->v->co, BM_OtherEdgeVert(l3->e, l->next->v)->co); #endif - *d3 = (d1+d2)*0.5f; + *d3 = (d1 + d2) * 0.5f; } if (!f) { @@ -554,7 +554,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) BMO_SetFlag(bm, f, FACE_NEW|FACE_SPAN); - /*un-tag edges in f for deletion*/ + /* un-tag edges in f for deletio */ BM_ITER(l2, &liter2, bm, BM_LOOPS_OF_FACE, f) { BMO_ClearFlag(bm, l2->e, BEVEL_DEL); } @@ -565,12 +565,12 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) } } - /*fill in holes at vertices*/ + /* fill in holes at vertices */ BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { BMIter eiter; - BMVert *vv, *vstart=NULL, *lastv=NULL; + BMVert *vv, *vstart = NULL, *lastv = NULL; SmallHash tmphash; - int rad, insorig=0, err=0; + int rad, insorig = 0, err = 0; BLI_smallhash_init(&tmphash); @@ -582,7 +582,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, v) { BMIter liter; - BMVert *v1=NULL, *v2=NULL; + BMVert *v1 = NULL, *v2 = NULL; BMLoop *l; if (BM_Edge_FaceCount(e) < 2) @@ -598,10 +598,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) rad++; - if (l->v == v) - tag = tags + BM_GetIndex(l); - else - tag = tags + BM_GetIndex(l->next); + tag = tags + BM_GetIndex((l->v == v) ? l : l->next); if (!v1) v1 = tag->newv; @@ -638,8 +635,8 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) BLI_smallhash_insert(&tmphash, (intptr_t)v, NULL); } - /*find edges that exist between vertices in verts. this is basically - a topological walk of the edges connecting them.*/ + /* find edges that exist between vertices in verts. this is basically + * a topological walk of the edges connecting them */ vstart = vstart ? vstart : verts[0]; vv = vstart; do { @@ -647,14 +644,14 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) BMVert *vv2 = BM_OtherEdgeVert(e, vv); if (vv2 != lastv && BLI_smallhash_haskey(&tmphash, (intptr_t)vv2)) { - /*if we've go over the same vert twice, break out of outer loop*/ + /* if we've go over the same vert twice, break out of outer loop */ if (BLI_smallhash_lookup(&tmphash, (intptr_t)vv2) != NULL) { e = NULL; err = 1; break; } - /*use self pointer as tag*/ + /* use self pointer as ta */ BLI_smallhash_remove(&tmphash, (intptr_t)vv2); BLI_smallhash_insert(&tmphash, (intptr_t)vv2, vv2); @@ -664,19 +661,22 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) break; } } - if (e == NULL) + + if (e == NULL) { break; + } } while (vv != vstart); - if (err) + if (err) { continue; - - /*there may not be a complete loop of edges, so start again and make - final edge afterwards. in this case, the previous loop worked to - find one of the two edges at the extremes.*/ + } + + /* there may not be a complete loop of edges, so start again and make + * final edge afterwards. in this case, the previous loop worked to + * find one of the two edges at the extremes. */ if (vv != vstart) { - /*undo previous tagging*/ - for (i=0; ilen == 2) { BMFace *faces[2] = {f, bm_firstfaceloop(f)->radial_next->f}; @@ -819,7 +819,7 @@ void bmesh_bevel_exec(BMesh *bm, BMOperator *op) BMO_CallOpf(bm, "del geom=%fv context=%i", BEVEL_DEL, DEL_VERTS); - /*clean up any edges that might not get properly deleted*/ + /* clean up any edges that might not get properly delete */ BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (BMO_TestFlag(bm, e, EDGE_OLD) && !e->l) BMO_SetFlag(bm, e, BEVEL_DEL); diff --git a/source/blender/bmesh/operators/bmesh_dupeops.c b/source/blender/bmesh/operators/bmesh_dupeops.c index b3610ea8bfb..4de7dd8eb1f 100644 --- a/source/blender/bmesh/operators/bmesh_dupeops.c +++ b/source/blender/bmesh/operators/bmesh_dupeops.c @@ -10,8 +10,8 @@ #include "bmesh.h" #include "bmesh_operators_private.h" -/*local flag defines*/ -#define DUPE_INPUT 1 /*input from operator*/ +/* local flag define */ +#define DUPE_INPUT 1 /* input from operato */ #define DUPE_NEW 2 #define DUPE_DONE 4 #define DUPE_MAPPED 8 @@ -21,22 +21,22 @@ * * Copy an existing vertex from one bmesh to another. * -*/ + */ static BMVert *copy_vertex(BMesh *source_mesh, BMVert *source_vertex, BMesh *target_mesh, GHash *vhash) { BMVert *target_vertex = NULL; - /*Create a new vertex*/ + /* Create a new verte */ target_vertex = BM_Make_Vert(target_mesh, source_vertex->co, NULL); - /*Insert new vertex into the vert hash*/ + /* Insert new vertex into the vert has */ BLI_ghash_insert(vhash, source_vertex, target_vertex); - /*Copy attributes*/ + /* Copy attribute */ BM_Copy_Attributes(source_mesh, target_mesh, source_vertex, target_vertex); - /*Set internal op flags*/ - BMO_SetFlag(target_mesh, (BMHeader*)target_vertex, DUPE_NEW); + /* Set internal op flag */ + BMO_SetFlag(target_mesh, (BMHeader *)target_vertex, DUPE_NEW); return target_vertex; } @@ -46,7 +46,7 @@ static BMVert *copy_vertex(BMesh *source_mesh, BMVert *source_vertex, BMesh *tar * * Copy an existing edge from one bmesh to another. * -*/ + */ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh, BMEdge *source_edge, BMesh *target_mesh, GHash *vhash, GHash *ehash) @@ -57,40 +57,40 @@ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh, BMIter fiter; int rlen; - /*see if any of the neighboring faces are - not being duplicated. in that case, - add it to the new/old map.*/ + /* see if any of the neighboring faces are + * not being duplicated. in that case, + * add it to the new/old map. */ rlen = 0; - for (face=BMIter_New(&fiter,source_mesh, BM_FACES_OF_EDGE,source_edge); - face; face=BMIter_Step(&fiter)) { + for (face = BMIter_New(&fiter, source_mesh, BM_FACES_OF_EDGE, source_edge); + face; face = BMIter_Step(&fiter)) { if (BMO_TestFlag(source_mesh, face, DUPE_INPUT)) { rlen++; } } - /*Lookup v1 and v2*/ + /* Lookup v1 and v2 */ target_vert1 = BLI_ghash_lookup(vhash, source_edge->v1); target_vert2 = BLI_ghash_lookup(vhash, source_edge->v2); - /*Create a new edge*/ + /* Create a new edg */ target_edge = BM_Make_Edge(target_mesh, target_vert1, target_vert2, NULL, 0); - /*add to new/old edge map if necassary*/ + /* add to new/old edge map if necassar */ if (rlen < 2) { - /*not sure what non-manifold cases of greater then three - radial should do.*/ - BMO_Insert_MapPointer(source_mesh,op, "boundarymap", - source_edge, target_edge); + /* not sure what non-manifold cases of greater then three + * radial should do. */ + BMO_Insert_MapPointer(source_mesh, op, "boundarymap", + source_edge, target_edge); } - /*Insert new edge into the edge hash*/ + /* Insert new edge into the edge hash */ BLI_ghash_insert(ehash, source_edge, target_edge); - /*Copy attributes*/ + /* Copy attributes */ BM_Copy_Attributes(source_mesh, target_mesh, source_edge, target_edge); - /*Set internal op flags*/ - BMO_SetFlag(target_mesh, (BMHeader*)target_edge, DUPE_NEW); + /* Set internal op flags */ + BMO_SetFlag(target_mesh, (BMHeader *)target_edge, DUPE_NEW); return target_edge; } @@ -99,8 +99,8 @@ static BMEdge *copy_edge(BMOperator *op, BMesh *source_mesh, * COPY FACE * * Copy an existing face from one bmesh to another. - * -*/ + */ + static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, BMFace *source_face, BMesh *target_mesh, BMVert **vtar, BMEdge **edar, GHash *vhash, GHash *ehash) @@ -111,7 +111,7 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, BMIter iter, iter2; int i; - /*lookup the first and second verts*/ + /* lookup the first and second vert */ #if 0 /* UNUSED */ target_vert1 = BLI_ghash_lookup(vhash, BMIter_New(&iter, source_mesh, BM_VERTS_OF_FACE, source_face)); target_vert2 = BLI_ghash_lookup(vhash, BMIter_Step(&iter)); @@ -120,26 +120,28 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, BMIter_Step(&iter); #endif - /*lookup edges*/ - for (i=0,source_loop=BMIter_New(&iter, source_mesh, BM_LOOPS_OF_FACE, source_face); - source_loop; source_loop=BMIter_Step(&iter), i++) { + /* lookup edge */ + for (i = 0, source_loop = BMIter_New(&iter, source_mesh, BM_LOOPS_OF_FACE, source_face); + source_loop; + source_loop = BMIter_Step(&iter), i++) + { vtar[i] = BLI_ghash_lookup(vhash, source_loop->v); edar[i] = BLI_ghash_lookup(ehash, source_loop->e); } - /*create new face*/ + /* create new fac */ target_face = BM_Make_Face(target_mesh, vtar, edar, source_face->len, 0); - BMO_Insert_MapPointer(source_mesh, op, - "facemap", source_face, target_face); - BMO_Insert_MapPointer(source_mesh, op, - "facemap", target_face, source_face); + BMO_Insert_MapPointer(source_mesh, op, + "facemap", source_face, target_face); + BMO_Insert_MapPointer(source_mesh, op, + "facemap", target_face, source_face); BM_Copy_Attributes(source_mesh, target_mesh, source_face, target_face); - /*mark the face for output*/ - BMO_SetFlag(target_mesh, (BMHeader*)target_face, DUPE_NEW); + /* mark the face for outpu */ + BMO_SetFlag(target_mesh, (BMHeader *)target_face, DUPE_NEW); - /*copy per-loop custom data*/ + /* copy per-loop custom dat */ BM_ITER(source_loop, &iter, source_mesh, BM_LOOPS_OF_FACE, source_face) { BM_ITER(target_loop, &iter2, target_mesh, BM_LOOPS_OF_FACE, target_face) { if (BLI_ghash_lookup(vhash, source_loop->v) == target_loop->v) { @@ -176,12 +178,12 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) GHash *vhash; GHash *ehash; - /*initialize pointer hashes*/ + /* initialize pointer hashe */ 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))) { + if (BMO_TestFlag(source, (BMHeader *)v, DUPE_INPUT) && (!BMO_TestFlag(source, (BMHeader *)v, DUPE_DONE))) { BMIter iter; int iso = 1; @@ -206,44 +208,44 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) if (iso) BMO_Insert_MapPointer(source, op, "isovertmap", v, v2); - BMO_SetFlag(source, (BMHeader*)v, DUPE_DONE); + BMO_SetFlag(source, (BMHeader *)v, DUPE_DONE); } } - /*now we dupe all the edges*/ + /* now we dupe all the edge */ 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, DUPE_INPUT) && (!BMO_TestFlag(source, (BMHeader *)e, DUPE_DONE))) { + /* make sure that verts are copie */ + if (!BMO_TestFlag(source, (BMHeader *)e->v1, DUPE_DONE)) { copy_vertex(source, e->v1, target, vhash); - BMO_SetFlag(source, (BMHeader*)e->v1, DUPE_DONE); + 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); + BMO_SetFlag(source, (BMHeader *)e->v2, DUPE_DONE); } - /*now copy the actual edge*/ + /* now copy the actual edg */ copy_edge(op, source, e, target, vhash, ehash); - BMO_SetFlag(source, (BMHeader*)e, DUPE_DONE); + BMO_SetFlag(source, (BMHeader *)e, DUPE_DONE); } } - /*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)) { - /*vertex pass*/ + /* first we dupe all flagged faces and their elements from sourc */ + 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 pas */ 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); + if (!BMO_TestFlag(source, (BMHeader *)v, DUPE_DONE)) { + copy_vertex(source, v, target, vhash); + BMO_SetFlag(source, (BMHeader *)v, DUPE_DONE); } } - /*edge pass*/ + /* edge pas */ for (e = BMIter_New(&edges, source, BM_EDGES_OF_FACE, f); e; e = BMIter_Step(&edges)) { - if (!BMO_TestFlag(source, (BMHeader*)e, DUPE_DONE)) { + if (!BMO_TestFlag(source, (BMHeader *)e, DUPE_DONE)) { copy_edge(op, source, e, target, vhash, ehash); - BMO_SetFlag(source, (BMHeader*)e, DUPE_DONE); + BMO_SetFlag(source, (BMHeader *)e, DUPE_DONE); } } @@ -255,11 +257,11 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) BLI_array_growitems(edar, f->len); copy_face(op, source, f, target, vtar, edar, vhash, ehash); - BMO_SetFlag(source, (BMHeader*)f, DUPE_DONE); + BMO_SetFlag(source, (BMHeader *)f, DUPE_DONE); } } - /*free pointer hashes*/ + /* free pointer hashe */ BLI_ghash_free(vhash, NULL, NULL); BLI_ghash_free(ehash, NULL, NULL); @@ -287,7 +289,7 @@ static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) * BMOP_DUPE_ENEW: Buffer containing pointers to the new mesh edges * BMOP_DUPE_FNEW: Buffer containing pointers to the new mesh faces * -*/ + */ void dupeop_exec(BMesh *bm, BMOperator *op) { @@ -297,24 +299,24 @@ void dupeop_exec(BMesh *bm, BMOperator *op) if (!bm2) bm2 = bm; - /*flag input*/ + /* flag inpu */ BMO_Flag_Buffer(bm, dupeop, "geom", DUPE_INPUT, BM_ALL); - /*use the internal copy function*/ + /* use the internal copy functio */ copy_mesh(dupeop, bm, bm2); - /*Output*/ - /*First copy the input buffers to output buffers - original data*/ + /* Outpu */ + /* First copy the input buffers to output buffers - original dat */ BMO_CopySlot(dupeop, dupeop, "geom", "origout"); - /*Now alloc the new output buffers*/ + /* Now alloc the new output buffer */ BMO_Flag_To_Slot(bm, dupeop, "newout", DUPE_NEW, BM_ALL); } -/*executes the duplicate operation, feeding elements of +/* executes the duplicate operation, feeding elements of type flag etypeflag and header flag flag to it. note, to get more useful information (such as the mapping from - original to new elements) you should run the dupe op manually.*/ + original to new elements) you should run the dupe op manually */ void BMOP_DupeFromFlag(BMesh *bm, int etypeflag, const char hflag) { BMOperator dupeop; @@ -343,7 +345,7 @@ void BMOP_DupeFromFlag(BMesh *bm, int etypeflag, const char hflag) * BMOP_DUPE_EOUTPUT: Buffer containing pointers to the split mesh edges * BMOP_DUPE_FOUTPUT: Buffer containing pointers to the split mesh faces * -*/ + */ #define SPLIT_INPUT 1 void splitop_exec(BMesh *bm, BMOperator *op) @@ -357,7 +359,7 @@ void splitop_exec(BMesh *bm, BMOperator *op) BMIter iter, iter2; int found; - /*initialize our sub-operators*/ + /* initialize our sub-operator */ BMO_Init_Op(bm, &dupeop, "dupe"); BMO_Init_Op(bm, &delop, "del"); @@ -366,11 +368,11 @@ void splitop_exec(BMesh *bm, BMOperator *op) BMO_Flag_Buffer(bm, splitop, "geom", SPLIT_INPUT, BM_ALL); - /*make sure to remove edges and verts we don't need.*/ - for (e= BMIter_New(&iter, bm, BM_EDGES_OF_MESH, NULL);e;e=BMIter_Step(&iter)) { + /* make sure to remove edges and verts we don't need */ + 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; @@ -379,10 +381,10 @@ void splitop_exec(BMesh *bm, BMOperator *op) if (!found) BMO_SetFlag(bm, e, SPLIT_INPUT); } - for (v= BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);v;v=BMIter_Step(&iter)) { + 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; @@ -392,20 +394,20 @@ void splitop_exec(BMesh *bm, BMOperator *op) } - /*connect outputs of dupe to delete, exluding keep geometry*/ + /* connect outputs of dupe to delete, exluding keep geometr */ BMO_Set_Int(&delop, "context", DEL_FACES); BMO_Flag_To_Slot(bm, &delop, "geom", SPLIT_INPUT, BM_ALL); BMO_Exec_Op(bm, &delop); - /*now we make our outputs by copying the dupe outputs*/ + /* now we make our outputs by copying the dupe output */ BMO_CopySlot(&dupeop, splitop, "newout", "geomout"); BMO_CopySlot(&dupeop, splitop, "boundarymap", "boundarymap"); BMO_CopySlot(&dupeop, splitop, "isovertmap", "isovertmap"); - /*cleanup*/ + /* cleanu */ BMO_Finish_Op(bm, &delop); BMO_Finish_Op(bm, &dupeop); } @@ -420,7 +422,7 @@ void delop_exec(BMesh *bm, BMOperator *op) { BMOperator *delop = op; - /*Mark Buffers*/ + /* Mark Buffer */ BMO_Flag_Buffer(bm, delop, "geom", DEL_INPUT, BM_ALL); delete_context(bm, BMO_Get_Int(op, "context")); @@ -437,13 +439,13 @@ static void delete_verts(BMesh *bm) 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)) { - /*Visit edges*/ + if (BMO_TestFlag(bm, (BMHeader *)v, DEL_INPUT)) { + /* Visit edge */ 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*/ + BMO_SetFlag(bm, (BMHeader *)e, DEL_INPUT); + /* Visit face */ for (f = BMIter_New(&faces, bm, BM_FACES_OF_VERT, v); f; f = BMIter_Step(&faces)) - BMO_SetFlag(bm, (BMHeader*)f, DEL_INPUT); + BMO_SetFlag(bm, (BMHeader *)f, DEL_INPUT); } } @@ -461,9 +463,9 @@ static void delete_edges(BMesh *bm) 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)) { + 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); + BMO_SetFlag(bm, (BMHeader *)f, DEL_INPUT); } } } @@ -471,15 +473,15 @@ static void delete_edges(BMesh *bm) BM_remove_tagged_edges(bm, DEL_INPUT); } -/*you need to make remove tagged verts/edges/faces - api functions that take a filter callback..... - and this new filter type will be for opstack flags. - This is because the BM_remove_taggedXXX functions bypass iterator API. - -Ops dont care about 'UI' considerations like selection state, hide state, ect. If you want to work on unhidden selections for instance, - copy output from a 'select context' operator to another operator.... -*/ +/* you need to make remove tagged verts/edges/faces + * api functions that take a filter callback..... + * and this new filter type will be for opstack flags. + * This is because the BM_remove_taggedXXX functions bypass iterator API. + * - Ops dont care about 'UI' considerations like selection state, hide state, ect. If you want to work on unhidden selections for instance, + * copy output from a 'select context' operator to another operator.... + */ -/*Break this into smaller functions*/ +/* Break this into smaller functions */ static void delete_context(BMesh *bm, int type) { @@ -493,18 +495,18 @@ static void delete_context(BMesh *bm, int type) if (type == DEL_VERTS) delete_verts(bm); else if (type == DEL_EDGES) { - /*flush down to verts*/ + /* flush down to vert */ 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); + 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*/ + /* remove loose vertice */ 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); + if (BMO_TestFlag(bm, (BMHeader *)v, DEL_INPUT) && (!(v->e))) + BMO_SetFlag(bm, (BMHeader *)v, DEL_WIREVERT); } BM_remove_tagged_verts(bm, DEL_WIREVERT); } @@ -516,48 +518,48 @@ static void delete_context(BMesh *bm, int type) BM_remove_tagged_verts(bm, DEL_INPUT); } else if (type == DEL_FACES) { - /*go through and mark all edges and all verts of all faces for delete*/ + /* go through and mark all edges and all verts of all faces for delet */ for (f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)) { - if (BMO_TestFlag(bm, (BMHeader*)f, DEL_INPUT)) { + 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); + BMO_SetFlag(bm, (BMHeader *)e, DEL_INPUT); for (v = BMIter_New(&verts, bm, BM_VERTS_OF_FACE, f); v; v = BMIter_Step(&verts)) - BMO_SetFlag(bm, (BMHeader*)v, DEL_INPUT); + BMO_SetFlag(bm, (BMHeader *)v, DEL_INPUT); } } - /*now go through and mark all remaining faces all edges for keeping.*/ + /* 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)) { - BMO_ClearFlag(bm, (BMHeader*)e, DEL_INPUT); + 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)) { - BMO_ClearFlag(bm, (BMHeader*)v, DEL_INPUT); + 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.*/ + /* 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)) { - BMO_ClearFlag(bm, (BMHeader*)e->v1, DEL_INPUT); - BMO_ClearFlag(bm, (BMHeader*)e->v2, DEL_INPUT); + if (!BMO_TestFlag(bm, (BMHeader *)e, DEL_INPUT)) { + BMO_ClearFlag(bm, (BMHeader *)e->v1, DEL_INPUT); + BMO_ClearFlag(bm, (BMHeader *)e->v2, DEL_INPUT); } } - /*now delete marked faces*/ + /* now delete marked face */ BM_remove_tagged_faces(bm, DEL_INPUT); - /*delete marked edges*/ + /* delete marked edge */ BM_remove_tagged_edges(bm, DEL_INPUT); - /*remove loose vertices*/ + /* remove loose vertice */ BM_remove_tagged_verts(bm, DEL_INPUT); } - /*does this option even belong in here?*/ + /* 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)) - BMO_SetFlag(bm, (BMHeader*)f, DEL_INPUT); + BMO_SetFlag(bm, (BMHeader *)f, DEL_INPUT); for (e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)) - BMO_SetFlag(bm, (BMHeader*)e, DEL_INPUT); + BMO_SetFlag(bm, (BMHeader *)e, DEL_INPUT); for (v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)) - BMO_SetFlag(bm, (BMHeader*)v, DEL_INPUT); + BMO_SetFlag(bm, (BMHeader *)v, DEL_INPUT); BM_remove_tagged_faces(bm, DEL_INPUT); BM_remove_tagged_edges(bm, DEL_INPUT); @@ -570,7 +572,7 @@ static void delete_context(BMesh *bm, int type) * * Extrude or duplicate geometry a number of times, * rotating and possibly translating after each step -*/ + */ void spinop_exec(BMesh *bm, BMOperator *op) { @@ -588,7 +590,7 @@ void spinop_exec(BMesh *bm, BMOperator *op) BMO_Get_Vec(op, "dvec", dvec); usedvec = !is_zero_v3(dvec); steps = BMO_Get_Int(op, "steps"); - phi = BMO_Get_Float(op, "ang")*(float)M_PI/(360.0f*steps); + phi = BMO_Get_Float(op, "ang") * (float)M_PI / (360.0f * steps); dupli = BMO_Get_Int(op, "dupli"); si = (float)sin(phi); @@ -599,7 +601,7 @@ void spinop_exec(BMesh *bm, BMOperator *op) quat_to_mat3(rmat, q); BMO_CopySlot(op, op, "geom", "lastout"); - for (a=0; av, VERT_INPUT)) { if (!lastl) { lastl = l; continue; } - if (lastl != l->prev && lastl != - l->next) - { + if (lastl != l->prev && lastl != l->next) { BLI_array_growone(loops); - loops[BLI_array_count(loops)-1] = lastl; + loops[BLI_array_count(loops) - 1] = lastl; BLI_array_growone(loops); - loops[BLI_array_count(loops)-1] = l; + loops[BLI_array_count(loops) - 1] = l; } lastl = l; @@ -63,32 +61,30 @@ void connectverts_exec(BMesh *bm, BMOperator *op) if (BLI_array_count(loops) > 2) { BLI_array_growone(loops); - loops[BLI_array_count(loops)-1] = loops[BLI_array_count(loops)-2]; + loops[BLI_array_count(loops) - 1] = loops[BLI_array_count(loops) - 2]; BLI_array_growone(loops); - loops[BLI_array_count(loops)-1] = loops[0]; + loops[BLI_array_count(loops) - 1] = loops[0]; } - BM_LegalSplits(bm, f, (BMLoop *(*)[2])loops, BLI_array_count(loops)/2); + BM_LegalSplits(bm, f, (BMLoop *(*)[2])loops, BLI_array_count(loops) / 2); - for (i=0; iv; + verts[BLI_array_count(verts) - 1] = loops[i * 2]->v; BLI_array_growone(verts); - verts[BLI_array_count(verts)-1] = loops[i*2+1]->v; + verts[BLI_array_count(verts) - 1] = loops[i * 2 + 1]->v; } - for (i=0; iv1) { - if (BMO_TestFlag(bm, e2, EDGE_MARK)) + if (BMO_TestFlag(bm, e2, EDGE_MARK)) { i++; + } } - - if (i==2) - return e->v2; - else - return e->v1; + + return (i == 2) ? e->v2 : e->v1; } /* Clamp x to the interval {0..len-1}, with wrap-around */ @@ -159,7 +153,7 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) BMOIter siter; BMIter iter; BMEdge *e, *nexte; - int c=0, cl1=0, cl2=0; + int c = 0, cl1 = 0, cl2 = 0; BMO_Flag_Buffer(bm, op, "edges", EDGE_MARK, BM_EDGE); @@ -188,7 +182,7 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) /* edges do not form a loop: there is a disk * with more than two marked edges. */ BMO_RaiseError(bm, op, BMERR_INVALID_SELECTION, - "Selection must only contain edges from two edge loops"); + "Selection must only contain edges from two edge loops"); goto cleanup; } } @@ -204,7 +198,7 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) e = e2; ov = v; do { - if (c==0) { + if (c == 0) { BLI_array_append(ee1, e2); BLI_array_append(vv1, v); } @@ -226,8 +220,8 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) } while (e3 && e2 != e); if (v && !e3) { - if (c==0) { - if (BLI_array_count(vv1) && v == vv1[BLI_array_count(vv1)-1]) { + if (c == 0) { + if (BLI_array_count(vv1) && v == vv1[BLI_array_count(vv1) - 1]) { printf("%s: internal state waning *TODO DESCRIPTION!*\n", __func__); } BLI_array_append(vv1, v); @@ -239,10 +233,12 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) /* test for connected loops, and set cl1 or cl2 if so */ if (v == ov) { - if (c==0) + if (c == 0) { cl1 = 1; - else + } + else { cl2 = 1; + } } c++; @@ -252,7 +248,7 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) if (ee1 && ee2) { int i, j; BMVert *v1, *v2, *v3, *v4; - int starti=0, dir1=1, wdir=0, lenv1, lenv2; + int starti = 0, dir1 = 1, wdir = 0, lenv1, lenv2; /* Simplify code below by avoiding the (!cl1 && cl2) case */ if (!cl1 && cl2) { @@ -272,15 +268,15 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) * the bridge instead of quads only. */ if (BLI_array_count(ee1) != BLI_array_count(ee2)) { BMO_RaiseError(bm, op, BMERR_INVALID_SELECTION, - "Selected loops must have equal edge counts"); + "Selected loops must have equal edge counts"); goto cleanup; } j = 0; - if (vv1[0] == vv1[lenv1-1]) { + if (vv1[0] == vv1[lenv1 - 1]) { lenv1--; } - if (vv2[0] == vv2[lenv2-1]) { + if (vv2[0] == vv2[lenv2 - 1]) { lenv2--; } @@ -318,7 +314,7 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) * the vertices in both loops to find a more accurate match for the * starting point and winding direction of the bridge generation. */ - for (i=0; ico, vv2[0]->co) < min) { min = len_v3v3(vv1[i]->co, vv2[0]->co); starti = i; @@ -326,8 +322,8 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) } /* Reverse iteration order for the first loop if the distance of - * the (starti-1) vert from vv1 is a better match for vv2[1] than - * the (starti+1) vert. + * the (starti - 1) vert from vv1 is a better match for vv2[1] than + * the (starti + 1) vert. * * This is not always going to be right, but it will work better in * the average case. @@ -345,7 +341,7 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) /* Vert rough attempt to determine proper winding for the bridge quads: * just uses the first loop it finds for any of the edges of ee2 or ee1 */ if (wdir == 0) { - for (i=0; il) { wdir = (ee2[i]->l->v == vv2[i]) ? (-1) : (1); break; @@ -353,7 +349,7 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) } } if (wdir == 0) { - for (i=0; il && ee2[j]->l) { wdir = (ee2[j]->l->v == vv2[j]) ? (1) : (-1); @@ -363,7 +359,7 @@ void bmesh_bridge_loops_exec(BMesh *bm, BMOperator *op) } /* Generate the bridge quads */ - for (i=0; iv1 ? (Link*)&(((EdgeData*)(ed))->dlink1) : (Link*)&(((EdgeData*)(ed))->dlink2)) +#define rs_get_edge_link(e, v, ed) ((v) == ((BMEdge *)(e))->v1 ? (Link *)&(((EdgeData *)(ed))->dlink1) : (Link *)&(((EdgeData *)(ed))->dlink2)) static int rotsys_append_edge(struct BMEdge *e, struct BMVert *v, EdgeData *edata, VertData *vdata) @@ -74,10 +74,10 @@ static int rotsys_append_edge(struct BMEdge *e, struct BMVert *v, VertData *vd = &vdata[BM_GetIndex(v)]; if (!vd->e) { - Link *e1 = (Link*)rs_get_edge_link(e, v, ed); + Link *e1 = (Link *)rs_get_edge_link(e, v, ed); vd->e = e; - e1->next = e1->prev = (Link*)e; + e1->next = e1->prev = (Link *)e; } else { Link *e1, *e2, *e3; @@ -87,12 +87,12 @@ static int rotsys_append_edge(struct BMEdge *e, struct BMVert *v, e2 = rs_get_edge_link(vd->e, v, ved); e3 = e2->prev ? rs_get_edge_link(e2->prev, v, &edata[BM_GetIndex(e2->prev)]) : NULL; - e1->next = (Link*)vd->e; + e1->next = (Link *)vd->e; e1->prev = e2->prev; - e2->prev = (Link*)e; + e2->prev = (Link *)e; if (e3) - e3->next = (Link*)e; + e3->next = (Link *)e; } return 1; @@ -117,7 +117,7 @@ static void UNUSED_FUNCTION(rotsys_remove_edge)(struct BMEdge *e, struct BMVert } if (vd->e == e) - vd->e = (e != (BMEdge *)e1->next) ? (BMEdge*)e1->next : NULL; + vd->e = (e != (BMEdge *)e1->next) ? (BMEdge *)e1->next : NULL; e1->next = e1->prev = NULL; } @@ -157,12 +157,12 @@ static void rotsys_reverse(struct BMEdge *UNUSED(e), struct BMVert *v, EdgeData } while (e != e_first); totedge = BLI_array_count(edges); - for (i=0; i= (1<<20)) { + if (i >= (1 << 20)) { printf("bmesh error: infinite loop in disk cycle!\n"); return 0; } @@ -201,7 +201,7 @@ static int UNUSED_FUNCTION(rotsys_fill_faces)(BMesh *bm, EdgeData *edata, VertDa BMVert *v, **verts = NULL; BMFace *f; BLI_array_declare(verts); - SmallHash visithash, *hash=&visithash; + SmallHash visithash, *hash = &visithash; int i; BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { @@ -216,8 +216,8 @@ static int UNUSED_FUNCTION(rotsys_fill_faces)(BMesh *bm, EdgeData *edata, VertDa else continue; - /*do two passes, going forward then backward*/ - for (i=0; i<2; i++) { + /* do two passes, going forward then backwar */ + for (i = 0; i < 2; i++) { BLI_smallhash_init(hash); BLI_array_empty(verts); @@ -264,11 +264,11 @@ static void rotsys_make_consistent(BMesh *bm, EdgeData *edata, VertData *vdata) { BMIter iter; BMEdge *e; - BMVert *v, **stack=NULL; + BMVert *v, **stack = NULL; BLI_array_declare(stack); int i; - for (i=0; itotvert; i++) { + for (i = 0; i < bm->totvert; i++) { vdata[i].tag = 0; } @@ -278,7 +278,7 @@ static void rotsys_make_consistent(BMesh *bm, EdgeData *edata, VertData *vdata) float dis; v = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); - for (i=0; itotvert; i++, BMIter_Step(&iter)) { + for (i = 0; i < bm->totvert; i++, BMIter_Step(&iter)) { vd = vdata + BM_GetIndex(v); if (vd->tag) @@ -312,7 +312,7 @@ static void rotsys_make_consistent(BMesh *bm, EdgeData *edata, VertData *vdata) BMVert *v2 = BM_OtherEdgeVert(e, v); VertData *vd2 = vdata + BM_GetIndex(v2); - if (dot_v3v3(vd->no, vd2->no) < 0.0f+FLT_EPSILON*2) { + if (dot_v3v3(vd->no, vd2->no) < 0.0f + FLT_EPSILON * 2) { rotsys_reverse(e, v2, edata, vdata); mul_v3_fl(vd2->no, -1.0f); } @@ -337,8 +337,8 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) BMEdge **edges = NULL; BLI_array_staticdeclare(edges, BM_NGON_STACK_SIZE); BMVert *v; - /*BMVert **verts = NULL; */ - /*BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE);*/ /*UNUSED*/ + /* BMVert **verts = NULL; */ + /* BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE); */ /* UNUSE */ int i; #define SIGN(n) ((n)<0.0f) @@ -346,7 +346,7 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { BMIter eiter; float no[3], cent[3]; - int j, k=0, totedge=0; + int j, k = 0, totedge = 0; if (BM_GetIndex(v) == -1) continue; @@ -363,12 +363,12 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) copy_v3_v3(cent, v->co); zero_v3(no); - for (i=0; ico, v->co); sub_v3_v3v3(vec2, (BM_OtherEdgeVert(e2, v))->co, v->co); @@ -376,15 +376,15 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) cross_v3_v3v3(cno, vec1, vec2); normalize_v3(cno); - if (i && dot_v3v3(cno, no) < 0.0f+FLT_EPSILON*10) + if (i && dot_v3v3(cno, no) < 0.0f + FLT_EPSILON * 10) mul_v3_fl(cno, -1.0f); add_v3_v3(no, cno); normalize_v3(no); } - /*generate plane-flattened coordinates*/ - for (i=0; isco, cent); sub_v3_v3v3(vec2, vd2->sco, cent); @@ -432,18 +437,18 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) size = (len_v3(vec1) + len_v3(vec3)) * 0.01f; normalize_v3(vec1); normalize_v3(vec2); normalize_v3(vec3); - #ifdef STRAIGHT - #undef STRAIGHT - #endif - #define STRAIGHT(vec11, vec22) (fabsf(dot_v3v3((vec11), (vec22))) > 1.0f - ((float)FLT_EPSILON*1000.0f)) +#ifdef STRAIGHT +#undef STRAIGHT +#endif +#define STRAIGHT(vec11, vec22) (fabsf(dot_v3v3((vec11), (vec22))) > 1.0f - ((float)FLT_EPSILON * 1000.0f)) s1 = STRAIGHT(vec1, vec2); s2 = STRAIGHT(vec2, vec3); s3 = STRAIGHT(vec1, vec3); if (s1 || s2 || s3) { copy_v3_v3(cent, v->co); - for (j=0; j<3; j++) { - float fac = (BLI_frand()-0.5f)*size; + for (j = 0; j < 3; j++) { + float fac = (BLI_frand() - 0.5f)*size; cent[j] += fac; } @@ -463,23 +468,28 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) copy_v3_v3(vdata[BM_GetIndex(v)].offco, cent); //copy_v3_v3(v->co, cent); - /*now, sort edges so the triangle fan of all edges - has a consistent normal. this is the same as - sorting by polar coordinates along a group normal*/ - for (j=0; jsco, cent); sub_v3_v3v3(vec2, vd2->sco, cent); @@ -491,9 +501,9 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) /* Other way to determine if two vectors approach are (nearly) parallel: the cross product of the two vectors will approach zero */ - s1 = (dot_v3v3(n1, n1) < (0.0f + FLT_EPSILON*10)); - s2 = (dot_v3v3(n2, n2) < (0.0f + FLT_EPSILON*10)); - s3 = (totedge < 3) ? 0 : (dot_v3v3(n3, n3) < (0.0f + FLT_EPSILON*10)); + s1 = (dot_v3v3(n1, n1) < (0.0f + FLT_EPSILON * 10)); + s2 = (dot_v3v3(n2, n2) < (0.0f + FLT_EPSILON * 10)); + s3 = (totedge < 3) ? 0 : (dot_v3v3(n3, n3) < (0.0f + FLT_EPSILON * 10)); normalize_v3(n1); normalize_v3(n2); normalize_v3(n3); @@ -501,24 +511,24 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) fprintf(stderr, "%s: s1: %d, s2: %d, s3: %dx (bmesh internal error)\n", __func__, s1, s2, s3); } 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]); + if (dot_v3v3(n1, n3) >= 0.0f + FLT_EPSILON * 10) { + SWAP(BMEdge*, edges[i], edges[(i + 1) % totedge]); } else { - SWAP(BMEdge*, edges[(i+totedge-1)%totedge], edges[(i+1)%totedge]) - SWAP(BMEdge*, edges[i], edges[(i+1)%totedge]) + SWAP(BMEdge*, edges[(i + totedge - 1) % totedge], edges[(i + 1) % totedge]) + SWAP(BMEdge*, edges[i], edges[(i + 1) % totedge]) } } } } - #undef STRAIGHT - +#undef STRAIGHT + zero_v3(no); - - /*yay, edges is sorted*/ - for (i=0; ico, v->co, BM_OtherEdgeVert(e2, v)->co); @@ -531,14 +541,14 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) copy_v3_v3(vdata[BM_GetIndex(v)].no, no); } - /*now, make sure rotation system is topologically consistent - (e.g. vert normals consistently point either inside or outside)*/ + /* now, make sure rotation system is topologically consistent + * (e.g. vert normals consistently point either inside or outside) */ rotsys_make_consistent(bm, edata, vdata); //rotsys_fill_faces(bm, edata, vdata); #if 0 - /*create visualizing geometry*/ + /* create visualizing geometr */ BMVert *lastv; BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { BMVert *v2; @@ -556,7 +566,7 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) do { BMEdge *e2; BMVert *v2; - float f = ((float)i / (float)totedge)*0.35 + 0.05; + float f = ((float)i / (float)totedge) * 0.35 + 0.05; float co[3]; if (!e) @@ -618,7 +628,7 @@ static EPath *edge_copy_add_path(PathBase *pb, EPath *path, BMVert *appendv, BME path2->weight = 0.0f; path2->group = path->group; - for (node=path->nodes.first; node; node=node->next) { + for (node = path->nodes.first; node; node = node->next) { node2 = BLI_mempool_alloc(pb->nodepool); *node2 = *node; BLI_addtail(&path2->nodes, node2); @@ -656,17 +666,17 @@ static EPath *edge_path_new(PathBase *pb, BMVert *start, BMEdge *starte) static float edge_weight_path(EPath *path, EdgeData *edata, VertData *UNUSED(vdata)) { - EPathNode *node, *first=path->nodes.first; + EPathNode *node, *first = path->nodes.first; float w = 0.0; - for (node=path->nodes.first; node; node=node->next) { + for (node = path->nodes.first; node; node = node->next) { if (node->e && node != path->nodes.first) { w += edata[BM_GetIndex(node->e)].ftag; if (node->prev) { - /*BMESH_TODO*/ + /* BMESH_TOD */ (void)first; - //w += len_v3v3(node->v->co, first->e->v1->co)*0.0001f; - //w += len_v3v3(node->v->co, first->e->v2->co)*0.0001f; + //w += len_v3v3(node->v->co, first->e->v1->co) * 0.0001f; + //w += len_v3v3(node->v->co, first->e->v2->co) * 0.0001f; } } @@ -681,7 +691,7 @@ static void edge_free_path(PathBase *pathbase, EPath *path) { EPathNode *node, *next; - for (node=path->nodes.first; node; node=next) { + for (node = path->nodes.first; node; node = next) { next = node->next; BLI_mempool_free(pathbase->nodepool, node); } @@ -722,10 +732,10 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E v1 = last->v; if (v1 == endv) { - /*make sure this path loop doesn't already exist*/ + /* make sure this path loop doesn't already exist */ i = 0; BLI_array_empty(verts); - for (i=0, node = path->nodes.first; node; node=node->next, i++) { + for (i = 0, node = path->nodes.first; node; node = node->next, i++) { BLI_array_growone(verts); verts[i] = node->v; } @@ -787,10 +797,10 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E continue; } - /*add path back into heap*/ + /* add path back into hea */ BLI_heap_insert(heap, path->weight, path); - /*put v2 in gh map*/ + /* put v2 in gh ma */ BLI_ghash_insert(gh, v2, NULL); path2 = edge_copy_add_path(pathbase, path, v2, e); @@ -799,7 +809,7 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E BLI_heap_insert(heap, path2->weight, path2); } - if (path && ((EPathNode*)path->nodes.last)->v != endv) { + if (path && ((EPathNode *)path->nodes.last)->v != endv) { edge_free_path(pathbase, path); path = NULL; } @@ -813,19 +823,21 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E static int count_edge_faces(BMesh *bm, BMEdge *e) { - int i=0; + int i = 0; BMLoop *l = e->l; - if (!l) + if (!l) { return 0; - + } + do { - if (!BMO_TestFlag(bm, l->f, FACE_IGNORE)) + if (!BMO_TestFlag(bm, l->f, FACE_IGNORE)) { i++; + } l = l->radial_next; } while (l != e->l); - + return i; } @@ -882,7 +894,7 @@ void bmesh_edgenet_fill_exec(BMesh *bm, BMOperator *op) group = 0; BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) { - /*if restrict is on, only start on faces in the restrict map*/ + /* if restrict is on, only start on faces in the restrict map */ if (use_restrict && !BMO_InMap(bm, op, "restrict", e)) continue; @@ -890,21 +902,22 @@ void bmesh_edgenet_fill_exec(BMesh *bm, BMOperator *op) edge = e; if (use_restrict) { - int i=0, j=0, gi=0; + int i = 0, j = 0, gi = 0; group = BMO_Get_MapInt(bm, op, "restrict", e); - for (i=0; i<30; i++) { - if (group & (1<nodes.first; node; node=node->next) { + for (node = path->nodes.first; node; node = node->next) { if (!node->next) continue; e = BM_Edge_Exist(node->v, node->next->v); - /*this should never happen*/ + /* this should never happe */ if (!e) break; @@ -956,32 +969,33 @@ void bmesh_edgenet_fill_exec(BMesh *bm, BMOperator *op) edges[i++] = edge; edata[BM_GetIndex(edge)].ftag++; - for (j=0; j= 2) { + for (j = 0; j < i; j++) { + if (count_edge_faces(bm, edges[j]) >= 2) { edge_free_path(pathbase, path); break; } } - - if (j != i) + + if (j != i) { continue; - + } + if (i) { BMVert *v1, *v2; /* to define the winding order must select first edge, * otherwise we could leave this as-is */ - edge= edges[0]; + edge = edges[0]; /* if these are even it doesnt really matter what to do, * with consistent geometry one will be zero, the choice is clear */ if (winding[0] > winding[1]) { - v1= verts[0]; - v2= verts[1]; + v1 = verts[0]; + v2 = verts[1]; } else { - v1= verts[1]; - v2= verts[0]; + v1 = verts[1]; + v2 = verts[0]; } f = BM_Make_Ngon(bm, v1, v2, edges, i, 1); @@ -1011,10 +1025,11 @@ static BMEdge *edge_next(BMesh *bm, BMEdge *e) BMEdge *e2; int i; - for (i=0; i<2; i++) { - BM_ITER(e2, &iter, bm, BM_EDGES_OF_VERT, i?e->v2:e->v1) { - if (BMO_TestFlag(bm, e2, EDGE_MARK) - && !BMO_TestFlag(bm, e2, EDGE_VIS) && e2 != e) + for (i = 0; i < 2; i++) { + BM_ITER(e2, &iter, bm, BM_EDGES_OF_VERT, i ? e->v2 : e->v1) { + if ( (BMO_TestFlag(bm, e2, EDGE_MARK)) && + (!BMO_TestFlag(bm, e2, EDGE_VIS)) && + (e2 != e)) { return e2; } @@ -1037,44 +1052,53 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) BMO_Flag_Buffer(bm, op, "edges", EDGE_MARK, BM_EDGE); - /*validate that each edge has at most one other tagged edge in the - disk cycle around each of it's vertices*/ + /* validate that each edge has at most one other tagged edge in the + * disk cycle around each of it's vertices */ BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) { - for (i=0; i<2; i++) { - count = BMO_Vert_CountEdgeFlags(bm, i?e->v2:e->v1, EDGE_MARK); + for (i = 0; i < 2; i++) { + count = BMO_Vert_CountEdgeFlags(bm, i ? e->v2 : e->v1, EDGE_MARK); if (count > 2) { ok = 0; break; } } - if (!ok) break; + if (!ok) { + break; + } } - /*we don't have valid edge layouts, return*/ - if (!ok) + /* we don't have valid edge layouts, retur */ + if (!ok) { return; + } - - /*find connected loops within the input edges*/ + /* find connected loops within the input edge */ count = 0; while (1) { BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) { if (!BMO_TestFlag(bm, e, EDGE_VIS)) { - if (BMO_Vert_CountEdgeFlags(bm, e->v1, EDGE_MARK)==1) - break; - if (BMO_Vert_CountEdgeFlags(bm, e->v2, EDGE_MARK)==1) + if ( BMO_Vert_CountEdgeFlags(bm, e->v1, EDGE_MARK) == 1 || + BMO_Vert_CountEdgeFlags(bm, e->v2, EDGE_MARK) == 1) + { break; + } } } - if (!e) break; - - if (!count) + if (!e) { + break; + } + + if (!count) { edges = edges1; - else if (count==1) + } + else if (count == 1) { edges = edges2; - else break; + } + else { + break; + } i = 0; while (e) { @@ -1099,8 +1123,8 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) count++; } - if (edges1 && BLI_array_count(edges1) > 2 && BM_Edge_Share_Vert(edges1[0], edges1[BLI_array_count(edges1)-1])) { - if (edges2 && BLI_array_count(edges2) > 2 && BM_Edge_Share_Vert(edges2[0], edges2[BLI_array_count(edges2)-1])) { + if (edges1 && BLI_array_count(edges1) > 2 && BM_Edge_Share_Vert(edges1[0], edges1[BLI_array_count(edges1) - 1])) { + if (edges2 && BLI_array_count(edges2) > 2 && BM_Edge_Share_Vert(edges2[0], edges2[BLI_array_count(edges2) - 1])) { BLI_array_free(edges1); BLI_array_free(edges2); return; @@ -1111,15 +1135,15 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) } } - if (edges2 && BLI_array_count(edges2) > 2 && BM_Edge_Share_Vert(edges2[0], edges2[BLI_array_count(edges2)-1])) { + if (edges2 && BLI_array_count(edges2) > 2 && BM_Edge_Share_Vert(edges2[0], edges2[BLI_array_count(edges2) - 1])) { edges2 = NULL; } - /*two unconnected loops, connect them*/ + /* two unconnected loops, connect the */ if (edges1 && edges2) { BMVert *v1, *v2, *v3, *v4; - if (BLI_array_count(edges1)==1) { + if (BLI_array_count(edges1) == 1) { v1 = edges1[0]->v1; v2 = edges1[0]->v2; } @@ -1128,13 +1152,13 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) v1 = edges1[0]->v2; else v1 = edges1[0]->v1; - i = BLI_array_count(edges1)-1; - if (BM_Vert_In_Edge(edges1[i-1], edges1[i]->v1)) + i = BLI_array_count(edges1) - 1; + if (BM_Vert_In_Edge(edges1[i - 1], edges1[i]->v1)) v2 = edges1[i]->v2; else v2 = edges1[i]->v1; } - if (BLI_array_count(edges2)==1) { + if (BLI_array_count(edges2) == 1) { v3 = edges2[0]->v1; v4 = edges2[0]->v2; } @@ -1143,8 +1167,8 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) v3 = edges2[0]->v2; else v3 = edges2[0]->v1; - i = BLI_array_count(edges2)-1; - if (BM_Vert_In_Edge(edges2[i-1], edges2[i]->v1)) + i = BLI_array_count(edges2) - 1; + if (BM_Vert_In_Edge(edges2[i - 1], edges2[i]->v1)) v4 = edges2[i]->v2; else v4 = edges2[i]->v1; } @@ -1172,8 +1196,8 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) v1 = edges1[0]->v2; else v1 = edges1[0]->v1; - i = BLI_array_count(edges1)-1; - if (BM_Vert_In_Edge(edges1[i-1], edges1[i]->v1)) + i = BLI_array_count(edges1) - 1; + if (BM_Vert_In_Edge(edges1[i - 1], edges1[i]->v1)) v2 = edges1[i]->v2; else v2 = edges1[i]->v1; @@ -1188,7 +1212,7 @@ void bmesh_edgenet_prepare(BMesh *bm, BMOperator *op) BLI_array_free(edges2); } -/*this is essentially new fkey*/ +/* this is essentially new fke */ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) { BMOperator op2; @@ -1198,9 +1222,9 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) BMVert *v, *verts[4]; BMEdge *e; BMFace *f; - int totv=0, tote=0, totf=0, amount; + int totv = 0, tote = 0, totf = 0, amount; - /*count number of each element type we were passed*/ + /* count number of each element type we were passe */ BMO_ITER(h, &oiter, bm, op, "geom", BM_VERT|BM_EDGE|BM_FACE) { switch (h->htype) { case BM_VERT: totv++; break; @@ -1281,8 +1305,8 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) - /*call edgenet create*/ - /* call edgenet prepare op so additional face creation cases work*/ + /* call edgenet creat */ + /* call edgenet prepare op so additional face creation cases wor */ BMO_InitOpf(bm, &op2, "edgenet_prepare edges=%fe", ELE_NEW); BMO_Exec_Op(bm, &op2); BMO_Flag_Buffer(bm, &op2, "edgeout", ELE_NEW, BM_EDGE); @@ -1291,7 +1315,7 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) BMO_InitOpf(bm, &op2, "edgenet_fill edges=%fe", ELE_NEW); BMO_Exec_Op(bm, &op2); - /*return if edge net create did something*/ + /* return if edge net create did somethin */ if (BMO_CountSlotBuf(bm, &op2, "faceout")) { BMO_CopySlot(&op2, op, "faceout", "faceout"); BMO_Finish_Op(bm, &op2); @@ -1300,11 +1324,11 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) BMO_Finish_Op(bm, &op2); - /*now call dissolve faces*/ + /* now call dissolve face */ BMO_InitOpf(bm, &op2, "dissolvefaces faces=%ff", ELE_NEW); BMO_Exec_Op(bm, &op2); - /*if we dissolved anything, then return.*/ + /* if we dissolved anything, then return */ if (BMO_CountSlotBuf(bm, &op2, "regionout")) { BMO_CopySlot(&op2, op, "regionout", "faceout"); BMO_Finish_Op(bm, &op2); @@ -1313,7 +1337,7 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) BMO_Finish_Op(bm, &op2); - /*now, count how many verts we have*/ + /* now, count how many verts we hav */ amount = 0; BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { if (BMO_TestFlag(bm, v, ELE_NEW)) { @@ -1325,12 +1349,12 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) } if (amount == 2) { - /*create edge*/ + /* create edg */ e = BM_Make_Edge(bm, verts[0], verts[1], NULL, 1); BMO_SetFlag(bm, e, ELE_OUT); } else if (amount == 3) { - /*create triangle*/ + /* create triangl */ BM_Make_Face_QuadTri(bm, verts[0], verts[1], verts[2], NULL, NULL, 1); } else if (amount == 4) { @@ -1338,22 +1362,22 @@ void bmesh_contextual_create_exec(BMesh *bm, BMOperator *op) /* 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)) { - f= BM_Make_Face_QuadTri(bm, verts[0], verts[1], verts[2], verts[3], NULL, 1); + 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)) { - f= BM_Make_Face_QuadTri(bm, verts[0], verts[2], verts[3], verts[1], NULL, 1); + 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)) { - f= BM_Make_Face_QuadTri(bm, verts[0], verts[2], verts[1], verts[3], NULL, 1); + 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)) { - f= BM_Make_Face_QuadTri(bm, verts[0], verts[1], verts[3], verts[2], NULL, 1); + 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)) { - f= BM_Make_Face_QuadTri(bm, verts[0], verts[3], verts[2], verts[1], NULL, 1); + 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)) { - f= BM_Make_Face_QuadTri(bm, verts[0], verts[3], verts[1], verts[2], NULL, 1); + f = BM_Make_Face_QuadTri(bm, verts[0], verts[3], verts[1], verts[2], NULL, 1); } else { printf("cannot find nice quad from concave set of vertices\n"); diff --git a/source/blender/bmesh/operators/dissolveops.c b/source/blender/bmesh/operators/dissolveops.c index d3743581684..2ce02ff0ca4 100644 --- a/source/blender/bmesh/operators/dissolveops.c +++ b/source/blender/bmesh/operators/dissolveops.c @@ -26,13 +26,13 @@ static int UNUSED_FUNCTION(check_hole_in_region)(BMesh *bm, BMFace *f) BMLoop *l2, *l3; BMFace *f2; - /*checks if there are any unmarked boundary edges in the face region*/ + /* checks if there are any unmarked boundary edges in the face regio */ - BMW_Init(®walker, bm, BMW_ISLAND, 0,0,0,FACE_MARK, BMW_NIL_LAY); + 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)) @@ -61,22 +61,22 @@ void dissolvefaces_exec(BMesh *bm, BMOperator *op) BMO_Flag_Buffer(bm, op, "faces", FACE_MARK, BM_FACE); - /*collect regions*/ + /* collect region */ BMO_ITER(f, &oiter, bm, op, "faces", BM_FACE) { if (!BMO_TestFlag(bm, f, FACE_MARK)) continue; BLI_array_empty(faces); - faces = NULL; /*forces different allocation*/ + faces = NULL; /* forces different allocatio */ - /*yay, walk!*/ - BMW_Init(®walker, bm, BMW_ISLAND, 0,0,0,FACE_MARK, BMW_NIL_LAY); + /* 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); - for (i=0; ie) { BM_Collapse_Vert_Edges(bm, verts[i]->e, verts[i]); } @@ -203,7 +202,7 @@ void dissolveedges_exec(BMesh *bm, BMOperator *op) #endif /* DISSOLVE_EDGE_VERTS */ BMO_ITER(e, &eiter, bm, op, "edges", BM_EDGE) { - const int edge_face_count= BM_Edge_FaceCount(e); + const int edge_face_count = BM_Edge_FaceCount(e); if (edge_face_count == 2) { #ifdef DISSOLVE_EDGE_VERTS @@ -219,9 +218,9 @@ void dissolveedges_exec(BMesh *bm, BMOperator *op) } else if (edge_face_count < 2) { /* join verts, assign because first join frees the edge */ - BMVert *v1= e->v1, *v2= e->v2; + BMVert *v1 = e->v1, *v2 = e->v2; - /*collapse the vert*/ + /* collapse the ver */ if (BM_Vert_EdgeCount(v1) == 2) BM_Collapse_Vert_Edges(bm, v1->e, v1); if (BM_Vert_EdgeCount(v2) == 2) BM_Collapse_Vert_Edges(bm, v2->e, v2); @@ -248,36 +247,42 @@ static int test_extra_verts(BMesh *bm, BMVert *v) BMEdge *e; int found; - /*test faces around verts for verts that would be wronly killed - by dissolve faces.*/ + /* 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)) { - l=BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f); - for ( ; l; l=BMIter_Step(&liter)) { + for ( ; f; f = BMIter_Step(&iter)) { + l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f); + 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. - also if it forms a boundary with one - of the face regions*/ - found = 0; + /* if an edge around a vert is a boundary edge, + * then dissolve faces won't destroy it. + * also if it forms a boundary with one + * of the face region */ + found = FALSE; e = BMIter_New(&iter2, bm, BM_EDGES_OF_VERT, l->v); - for ( ; e; e=BMIter_Step(&iter2)) { - if (BM_Edge_FaceCount(e)==1) found = 1; + for ( ; e; e = BMIter_Step(&iter2)) { + if (BM_Edge_FaceCount(e) == 1) { + found = TRUE; + } 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; + found = TRUE; break; } } - if (found) break; + if (found == TRUE) { + break; + } + } + if (found == FALSE) { + return FALSE; } - if (!found) return 0; } } } - return 1; + return TRUE; } void dissolveverts_exec(BMesh *bm, BMOperator *op) { @@ -290,27 +295,27 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) vinput = BMO_GetSlot(op, "verts"); BMO_Flag_Buffer(bm, op, "verts", VERT_MARK, BM_VERT); - for (v=BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); v; v=BMIter_Step(&iter)) { + for (v = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); v; v = BMIter_Step(&iter)) { if (BMO_TestFlag(bm, v, VERT_MARK)) { - /*check if it's a two-valence vert*/ + /* check if it's a two-valence ver */ if (BM_Vert_EdgeCount(v) == 2) { - /*collapse the vert*/ + /* collapse the ver */ BM_Collapse_Vert_Faces(bm, v->e, v, 1.0f, TRUE); continue; } - f=BMIter_New(&fiter, bm, BM_FACES_OF_VERT, v); - for ( ; f; f=BMIter_Step(&fiter)) { + f = BMIter_New(&fiter, bm, BM_FACES_OF_VERT, v); + for ( ; f; f = BMIter_Step(&fiter)) { BMO_SetFlag(bm, f, FACE_ORIG); BMO_SetFlag(bm, f, FACE_MARK); } - /*check if our additions to the input to face dissolve - will destroy nonmarked vertices.*/ + /* check if our additions to the input to face dissolve + * 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)) { + f = BMIter_New(&fiter, bm, BM_FACES_OF_VERT, v); + 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); @@ -318,8 +323,8 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) } } else { - f=BMIter_New(&fiter, bm, BM_FACES_OF_VERT, v); - for ( ; f; f=BMIter_Step(&fiter)) { + f = BMIter_New(&fiter, bm, BM_FACES_OF_VERT, v); + for ( ; f; f = BMIter_Step(&fiter)) { BMO_ClearFlag(bm, f, FACE_ORIG); } } @@ -332,15 +337,14 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) BMO_GetError(bm, &msg, NULL); BMO_ClearStack(bm); - BMO_RaiseError(bm, op, BMERR_DISSOLVEVERTS_FAILED,msg); + BMO_RaiseError(bm, op, BMERR_DISSOLVEVERTS_FAILED, msg); } - /*clean up any remaining*/ - for (v=BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); v; v=BMIter_Step(&iter)) { + /* clean up any remainin */ + for (v = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); v; v = BMIter_Step(&iter)) { if (BMO_TestFlag(bm, v, VERT_MARK)) { if (!BM_Dissolve_Vert(bm, v)) { - BMO_RaiseError(bm, op, - BMERR_DISSOLVEVERTS_FAILED, NULL); + BMO_RaiseError(bm, op, BMERR_DISSOLVEVERTS_FAILED, NULL); return; } } @@ -348,17 +352,17 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) } -/*this code is for cleaning up two-edged faces, it shall become - it's own function one day.*/ +/* this code is for cleaning up two-edged faces, it shall become + * it's own function one day */ #if 0 - /*clean up two-edged faces*/ - /*basic idea is to keep joining 2-edged faces until their - gone. this however relies on joining two 2-edged faces - together to work, which doesn't.*/ + /* clean up two-edged face */ + /* basic idea is to keep joining 2-edged faces until their + * gone. this however relies on joining two 2-edged faces + * together to work, which doesn't */ found3 = 1; while (found3) { found3 = 0; - for (f=BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); f; f=BMIter_Step(&iter)) { + for (f = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); f; f = BMIter_Step(&iter)) { if (!BM_Validate_Face(bm, f, stderr)) { printf("error.\n"); } @@ -372,10 +376,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; @@ -389,15 +393,15 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) bmesh_kf(bm, f); bmesh_ke(bm, fe); } - } /*else if (f->len == 3) { + } /* else if (f->len == 3) { BMEdge *ed[3]; BMVert *vt[3]; BMLoop *lp[3]; - int i=0; + int i = 0; //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; @@ -405,7 +409,7 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op) if (vt[0] == vt[1] || vt[0] == vt[2]) { i += 1; } - }*/ + */ } } if (oldlen == len) break; diff --git a/source/blender/bmesh/operators/edgesplitop.c b/source/blender/bmesh/operators/edgesplitop.c index 3d9acb98b50..88d36ff68ce 100644 --- a/source/blender/bmesh/operators/edgesplitop.c +++ b/source/blender/bmesh/operators/edgesplitop.c @@ -70,13 +70,13 @@ static BMFace *remake_face(BMesh *bm, EdgeTag *etags, BMFace *f, BMVert **verts, BMVert *lastv1, *lastv2 /* , *v1, *v2 */ /* UNUSED */; int i; - /*we do final edge last*/ - lastv1 = verts[f->len-1]; + /* we do final edge last */ + lastv1 = verts[f->len - 1]; lastv2 = verts[0]; /* v1 = verts[0]; */ /* UNUSED */ /* v2 = verts[1]; */ /* UNUSED */ - for (i=0; ilen-1; i++) { - e = BM_Make_Edge(bm, verts[i], verts[i+1], NULL, 1); + for (i = 0; i < f->len - 1; i++) { + e = BM_Make_Edge(bm, verts[i], verts[i + 1], NULL, 1); if (!e) { return NULL; } @@ -94,11 +94,11 @@ 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 - the splits*/ + /* set up data for figuring out the two sides of + * the split */ BMO_SetIndex(bm, l2->e, BMO_GetIndex(bm, l->e)); et = etags + BMO_GetIndex(bm, l->e); @@ -110,7 +110,8 @@ static BMFace *remake_face(BMesh *bm, EdgeTag *etags, BMFace *f, BMVert **verts, } else { /* Only two new edges should be created from each original edge - for edge split operation */ + * for edge split operation */ + //BLI_assert(et->newe1 == l2->e || et->newe2 == l2->e); et->newe2 = l2->e; } @@ -138,7 +139,7 @@ static void tag_out_edges(BMesh *bm, EdgeTag *etags, BMOperator *UNUSED(op)) BMVert *v; int i, ok; - ok=0; + ok = 0; while (ok++ < 100000) { BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (!BMO_TestFlag(bm, e, EDGE_SEAM)) @@ -150,12 +151,13 @@ static void tag_out_edges(BMesh *bm, EdgeTag *etags, BMOperator *UNUSED(op)) } } - if (!e) + if (!e) { break; + } - /*ok we found an edge, part of a region of splits we need - to identify. now walk along it.*/ - for (i=0; i<2; i++) { + /* ok we found an edge, part of a region of splits we need + * to identify. now walk along it */ + for (i = 0; i < 2; i++) { l = e->l; v = i ? l->next->v : l->v; @@ -226,7 +228,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op) /* single marked edges unconnected to any other marked edges * are illegal, go through and unmark them */ BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) { - for (i=0; i<2; i++) { + for (i = 0; i < 2; i++) { BM_ITER(e2, &iter, bm, BM_EDGES_OF_VERT, i ? e->v2 : e->v1) { if (e != e2 && BMO_TestFlag(bm, e2, EDGE_SEAM)) { break; @@ -266,7 +268,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op) BLI_array_empty(verts); BLI_array_growitems(verts, f->len); - memset(verts, 0, sizeof(BMVert*)*f->len); + memset(verts, 0, sizeof(BMVert *) * f->len); /* this is passed onto remake_face() so it doesnt need to allocate * a new array on each call. */ @@ -294,15 +296,15 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op) nextl = l->next; prevl = l->prev; - for (j=0; j<2; j++) { + for (j = 0; j < 2; j++) { /* correct as long as i & j dont change during the loop */ - const int fv_index= j ? (i+1) % f->len : i; /* face vert index */ + const int fv_index = j ? (i + 1) % f->len : i; /* face vert index */ l2 = j ? nextl : prevl; v = j ? l2->v : l->v; if (BMO_TestFlag(bm, l2->e, EDGE_SEAM)) { if (verts[fv_index] == NULL) { - /*make unique vert here for this face only*/ + /* make unique vert here for this face only */ v2 = BM_Make_Vert(bm, v->co, v); verts[fv_index] = v2; } @@ -315,7 +317,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op) * around the manifold vert fan if necassary */ /* first check that we have two seam edges - * somewhere within this fan*/ + * somewhere within this fa */ l3 = l2; do { if (BM_Edge_FaceCount(l3->e) != 2) { @@ -375,7 +377,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op) 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 6d454ac34ac..83ddaae3443 100644 --- a/source/blender/bmesh/operators/extrudeops.c +++ b/source/blender/bmesh/operators/extrudeops.c @@ -114,9 +114,9 @@ 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; + e2 = *(BMEdge **)e2; if (e->l && e->v1 != e->l->v) { v1 = e->v1; @@ -130,7 +130,7 @@ void bmesh_extrude_onlyedge_exec(BMesh *bm, BMOperator *op) v3 = e->v2; v4 = e->v1; } - /*not sure what to do about example face, pass NULL for now.*/ + /* not sure what to do about example face, pass NULL for now */ f = BM_Make_Face_QuadTri(bm, v1, v2, v3, v4, NULL, 0); if (BMO_TestFlag(bm, e, EXT_INPUT)) @@ -155,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); @@ -177,22 +177,22 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) BMLoop *l, *l2; BMVert *verts[4], *v, *v2; BMFace *f; - int rlen, found, fwd, delorig=0; + int rlen, found, fwd, delorig = 0; - /*initialize our sub-operators*/ + /* initialize our sub-operators */ BMO_Init_Op(bm, &dupeop, "dupe"); BMO_Flag_Buffer(bm, op, "edgefacein", EXT_INPUT, BM_EDGE|BM_FACE); - /*if one flagged face is bordered by an unflagged face, then we delete - original geometry unless caller explicitly asked to keep it. */ + /* if one flagged face is bordered by an unflagged face, then we delete + * original geometry unless caller explicitly asked to keep it. */ if (!BMO_Get_Int(op, "alwayskeeporig")) { BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (!BMO_TestFlag(bm, e, EXT_INPUT)) continue; found = 0; f = BMIter_New(&fiter, bm, BM_FACES_OF_EDGE, e); - for (rlen=0; f; f=BMIter_Step(&fiter), rlen++) { + for (rlen = 0; f; f = BMIter_Step(&fiter), rlen++) { if (!BMO_TestFlag(bm, f, EXT_INPUT)) { found = 1; delorig = 1; @@ -204,7 +204,7 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) } } - /*calculate verts to delete*/ + /* calculate verts to delet */ BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { found = 0; @@ -245,9 +245,9 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) if (delorig) BMO_Exec_Op(bm, &delop); - /*if not delorig, reverse loops of original faces*/ + /* if not delorig, reverse loops of original face */ if (!delorig) { - for (f=BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); f; f=BMIter_Step(&iter)) { + for (f = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); f; f = BMIter_Step(&iter)) { if (BMO_TestFlag(bm, f, EXT_INPUT)) { BM_flip_normal(bm, f); } @@ -256,11 +256,11 @@ 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); - newedge = *(BMEdge**)newedge; + newedge = *(BMEdge **)newedge; if (!newedge) continue; /* orient loop to give same normal as a loop of newedge @@ -285,12 +285,12 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) verts[0] = newedge->v1; } - /*not sure what to do about example face, pass NULL for now.*/ + /* not sure what to do about example face, pass NULL for now */ f = BM_Make_Face_QuadTri_v(bm, verts, 4, NULL, 0); - /*copy attributes*/ - l=BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); - for ( ; l; l=BMIter_Step(&iter)) { + /* copy attribute */ + l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, f); + for ( ; l; l = BMIter_Step(&iter)) { if (l->e != e && l->e != newedge) continue; l2 = l->radial_next; @@ -306,7 +306,7 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) else { BM_Copy_Attributes(bm, bm, l2->f, l->f); - /*copy data*/ + /* copy dat */ if (l2->v == l->v) { BM_Copy_Attributes(bm, bm, l2, l); l2 = l2->next; @@ -324,14 +324,14 @@ void extrude_edge_context_exec(BMesh *bm, BMOperator *op) } } - /*link isolated verts*/ + /* link isolated vert */ v = BMO_IterNew(&siter, bm, &dupeop, "isovertmap", 0); - for ( ; v; v=BMO_IterStep(&siter)) { - v2 = *((void**)BMO_IterMapVal(&siter)); + for ( ; v; v = BMO_IterStep(&siter)) { + v2 = *((void **)BMO_IterMapVal(&siter)); BM_Make_Edge(bm, v, v2, v->e, 1); } - /*cleanup*/ + /* cleanu */ if (delorig) BMO_Finish_Op(bm, &delop); BMO_Finish_Op(bm, &dupeop); } @@ -352,7 +352,7 @@ static void calc_solidify_normals(BMesh *bm) int i; /* can't use BM_Edge_FaceCount because we need to count only marked faces */ - int *edge_face_count= MEM_callocN(sizeof(int) * bm->totedge, __func__); + int *edge_face_count = MEM_callocN(sizeof(int) * bm->totedge, __func__); BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) { BM_SetHFlag(v, BM_TMP_TAG); @@ -392,7 +392,7 @@ static void calc_solidify_normals(BMesh *bm) } } MEM_freeN(edge_face_count); - edge_face_count= NULL; /* dont re-use */ + edge_face_count = NULL; /* dont re-use */ BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) { if (BM_Nonmanifold_Vert(bm, v)) { @@ -447,7 +447,7 @@ static void calc_solidify_normals(BMesh *bm) } else { /* can't do anything useful here! - Set the face index for a vert incase it gets a zero normal */ + * Set the face index for a vert incase it gets a zero normal */ BM_ClearHFlag(e->v1, BM_TMP_TAG); BM_ClearHFlag(e->v2, BM_TMP_TAG); continue; @@ -456,16 +456,16 @@ static void calc_solidify_normals(BMesh *bm) else { /* only one face attached to that edge */ /* an edge without another attached- the weight on this is - * undefined, M_PI/2 is 90d in radians and that seems good enough */ + * undefined, M_PI / 2 is 90d in radians and that seems good enough */ copy_v3_v3(edge_normal, f1->no); - mul_v3_fl(edge_normal, M_PI/2); + mul_v3_fl(edge_normal, M_PI / 2); } add_v3_v3(e->v1->no, edge_normal); add_v3_v3(e->v2->no, edge_normal); } - /* normalize accumulated vertex normals*/ + /* normalize accumulated vertex normal */ BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) { if (!BMO_TestFlag(bm, v, VERT_MARK)) { continue; diff --git a/source/blender/bmesh/operators/join_triangles.c b/source/blender/bmesh/operators/join_triangles.c index 49fb6967965..3a2e25cf206 100644 --- a/source/blender/bmesh/operators/join_triangles.c +++ b/source/blender/bmesh/operators/join_triangles.c @@ -34,24 +34,24 @@ * utility bmesh operators, e.g. transform, * translate, rotate, scale, etc. * -*/ + */ -/*Bitflags for edges.*/ +/* Bitflags for edges */ #define T2QDELETE 1 #define T2QCOMPLEX 2 #define T2QJOIN 4 -/*assumes edges are validated before reaching this point*/ +/* assumes edges are validated before reaching this poin */ static float measure_facepair(BMesh *UNUSED(bm), BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, float limit) { - /*gives a 'weight' to a pair of triangles that join an edge to decide how good a join they would make*/ - /*Note: this is more complicated than it needs to be and should be cleaned up...*/ + /* gives a 'weight' to a pair of triangles that join an edge to decide how good a join they would mak */ + /* Note: this is more complicated than it needs to be and should be cleaned up.. */ float n1[3], n2[3], measure = 0.0f, angle1, angle2, diff; float edgeVec1[3], edgeVec2[3], edgeVec3[3], edgeVec4[3]; float minarea, maxarea, areaA, areaB; - /*First Test: Normal difference*/ + /* First Test: Normal differenc */ normal_tri_v3(n1, v1->co, v2->co, v3->co); normal_tri_v3(n2, v1->co, v3->co, v4->co); @@ -67,7 +67,7 @@ static float measure_facepair(BMesh *UNUSED(bm), BMVert *v1, BMVert *v2, measure += (angle1 + angle2) * 0.5f; if (measure > limit) return measure; - /*Second test: Colinearity*/ + /* Second test: Colinearit */ sub_v3_v3v3(edgeVec1, v1->co, v2->co); sub_v3_v3v3(edgeVec2, v2->co, v3->co); sub_v3_v3v3(edgeVec3, v3->co, v4->co); @@ -84,7 +84,7 @@ static float measure_facepair(BMesh *UNUSED(bm), BMVert *v1, BMVert *v2, measure += diff; if (measure > limit) return measure; - /*Third test: Concavity*/ + /* Third test: Concavit */ 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); @@ -109,12 +109,12 @@ static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols) MLoopCol *lcol1, *lcol2, *lcol3, *lcol4; MLoopUV *luv1, *luv2, *luv3, *luv4; BMLoop *l1, *l2, *l3, *l4; - int mergeok_uvs=!douvs, mergeok_vcols=!dovcols; + int mergeok_uvs = !douvs, mergeok_vcols = !dovcols; l1 = e->l; l3 = e->l->radial_next; - /*match up loops on each side of an edge corrusponding to each vert*/ + /* match up loops on each side of an edge corrusponding to each ver */ if (l1->v == l3->v) { l2 = l1->next; l4 = l2->next; @@ -145,14 +145,14 @@ static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols) if (!luv1) mergeok_uvs = 1; - /*compare faceedges for each face attribute. Additional per face attributes can be added later*/ + /* compare faceedges for each face attribute. Additional per face attributes can be added late */ - /*do VCOLs*/ + /* do VCOL */ if (lcol1 && dovcols) { - char *cols[4] = {(char*)lcol1, (char*)lcol2, (char*)lcol3, (char*)lcol4}; + char *cols[4] = {(char *)lcol1, (char *)lcol2, (char *)lcol3, (char *)lcol4}; int i; - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { if (cols[0][i] + T2QCOL_LIMIT < cols[2][i] - T2QCOL_LIMIT) break; if (cols[1][i] + T2QCOL_LIMIT < cols[3][i] - T2QCOL_LIMIT) @@ -163,9 +163,9 @@ static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols) mergeok_vcols = 1; } - /*do UVs*/ + /* do UV */ if (luv1 && douvs) { - if (tp1->tpage != tp2->tpage); /*do nothing*/ + if (tp1->tpage != tp2->tpage); /* do nothin */ else { int i; @@ -201,7 +201,7 @@ typedef struct JoinEdge { static int fplcmp(const void *v1, const void *v2) { - const JoinEdge *e1= ((JoinEdge*)v1), *e2=((JoinEdge*)v2); + const JoinEdge *e1 = (JoinEdge *)v1, *e2 = (JoinEdge *)v2; if (e1->weight > e2->weight) return 1; else if (e1->weight < e2->weight) return -1; @@ -218,12 +218,12 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) BMEdge *e; BLI_array_declare(jedges); JoinEdge *jedges = NULL; - int dosharp = BMO_Get_Int(op, "compare_sharp"), douvs=BMO_Get_Int(op, "compare_uvs"); - int dovcols = BMO_Get_Int(op, "compare_vcols"), domat=BMO_Get_Int(op, "compare_materials"); + int dosharp = BMO_Get_Int(op, "compare_sharp"), douvs = BMO_Get_Int(op, "compare_uvs"); + int dovcols = BMO_Get_Int(op, "compare_vcols"), domat = BMO_Get_Int(op, "compare_materials"); float limit = BMO_Get_Float(op, "limit"); int i, totedge; - /*flag all edges of all input faces*/ + /* flag all edges of all input face */ BMO_ITER(f1, &siter, bm, op, "faces", BM_FACE) { BMO_SetFlag(bm, f1, FACE_INPUT); BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f1) { @@ -231,7 +231,7 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) } } - /*unflag edges that are invalid; e.g. aren't surrounded by triangles*/ + /* unflag edges that are invalid; e.g. aren't surrounded by triangle */ BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (!BMO_TestFlag(bm, e, EDGE_MARK)) continue; @@ -298,7 +298,7 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) qsort(jedges, BLI_array_count(jedges), sizeof(JoinEdge), fplcmp); totedge = BLI_array_count(jedges); - for (i=0; il->f; f2 = e->l->radial_next->f; @@ -334,21 +334,24 @@ void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op) if (f1->len != 3 || f2->len != 3) continue; - for (i=0; i<2; i++) { + for (i = 0; i < 2; i++) { BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, i ? f2 : f1) { - if (l->e != e && BMO_TestFlag(bm, l->e, EDGE_MARK)) + if (l->e != e && BMO_TestFlag(bm, l->e, EDGE_MARK)) { break; + } } - /*if l isn't NULL, we broke out of the loop*/ - if (l) + /* if l isn't NULL, we broke out of the loo */ + if (l) { break; + } } - /*if i isn't 2, we broke out of that loop*/ - if (i != 2) + /* if i isn't 2, we broke out of that loo */ + if (i != 2) { continue; - + } + BM_Join_TwoFaces(bm, f1, f2, e); } } diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c index 6bc9fdda116..18fc1f1d979 100644 --- a/source/blender/bmesh/operators/mesh_conv.c +++ b/source/blender/bmesh/operators/mesh_conv.c @@ -41,7 +41,7 @@ * for converting a Mesh * into a Bmesh, and back again. * -*/ + */ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { @@ -53,28 +53,28 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) MLoop *ml; MPoly *mpoly; KeyBlock *actkey, *block; - BMVert *v, **vt=NULL, **verts = NULL; - BMEdge *e, **fedges=NULL, **et = NULL; + BMVert *v, **vt = NULL, **verts = NULL; + BMEdge *e, **fedges = NULL, **et = NULL; BMFace *f; BMLoop *l; BLI_array_declare(fedges); - float (*keyco)[3]= NULL; + float (*keyco)[3] = NULL; int *keyi; int set_key = BMO_Get_Int(op, "set_shapekey"); int totuv, i, j, allocsize[4] = {512, 512, 2048, 512}; - if (!me || !me->totvert) return; /*sanity check*/ + if (!me || !me->totvert) return; /* sanity chec */ - vt = MEM_mallocN(sizeof(void**)*me->totvert, "mesh to bmesh vtable"); + vt = MEM_mallocN(sizeof(void **) * me->totvert, "mesh to bmesh vtable"); CustomData_copy(&me->vdata, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0); CustomData_copy(&me->edata, &bm->edata, CD_MASK_BMESH, CD_CALLOC, 0); CustomData_copy(&me->ldata, &bm->ldata, CD_MASK_BMESH, CD_CALLOC, 0); CustomData_copy(&me->pdata, &bm->pdata, CD_MASK_BMESH, CD_CALLOC, 0); - /*make sure uv layer names are consistent*/ + /* make sure uv layer names are consisten */ totuv = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY); - for (i=0; ipdata, CD_MTEXPOLY, i); CustomData_set_layer_name(&bm->ldata, CD_MLOOPUV, i, bm->pdata.layers[li].name); } @@ -90,27 +90,27 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) if (me->key && ob->shapenr > me->key->totkey) { - ob->shapenr = me->key->totkey-1; + ob->shapenr = me->key->totkey - 1; } actkey = ob_get_keyblock(ob); 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. + /* check if we need to generate unique ids for the shapekeys. this also exists in the file reading code, but is here for - a sanity check*/ + a sanity chec */ if (!me->key->uidgen) { fprintf(stderr, "%s had to generate shape key uid's in a situation we shouldn't need to! (bmesh internal error)\n", __func__); me->key->uidgen = 1; - for (block=me->key->block.first; block; block=block->next) { + for (block = me->key->block.first; block; block = block->next) { block->uid = me->key->uidgen++; } } - keyco= actkey->data; - bm->shapenr= ob->shapenr; - for (i=0, block=me->key->block.first; block; block=block->next, i++) { + keyco = actkey->data; + bm->shapenr = ob->shapenr; + for (i = 0, block = me->key->block.first; block; block = block->next, i++) { CustomData_add_layer_named(&bm->vdata, CD_SHAPEKEY, CD_ASSIGN, NULL, 0, block->name); @@ -127,37 +127,38 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) CustomData_bmesh_init_pool(&bm->ldata, allocsize[2]); CustomData_bmesh_init_pool(&bm->pdata, allocsize[3]); - for (i=0, mvert = me->mvert; itotvert; i++, mvert++) { - v = BM_Make_Vert(bm, keyco&&set_key ? keyco[i] : mvert->co, NULL); + for (i = 0, mvert = me->mvert; i < me->totvert; i++, mvert++) { + v = BM_Make_Vert(bm, keyco && set_key ? keyco[i] : mvert->co, NULL); BM_SetIndex(v, i); /* set_ok */ vt[i] = v; - /*transfer flags*/ + /* transfer flag */ v->head.hflag = BM_Vert_Flag_From_MEFlag(mvert->flag); - /*this is necassary for selection counts to work properly*/ + /* this is necassary for selection counts to work properl */ if (BM_TestHFlag(v, BM_SELECT)) BM_Select_Vert(bm, v, TRUE); normal_short_to_float_v3(v->no, mvert->no); BM_SetCDf(&bm->vdata, v, CD_BWEIGHT, (float)mvert->bweight / 255.0f); - /*Copy Custom Data*/ + /* Copy Custom Dat */ CustomData_to_bmesh_block(&me->vdata, &bm->vdata, i, &v->head.data); - /*set shapekey data*/ + /* set shapekey dat */ if (me->key) { - /*set shape key original index*/ + /* set shape key original inde */ keyi = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_SHAPE_KEYINDEX); if (keyi) { *keyi = i; } - for (block=me->key->block.first, j=0; block; block=block->next, j++) { + for (block = me->key->block.first, j = 0; block; block = block->next, j++) { float *co = CustomData_bmesh_get_n(&bm->vdata, v->head.data, CD_SHAPEKEY, j); - if (co) - copy_v3_v3(co, ((float*)block->data)+3*i); + if (co) { + copy_v3_v3(co, ((float *)block->data) + 3 * i); + } } } } @@ -169,10 +170,10 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) return; } - et = MEM_mallocN(sizeof(void**)*me->totedge, "mesh to bmesh etable"); + et = MEM_mallocN(sizeof(void **) * me->totedge, "mesh to bmesh etable"); medge = me->medge; - for (i=0; itotedge; i++, medge++) { + for (i = 0; i < me->totedge; i++, medge++) { e = BM_Make_Edge(bm, vt[medge->v1], vt[medge->v2], NULL, 0); BM_SetIndex(e, i); /* set_ok */ et[i] = e; @@ -183,7 +184,7 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) /* this is necassary for selection counts to work properly */ if (BM_TestHFlag(e, BM_SELECT)) BM_Select(bm, e, TRUE); - /*Copy Custom Data*/ + /* Copy Custom Dat */ CustomData_to_bmesh_block(&me->edata, &bm->edata, i, &e->head.data); BM_SetCDf(&bm->edata, e, CD_CREASE, (float)medge->crease / 255.0f); @@ -199,7 +200,7 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) } mpoly = me->mpoly; - for (i=0; itotpoly; i++, mpoly++) { + for (i = 0; i < me->totpoly; i++, mpoly++) { BMIter iter; BLI_array_empty(fedges); @@ -208,8 +209,8 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) BLI_array_growitems(fedges, mpoly->totloop); BLI_array_growitems(verts, mpoly->totloop); - for (j=0; jtotloop; j++) { - ml = &me->mloop[mpoly->loopstart+j]; + for (j = 0; j < mpoly->totloop; j++) { + ml = &me->mloop[mpoly->loopstart + j]; v = vt[ml->v]; e = et[ml->e]; @@ -223,7 +224,7 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { BMVert *v1, *v2; v1 = vt[me->mloop[mpoly->loopstart].v]; - v2 = vt[me->mloop[mpoly->loopstart+1].v]; + v2 = vt[me->mloop[mpoly->loopstart + 1].v]; if (v1 == fedges[0]->v1) { v2 = fedges[0]->v2; @@ -240,17 +241,17 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) if (!f) { printf("%s: Warning! Bad face in mesh" " \"%s\" at index %d!, skipping\n", - __func__, me->id.name+2, i); + __func__, me->id.name + 2, i); continue; } /* dont use 'i' since we may have skipped the face */ - BM_SetIndex(f, bm->totface-1); /* set_ok */ + BM_SetIndex(f, bm->totface - 1); /* set_ok */ - /*transfer flags*/ + /* transfer flag */ f->head.hflag = BM_Face_Flag_From_MEFlag(mpoly->flag); - /*this is necassary for selection counts to work properly*/ + /* this is necassary for selection counts to work properl */ if (BM_TestHFlag(f, BM_SELECT)) BM_Select(bm, f, TRUE); f->mat_nr = mpoly->mat_nr; @@ -259,10 +260,10 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) j = 0; BM_ITER_INDEX(l, &iter, bm, BM_LOOPS_OF_FACE, f, j) { /* Save index of correspsonding MLoop */ - BM_SetIndex(l, mpoly->loopstart+j); /* set_loop */ + BM_SetIndex(l, mpoly->loopstart + j); /* set_loop */ } - /*Copy Custom Data*/ + /* Copy Custom Dat */ CustomData_to_bmesh_block(&me->pdata, &bm->pdata, i, &f->head.data); } @@ -329,7 +330,7 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) } } else { - me->totselect= 0; + me->totselect = 0; } MEM_freeN(vertex_array); @@ -366,7 +367,7 @@ static BMVert **bmesh_to_mesh_vertex_map(BMesh *bm, int ototvert) BMVert **vertMap = NULL; BMVert *eve; int index; - int i= 0; + int i = 0; BMIter iter; /* caller needs to ensure this */ @@ -378,7 +379,7 @@ static BMVert **bmesh_to_mesh_vertex_map(BMesh *bm, int ototvert) 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 (((index= *keyi) != ORIGINDEX_NONE) && (index < ototvert)) { + if (((index = *keyi) != ORIGINDEX_NONE) && (index < ototvert)) { vertMap[index] = eve; } } @@ -439,30 +440,30 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) ototvert = me->totvert; /* new Vertex block */ - if (bm->totvert==0) mvert= NULL; - else mvert= MEM_callocN(bm->totvert*sizeof(MVert), "loadeditbMesh vert"); + 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; - else medge= MEM_callocN(bm->totedge*sizeof(MEdge), "loadeditbMesh edge"); + if (bm->totedge == 0) medge = NULL; + else medge = MEM_callocN(bm->totedge*sizeof(MEdge), "loadeditbMesh edge"); - /*build ngon data*/ + /* build ngon dat */ /* new Ngon Face block */ - if (bm->totface==0) mpoly = NULL; - else mpoly= MEM_callocN(bm->totface*sizeof(MPoly), "loadeditbMesh poly"); + if (bm->totface == 0) mpoly = NULL; + else mpoly = MEM_callocN(bm->totface*sizeof(MPoly), "loadeditbMesh poly"); - /*find number of loops to allocate*/ + /* find number of loops to allocat */ totloop = 0; BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { totloop += f->len; } - if (totloop==0) mloop = NULL; + if (totloop == 0) mloop = NULL; else mloop = MEM_callocN(totloop*sizeof(MLoop), "loadeditbMesh loop"); /* lets save the old verts just in case we are actually working on * a key ... we now do processing of the keys at the end */ - oldverts= me->mvert; + oldverts = me->mvert; /* don't free this yet */ CustomData_set_layer(&me->vdata, CD_MVERT, NULL); @@ -475,14 +476,14 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) CustomData_free(&me->pdata, me->totpoly); /* add new custom data */ - me->totvert= bm->totvert; - me->totedge= bm->totedge; - me->totloop= totloop; - me->totpoly= bm->totface; + me->totvert = bm->totvert; + me->totedge = bm->totedge; + me->totloop = totloop; + me->totpoly = bm->totface; /* will be overwritten with a valid value if 'dotess' is set, otherwise we * end up with 'me->totface' and me->mface == NULL which can crash [#28625] */ - me->totface= 0; + me->totface = 0; CustomData_copy(&bm->vdata, &me->vdata, CD_MASK_MESH, CD_CALLOC, me->totvert); CustomData_copy(&bm->edata, &me->edata, CD_MASK_MESH, CD_CALLOC, me->totedge); @@ -501,7 +502,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { float *bweight = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_BWEIGHT); - mvert->bweight = bweight ? (char)((*bweight)*255) : 0; + mvert->bweight = bweight ? (char)((*bweight) * 255) : 0; copy_v3_v3(mvert->co, v->co); normal_float_to_short_v3(mvert->no, v->no); @@ -510,7 +511,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) BM_SetIndex(v, i); /* set_inline */ - /*copy over customdata*/ + /* copy over customdat */ CustomData_from_bmesh_block(&bm->vdata, &me->vdata, v->head.data, i); i++; @@ -520,7 +521,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) } bm->elem_index_dirty &= ~BM_VERT; - med= medge; + med = medge; i = 0; BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { float *crease = CustomData_bmesh_get(&bm->edata, e->head.data, CD_CREASE); @@ -528,14 +529,14 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) med->v1 = BM_GetIndex(e->v1); med->v2 = BM_GetIndex(e->v2); - med->crease = crease ? (char)((*crease)*255) : 0; - med->bweight = bweight ? (char)((*bweight)*255) : 0; + med->crease = crease ? (char)((*crease) * 255) : 0; + med->bweight = bweight ? (char)((*bweight) * 255) : 0; med->flag = BM_Edge_Flag_To_MEFlag(e); BM_SetIndex(e, i); /* set_inline */ - /*copy over customdata*/ + /* copy over customdat */ CustomData_from_bmesh_block(&bm->edata, &me->edata, e->head.data, i); bmesh_quick_edgedraw_flag(med, e); @@ -555,11 +556,11 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) mpoly->flag = BM_Face_Flag_To_MEFlag(f); l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f); - for ( ; l; l=BMIter_Step(&liter), j++, mloop++) { + for ( ; l; l = BMIter_Step(&liter), j++, mloop++) { mloop->e = BM_GetIndex(l->e); mloop->v = BM_GetIndex(l->v); - /*copy over customdata*/ + /* copy over customdat */ CustomData_from_bmesh_block(&bm->ldata, &me->ldata, l->head.data, j); BM_CHECK_ELEMENT(bm, l); BM_CHECK_ELEMENT(bm, l->e); @@ -568,7 +569,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) if (f == bm->act_face) me->act_face = i; - /*copy over customdata*/ + /* copy over customdat */ CustomData_from_bmesh_block(&bm->pdata, &me->pdata, f->head.data, i); i++; @@ -581,39 +582,39 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) Object *ob; ModifierData *md; BMVert **vertMap = NULL; - int i,j; + int i, j; - for (ob=G.main->object.first; ob; ob=ob->id.next) { - if (ob->parent==bm->ob && ELEM(ob->partype, PARVERT1,PARVERT3)) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { + if (ob->parent == bm->ob && ELEM(ob->partype, PARVERT1, PARVERT3)) { if (vertMap == NULL) { - vertMap= bmesh_to_mesh_vertex_map(bm, ototvert); + vertMap = bmesh_to_mesh_vertex_map(bm, 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) { eve = vertMap[ob->par2]; - if (eve) ob->par2= BM_GetIndex(eve); + if (eve) ob->par2 = BM_GetIndex(eve); } if (ob->par3 < ototvert) { eve = vertMap[ob->par3]; - if (eve) ob->par3= BM_GetIndex(eve); + if (eve) ob->par3 = BM_GetIndex(eve); } } - if (ob->data==me) { - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Hook) { - HookModifierData *hmd = (HookModifierData*) md; + if (ob->data == me) { + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Hook) { + HookModifierData *hmd = (HookModifierData *) md; if (vertMap == NULL) { - vertMap= bmesh_to_mesh_vertex_map(bm, ototvert); + vertMap = bmesh_to_mesh_vertex_map(bm, ototvert); } - for (i=j=0; itotindex; i++) { + for (i = j = 0; i < hmd->totindex; i++) { if (hmd->indexar[i] < ototvert) { eve = vertMap[hmd->indexar[i]]; @@ -669,19 +670,19 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) if (me->key) { KeyBlock *currkey; - KeyBlock *actkey= BLI_findlink(&me->key->block, bm->shapenr-1); + KeyBlock *actkey = BLI_findlink(&me->key->block, bm->shapenr - 1); float (*ofs)[3] = NULL; - /*go through and find any shapekey customdata layers - that might not have corrusponding KeyBlocks, and add them if - necassary.*/ + /* go through and find any shapekey customdata layers + * that might not have corrusponding KeyBlocks, and add them if + * necassary */ j = 0; - for (i=0; ivdata.totlayer; i++) { + for (i = 0; i < bm->vdata.totlayer; i++) { if (bm->vdata.layers[i].type != CD_SHAPEKEY) continue; - for (currkey=me->key->block.first; currkey; currkey=currkey->next) { + for (currkey = me->key->block.first; currkey; currkey = currkey->next) { if (currkey->uid == bm->vdata.layers[i].uid) break; } @@ -701,21 +702,21 @@ 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 */ - float (*fp)[3]= actkey->data; + float (*fp)[3] = actkey->data; int *keyi; - i=0; - ofs= MEM_callocN(sizeof(float) * 3 * bm->totvert, "currkey->data"); + i = 0; + ofs = MEM_callocN(sizeof(float) * 3 * bm->totvert, "currkey->data"); 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); @@ -729,25 +730,25 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) } - for (currkey=me->key->block.first; currkey; currkey=currkey->next) { + for (currkey = me->key->block.first; currkey; currkey = currkey->next) { j = 0; - for (i=0; ivdata.totlayer; i++) { + for (i = 0; i < bm->vdata.totlayer; i++) { if (bm->vdata.layers[i].type != CD_SHAPEKEY) continue; if (currkey->uid == bm->vdata.layers[i].uid) { - int apply_offset = (ofs && (currkey != actkey) && (bm->shapenr-1 == currkey->relative)); + int apply_offset = (ofs && (currkey != actkey) && (bm->shapenr - 1 == currkey->relative)); float *fp, *co; float (*ofs_pt)[3] = ofs; if (currkey->data) MEM_freeN(currkey->data); - currkey->data = fp = MEM_mallocN(sizeof(float)*3*bm->totvert, "shape key data"); + currkey->data = fp = MEM_mallocN(sizeof(float) * 3 * bm->totvert, "shape key data"); currkey->totelem = bm->totvert; BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { - co = currkey==actkey ? eve->co : CustomData_bmesh_get_n(&bm->vdata, eve->head.data, CD_SHAPEKEY, j); + co = currkey == actkey ? eve->co : CustomData_bmesh_get_n(&bm->vdata, eve->head.data, CD_SHAPEKEY, j); copy_v3_v3(fp, co); @@ -764,8 +765,8 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) j++; } - /*if we didn't find a shapekey, tag the block to be reconstructed - via the old method below*/ + /* if we didn't find a shapekey, tag the block to be reconstructed + * via the old method below */ if (j == CustomData_number_of_layers(&bm->vdata, CD_SHAPEKEY)) { currkey->flag |= KEYBLOCK_MISSING; } @@ -781,30 +782,30 @@ 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).*/ + possible in certain cases of undo) */ if (me->key) { float *fp, *newkey, *oldkey; KeyBlock *currkey; - KeyBlock *actkey= BLI_findlink(&me->key->block, bm->shapenr-1); + KeyBlock *actkey = BLI_findlink(&me->key->block, bm->shapenr - 1); 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 */ - float (*fp)[3]= actkey->data; + float (*fp)[3] = actkey->data; int *keyi; - i=0; - ofs= MEM_callocN(sizeof(float) * 3 * bm->totvert, "currkey->data"); + i = 0; + ofs = MEM_callocN(sizeof(float) * 3 * bm->totvert, "currkey->data"); 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); @@ -821,7 +822,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) * with the way things were before editmode */ currkey = me->key->block.first; while (currkey) { - int apply_offset = (ofs && (currkey != actkey) && (bm->shapenr-1 == currkey->relative)); + int apply_offset = (ofs && (currkey != actkey) && (bm->shapenr - 1 == currkey->relative)); if (!(currkey->flag & KEYBLOCK_MISSING)) { currkey = currkey->next; @@ -833,10 +834,10 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) currkey->flag &= ~KEYBLOCK_MISSING; - fp= newkey= MEM_callocN(me->key->elemsize*bm->totvert, "currkey->data"); + fp = newkey = MEM_callocN(me->key->elemsize*bm->totvert, "currkey->data"); oldkey = currkey->data; - eve= BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); + eve = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); i = 0; mvert = me->mvert; @@ -875,13 +876,13 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) fp+= 3; ++i; ++mvert; - eve= BMIter_Step(&iter); + eve = BMIter_Step(&iter); } - currkey->totelem= bm->totvert; + currkey->totelem = bm->totvert; if (currkey->data) MEM_freeN(currkey->data); currkey->data = newkey; - currkey= currkey->next; + currkey = currkey->next; } if (ofs) MEM_freeN(ofs); diff --git a/source/blender/bmesh/operators/mirror.c b/source/blender/bmesh/operators/mirror.c index 07c86a45402..a5362df3977 100644 --- a/source/blender/bmesh/operators/mirror.c +++ b/source/blender/bmesh/operators/mirror.c @@ -32,8 +32,7 @@ * MIRROR.C * * mirror bmop. - * -*/ + */ #define ELE_NEW 1 @@ -65,21 +64,21 @@ void bmesh_mirror_exec(BMesh *bm, BMOperator *op) BMO_Flag_Buffer(bm, &dupeop, "newout", ELE_NEW, BM_ALL); - /*create old -> new mapping*/ + /* create old -> new mappin */ i = 0; v2 = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); BMO_ITER(v, &siter, bm, &dupeop, "newout", BM_VERT) { BLI_array_growone(vmap); vmap[i] = v; - BM_SetIndex(v2, i); /* set_dirty! */ /*BMESH_TODO, double check this is being made dirty, 99% sure it is - campbell */ + BM_SetIndex(v2, i); /* set_dirty! */ /* BMESH_TODO, double check this is being made dirty, 99% sure it is - campbell */ v2 = BMIter_Step(&iter); i++; } bm->elem_index_dirty |= BM_VERT; - /*feed old data to transform bmop*/ + /* feed old data to transform bmo */ scale[axis] = -1.0f; BMO_CallOpf(bm, "transform verts=%fv mat=%m4", ELE_NEW, mtx); BMO_CallOpf(bm, "scale verts=%fv vec=%v", ELE_NEW, scale); @@ -88,7 +87,7 @@ void bmesh_mirror_exec(BMesh *bm, BMOperator *op) BMO_Init_Op(bm, &weldop, "weldverts"); v = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL); - for (i=0; ico[axis]) <= dist) { BMO_Insert_MapPointer(bm, &weldop, "targetmap", vmap[i], v); } @@ -105,12 +104,12 @@ void bmesh_mirror_exec(BMesh *bm, BMOperator *op) BMO_ITER(f, &siter, bm, &dupeop, "newout", BM_FACE) { BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { totlayer = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV); - for (i=0; ildata, l->head.data, CD_MLOOPUV, i); if (mirroru) - luv->uv[0]= 1.0f - luv->uv[0]; + luv->uv[0] = 1.0f - luv->uv[0]; if (mirrorv) - luv->uv[1]= 1.0f - luv->uv[1]; + luv->uv[1] = 1.0f - luv->uv[1]; } } } diff --git a/source/blender/bmesh/operators/primitiveops.c b/source/blender/bmesh/operators/primitiveops.c index 10d8319fda5..1a619d5ae2d 100644 --- a/source/blender/bmesh/operators/primitiveops.c +++ b/source/blender/bmesh/operators/primitiveops.c @@ -63,13 +63,13 @@ static short icoface[20][3] = { }; // HACK: these can also be found in cmoview.tga.c, but are here so that they can be found by linker -// this hack is only used so that scons+mingw + split-sources hack works +// this hack is only used so that scons & mingw + split-sources hack works // ------------------------------- start copied code /* these are not the monkeys you are looking for */ -static int monkeyo= 4; -static int monkeynv= 271; -static int monkeynf= 250; -static signed char monkeyv[271][3]= { +static int monkeyo = 4; +static int monkeynv = 271; +static int monkeynf = 250; +static signed char monkeyv[271][3] = { {-71,21,98},{-63,12,88},{-57,7,74},{-82,-3,79},{-82,4,92}, {-82,17,100},{-92,21,102},{-101,12,95},{-107,7,83}, {-117,31,84},{-109,31,95},{-96,31,102},{-92,42,102}, @@ -140,7 +140,7 @@ static signed char monkeyv[271][3]= { {-26,-16,-42},{-17,49,-49}, }; -static signed char monkeyf[250][4]= { +static signed char monkeyf[250][4] = { {27,4,5,26}, {25,4,5,24}, {3,6,5,4}, {1,6,5,2}, {5,6,7,4}, {3,6,7,2}, {5,8,7,6}, {3,8,7,4}, {7,8,9,6}, {5,8,9,4}, {7,10,9,8}, {5,10,9,6}, {9,10,11,8}, @@ -219,8 +219,8 @@ void bmesh_create_grid_exec(BMesh *bm, BMOperator *op) BMOperator bmop, prevop; BMVert *eve, *preveve; BMEdge *e; - float vec[3], mat[4][4], phi, phid, dia=BMO_Get_Float(op, "size"); - int a, tot=BMO_Get_Int(op, "xsegments"), seg=BMO_Get_Int(op, "ysegments"); + float vec[3], mat[4][4], phi, phid, dia = BMO_Get_Float(op, "size"); + int a, tot = BMO_Get_Int(op, "xsegments"), seg = BMO_Get_Int(op, "ysegments"); if (tot < 2) tot = 2; if (seg < 2) seg = 2; @@ -228,15 +228,15 @@ void bmesh_create_grid_exec(BMesh *bm, BMOperator *op) BMO_Get_Mat4(op, "mat", mat); /* one segment first: the X axis */ - phi= 1.0f; - phid= 2.0f/((float)tot-1); - for (a=0;aco); BM_Select(bm, eva[a], TRUE); } - for (a=0;a<20;a++) { + for (a = 0; a < 20; a++) { BMFace *eftemp; BMVert *v1, *v2, *v3; - v1= eva[ icoface[a][0] ]; - v2= eva[ icoface[a][1] ]; - v3= eva[ icoface[a][2] ]; + v1 = eva[icoface[a][0]]; + v2 = eva[icoface[a][1]]; + v3 = eva[icoface[a][2]]; eftemp = BM_Make_Face_QuadTri(bm, v1, v2, v3, NULL, NULL, 0); @@ -393,14 +393,14 @@ void bmesh_create_icosphere_exec(BMesh *bm, BMOperator *op) BMO_SetFlag(bm, eftemp, FACE_MARK); } - dia*=200; + dia *= 200.0f; - for (a=1; aco), eve); - BMO_SetFlag(bm, tv[monkeynv+i], VERT_MARK); + tv[monkeynv + i] = (fabsf(v[0] = -v[0]) < 0.001f) ? tv[i]: (eve = BM_Make_Vert(bm, v, NULL), mul_m4_v3(mat, eve->co), eve); + BMO_SetFlag(bm, tv[monkeynv + i], VERT_MARK); mul_m4_v3(mat, tv[i]->co); } - for (i=0; i #include -#define BL(ptr) ((BMLoop*)(ptr)) - static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op) { BMIter liter; BMLoop *l; BMVert *v2, *doub; - int split=0; + int split = 0; BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { v2 = BMO_Get_MapPointer(bm, op, "targetmap", l->v); - /*ok: if v2 is NULL (e.g. not in the map) then it's - a target vert, otherwise it's a double*/ - if (v2 && BM_Vert_In_Face(f, v2) && v2 != BL(l->prev)->v - && v2 != BL(l->next)->v) - { + /* ok: if v2 is NULL (e.g. not in the map) then it's + * a target vert, otherwise it's a doubl */ + if (v2 && BM_Vert_In_Face(f, v2) && (v2 != ((BMLoop *)l->prev)->v) && (v2 != ((BMLoop *)l->next)->v)) { doub = l->v; split = 1; break; @@ -66,7 +62,7 @@ int remdoubles_face_overlaps(BMesh *bm, BMVert **varr, if (overlapface) *overlapface = NULL; - for (i=0; i < len; i++) { + 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); @@ -93,7 +89,7 @@ void bmesh_weldverts_exec(BMesh *bm, BMOperator *op) int a, b; BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { - if ((v2= BMO_Get_MapPointer(bm, op, "targetmap", v))) { + if ((v2 = BMO_Get_MapPointer(bm, op, "targetmap", v))) { BMO_SetFlag(bm, v, ELE_DEL); /* merge the vertex flags, else we get randomly selected/unselected verts */ @@ -129,7 +125,7 @@ void bmesh_weldverts_exec(BMesh *bm, BMOperator *op) if (BMO_TestFlag(bm, l->v, ELE_DEL)) BMO_SetFlag(bm, f, FACE_MARK|ELE_DEL); if (BMO_TestFlag(bm, l->e, EDGE_COL)) - BM_SetIndex(f, BM_GetIndex(f)+1); /* set_dirty! */ + BM_SetIndex(f, BM_GetIndex(f) + 1); /* set_dirty! */ } } bm->elem_index_dirty |= BM_FACE; @@ -148,7 +144,7 @@ void bmesh_weldverts_exec(BMesh *bm, BMOperator *op) a = 0; BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { v = l->v; - v2 = BL(l->next)->v; + v2 = ((BMLoop *)l->next)->v; if (BMO_TestFlag(bm, v, ELE_DEL)) v = BMO_Get_MapPointer(bm, op, "targetmap", v); if (BMO_TestFlag(bm, v2, ELE_DEL)) @@ -156,12 +152,14 @@ void bmesh_weldverts_exec(BMesh *bm, BMOperator *op) e2 = v != v2 ? BM_Edge_Exist(v, v2) : NULL; if (e2) { - for (b=0; bco[0] + v1->co[1] + v1->co[2]; float x2 = v2->co[0] + v2->co[1] + v2->co[2]; - if (x1 > x2) return 1; + if (x1 > x2) return 1; else if (x1 < x2) return -1; else return 0; } @@ -244,7 +242,7 @@ void bmesh_pointmerge_facedata_exec(BMesh *bm, BMOperator *op) firstl = l; } - for (i=0; ildata.totlayer; i++) { + for (i = 0; i < bm->ldata.totlayer; i++) { if (CustomData_layer_has_math(&bm->ldata, i)) { int type = bm->ldata.layers[i].type; void *e1, *e2; @@ -280,7 +278,7 @@ void bmesh_vert_average_facedata_exec(BMesh *bm, BMOperator *op) void *block; int i, type; - for (i=0; ildata.totlayer; i++) { + for (i = 0; i < bm->ldata.totlayer; i++) { if (!CustomData_layer_has_math(&bm->ldata, i)) continue; @@ -347,7 +345,7 @@ void bmesh_collapse_exec(BMesh *bm, BMOperator *op) BMO_Init_Op(bm, &weldop, "weldverts"); BMO_Flag_Buffer(bm, op, "edges", EDGE_MARK, BM_EDGE); - BMW_Init(&walker, bm, BMW_SHELL, 0,EDGE_MARK,0,0, BMW_NIL_LAY); + BMW_Init(&walker, bm, BMW_SHELL, 0, EDGE_MARK, 0, 0, BMW_NIL_LAY); BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if (!BMO_TestFlag(bm, e, EDGE_MARK)) @@ -357,7 +355,7 @@ void bmesh_collapse_exec(BMesh *bm, BMOperator *op) BLI_array_empty(edges); INIT_MINMAX(min, max); - for (tot=0; e; tot++, e=BMW_Step(&walker)) { + for (tot = 0; e; tot++, e = BMW_Step(&walker)) { BLI_array_growone(edges); edges[tot] = e; @@ -368,8 +366,8 @@ void bmesh_collapse_exec(BMesh *bm, BMOperator *op) add_v3_v3v3(min, min, max); mul_v3_fl(min, 0.5f); - /*snap edges to a point. for initial testing purposes anyway.*/ - for (i=0; iv1->co, min); copy_v3_v3(edges[i]->v2->co, min); @@ -387,7 +385,7 @@ void bmesh_collapse_exec(BMesh *bm, BMOperator *op) BLI_array_free(edges); } -/*uv collapse function*/ +/* uv collapse functio */ static void bmesh_collapsecon_do_layer(BMesh *bm, BMOperator *op, int layer) { BMIter iter, liter; @@ -402,18 +400,18 @@ static void bmesh_collapsecon_do_layer(BMesh *bm, BMOperator *op, int layer) BMO_Clear_Flag_All(bm, op, BM_ALL, 65535); BMO_Flag_Buffer(bm, op, "edges", EDGE_MARK, BM_EDGE); - BMW_Init(&walker, bm, BMW_LOOPDATA_ISLAND, 0,EDGE_MARK,0,0, layer); + BMW_Init(&walker, bm, BMW_LOOPDATA_ISLAND, 0, EDGE_MARK, 0, 0, layer); BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { if (BMO_TestFlag(bm, l->e, EDGE_MARK)) { - /*walk*/ + /* wal */ BLI_array_empty(blocks); tot = 0; l2 = BMW_Begin(&walker, l); CustomData_data_initminmax(type, &min, &max); - for (tot=0; l2; tot++, l2=BMW_Step(&walker)) { + for (tot = 0; l2; tot++, l2 = BMW_Step(&walker)) { BLI_array_growone(blocks); blocks[tot] = CustomData_bmesh_get_layer_n(&bm->ldata, l2->head.data, layer); CustomData_data_dominmax(type, blocks[tot], &min, &max); @@ -424,8 +422,8 @@ static void bmesh_collapsecon_do_layer(BMesh *bm, BMOperator *op, int layer) CustomData_data_multiply(type, &max, 0.5f); CustomData_data_add(type, &min, &max); - /*snap CD (uv, vcol) points to their centroid*/ - for (i=0; ildata.totlayer; i++) { + for (i = 0; i < bm->ldata.totlayer; i++) { if (CustomData_layer_has_math(&bm->ldata, i)) bmesh_collapsecon_do_layer(bm, op, i); } @@ -451,7 +449,7 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c { BMOIter oiter; BMVert *v, *v2; - BMVert **verts=NULL; + BMVert **verts = NULL; BLI_array_declare(verts); float dist, dist3; int i, j, len, keepvert = 0; @@ -470,8 +468,8 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c keepvert = BMO_IterNew(&oiter, bm, op, "keepverts", BM_VERT) != NULL; } - /*sort by vertex coordinates added together*/ - qsort(verts, BLI_array_count(verts), sizeof(void*), vergaverco); + /* sort by vertex coordinates added togethe */ + qsort(verts, BLI_array_count(verts), sizeof(void *), vergaverco); /* Flag keepverts */ if (keepvert) { @@ -479,11 +477,11 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c } len = BLI_array_count(verts); - for (i=0; i #include -/*flags for all elements share a common bitfield space*/ +/* flags for all elements share a common bitfield space */ #define SUBD_SPLIT 1 #define EDGE_PERCENT 2 -/*I don't think new faces are flagged, currently, but - better safe than sorry.*/ +/* I don't think new faces are flagged, currently, but + * better safe than sorry. */ #define FACE_NEW 4 #define FACE_CUSTOMFILL 8 #define ELE_INNER 16 #define ELE_SPLIT 32 #define ELE_CONNECT 64 -/*stuff for the flag paramter. note that - what used to live in "beauty" and - in "seltype" live here. still have to - convert the beauty flags over, which - is why it starts at 128 (to avoid - collision).*/ +/* stuff for the flag paramter. note that + * what used to live in "beauty" and + * in "seltype" live here. still have to + * convert the beauty flags over, which + * is why it starts at 128 (to avoid + * collision). */ #define SELTYPE_INNER 128 /* -NOTE: beauty has been renamed to flag! -*/ + * NOTE: beauty has been renamed to flag! + */ -/*generic subdivision rules: - - * two selected edges in a face should make a link - between them. - - * one edge should do, what? make pretty topology, or just - split the edge only? -*/ +/* generic subdivision rules: + * + * - two selected edges in a face should make a link + * between them. + * + * - one edge should do, what? make pretty topology, or just + * split the edge only? + */ #if 0 //misc. code, maps a parametric coordinate to a fractal line float lastrnd[3], vec2[3] = {0.0f, 0.0f, 0.0f}; @@ -89,7 +89,7 @@ NOTE: beauty has been renamed to flag! BLI_srandom(seed); - wid = (params->numcuts+2); + wid = (params->numcuts + 2); dp = perc*wid; wid /= 2; d = lvl = 0; @@ -105,29 +105,29 @@ NOTE: beauty has been renamed to flag! } - wid = MAX2((wid/2), 1); + wid = MAX2((wid / 2), 1); lvl++; } zero_v3(vec1); df = 1.0f; - for (i=0; inumcuts/(float)tot); - b = (float)(j+1)*(float)((float)params->numcuts/(float)tot); + a = (float)j * (float)((float)params->numcuts / (float)tot); + b = (float)(j + 1) * (float)((float)params->numcuts / (float)tot); if (d >= a && d <= b) { - interp_v3_v3v3(rnd2, lastrnd, rnd, (((float)d)-a)/(b-a)); + interp_v3_v3v3(rnd2, lastrnd, rnd, (((float)d) - a) / (b - a)); mul_v3_fl(rnd2, df); add_v3_v3(vec1, rnd2); } @@ -136,20 +136,20 @@ NOTE: beauty has been renamed to flag! } } #endif -/*connects face with smallest len, which I think should always be correct for - edge subdivision*/ -static BMEdge *connect_smallest_face(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **nf) +/* connects face with smallest len, which I think should always be correct for + * edge subdivision */ +static BMEdge *connect_smallest_face(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_nf) { BMIter iter, iter2; BMVert *v; BMLoop *nl; BMFace *face, *curf = NULL; - /*this isn't the best thing in the world. it doesn't handle cases where there's - multiple faces yet. that might require a convexity test to figure out which - face is "best," and who knows what for non-manifold conditions.*/ - for (face = BMIter_New(&iter, bm, BM_FACES_OF_VERT, v1); face; face=BMIter_Step(&iter)) { - for (v=BMIter_New(&iter2, bm, BM_VERTS_OF_FACE, face); v; v=BMIter_Step(&iter2)) { + /* this isn't the best thing in the world. it doesn't handle cases where there's + * multiple faces yet. that might require a convexity test to figure out which + * face is "best," and who knows what for non-manifold conditions. */ + for (face = BMIter_New(&iter, bm, BM_FACES_OF_VERT, v1); face; face = BMIter_Step(&iter)) { + for (v = BMIter_New(&iter2, bm, BM_VERTS_OF_FACE, face); v; v = BMIter_Step(&iter2)) { if (v == v2) { if (!curf || face->len < curf->len) curf = face; } @@ -159,7 +159,7 @@ static BMEdge *connect_smallest_face(BMesh *bm, BMVert *v1, BMVert *v2, BMFace * if (curf) { face = BM_Split_Face(bm, curf, v1, v2, &nl, NULL); - if (nf) *nf = face; + if (r_nf) *r_nf = face; return nl ? nl->e : NULL; } @@ -170,7 +170,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const subdpar BMVert *vsta, BMVert *vend) { float tvec[3], prev_co[3], fac; - float *co=NULL; + float *co = NULL; int i, totlayer = CustomData_number_of_layers(&bm->vdata, CD_SHAPEKEY); BM_Vert_UpdateAllNormals(bm, v); @@ -180,10 +180,10 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const subdpar 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; + float len, nor[3], nor1[3], nor2[3], smooth = params->smooth; sub_v3_v3v3(nor, vsta->co, vend->co); - len= 0.5f*normalize_v3(nor); + len = 0.5f*normalize_v3(nor); copy_v3_v3(nor1, vsta->no); copy_v3_v3(nor2, vend->no); @@ -193,7 +193,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const subdpar mul_v3_v3fl(tvec, nor1, fac); /* cosine angle */ - fac= -dot_v3v3(nor, nor2); + fac = -dot_v3v3(nor, nor2); madd_v3_v3fl(tvec, nor2, fac); /* falloff for multi subdivide */ @@ -212,20 +212,20 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const subdpar float len = len_v3v3(vsta->co, vend->co); float vec2[3] = {0.0f, 0.0f, 0.0f}, co2[3]; - fac= params->fractal*len; + fac = params->fractal*len; add_v3_v3(vec2, vsta->no); add_v3_v3(vec2, vend->no); mul_v3_fl(vec2, 0.5f); add_v3_v3v3(co2, v->co, params->off); - tvec[0] = fac*(BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1)-0.5f); - tvec[1] = fac*(BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1)-0.5f); - tvec[2] = fac*(BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1)-0.5f); + tvec[0] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1) - 0.5f); + tvec[1] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1) - 0.5f); + tvec[2] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1) - 0.5f); mul_v3_v3(vec2, tvec); - /*add displacement*/ + /* add displacemen */ add_v3_v3v3(co, co, vec2); } @@ -236,7 +236,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const subdpar * for now its ok to simply apply the difference IMHO - campbell */ sub_v3_v3v3(tvec, prev_co, co); - for (i=0; iorigkey != i) { co = CustomData_bmesh_get_n(&bm->vdata, v->head.data, CD_SHAPEKEY, i); sub_v3_v3(co, tvec); @@ -248,10 +248,10 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const subdpar /* assumes in the edge is the correct interpolated vertices already */ /* percent defines the interpolation, rad and flag are for special options */ /* results in new vertex with correct coordinate, vertex normal and weight group info */ -static BMVert *bm_subdivide_edge_addvert(BMesh *bm, BMEdge *edge,BMEdge *oedge, +static BMVert *bm_subdivide_edge_addvert(BMesh *bm, BMEdge *edge, BMEdge *oedge, const subdparams *params, float percent, float percent2, - BMEdge **out,BMVert *vsta,BMVert *vend) + BMEdge **out, BMVert *vsta, BMVert *vend) { BMVert *ev; @@ -266,13 +266,13 @@ static BMVert *bm_subdivide_edge_addvert(BMesh *bm, BMEdge *edge,BMEdge *oedge, /* clip if needed by mirror modifier */ if (edge->v1->f2) { if (edge->v1->f2 & edge->v2->f2 & 1) { - co[0]= 0.0f; + co[0] = 0.0f; } if (edge->v1->f2 & edge->v2->f2 & 2) { - co[1]= 0.0f; + co[1] = 0.0f; } if (edge->v1->f2 & edge->v2->f2 & 4) { - co[2]= 0.0f; + co[2] = 0.0f; } } #endif @@ -291,12 +291,12 @@ static BMVert *subdivideedgenum(BMesh *bm, BMEdge *edge, BMEdge *oedge, percent = BMO_Get_MapFloat(bm, params->op, "edgepercents", edge); else { - percent= 1.0f/(float)(totpoint+1-curpoint); - percent2 = (float)(curpoint+1) / (float)(totpoint+1); + percent = 1.0f / (float)(totpoint + 1-curpoint); + percent2 = (float)(curpoint + 1) / (float)(totpoint + 1); } - ev= bm_subdivide_edge_addvert(bm, edge, oedge, params, percent, + ev = bm_subdivide_edge_addvert(bm, edge, oedge, params, percent, percent2, newe, vsta, vend); return ev; } @@ -305,13 +305,13 @@ static void bm_subdivide_multicut(BMesh *bm, BMEdge *edge, const subdparams *par BMVert *vsta, BMVert *vend) { BMEdge *eed = edge, *newe, temp = *edge; - BMVert *v, ov1=*edge->v1, ov2=*edge->v2, *v1=edge->v1, *v2=edge->v2; + BMVert *v, ov1 = *edge->v1, ov2 = *edge->v2, *v1 = edge->v1, *v2 = edge->v2; int i, numcuts = params->numcuts; temp.v1 = &ov1; temp.v2 = &ov2; - for (i=0;inumcuts, params, &newe, vsta, vend); @@ -332,45 +332,41 @@ static void bm_subdivide_multicut(BMesh *bm, BMEdge *edge, const subdparams *par alter_co(bm, v2, &temp, params, 1.0, &ov1, &ov2); } -/*note: the patterns are rotated as necassary to - match the input geometry. they're based on the - pre-split state of the face*/ +/* note: the patterns are rotated as necassary to + * match the input geometry. they're based on the + * pre-split state of the face */ /* - -v3---------v2 -| | -| | -| | -| | -v4---v0---v1 - -*/ + * v3---------v2 + * | | + * | | + * | | + * | | + * v4---v0---v1 + */ static void quad_1edge_split(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, const subdparams *params) { BMFace *nf; int i, add, numcuts = params->numcuts; - /*if it's odd, the middle face is a quad, otherwise it's a triangle*/ - if (numcuts % 2==0) { + /* if it's odd, the middle face is a quad, otherwise it's a triangl */ + if ((numcuts % 2) == 0) { add = 2; - for (i=0; inumcuts; - for (i=0; i=0; i--) { - e = connect_smallest_face(bm, verts[i], verts[numcuts+(numcuts-i)], - &nf); - + for (i = numcuts - 1; i >= 0; i--) { + e = connect_smallest_face(bm, verts[i], verts[numcuts + (numcuts - i)], &nf); + olde = *e; v = bm_subdivide_edge_addvert(bm, e, &olde, params, 0.5f, 0.5f, &ne, e->v1, e->v2); - if (i != numcuts-1) + if (i != numcuts - 1) { connect_smallest_face(bm, lastv, v, &nf); - + } + lastv = v; } - connect_smallest_face(bm, lastv, verts[numcuts*2+2], &nf); + connect_smallest_face(bm, lastv, verts[numcuts * 2 + 2], &nf); } static subdpattern quad_2edge_innervert = { @@ -454,27 +447,26 @@ static subdpattern quad_2edge_innervert = { }; /* -v6--------v5 -| | -| |v4s -| |v3s -| s s | -v7-v0--v1-v2 - -*/ + * v6--------v5 + * | | + * | |v4s + * | |v3s + * | s s | + * v7-v0--v1-v2 + * + */ static void quad_2edge_split_fan(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, const subdparams *params) { BMFace *nf; /* BMVert *v; */ /* UNUSED */ - /* BMVert *lastv= verts[2]; */ /* UNUSED */ + /* BMVert *lastv = verts[2]; */ /* UNUSED */ /* BMEdge *e, *ne; */ /* UNUSED */ int i, numcuts = params->numcuts; - for (i=0; inumcuts; + int i, add = 0, numcuts = params->numcuts; - for (i=0; inumcuts; - int i, j, a, b, s=numcuts+2 /* , totv=numcuts*4+4 */; + int i, j, a, b, s = numcuts + 2 /* , totv = numcuts * 4 + 4 */; - lines = MEM_callocN(sizeof(BMVert*)*(numcuts+2)*(numcuts+2), - "q_4edge_split"); - /*build a 2-dimensional array of verts, - containing every vert (and all new ones) - in the face.*/ + lines = MEM_callocN(sizeof(BMVert *)*(numcuts + 2)*(numcuts + 2), "q_4edge_split"); + /* build a 2-dimensional array of verts, + * containing every vert (and all new ones) + * in the face */ - /*first line*/ - for (i=0; inumcuts; - for (i=0; inumcuts; - /*number of verts in each line*/ - lines = MEM_callocN(sizeof(void*)*(numcuts+2), "triangle vert table"); + /* number of verts in each lin */ + lines = MEM_callocN(sizeof(void *)*(numcuts + 2), "triangle vert table"); - lines[0] = (BMVert**) stackarr; - lines[0][0] = verts[numcuts*2+1]; + lines[0] = (BMVert **) stackarr; + lines[0][0] = verts[numcuts * 2 + 1]; - lines[1+numcuts] = MEM_callocN(sizeof(void*)*(numcuts+2), - "triangle vert table 2"); - for (i=0; ivdata, CD_SHAPEKEY); - skey = CustomData_number_of_layers(&bmesh->vdata, CD_SHAPEKEY)-1; + skey = CustomData_number_of_layers(&bmesh->vdata, CD_SHAPEKEY) - 1; BM_ITER(v, &viter, bmesh, BM_VERTS_OF_MESH, NULL) { float *co = CustomData_bmesh_get_n(&bmesh->vdata, v->head.data, CD_SHAPEKEY, skey); copy_v3_v3(co, v->co); } - /*first go through and tag edges*/ + /* first go through and tag edge */ BMO_Flag_To_Slot(bmesh, op, "edges", SUBD_SPLIT, BM_EDGE); @@ -840,9 +824,9 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) params.fractal = fractal; params.beauty = beauty; params.origkey = skey; - params.off[0] = (float)BLI_drand()*200.0f; - params.off[1] = (float)BLI_drand()*200.0f; - params.off[2] = (float)BLI_drand()*200.0f; + params.off[0] = (float)BLI_drand() * 200.0f; + params.off[1] = (float)BLI_drand() * 200.0f; + params.off[2] = (float)BLI_drand() * 200.0f; BMO_Mapping_To_Flag(bmesh, op, "custompatterns", FACE_CUSTOMFILL); @@ -850,12 +834,12 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) BMO_Mapping_To_Flag(bmesh, op, "edgepercents", EDGE_PERCENT); - for (face=BMIter_New(&fiter, bmesh, BM_FACES_OF_MESH, NULL); - face; face=BMIter_Step(&fiter)) { + for (face = BMIter_New(&fiter, bmesh, BM_FACES_OF_MESH, NULL); + face; face = BMIter_Step(&fiter)) { BMEdge *e1 = NULL, *e2 = NULL; float vec1[3], vec2[3]; - /*figure out which pattern to use*/ + /* figure out which pattern to us */ BLI_array_empty(edges); BLI_array_empty(verts); @@ -863,8 +847,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) i = 0; totesel = 0; - for (nl=BMIter_New(&liter, bmesh, BM_LOOPS_OF_FACE, face); - nl; nl=BMIter_Step(&liter)) { + for (nl = BMIter_New(&liter, bmesh, BM_LOOPS_OF_FACE, face); nl; nl = BMIter_Step(&liter)) { BLI_array_growone(edges); BLI_array_growone(verts); edges[i] = nl->e; @@ -880,7 +863,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) i++; } - /*make sure the two edges have a valid angle to each other*/ + /* make sure the two edges have a valid angle to each othe */ if (totesel == 2 && BM_Edge_Share_Vert(e1, e2)) { float angle; @@ -899,9 +882,9 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) if (BMO_TestFlag(bmesh, face, FACE_CUSTOMFILL)) { pat = BMO_Get_MapData(bmesh, op, "custompatterns", face); - for (i=0; ilen; i++) { + for (i = 0; i < pat->len; i++) { matched = 1; - for (j=0; jlen; j++) { + for (j = 0; j < pat->len; j++) { a = (j + i) % pat->len; if ((!!BMO_TestFlag(bmesh, edges[a], SUBD_SPLIT)) != (!!pat->seledges[j])) { @@ -911,7 +894,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) } if (matched) { BLI_array_growone(facedata); - b = BLI_array_count(facedata)-1; + b = BLI_array_count(facedata) - 1; facedata[b].pat = pat; facedata[b].start = verts[i]; facedata[b].face = face; @@ -921,18 +904,18 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) } } - /*obvously don't test for other patterns matching*/ + /* obvously don't test for other patterns matchin */ continue; } - for (i=0; ilen == face->len) { - for (a=0; alen; a++) { + for (a = 0; a < pat->len; a++) { matched = 1; - for (b=0; blen; b++) { + for (b = 0; b < pat->len; b++) { j = (b + a) % pat->len; if ((!!BMO_TestFlag(bmesh, edges[j], SUBD_SPLIT)) != (!!pat->seledges[b])) { @@ -970,17 +953,17 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) einput = BMO_GetSlot(op, "edges"); - /*go through and split edges*/ - for (i=0; ilen; i++) { - edge = ((BMEdge**)einput->data.p)[i]; + /* go through and split edge */ + for (i = 0; i < einput->len; i++) { + edge = ((BMEdge **)einput->data.p)[i]; bm_subdivide_multicut(bmesh, edge, ¶ms, edge->v1, edge->v2); } i = 0; - for (i=0; iv, ELE_INNER) - && BMO_TestFlag(bmesh, loops[a]->v, ELE_INNER)) + /* find the boundary of one of the split edge */ + for (a = 1; a < vlen; a++) { + if ( !BMO_TestFlag(bmesh, loops[a - 1]->v, ELE_INNER) && + BMO_TestFlag(bmesh, loops[a]->v, ELE_INNER)) + { break; + } } - if (BMO_TestFlag(bmesh, loops[(a+numcuts+1)%vlen]->v, ELE_INNER)) { - b = (a+numcuts+1)%vlen; + if (BMO_TestFlag(bmesh, loops[(a + numcuts + 1) % vlen]->v, ELE_INNER)) { + b = (a + numcuts + 1) % vlen; } else { - /*find the boundary of the other edge.*/ - for (j=0; jv, ELE_INNER) - && BMO_TestFlag(bmesh, loops[b]->v, ELE_INNER)) + if ( !BMO_TestFlag(bmesh, loops[b == 0 ? vlen - 1 : b - 1]->v, ELE_INNER) && + BMO_TestFlag(bmesh, loops[b]->v, ELE_INNER)) + { break; + } } } b += numcuts - 1; - for (j=0; jv, splits[j*2+1]->v, &nl, NULL); + for (j = 0; j < BLI_array_count(splits) / 2; j++) { + if (splits[j * 2]) { + /* BMFace *nf = */ /* UNUSED */ + BM_Split_Face(bmesh, face, splits[j * 2]->v, splits[j * 2 + 1]->v, &nl, NULL); } } @@ -1049,23 +1036,22 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) } j = a = 0; - for (nl=BMIter_New(&liter, bmesh, BM_LOOPS_OF_FACE, face); - nl; nl=BMIter_Step(&liter)) { + for (nl = BMIter_New(&liter, bmesh, BM_LOOPS_OF_FACE, face); + nl; nl = BMIter_Step(&liter)) { if (nl->v == facedata[i].start) { - a = j+1; + a = j + 1; break; } j++; } - for (j=0; jlen; j++) { + for (j = 0; j < face->len; j++) { BLI_array_growone(verts); } j = 0; - for (nl=BMIter_New(&liter, bmesh, BM_LOOPS_OF_FACE, face); - nl; nl=BMIter_Step(&liter)) { - b = (j-a+face->len) % face->len; + for (nl = BMIter_New(&liter, bmesh, BM_LOOPS_OF_FACE, face); nl; nl = BMIter_Step(&liter)) { + b = (j - a + face->len) % face->len; verts[b] = nl->v; j += 1; } @@ -1074,7 +1060,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) pat->connectexec(bmesh, face, verts, ¶ms); } - /*copy original-geometry displacements to current coordinates*/ + /* copy original-geometry displacements to current coordinate */ BM_ITER(v, &viter, bmesh, BM_VERTS_OF_MESH, NULL) { float *co = CustomData_bmesh_get_n(&bmesh->vdata, v->head.data, CD_SHAPEKEY, skey); copy_v3_v3(v->co, co); @@ -1097,7 +1083,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) ELE_INNER|ELE_SPLIT|SUBD_SPLIT, BM_ALL); } -/*editmesh-emulating function*/ +/* editmesh-emulating functio */ void BM_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float smooth, float fractal, int beauty, int numcuts, int seltype, int cornertype, int singleedge, @@ -1106,10 +1092,10 @@ void BM_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float smooth BMOperator op; BMO_InitOpf(bm, &op, "esubd edges=%he smooth=%f fractal=%f " - "beauty=%d numcuts=%d quadcornertype=%d singleedge=%d " - "gridfill=%d seed=%d", - flag, smooth, fractal, beauty, numcuts, - cornertype, singleedge, gridfill, seed); + "beauty=%d numcuts=%d quadcornertype=%d singleedge=%d " + "gridfill=%d seed=%d", + flag, smooth, fractal, beauty, numcuts, + cornertype, singleedge, gridfill, seed); BMO_Exec_Op(bm, &op); @@ -1119,7 +1105,7 @@ 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); } } @@ -1128,11 +1114,11 @@ void BM_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float smooth BMHeader *ele; // int i; - /*deselect input*/ + /* deselect inpu */ 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) { @@ -1140,13 +1126,17 @@ void BM_esubdivideflag(Object *UNUSED(obedit), BMesh *bm, int flag, float smooth BMIter eiter; BM_ITER(e, &eiter, bm, BM_EDGES_OF_VERT, ele) { - if (!BM_TestHFlag(e, BM_SELECT) && BM_TestHFlag(e->v1, BM_SELECT) - && BM_TestHFlag(e->v2, BM_SELECT)) { + if ( !BM_TestHFlag(e, BM_SELECT) && + BM_TestHFlag(e->v1, BM_SELECT) && + 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) - || !BM_TestHFlag(e->v2, 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; } @@ -1169,11 +1159,11 @@ void esplit_exec(BMesh *bm, BMOperator *op) params.op = op; BM_add_data_layer(bm, &bm->vdata, CD_SHAPEKEY); - skey = CustomData_number_of_layers(&bm->vdata, CD_SHAPEKEY)-1; + skey = CustomData_number_of_layers(&bm->vdata, CD_SHAPEKEY) - 1; params.origkey = skey; - /*go through and split edges*/ + /* go through and split edge */ BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) { bm_subdivide_multicut(bm, e, ¶ms, e->v1, e->v2); } diff --git a/source/blender/bmesh/operators/triangulateop.c b/source/blender/bmesh/operators/triangulateop.c index c1f31bcbd79..af7ba130efc 100644 --- a/source/blender/bmesh/operators/triangulateop.c +++ b/source/blender/bmesh/operators/triangulateop.c @@ -29,14 +29,14 @@ void triangulate_exec(BMesh *bm, BMOperator *op) BLI_array_declare(newfaces); float (*projectverts)[3] = NULL; BLI_array_declare(projectverts); - int i, lastlen=0 /* , count = 0 */; + 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); - for (lastlen=0; lastlenlen; lastlen++) { + for (lastlen = 0; lastlen < face->len; lastlen++) { BLI_array_growone(projectverts); BLI_array_growone(projectverts); BLI_array_growone(projectverts); @@ -48,10 +48,10 @@ void triangulate_exec(BMesh *bm, BMOperator *op) FACE_NEW, newfaces); BMO_Insert_MapPointer(bm, op, "facemap", - face, face); - for (i=0; newfaces[i]; i++) { - BMO_Insert_MapPointer(bm, op, "facemap", - newfaces[i], face); + face, face); + for (i = 0; newfaces[i]; i++) { + BMO_Insert_MapPointer(bm, op, "facemap", + newfaces[i], face); } } @@ -69,7 +69,7 @@ void bmesh_beautify_fill_exec(BMesh *bm, BMOperator *op) BMIter iter; BMFace *f; BMEdge *e; - int stop=0; + int stop = 0; BMO_Flag_Buffer(bm, op, "constrain_edges", EDGE_MARK, BM_EDGE); @@ -99,22 +99,22 @@ void bmesh_beautify_fill_exec(BMesh *bm, BMOperator *op) /* testing rule: * the area divided by the total edge lengths */ - len1= len_v3v3(v1->co, v2->co); - len2= len_v3v3(v2->co, v3->co); - len3= len_v3v3(v3->co, v4->co); - len4= len_v3v3(v4->co, v1->co); - len5= len_v3v3(v1->co, v3->co); - len6= len_v3v3(v2->co, v4->co); + len1 = len_v3v3(v1->co, v2->co); + len2 = len_v3v3(v2->co, v3->co); + len3 = len_v3v3(v3->co, v4->co); + len4 = len_v3v3(v4->co, v1->co); + len5 = len_v3v3(v1->co, v3->co); + len6 = len_v3v3(v2->co, v4->co); - opp1= area_tri_v3(v1->co, v2->co, v3->co); - opp2= area_tri_v3(v1->co, v3->co, v4->co); + opp1 = area_tri_v3(v1->co, v2->co, v3->co); + opp2 = area_tri_v3(v1->co, v3->co, v4->co); - fac1= opp1/(len1+len2+len5) + opp2/(len3+len4+len5); + fac1 = opp1 / (len1 + len2 + len5) + opp2 / (len3 + len4 + len5); - opp1= area_tri_v3(v2->co, v3->co, v4->co); - opp2= area_tri_v3(v2->co, v4->co, v1->co); + opp1 = area_tri_v3(v2->co, v3->co, v4->co); + opp2 = area_tri_v3(v2->co, v4->co, v1->co); - fac2= opp1/(len2+len3+len6) + opp2/(len4+len1+len6); + fac2 = opp1 / (len2 + len3 + len6) + opp2 / (len4 + len1 + len6); if (fac1 > fac2) { e = BM_Rotate_Edge(bm, e, 0); @@ -170,7 +170,7 @@ void bmesh_triangle_fill_exec(BMesh *bm, BMOperator *op) BLI_edgefill(0); - for (efa=fillfacebase.first; efa; efa=efa->next) { + for (efa = fillfacebase.first; efa; efa = efa->next) { BMFace *f = BM_Make_Face_QuadTri(bm, efa->v1->tmp.p, efa->v2->tmp.p, efa->v3->tmp.p, NULL, NULL, 1); BMLoop *l; BMIter liter; @@ -186,7 +186,7 @@ void bmesh_triangle_fill_exec(BMesh *bm, BMOperator *op) BLI_end_edgefill(); BLI_smallhash_release(&hash); - /*clean up fill*/ + /* clean up fill */ BMO_InitOpf(bm, &bmop, "beautify_fill faces=%ff constrain_edges=%fe", ELE_NEW, EDGE_MARK); BMO_Exec_Op(bm, &bmop); BMO_Flag_Buffer(bm, &bmop, "geomout", ELE_NEW, BM_FACE|BM_EDGE); diff --git a/source/blender/bmesh/operators/utils.c b/source/blender/bmesh/operators/utils.c index b535fa1eb4b..c3cc15b5807 100644 --- a/source/blender/bmesh/operators/utils.c +++ b/source/blender/bmesh/operators/utils.c @@ -33,7 +33,7 @@ * utility bmesh operators, e.g. transform, * translate, rotate, scale, etc. * -*/ + */ void bmesh_makevert_exec(BMesh *bm, BMOperator *op) { @@ -90,15 +90,15 @@ void bmesh_rotate_exec(BMesh *bm, BMOperator *op) BMO_Get_Vec(op, "cent", vec); - /*there has to be a proper matrix way to do this, but - this is how editmesh did it and I'm too tired to think - through the math right now.*/ - mul_v3_fl(vec, -1); + /* there has to be a proper matrix way to do this, but + * this is how editmesh did it and I'm too tired to think + * through the math right now. */ + mul_v3_fl(vec, -1.0f); BMO_CallOpf(bm, "translate verts=%s vec=%v", op, "verts", vec); BMO_CallOpf(bm, "transform mat=%s verts=%s", op, "mat", op, "verts"); - mul_v3_fl(vec, -1); + mul_v3_fl(vec, -1.0f); BMO_CallOpf(bm, "translate verts=%s vec=%v", op, "verts", vec); } @@ -227,7 +227,7 @@ void bmesh_regionextend_exec(BMesh *bm, BMOperator *op) BMO_Flag_To_Slot(bm, op, "geomout", SEL_FLAG, BM_ALL); } -/********* righthand faces implementation ********/ +/********* righthand faces implementation ****** */ #define FACE_VIS 1 #define FACE_FLAG 2 @@ -265,12 +265,12 @@ void bmesh_righthandfaces_exec(BMesh *bm, BMOperator *op) float maxx, cent[3]; int i, maxi, flagflip = BMO_Get_Int(op, "doflip"); - startf= NULL; - maxx= -1.0e10; + startf = NULL; + maxx = -1.0e10; BMO_Flag_Buffer(bm, op, "faces", FACE_FLAG, BM_FACE); - /*find a starting face*/ + /* find a starting face */ BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) { /* clear dirty flag */ @@ -294,7 +294,7 @@ void bmesh_righthandfaces_exec(BMesh *bm, BMOperator *op) BM_Compute_Face_CenterBounds(bm, startf, cent); - /*make sure the starting face has the correct winding*/ + /* make sure the starting face has the correct winding */ if (dot_v3v3(cent, startf->no) < 0.0f) { BM_flip_normal(bm, startf); BMO_ToggleFlag(bm, startf, FACE_FLIP); @@ -303,10 +303,10 @@ void bmesh_righthandfaces_exec(BMesh *bm, BMOperator *op) BM_ToggleHFlag(startf, BM_TMP_TAG); } - /*now that we've found our starting face, make all connected faces - have the same winding. this is done recursively, using a manual - stack (if we use simple function recursion, we'd end up overloading - the stack on large meshes).*/ + /* now that we've found our starting face, make all connected faces + * have the same winding. this is done recursively, using a manual + * stack (if we use simple function recursion, we'd end up overloading + * the stack on large meshes). */ BLI_array_growone(fstack); fstack[0] = startf; @@ -354,7 +354,7 @@ void bmesh_righthandfaces_exec(BMesh *bm, BMOperator *op) BLI_array_free(fstack); - /*check if we have faces yet to do. if so, recurse.*/ + /* check if we have faces yet to do. if so, recurse */ BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) { if (!BMO_TestFlag(bm, f, FACE_VIS)) { bmesh_righthandfaces_exec(bm, op); @@ -419,10 +419,10 @@ void bmesh_vertexsmooth_exec(BMesh *bm, BMOperator *op) } /* -** compute the perimeter of an ngon -** -** NOTE: This should probably go to bmesh_polygon.c -*/ + * compute the perimeter of an ngon + * + * NOTE: This should probably go to bmesh_polygon.c + */ static float ngon_perimeter(BMesh *bm, BMFace *f) { BMIter liter; @@ -449,12 +449,12 @@ static float ngon_perimeter(BMesh *bm, BMFace *f) } /* -** compute the fake surface of an ngon -** This is done by decomposing the ngon into triangles who share the centroid of the ngon -** while this method is far from being exact, it should garantee an invariance. -** -** NOTE: This should probably go to bmesh_polygon.c -*/ + * compute the fake surface of an ngon + * This is done by decomposing the ngon into triangles who share the centroid of the ngon + * while this method is far from being exact, it should garantee an invariance. + * + * NOTE: This should probably go to bmesh_polygon.c + */ static float ngon_fake_area(BMesh *bm, BMFace *f) { BMIter liter; @@ -484,8 +484,8 @@ static float ngon_fake_area(BMesh *bm, BMFace *f) } /* -** extra face data (computed data) -*/ + * extra face data (computed data) + */ typedef struct tmp_face_ext { BMFace *f; /* the face */ float c[3]; /* center */ @@ -498,9 +498,9 @@ typedef struct tmp_face_ext { } tmp_face_ext; /* -** Select similar faces, the choices are in the enum in source/blender/bmesh/bmesh_operators.h -** We select either similar faces based on material, image, area, perimeter, normal, or the coplanar faces -*/ + * Select similar faces, the choices are in the enum in source/blender/bmesh/bmesh_operators.h + * We select either similar faces based on material, image, area, perimeter, normal, or the coplanar faces + */ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) { BMIter fm_iter; @@ -531,8 +531,8 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) } /* allocate memory for the selected faces indices and for all temporary faces */ - indices = (int*)MEM_callocN(sizeof(int) * num_sels, "face indices util.c"); - f_ext = (tmp_face_ext*)MEM_callocN(sizeof(tmp_face_ext) * num_total, "f_ext util.c"); + indices = (int *)MEM_callocN(sizeof(int) * num_sels, "face indices util.c"); + f_ext = (tmp_face_ext *)MEM_callocN(sizeof(tmp_face_ext) * num_total, "f_ext util.c"); /* loop through all the faces and fill the faces/indices structure */ BM_ITER(fm, &fm_iter, bm, BM_FACES_OF_MESH, NULL) { @@ -650,12 +650,12 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) /****************************************************************************** ** Similar Edges -******************************************************************************/ +**************************************************************************** */ #define EDGE_MARK 1 /* -** compute the angle of an edge (i.e. the angle between two faces) -*/ + * compute the angle of an edge (i.e. the angle between two faces) + */ static float edge_angle(BMesh *bm, BMEdge *e) { BMIter fiter; @@ -665,7 +665,7 @@ static float edge_angle(BMesh *bm, BMEdge *e) BM_ITER(f, &fiter, bm, BM_FACES_OF_EDGE, e) { if (f_prev == NULL) { - f_prev= f; + f_prev = f; } else { return angle_v3v3(f_prev->no, f->no); @@ -675,13 +675,13 @@ static float edge_angle(BMesh *bm, BMEdge *e) return 0.0f; } /* -** extra edge information -*/ + * extra edge information + */ typedef struct tmp_edge_ext { BMEdge *e; union { float dir[3]; - float angle; /* angle between the faces*/ + float angle; /* angle between the face */ }; union { @@ -691,9 +691,9 @@ typedef struct tmp_edge_ext { } tmp_edge_ext; /* -** select similar edges: the choices are in the enum in source/blender/bmesh/bmesh_operators.h -** choices are length, direction, face, ... -*/ + * select similar edges: the choices are in the enum in source/blender/bmesh/bmesh_operators.h + * choices are length, direction, face, ... + */ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) { BMOIter es_iter; /* selected edges iterator */ @@ -719,8 +719,8 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) } /* allocate memory for the selected edges indices and for all temporary edges */ - indices = (int*)MEM_callocN(sizeof(int) * num_sels, "indices util.c"); - e_ext = (tmp_edge_ext*)MEM_callocN(sizeof(tmp_edge_ext) * num_total, "e_ext util.c"); + indices = (int *)MEM_callocN(sizeof(int) * num_sels, "indices util.c"); + e_ext = (tmp_edge_ext *)MEM_callocN(sizeof(tmp_edge_ext) * num_total, "e_ext util.c"); /* loop through all the edges and fill the edges/indices structure */ BM_ITER(e, &e_iter, bm, BM_EDGES_OF_MESH, NULL) { @@ -847,7 +847,7 @@ void bmesh_similaredges_exec(BMesh *bm, BMOperator *op) /****************************************************************************** ** Similar Vertices -******************************************************************************/ +**************************************************************************** */ #define VERT_MARK 1 typedef struct tmp_vert_ext { @@ -859,9 +859,9 @@ typedef struct tmp_vert_ext { } tmp_vert_ext; /* -** select similar vertices: the choices are in the enum in source/blender/bmesh/bmesh_operators.h -** choices are normal, face, vertex group... -*/ + * select similar vertices: the choices are in the enum in source/blender/bmesh/bmesh_operators.h + * choices are normal, face, vertex group... + */ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op) { BMOIter vs_iter; /* selected verts iterator */ @@ -883,8 +883,8 @@ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op) } /* allocate memory for the selected vertices indices and for all temporary vertices */ - indices = (int*)MEM_mallocN(sizeof(int) * num_sels, "vertex indices"); - v_ext = (tmp_vert_ext*)MEM_mallocN(sizeof(tmp_vert_ext) * num_total, "vertex extra"); + indices = (int *)MEM_mallocN(sizeof(int) * num_sels, "vertex indices"); + v_ext = (tmp_vert_ext *)MEM_mallocN(sizeof(tmp_vert_ext) * num_total, "vertex extra"); /* loop through all the vertices and fill the vertices/indices structure */ BM_ITER(v, &v_iter, bm, BM_VERTS_OF_MESH, NULL) { @@ -901,7 +901,7 @@ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op) 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 { @@ -963,7 +963,7 @@ void bmesh_similarverts_exec(BMesh *bm, BMOperator *op) /****************************************************************************** ** Cycle UVs for a face -******************************************************************************/ +**************************************************************************** */ void bmesh_rotateuvs_exec(BMesh *bm, BMOperator *op) { @@ -1002,7 +1002,7 @@ void bmesh_rotateuvs_exec(BMesh *bm, BMOperator *op) } else if (dir == DIRECTION_CCW) { /* counter loop direction */ BMLoop *lf; /* current face loops */ - MLoopUV *p_luv; /*previous loop uv */ + MLoopUV *p_luv; /* previous loop uv */ MLoopUV *luv; float t_uv[2]; /* current uvs */ @@ -1030,7 +1030,7 @@ void bmesh_rotateuvs_exec(BMesh *bm, BMOperator *op) /****************************************************************************** ** Reverse UVs for a face -******************************************************************************/ +**************************************************************************** */ void bmesh_reverseuvs_exec(BMesh *bm, BMOperator *op) { @@ -1073,7 +1073,7 @@ void bmesh_reverseuvs_exec(BMesh *bm, BMOperator *op) /****************************************************************************** ** Cycle colors for a face -******************************************************************************/ +**************************************************************************** */ void bmesh_rotatecolors_exec(BMesh *bm, BMOperator *op) { @@ -1112,7 +1112,7 @@ void bmesh_rotatecolors_exec(BMesh *bm, BMOperator *op) } else if (dir == DIRECTION_CCW) { /* counter loop direction */ BMLoop *lf; /* current face loops */ - MLoopCol *p_lcol; /*previous loop color */ + MLoopCol *p_lcol; /* previous loop color */ MLoopCol *lcol; MLoopCol t_col; /* current color */ @@ -1139,7 +1139,7 @@ void bmesh_rotatecolors_exec(BMesh *bm, BMOperator *op) /****************************************************************************** ** Reverse colors for a face -******************************************************************************/ +**************************************************************************** */ void bmesh_reversecolors_exec(BMesh *bm, BMOperator *op) { @@ -1181,7 +1181,7 @@ void bmesh_reversecolors_exec(BMesh *bm, BMOperator *op) /****************************************************************************** ** shortest vertex path select -******************************************************************************/ +**************************************************************************** */ typedef struct element_node { BMVert *v; /* vertex */ @@ -1211,7 +1211,7 @@ void bmesh_vertexshortestpath_exec(BMesh *bm, BMOperator *op) num_total = BM_Count_Element(bm, BM_VERT); /* allocate memory for the nodes */ - vert_list = (element_node*)MEM_mallocN(sizeof(element_node) * num_total, "vertex nodes"); + vert_list = (element_node *)MEM_mallocN(sizeof(element_node) * num_total, "vertex nodes"); /* iterate through all the mesh vertices */ /* loop through all the vertices and fill the vertices/indices structure */ @@ -1243,7 +1243,7 @@ void bmesh_vertexshortestpath_exec(BMesh *bm, BMOperator *op) float v_weight; /* take the vertex with the lowest weight out of the heap */ - BMVert *v = (BMVert*)BLI_heap_popmin(h); + BMVert *v = (BMVert *)BLI_heap_popmin(h); if (vert_list[BM_GetIndex(v)].weight == FLT_MAX) /* this means that there is no path */ break; diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c index e28ddb3f61d..238dda1805c 100644 --- a/source/blender/bmesh/tools/BME_bevel.c +++ b/source/blender/bmesh/tools/BME_bevel.c @@ -52,7 +52,7 @@ BME_TransData_Head *BME_init_transdata(int bufsize) BME_TransData_Head *td; td = MEM_callocN(sizeof(BME_TransData_Head), "BM transdata header"); - td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash,BLI_ghashutil_ptrcmp, "BME_init_transdata gh"); + td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "BME_init_transdata gh"); td->ma = BLI_memarena_new(bufsize, "BME_TransData arena"); BLI_memarena_use_calloc(td->ma); @@ -61,7 +61,7 @@ BME_TransData_Head *BME_init_transdata(int bufsize) void BME_free_transdata(BME_TransData_Head *td) { - BLI_ghash_free(td->gh,NULL,NULL); + BLI_ghash_free(td->gh, NULL, NULL); BLI_memarena_free(td->ma); MEM_freeN(td); } @@ -74,7 +74,9 @@ BME_TransData *BME_assign_transdata( BME_TransData *vtd; int is_new = 0; - if (v == NULL) return NULL; + if (v == NULL) { + return NULL; + } if ((vtd = BLI_ghash_lookup(td->gh, v)) == NULL && bm != NULL) { vtd = BLI_memarena_alloc(td->ma, sizeof(*vtd)); @@ -94,11 +96,11 @@ BME_TransData *BME_assign_transdata( copy_v3_v3(vtd->org, v->co); /* default */ } else if (org != NULL) { - copy_v3_v3(vtd->org,org); + copy_v3_v3(vtd->org, org); } if (vec != NULL) { - copy_v3_v3(vtd->vec,vec); + copy_v3_v3(vtd->vec, vec); normalize_v3(vtd->vec); } @@ -169,9 +171,9 @@ static int BME_bevel_is_split_vert(BMesh *bm, BMLoop *l) * beveling other polys; this can be determined by testing the * vert and the edges around it for originality */ - if (!BMO_TestFlag(bm, l->v, BME_BEVEL_ORIG) - && BMO_TestFlag(bm, l->e, BME_BEVEL_ORIG) - && BMO_TestFlag(bm, l->prev->e, BME_BEVEL_ORIG)) + if ( !BMO_TestFlag(bm, l->v, BME_BEVEL_ORIG) && + BMO_TestFlag(bm, l->e, BME_BEVEL_ORIG) && + BMO_TestFlag(bm, l->prev->e, BME_BEVEL_ORIG)) { return 1; } @@ -186,8 +188,8 @@ static int BME_bevel_get_vec(float *vec, BMVert *v1, BMVert *v2, BME_TransData_H { BME_TransData *vtd1, *vtd2; - vtd1 = BME_get_transdata(td,v1); - vtd2 = BME_get_transdata(td,v2); + vtd1 = BME_get_transdata(td, v1); + vtd2 = BME_get_transdata(td, v2); if (!vtd1 || !vtd2) { //printf("BME_bevel_get_vec() got called without proper BME_TransData\n"); return -1; @@ -196,7 +198,7 @@ static int BME_bevel_get_vec(float *vec, BMVert *v1, BMVert *v2, BME_TransData_H /* compare the transform origins to see if we can use the vert co's; * if they belong to different origins, then we will use the origins to determine * the vector */ - if (compare_v3v3(vtd1->org,vtd2->org,0.000001f)) { + if (compare_v3v3(vtd1->org, vtd2->org, 0.000001f)) { sub_v3_v3v3(vec, v2->co, v1->co); if (len_v3(vec) < 0.000001f) { zero_v3(vec); @@ -204,7 +206,7 @@ static int BME_bevel_get_vec(float *vec, BMVert *v1, BMVert *v2, BME_TransData_H return 0; } else { - sub_v3_v3v3(vec,vtd2->org,vtd1->org); + sub_v3_v3v3(vec, vtd2->org, vtd1->org); if (len_v3(vec) < 0.000001f) { zero_v3(vec); } @@ -223,25 +225,25 @@ static int BME_bevel_get_vec(float *vec, BMVert *v1, BMVert *v2, BME_TransData_H * returns the length of the projected vector that lies along vec1 */ static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *UNUSED(td)) { - float factor, vec3[3], tmp[3],c1,c2; + float factor, vec3[3], tmp[3], c1, c2; - cross_v3_v3v3(tmp,vec1,vec2); + cross_v3_v3v3(tmp, vec1, vec2); normalize_v3(tmp); - factor = dot_v3v3(up_vec,tmp); + factor = dot_v3v3(up_vec, tmp); if ((factor > 0 && is_forward) || (factor < 0 && !is_forward)) { - cross_v3_v3v3(vec3,vec2,tmp); /* hmm, maybe up_vec should be used instead of tmp */ + cross_v3_v3v3(vec3, vec2, tmp); /* hmm, maybe up_vec should be used instead of tmp */ } else { - cross_v3_v3v3(vec3,tmp,vec2); /* hmm, maybe up_vec should be used instead of tmp */ + cross_v3_v3v3(vec3, tmp, vec2); /* hmm, maybe up_vec should be used instead of tmp */ } normalize_v3(vec3); - c1 = dot_v3v3(vec3,vec1); - c2 = dot_v3v3(vec1,vec1); + c1 = dot_v3v3(vec3, vec1); + c2 = dot_v3v3(vec1, vec1); if (fabsf(c1) < 0.000001f || fabsf(c2) < 0.000001f) { factor = 0.0f; } else { - factor = c2/c1; + factor = c2 / c1; } return factor; @@ -288,17 +290,17 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l, else { e1 = e2; } - ov = BM_OtherEdgeVert(e1,v); - sv = BM_Split_Edge(bm,v,e1,&ne,0); - //BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /*this is technically wrong...*/ + ov = BM_OtherEdgeVert(e1, v); + sv = BM_Split_Edge(bm, v, e1, &ne, 0); + //BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /* this is technically wrong.. */ //BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25); //BME_data_interp_from_faceverts(bm, ov, v, sv, 0.25); BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, NULL); /* quick default */ BMO_SetFlag(bm, sv, BME_BEVEL_BEVEL); BMO_SetFlag(bm, ne, BME_BEVEL_ORIG); /* mark edge as original, even though it isn't */ - BME_bevel_get_vec(vec1,v1,v,td); - BME_bevel_get_vec(vec2,v2,v,td); - cross_v3_v3v3(t_up_vec,vec1,vec2); + BME_bevel_get_vec(vec1, v1, v, td); + BME_bevel_get_vec(vec2, v2, v, td); + cross_v3_v3v3(t_up_vec, vec1, vec2); normalize_v3(t_up_vec); up_vec = t_up_vec; } @@ -331,9 +333,9 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l, } else { is_split_vert = 0; - ov = BM_OtherEdgeVert(l->e,v); - sv = BM_Split_Edge(bm,v,l->e,&ne,0); - //BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /*this is technically wrong...*/ + ov = BM_OtherEdgeVert(l->e, v); + sv = BM_Split_Edge(bm, v, l->e, &ne, 0); + //BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /* this is technically wrong.. */ //BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25); //BME_data_interp_from_faceverts(bm, ov, v, sv, 0.25); BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1, NULL); /* quick default */ @@ -347,21 +349,21 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l, } } - is_edge = BME_bevel_get_vec(vec1,v,v1,td); /* get the vector we will be projecting onto */ - BME_bevel_get_vec(vec2,v,v2,td); /* get the vector we will be projecting parallel to */ + is_edge = BME_bevel_get_vec(vec1, v, v1, td); /* get the vector we will be projecting onto */ + BME_bevel_get_vec(vec2, v, v2, td); /* get the vector we will be projecting parallel to */ len = len_v3(vec1); normalize_v3(vec1); vtd = BME_get_transdata(td, sv); vtd1 = BME_get_transdata(td, v); - vtd2 = BME_get_transdata(td,v1); + vtd2 = BME_get_transdata(td, v1); if (vtd1->loc == NULL) { /* this is a vert with data only for calculating initial weights */ if (vtd1->weight < 0) { vtd1->weight = 0; } - scale = vtd1->weight/vtd1->factor; + scale = vtd1->weight / vtd1->factor; if (!vtd1->max) { vtd1->max = BME_new_transdata_float(td); *vtd1->max = -1; @@ -376,13 +378,13 @@ static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l, maxfactor = vtd1->maxfactor; } else { - maxfactor = scale*BME_bevel_project_vec(vec1,vec2,up_vec,forward,td); + maxfactor = scale*BME_bevel_project_vec(vec1, vec2, up_vec, forward, td); if (vtd->maxfactor > 0 && vtd->maxfactor < maxfactor) { maxfactor = vtd->maxfactor; } } - dis = BMO_TestFlag(bm, v1, BME_BEVEL_ORIG)? len/3 : len/2; + dis = BMO_TestFlag(bm, v1, BME_BEVEL_ORIG) ? len / 3 : len / 2; if (is_edge || dis > maxfactor*value) { dis = maxfactor*value; } @@ -411,7 +413,7 @@ static float BME_bevel_set_max(BMVert *v1, BMVert *v2, float value, BME_TransDat copy_v3_v3(vec2, vtd1->vec); mul_v3_fl(vec2, vtd1->factor); if (dot_v3v3(vec1, vec1)) { - project_v3_v3v3(vec2, vec2,vec1); + project_v3_v3v3(vec2, vec2, vec1); fac1 = len_v3(vec2) / value; } else { @@ -459,19 +461,19 @@ static BMVert *BME_bevel_wire(BMesh *bm, BMVert *v, float value, int res, int UN ov2 = BM_OtherEdgeVert(bmesh_disk_nextedge(v->e, v), v); /* split the edges */ - v1 = BME_bevel_split_edge(bm,v,ov1,NULL,NULL,value,td); + v1 = BME_bevel_split_edge(bm, v, ov1, NULL, NULL, value, td); BMO_SetFlag(bm, v1, BME_BEVEL_NONMAN); - v2 = BME_bevel_split_edge(bm,v,ov2,NULL,NULL,value,td); + v2 = BME_bevel_split_edge(bm, v, ov2, NULL, NULL, value, td); BMO_SetFlag(bm, v2, BME_BEVEL_NONMAN); if (value > 0.5) { - BME_bevel_set_max(v1,ov1,value,td); - BME_bevel_set_max(v2,ov2,value,td); + BME_bevel_set_max(v1, ov1, value, td); + BME_bevel_set_max(v2, ov2, value, td); } /* remove the original vert */ if (res) { - /*bmesh_jekv;*/ + /* bmesh_jekv; */ //void BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, int calcnorm){ //hrm, why is there a fac here? it just removes a vert @@ -485,7 +487,7 @@ static BMVert *BME_bevel_wire(BMesh *bm, BMVert *v, float value, int res, int UN static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(options), float *up_vec, BME_TransData_Head *td) { BMVert *v1, *v2, *kv; - BMLoop *kl=NULL, *nl; + BMLoop *kl = NULL, *nl; BMEdge *e, *ke, *se; BMFace *f, *jf; @@ -493,15 +495,17 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(opti e = l->e; /* sanity check */ - if (!BMO_TestFlag(bm, l->e, BME_BEVEL_BEVEL) - && (BMO_TestFlag(bm, l->v, BME_BEVEL_BEVEL) || BMO_TestFlag(bm, l->next->v, BME_BEVEL_BEVEL))) { + if ( !BMO_TestFlag(bm, l->e, BME_BEVEL_BEVEL) && + (BMO_TestFlag(bm, l->v, BME_BEVEL_BEVEL) || BMO_TestFlag(bm, l->next->v, BME_BEVEL_BEVEL))) + { return l; } /* checks and operations for prev edge */ /* first, check to see if this edge was inset previously */ - if (!BMO_TestFlag(bm, l->prev->e, BME_BEVEL_ORIG) - && !BMO_TestFlag(bm, l->v, BME_BEVEL_NONMAN)) { + if ( !BMO_TestFlag(bm, l->prev->e, BME_BEVEL_ORIG) && + !BMO_TestFlag(bm, l->v, BME_BEVEL_NONMAN)) + { kl = l->prev->radial_next; if (kl->v == l->v) kl = kl->prev; else kl = kl->next; @@ -515,24 +519,24 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(opti v1 = l->v; } else { /* we'll need to split the previous edge */ - v1 = BME_bevel_split_edge(bm,l->v,NULL,l->prev,up_vec,value,td); + v1 = BME_bevel_split_edge(bm, l->v, NULL, l->prev, up_vec, value, td); } /* if we need to clean up geometry... */ if (kv) { se = l->next->e; jf = NULL; if (kl->v == kv) { - BM_Split_Face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e); + BM_Split_Face(bm, kl->f, kl->prev->v, kl->next->v, &nl, kl->prev->e); ke = kl->e; /* BMESH-TODO: jfke doesn't handle customdata */ - jf = bmesh_jfke(bm,kl->prev->radial_next->f,kl->f,kl->prev->e); + jf = bmesh_jfke(bm, kl->prev->radial_next->f, kl->f, kl->prev->e); BM_Collapse_Vert_Edges(bm, ke, kv); } else { - BM_Split_Face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e); + BM_Split_Face(bm, kl->f, kl->next->next->v, kl->v, &nl, kl->next->e); ke = kl->e; /* BMESH-TODO: jfke doesn't handle customdata */ - jf = bmesh_jfke(bm,kl->next->radial_next->f,kl->f,kl->next->e); + jf = bmesh_jfke(bm, kl->next->radial_next->f, kl->f, kl->next->e); BM_Collapse_Vert_Edges(bm, ke, kv); } /* find saved loop pointer */ @@ -546,8 +550,9 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(opti /* checks and operations for the next edge */ /* first, check to see if this edge was inset previously */ - if (!BMO_TestFlag(bm, l->next->e, BME_BEVEL_ORIG) - && !BMO_TestFlag(bm, l->next->v, BME_BEVEL_NONMAN)) { + if ( !BMO_TestFlag(bm, l->next->e, BME_BEVEL_ORIG) && + !BMO_TestFlag(bm, l->next->v, BME_BEVEL_NONMAN)) + { kl = l->next->radial_next; if (kl->v == l->next->v) kl = kl->prev; else kl = kl->next; @@ -561,24 +566,24 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(opti v2 = l->next->v; } else { /* we'll need to split the next edge */ - v2 = BME_bevel_split_edge(bm,l->next->v,NULL,l->next,up_vec,value,td); + v2 = BME_bevel_split_edge(bm, l->next->v, NULL, l->next, up_vec, value, td); } /* if we need to clean up geometry... */ if (kv) { se = l->e; jf = NULL; if (kl->v == kv) { - BM_Split_Face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e); + BM_Split_Face(bm, kl->f, kl->prev->v, kl->next->v, &nl, kl->prev->e); ke = kl->e; /* BMESH-TODO: jfke doesn't handle customdata */ - jf = bmesh_jfke(bm,kl->prev->radial_next->f,kl->f,kl->prev->e); + jf = bmesh_jfke(bm, kl->prev->radial_next->f, kl->f, kl->prev->e); BM_Collapse_Vert_Edges(bm, ke, kv); } else { - BM_Split_Face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e); + BM_Split_Face(bm, kl->f, kl->next->next->v, kl->v, &nl, kl->next->e); ke = kl->e; /* BMESH-TODO: jfke doesn't handle customdata */ - jf = bmesh_jfke(bm,kl->next->radial_next->f,kl->f,kl->next->e); + jf = bmesh_jfke(bm, kl->next->radial_next->f, kl->f, kl->next->e); BM_Collapse_Vert_Edges(bm, ke, kv); } /* find saved loop pointer */ @@ -590,7 +595,7 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(opti } if (!BMO_TestFlag(bm, v1, BME_BEVEL_NONMAN) || !BMO_TestFlag(bm, v2, BME_BEVEL_NONMAN)) { - BM_Split_Face(bm,f,v2,v1,&l,e); + BM_Split_Face(bm, f, v2, v1, &l, e); BMO_SetFlag(bm, l->e, BME_BEVEL_BEVEL); l = l->radial_next; } @@ -609,21 +614,21 @@ static BMLoop *BME_bevel_vert(BMesh *bm, BMLoop *l, float value, int UNUSED(opti /* get/make the first vert to be used in SFME */ /* may need to split the previous edge */ - v1 = BME_bevel_split_edge(bm,l->v,NULL,l->prev,up_vec,value,td); + v1 = BME_bevel_split_edge(bm, l->v, NULL, l->prev, up_vec, value, td); /* get/make the second vert to be used in SFME */ /* may need to split this edge (so move l) */ l = l->prev; - v2 = BME_bevel_split_edge(bm,l->next->v,NULL,l->next,up_vec,value,td); + v2 = BME_bevel_split_edge(bm, l->next->v, NULL, l->next, up_vec, value, td); l = l->next->next; /* "cut off" this corner */ - f = BM_Split_Face(bm,l->f,v2,v1,NULL,l->e); + f = BM_Split_Face(bm, l->f, v2, v1, NULL, l->e); return l; } -/** +/* * BME_bevel_poly * * Polygon inset tool: @@ -635,37 +640,37 @@ static BMLoop *BME_bevel_vert(BMesh *bm, BMLoop *l, float value, int UNUSED(opti * * Returns - * A BMFace pointer to the resulting inner face. -*/ + */ static BMFace *BME_bevel_poly(BMesh *bm, BMFace *f, float value, int options, BME_TransData_Head *td) { - BMLoop *l/*, *ol*/; + BMLoop *l/*, *o */; BME_TransData *vtd1, *vtd2; float up_vec[3], vec1[3], vec2[3], vec3[3], fac1, fac2, max = -1; int len, i; BMIter iter; - up_vec[0] = 0.0f; - up_vec[1] = 0.0f; - up_vec[2] = 0.0f; + zero_v3(up_vec); + /* find a good normal for this face (there's better ways, I'm sure) */ BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) { - BME_bevel_get_vec(vec1,l->v,l->next->v,td); - BME_bevel_get_vec(vec2,l->prev->v,l->v,td); - cross_v3_v3v3(vec3,vec2,vec1); + BME_bevel_get_vec(vec1, l->v, l->next->v, td); + BME_bevel_get_vec(vec2, l->prev->v, l->v, td); + cross_v3_v3v3(vec3, vec2, vec1); add_v3_v3(up_vec, vec3); } normalize_v3(up_vec); - /*Can't use a BM_LOOPS_OF_FACE iterator here, because the loops are being modified - and so the end condition will never hit*/ - for (l=bm_firstfaceloop(f)->prev,i=0,len=f->len; inext) { + /* Can't use a BM_LOOPS_OF_FACE iterator here, because the loops are being modified + * and so the end condition will never hi */ + for (l = bm_firstfaceloop(f)->prev, i = 0, len = f->len; i < len; i++, l = l->next) { if (BMO_TestFlag(bm, l->e, BME_BEVEL_BEVEL) && BMO_TestFlag(bm, l->e, BME_BEVEL_ORIG)) { max = 1.0f; l = BME_bevel_edge(bm, l, value, options, up_vec, td); } - else if (BMO_TestFlag(bm, l->v, BME_BEVEL_BEVEL) - && BMO_TestFlag(bm, l->v, BME_BEVEL_ORIG) - && !BMO_TestFlag(bm, l->prev->e, BME_BEVEL_BEVEL)) { + else if ( BMO_TestFlag(bm, l->v, BME_BEVEL_BEVEL) && + BMO_TestFlag(bm, l->v, BME_BEVEL_ORIG) && + !BMO_TestFlag(bm, l->prev->e, BME_BEVEL_BEVEL)) + { max = 1.0f; l = BME_bevel_vert(bm, l, value, options, up_vec, td); } @@ -674,22 +679,22 @@ static BMFace *BME_bevel_poly(BMesh *bm, BMFace *f, float value, int options, BM f = l->f; /* max pass */ - if (value > 0.5 && max > 0) { + if (value > 0.5f && max > 0) { max = -1; BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) { if (BMO_TestFlag(bm, l->e, BME_BEVEL_BEVEL) || BMO_TestFlag(bm, l->e, BME_BEVEL_ORIG)) { - BME_bevel_get_vec(vec1,l->v,l->next->v,td); - vtd1 = BME_get_transdata(td,l->v); - vtd2 = BME_get_transdata(td,l->next->v); + BME_bevel_get_vec(vec1, l->v, l->next->v, td); + vtd1 = BME_get_transdata(td, l->v); + vtd2 = BME_get_transdata(td, l->next->v); if (vtd1->loc == NULL) { fac1 = 0; } else { - copy_v3_v3(vec2,vtd1->vec); - mul_v3_fl(vec2,vtd1->factor); + copy_v3_v3(vec2, vtd1->vec); + mul_v3_fl(vec2, vtd1->factor); if (dot_v3v3(vec1, vec1)) { - project_v3_v3v3(vec2,vec2,vec1); - fac1 = len_v3(vec2)/value; + project_v3_v3v3(vec2, vec2, vec1); + fac1 = len_v3(vec2) / value; } else { fac1 = 0; @@ -699,11 +704,11 @@ static BMFace *BME_bevel_poly(BMesh *bm, BMFace *f, float value, int options, BM fac2 = 0; } else { - copy_v3_v3(vec3,vtd2->vec); - mul_v3_fl(vec3,vtd2->factor); + copy_v3_v3(vec3, vtd2->vec); + mul_v3_fl(vec3, vtd2->factor); if (dot_v3v3(vec1, vec1)) { - project_v3_v3v3(vec2,vec3,vec1); - fac2 = len_v3(vec2)/value; + project_v3_v3v3(vec2, vec3, vec1); + fac2 = len_v3(vec2) / value; } else { fac2 = 0; @@ -722,7 +727,7 @@ static BMFace *BME_bevel_poly(BMesh *bm, BMFace *f, float value, int options, BM } } - /*return l->f;*/ + /* return l->f; */ return NULL; } @@ -779,7 +784,7 @@ static void bevel_init_verts(BMesh *bm, int options, BME_TransData_Head *td) weight = 1.0; if(weight > 0.0){ BMO_SetFlag(bm, v, BME_BEVEL_BEVEL); - BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0,weight, -1, NULL); + BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0, weight, -1, NULL); } } } @@ -813,7 +818,7 @@ static void bevel_init_edges(BMesh *bm, int options, BME_TransData_Head *td) } } - /*clean up edges with 2 faces that share more than one edge*/ + /* clean up edges with 2 faces that share more than one edg */ BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if(BMO_TestFlag(bm, e, BME_BEVEL_BEVEL)) { count = BM_Face_Share_Edges(e->l->f, e->l->radial_next->f); @@ -824,20 +829,20 @@ static void bevel_init_edges(BMesh *bm, int options, BME_TransData_Head *td) static BMesh *BME_bevel_initialize(BMesh *bm, int options, int UNUSED(defgrp_index), float UNUSED(angle), BME_TransData_Head *td) { - BMVert *v/*, *v2*/; - BMEdge *e/*, *curedge*/; + BMVert *v/*, *v2 */; + BMEdge *e/*, *curedg */; BMFace *f; BMIter iter; - int /*wire, */len; + int /* wire, */ len; - /*tag non-manifold geometry*/ + /* tag non-manifold geometr */ BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { BMO_SetFlag(bm, v, BME_BEVEL_ORIG); if(v->e){ BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 0, -1, -1, NULL); - if (BM_Nonmanifold_Vert(bm,v)) + if (BM_Nonmanifold_Vert(bm, v)) BMO_SetFlag(bm, v, BME_BEVEL_NONMAN); - /*test wire vert*/ + /* test wire ver */ len = BM_Vert_EdgeCount(v); if (len == 2 && BM_Wire_Vert(bm, v)) BMO_ClearFlag(bm, v, BME_BEVEL_NONMAN); @@ -896,7 +901,7 @@ static BMesh *BME_bevel_reinitialize(BMesh *bm) * * Returns - * A BMesh pointer to the BM passed as a parameter. -*/ + */ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int options, int UNUSED(defgrp_index), BME_TransData_Head *td) { @@ -906,23 +911,23 @@ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int option BMFace *f; BMIter iter; - /*unsigned int i, len;*/ + /* unsigned int i, len; */ - /*bevel polys*/ + /* bevel poly */ BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { if(BMO_TestFlag(bm, f, BME_BEVEL_ORIG)) { - BME_bevel_poly(bm,f,value,options,td); + BME_bevel_poly(bm, f, value, options, td); } } - /*get rid of beveled edges*/ + /* get rid of beveled edge */ BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { if(BMO_TestFlag(bm, e, BME_BEVEL_BEVEL) && BMO_TestFlag(bm, e, BME_BEVEL_ORIG)) { BM_Join_TwoFaces(bm, e->l->f, e->l->radial_next->f, e); } } - /*link up corners and clip*/ + /* link up corners and cli */ BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { if(BMO_TestFlag(bm, v, BME_BEVEL_ORIG) && BMO_TestFlag(bm, v, BME_BEVEL_BEVEL)) { curedge = v->e; @@ -932,16 +937,16 @@ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int option if(l->v != v) l = l->next; if(l2->v != v) l2 = l2->next; if(l->f->len > 3) - BM_Split_Face(bm,l->f,l->next->v,l->prev->v,&l,l->e); /* clip this corner off */ + BM_Split_Face(bm, l->f, l->next->v, l->prev->v, &l, l->e); /* clip this corner off */ if(l2->f->len > 3) - BM_Split_Face(bm,l2->f,l2->next->v,l2->prev->v,&l,l2->e); /* clip this corner off */ + BM_Split_Face(bm, l2->f, l2->next->v, l2->prev->v, &l, l2->e); /* clip this corner off */ curedge = bmesh_disk_nextedge(curedge, v); } while(curedge != v->e); - BME_Bevel_Dissolve_Disk(bm,v); + BME_Bevel_Dissolve_Disk(bm, v); } } - /*Debug print, remove*/ + /* Debug print, remov */ BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { if(f->len == 2){ printf("warning"); @@ -960,29 +965,29 @@ BMesh *BME_bevel(BMEditMesh *em, float value, int res, int options, int defgrp_i BME_TransData_Head *td; BME_TransData *vtd; int i; - double fac=1, d; + double fac = 1, d; td = BME_init_transdata(BLI_MEMARENA_STD_BUFSIZE); /* recursion math courtesy of Martin Poirier (theeth) */ - for (i=0; ico,vtd->org,vtd->vec,vtd->factor*d); + madd_v3_v3v3fl(v->co, vtd->org, vtd->vec, vtd->factor*d); } } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 267e3d87769..2f863d5f9ab 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1015,8 +1015,6 @@ BMVert *editbmesh_get_x_mirror_vert(Object *ob, struct BMEditMesh *em, BMVert *e } } - - static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float *mirrCent, float *face_cent) { float vec[2];