From 542dfd94a5fb4ebdb3ab5812cefe013da705178e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Feb 2012 01:46:47 +0000 Subject: [PATCH] Style Cleanup, use TRUE/FALSE defines. --- source/blender/bmesh/intern/bmesh_iterators.c | 16 +- source/blender/bmesh/intern/bmesh_mods.c | 34 ++-- source/blender/bmesh/intern/bmesh_newcore.c | 40 +++-- source/blender/bmesh/intern/bmesh_operators.c | 18 +- source/blender/bmesh/intern/bmesh_polygon.c | 44 ++--- source/blender/bmesh/intern/bmesh_queries.c | 63 +++---- source/blender/bmesh/intern/bmesh_structure.c | 163 +++++++++++------- .../blender/bmesh/intern/bmesh_walkers_impl.c | 23 +-- .../intern/in-progress/BME_conversions.c | 4 +- source/blender/bmesh/operators/createops.c | 12 +- source/blender/bmesh/operators/dissolveops.c | 8 +- .../blender/bmesh/operators/join_triangles.c | 16 +- .../blender/bmesh/operators/removedoubles.c | 4 +- source/blender/bmesh/operators/subdivideop.c | 36 ++-- 14 files changed, 279 insertions(+), 202 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index 10b1ab2989b..55d91620b89 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -260,7 +260,10 @@ void *bmiter__loop_of_vert_step(BMIter *iter) if (!iter->count) iter->nextloop = NULL; - if (current) return current; + if (current) { + return current; + } + return NULL; } @@ -287,7 +290,10 @@ void *bmiter__loops_of_edge_step(BMIter *iter) if (iter->nextloop == iter->firstloop) iter->nextloop = NULL; - if (current) return current; + if (current) { + return current; + } + return NULL; } @@ -314,7 +320,11 @@ void *bmiter__loops_of_loop_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; + + if (current) { + return current; + } + return NULL; } diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 07718b401b4..797c2beb336 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -71,7 +71,7 @@ int BM_Dissolve_Vert(BMesh *bm, BMVert *v) int len = 0; if (!v) { - return 0; + return FALSE; } e = BMIter_New(&iter, bm, BM_EDGES_OF_VERT, v); @@ -83,7 +83,7 @@ int BM_Dissolve_Vert(BMesh *bm, BMVert *v) if (v->e) BM_Kill_Edge(bm, v->e); BM_Kill_Vert(bm, v); - return 1; + return TRUE; } if (BM_Nonmanifold_Vert(bm, v)) { @@ -93,10 +93,10 @@ int BM_Dissolve_Vert(BMesh *bm, BMVert *v) BM_Kill_Vert(bm, v); } else { - return 0; + return FALSE; } - return 1; + return TRUE; } return BM_Dissolve_Disk(bm, v); @@ -109,7 +109,7 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) int len = 0; if (BM_Nonmanifold_Vert(bm, v)) { - return 0; + return FALSE; } if (v->e) { @@ -134,19 +134,19 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) 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; + return FALSE; if (!BM_Dissolve_Disk(bm, v)) { - return 0; + return FALSE; } - return 1; + return TRUE; } else if (keepedge == NULL && len == 2) { /* collapse the verte */ e = BM_Collapse_Vert_Faces(bm, v->e, v, 1.0, TRUE); if (!e) { - return 0; + return FALSE; } /* handle two-valenc */ @@ -154,10 +154,10 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) f2 = e->l->radial_next->f; if (f != f2 && !BM_Join_TwoFaces(bm, f, f2, e)) { - return 0; + return FALSE; } - return 1; + return TRUE; } if (keepedge) { @@ -175,7 +175,7 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) * conditions */ //!disabled for testing why bad things happen if (!f) { - return 0; + return FALSE; } } @@ -191,7 +191,7 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) e = BM_Collapse_Vert_Faces(bm, baseedge, v, 1.0, TRUE); if (!e) { - return 0; + return FALSE; } /* get remaining two face */ @@ -201,12 +201,12 @@ int BM_Dissolve_Disk(BMesh *bm, BMVert *v) if (f != f2) { /* join two remaining face */ if (!BM_Join_TwoFaces(bm, f, f2, e)) { - return 0; + return FALSE; } } } - return 1; + return TRUE; } #else void BM_Dissolve_Disk(BMesh *bm, BMVert *v) @@ -575,7 +575,9 @@ BMVert *BM_Split_Edge(BMesh *bm, BMVert *v, BMEdge *e, BMEdge **ne, float percen v2 = bmesh_edge_getothervert(e, v); nv = bmesh_semv(bm, v, e, ne); - if (nv == NULL) return NULL; + if (nv == NULL) { + return NULL; + } sub_v3_v3v3(nv->co, v2->co, v->co); madd_v3_v3v3fl(nv->co, v->co, nv->co, percent); diff --git a/source/blender/bmesh/intern/bmesh_newcore.c b/source/blender/bmesh/intern/bmesh_newcore.c index 59765900bb1..1e50fec0adb 100644 --- a/source/blender/bmesh/intern/bmesh_newcore.c +++ b/source/blender/bmesh/intern/bmesh_newcore.c @@ -794,21 +794,21 @@ static int disk_is_flagged(BMVert *v, int flag) BMEdge *e = v->e; if (!e) - return 0; + return FALSE; do { BMLoop *l = e->l; if (!l) { - return 0; + return FALSE; } if (bmesh_radial_length(l) == 1) - return 0; + return FALSE; do { if (!bmesh_api_getflag(l->f, flag)) - return 0; + return FALSE; l = l->radial_next; } while (l != e->l); @@ -816,7 +816,7 @@ static int disk_is_flagged(BMVert *v, int flag) e = bmesh_disk_nextedge(e, v); } while (e != v->e); - return 1; + return TRUE; } /* Midlevel Topology Manipulation Functions */ @@ -1079,7 +1079,9 @@ BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, else if (curloop->v == v2) v2loop = curloop; } - if (!v1loop || !v2loop) return NULL; + if (!v1loop || !v2loop) { + return NULL; + } /* allocate new edge between v1 and v2 */ e = BM_Make_Edge(bm, v1, v2, NULL, 0); @@ -1365,7 +1367,7 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) int len, radlen = 0, halt = 0, i, valence1, valence2, edok; if (bmesh_vert_in_edge(ke, kv) == 0) { - return 0; + return FALSE; } len = bmesh_disk_count(kv); @@ -1377,7 +1379,7 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) halt = bmesh_verts_in_edge(kv, tv, oe); /* check for double edge */ if (halt) { - return 0; + return FALSE; } else { /* For verification later, count valence of ov and t */ @@ -1469,10 +1471,10 @@ int bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv) BM_CHECK_ELEMENT(bm, tv); BM_CHECK_ELEMENT(bm, oe); - return 1; + return TRUE; } } - return 0; + return FALSE; } /** @@ -1543,7 +1545,9 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) } /* validate direction of f2's loop cycle is compatible */ - if (f1loop->v == f2loop->v) return NULL; + if (f1loop->v == f2loop->v) { + return NULL; + } /* validate that for each face, each vertex has another edge in its disk cycle that is * not e, and not shared. */ @@ -1651,7 +1655,7 @@ static int bmesh_splicevert(BMesh *bm, BMVert *v, BMVert *vtarget) /* verts already spliced */ if (v == vtarget) { - return 0; + return FALSE; } /* retarget all the loops of v to vtarget */ @@ -1674,7 +1678,7 @@ static int bmesh_splicevert(BMesh *bm, BMVert *v, BMVert *vtarget) /* v is unused now, and can be killed */ BM_Kill_Vert(bm, v); - return 1; + return TRUE; } /* BMESH CUT VERT @@ -1777,7 +1781,7 @@ static int bmesh_cutvert(BMesh *bm, BMVert *v, BMVert ***vout, int *len) MEM_freeN(verts); } - return 1; + return TRUE; } /* BMESH SPLICE EDGE @@ -1792,7 +1796,7 @@ static int UNUSED_FUNCTION(bmesh_spliceedge)(BMesh *bm, BMEdge *e, BMEdge *etarg if (!BM_Vert_In_Edge(e, etarget->v1) || !BM_Vert_In_Edge(e, etarget->v2)) { /* not the same vertices can't splice */ - return 0; + return FALSE; } while (e->l) { @@ -1810,7 +1814,7 @@ static int UNUSED_FUNCTION(bmesh_spliceedge)(BMesh *bm, BMEdge *e, BMEdge *etarg BM_Kill_Edge(bm, e); - return 1; + return TRUE; } /* @@ -1833,7 +1837,7 @@ static int bmesh_cutedge(BMesh *bm, BMEdge *e, BMLoop *cutl) radlen = bmesh_radial_length(e->l); if (radlen < 2) { /* no cut required */ - return 1; + return TRUE; } if (cutl == e->l) { @@ -1851,7 +1855,7 @@ static int bmesh_cutedge(BMesh *bm, BMEdge *e, BMLoop *cutl) BM_CHECK_ELEMENT(bm, ne); BM_CHECK_ELEMENT(bm, e); - return 1; + return TRUE; } /* diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 6728226d0ab..04562af2f3b 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1209,7 +1209,7 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) if (i == -1) { MEM_freeN(ofmt); - return 0; + return FALSE; } BMO_Init_Op(bm, op, opname); @@ -1344,7 +1344,7 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) } MEM_freeN(ofmt); - return 1; + return TRUE; error: /* non urgent todo - explain exactly what is failing */ @@ -1354,7 +1354,7 @@ error: MEM_freeN(ofmt); BMO_Finish_Op(bm, op); - return 0; + return FALSE; #undef GOTO_ERROR @@ -1369,11 +1369,11 @@ int BMO_InitOpf(BMesh *bm, BMOperator *op, const char *fmt, ...) if (!BMO_VInitOpf(bm, op, fmt, list)) { printf("%s: failed\n", __func__); va_end(list); - return 0; + return FALSE; } va_end(list); - return 1; + return TRUE; } int BMO_CallOpf(BMesh *bm, const char *fmt, ...) @@ -1385,14 +1385,14 @@ int BMO_CallOpf(BMesh *bm, const char *fmt, ...) if (!BMO_VInitOpf(bm, &op, fmt, list)) { printf("%s: failed, format is:\n \"%s\"\n", __func__, fmt); va_end(list); - return 0; + return FALSE; } BMO_Exec_Op(bm, &op); BMO_Finish_Op(bm, &op); va_end(list); - return 1; + return TRUE; } /* @@ -1450,6 +1450,6 @@ static int BMO_TestFlag(BMesh *bm, void *element, int flag) { BMHeader *head = element; if (head->flags[bm->stackdepth - 1].f & flag) - return 1; - return 0; + return TRUE; + return FALSE; } diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index f8dcb24ed92..8bca38ebfc2 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -67,13 +67,13 @@ static short testedgeside(const double v1[2], const double v2[2], const double v inp = (v2[0] - v1[0]) * (v1[1] - v3[1]) + (v1[1] - v2[1]) * (v1[0] - v3[0]); if (inp < 0.0) { - return 0; + return FALSE; } 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 (v1[0] == v3[0] && v1[1] == v3[1]) return FALSE; + if (v2[0] == v3[0] && v2[1] == v3[1]) return FALSE; } - return 1; + return TRUE; } static short testedgesidef(const float v1[2], const float v2[2], const float v3[2]) @@ -85,20 +85,21 @@ static short testedgesidef(const float v1[2], const float v2[2], const float v3[ inp = (v2[0] - v1[0]) * (v1[1] - v3[1]) + (v1[1] - v2[1]) * (v1[0] - v3[0]); if (inp < 0.0) { - return 0; + return FALSE; } 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 (v1[0] == v3[0] && v1[1] == v3[1]) return FALSE; + if (v2[0] == v3[0] && v2[1] == v3[1]) return FALSE; } - return 1; + return TRUE; } 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)) - return 1; - return 0; + if (testedgeside(v1, v2, pt) && testedgeside(v2, v3, pt) && testedgeside(v3, v1, pt)) { + return TRUE; + } + return FALSE; } /* @@ -202,7 +203,7 @@ static int compute_poly_center(float center[3], float *r_area, float (*verts)[3] zero_v3(center); if (nverts < 3) - return 0; + return FALSE; i = nverts - 1; j = 0; @@ -222,9 +223,9 @@ static int compute_poly_center(float center[3], float *r_area, float (*verts)[3] if (atmp != 0) { center[0] = xtmp / (3.0f * atmp); center[1] = xtmp / (3.0f * atmp); - return 1; + return TRUE; } - return 0; + return FALSE; } float BM_Compute_Face_Area(BMesh *bm, BMFace *f) @@ -652,8 +653,9 @@ static int linecrossesf(const float v1[2], const float v2[2], const float v3[2], w4 = testedgesidef(v3, v2, v4); w5 = !testedgesidef(v3, v1, v4); - if (w1 == w2 && w2 == w3 && w3 == w4 && w4 == w5) - return 1; + if (w1 == w2 && w2 == w3 && w3 == w4 && w4 == w5) { + return TRUE; + } #define GETMIN2_AXIS(a, b, ma, mb, axis) ma[axis] = MIN2(a[axis], b[axis]), mb[axis] = MAX2(a[axis], b[axis]) #define GETMIN2(a, b, ma, mb) GETMIN2_AXIS(a, b, ma, mb, 0); GETMIN2_AXIS(a, b, ma, mb, 1); @@ -679,7 +681,7 @@ static int linecrossesf(const float v1[2], const float v2[2], const float v3[2], return (mv4[1] >= mv1[1] && mv3[1] <= mv2[1]); } - return 0; + return FALSE; } /* @@ -753,7 +755,7 @@ static int goodline(float (*projectverts)[3], BMFace *f, int v1i, VECCOPY(v3, projectverts[v3i]); if (testedgeside(v1, v2, v3)) { - return 0; + return FALSE; } //for (i = 0; i < nvert; i++) { @@ -768,15 +770,15 @@ static int goodline(float (*projectverts)[3], BMFace *f, int v1i, VECCOPY(pv1, projectverts[BM_GetIndex(l_iter->v)]); VECCOPY(pv2, projectverts[BM_GetIndex(l_iter->next->v)]); - //if (linecrosses(pv1, pv2, v1, v3)) return 0; + //if (linecrosses(pv1, pv2, v1, v3)) return FALSE; if ( point_in_triangle(v1, v2, v3, pv1) || point_in_triangle(v3, v2, v1, pv1)) { - return 0; + return FALSE; } } while ((l_iter = l_iter->next) != l_first); - return 1; + return TRUE; } /* * FIND EAR diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 62eedd75240..a490ca4b921 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -107,20 +107,18 @@ BMLoop *BM_OtherFaceLoop(BMEdge *e, BMFace *f, BMVert *v) int BM_Vert_In_Face(BMFace *f, BMVert *v) { BMLoopList *lst; - BMLoop *l; + BMLoop *l_iter; for (lst = f->loops.first; lst; lst = lst->next) { - l = lst->first; + l_iter = lst->first; do { - if (l->v == v) { - return 1; + if (l_iter->v == v) { + return TRUE; } - - l = l->next; - } while (l != lst->first); + } while ((l_iter = l_iter->next) != lst->first); } - return 0; + return FALSE; } /* @@ -171,11 +169,11 @@ int BM_Edge_In_Face(BMFace *f, BMEdge *e) do { if (l_iter->e == e) { - return 1; + return TRUE; } } while ((l_iter = l_iter->next) != l_first); - return 0; + return FALSE; } /* @@ -281,18 +279,20 @@ int BM_Wire_Vert(BMesh *UNUSED(bm), BMVert *v) { BMEdge *curedge; - if (!(v->e)) return 0; + if (v->e == NULL) { + return FALSE; + } curedge = v->e; do { if (curedge->l) { - return 0; + return FALSE; } curedge = bmesh_disk_nextedge(curedge, v); } while (curedge != v->e); - return 1; + return TRUE; } /* @@ -307,8 +307,7 @@ int BM_Wire_Vert(BMesh *UNUSED(bm), BMVert *v) int BM_Wire_Edge(BMesh *UNUSED(bm), BMEdge *e) { - if (e->l) return 0; - return 1; + return (e->l) ? FALSE : TRUE; } /* @@ -332,7 +331,7 @@ int BM_Nonmanifold_Vert(BMesh *UNUSED(bm), BMVert *v) if (v->e == NULL) { /* loose vert */ - return 1; + return TRUE; } /* count edges while looking for non-manifold edges */ @@ -340,12 +339,12 @@ int BM_Nonmanifold_Vert(BMesh *UNUSED(bm), BMVert *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; + return TRUE; } if (bmesh_radial_length(e->l) > 2) { /* edge shared by more than two faces */ - return 1; + return TRUE; } } @@ -378,10 +377,10 @@ int BM_Nonmanifold_Vert(BMesh *UNUSED(bm), BMVert *v) if (count < len) { /* vert shared by multiple regions */ - return 1; + return TRUE; } - return 0; + return FALSE; } /* @@ -398,8 +397,10 @@ int BM_Nonmanifold_Vert(BMesh *UNUSED(bm), BMVert *v) int BM_Nonmanifold_Edge(BMesh *UNUSED(bm), BMEdge *e) { int count = BM_Edge_FaceCount(e); - if (count != 2 && count != 1) return 1; - return 0; + if (count != 2 && count != 1) { + return TRUE; + } + return FALSE; } /* @@ -415,8 +416,10 @@ int BM_Nonmanifold_Edge(BMesh *UNUSED(bm), BMEdge *e) int BM_Boundary_Edge(BMEdge *e) { int count = BM_Edge_FaceCount(e); - if (count == 1) return 1; - return 0; + if (count == 1) { + return TRUE; + } + return FALSE; } /* @@ -465,12 +468,12 @@ int BM_Edge_Share_Faces(BMEdge *e1, BMEdge *e2) do { f = l->f; if (bmesh_radial_find_face(e2, f)) { - return 1; + return TRUE; } l = l->radial_next; } while (l != e1->l); } - return 0; + return FALSE; } /** @@ -567,12 +570,12 @@ int BM_Exist_Face_Overlaps(BMesh *bm, BMVert **varr, int len, BMFace **overlapfa amount = BM_Verts_In_Face(bm, f, varr, len); if (amount >= len) { if (overlapface) *overlapface = f; - return 1; + return TRUE; } f = BMIter_Step(&vertfaces); } } - return 0; + return FALSE; } /* @@ -601,10 +604,10 @@ int BM_Face_Exists(BMesh *bm, BMVert **varr, int len, BMFace **existface) amount = BM_Verts_In_Face(bm, f, varr, len); if (amount == len && amount == f->len) { if (existface) *existface = f; - return 1; + return TRUE; } f = BMIter_Step(&vertfaces); } } - return 0; + return FALSE; } diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c index 428e9065057..de7d2c1d5f8 100644 --- a/source/blender/bmesh/intern/bmesh_structure.c +++ b/source/blender/bmesh/intern/bmesh_structure.c @@ -53,19 +53,23 @@ int bmesh_vert_in_edge(BMEdge *e, BMVert *v) { - if (e->v1 == v || e->v2 == v) return 1; - return 0; + if (e->v1 == v || e->v2 == v) return TRUE; + return FALSE; } int bmesh_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e) { - if (e->v1 == v1 && e->v2 == v2) return 1; - else if (e->v1 == v2 && e->v2 == v1) return 1; - return 0; + if (e->v1 == v1 && e->v2 == v2) return TRUE; + else if (e->v1 == v2 && e->v2 == v1) return TRUE; + return FALSE; } BMVert *bmesh_edge_getothervert(BMEdge *e, BMVert *v) { - if (e->v1 == v) return e->v2; - else if (e->v2 == v) return e->v1; + if (e->v1 == v) { + return e->v2; + } + else if (e->v2 == v) { + return e->v1; + } return NULL; } @@ -74,14 +78,14 @@ int bmesh_edge_swapverts(BMEdge *e, BMVert *orig, BMVert *newv) if (e->v1 == orig) { e->v1 = newv; e->dlink1.next = e->dlink1.prev = NULL; - return 1; + return TRUE; } else if (e->v2 == orig) { e->v2 = newv; e->dlink2.next = e->dlink2.prev = NULL; - return 1; + return TRUE; } - return 0; + return FALSE; } /** @@ -179,7 +183,7 @@ int bmesh_disk_append_edge(struct BMEdge *e, struct BMVert *v) e3->next = (Link *)e; } - return 1; + return TRUE; } void bmesh_disk_remove_edge(struct BMEdge *e, struct BMVert *v) @@ -229,7 +233,10 @@ 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); } @@ -242,12 +249,15 @@ int bmesh_disk_count(struct BMVert *v) BMEdge *e = v->e; int i = 0; - if (!e) + if (!e) { return 0; + } do { - if (!e) + if (!e) { return 0; + } + e = bmesh_disk_nextedge(e, v); if (i >= (1 << 20)) { @@ -255,7 +265,7 @@ int bmesh_disk_count(struct BMVert *v) return 0; } - i += 1; + i++; } while (e != v->e); return i; @@ -266,19 +276,20 @@ int bmesh_disk_validate(int len, BMEdge *e, BMVert *v) BMEdge *e2; if (!BM_Vert_In_Edge(e, v)) - return 0; + return FALSE; if (bmesh_disk_count(v) != len || len == 0) - return 0; + return FALSE; e2 = e; do { - if (len != 1 && bmesh_disk_prevedge(e2, v) == e2) - return 0; + if (len != 1 && bmesh_disk_prevedge(e2, v) == e2) { + return FALSE; + } e2 = bmesh_disk_nextedge(e2, v); } while (e2 != e); - return 1; + return TRUE; } /* @@ -314,7 +325,10 @@ struct BMEdge *bmesh_disk_find_first_faceedge(struct BMEdge *e, struct BMVert *v BMEdge *searchedge = NULL; searchedge = e; do { - if (searchedge->l && bmesh_radial_count_facevert(searchedge->l, v)) return searchedge; + if (searchedge->l && bmesh_radial_count_facevert(searchedge->l, v)) { + return searchedge; + } + searchedge = bmesh_disk_nextedge(searchedge, v); } while (searchedge != e); @@ -341,29 +355,29 @@ int bmesh_radial_validate(int radlen, BMLoop *l) int i = 0; if (bmesh_radial_length(l) != radlen) - return 0; + return FALSE; do { if (!l2) { bmesh_error(); - return 0; + return FALSE; } if (l2->e != l->e) - return 0; + return FALSE; if (l2->v != l->e->v1 && l2->v != l->e->v2) - return 0; + return FALSE; if (i > BM_LOOP_RADIAL_MAX) { bmesh_error(); - return 0; + return FALSE; } i++; l2 = l2->radial_next; } while (l2 != l); - return 1; + return TRUE; } /* @@ -503,9 +517,9 @@ int bmesh_radial_find_face(BMEdge *e, BMFace *f) len = bmesh_radial_length(e->l); for (i = 0, curloop = e->l; i < len; i++, curloop = curloop->radial_next) { if (curloop->f == f) - return 1; + return TRUE; } - return 0; + return FALSE; } /* @@ -536,23 +550,33 @@ int bmesh_loop_validate(BMFace *f) BMLoop *curloop, *head; head = BM_FACE_FIRST_LOOP(f); - if (head == NULL) - return 0; + if (head == NULL) { + return FALSE; + } /* Validate that the face loop cycle is the length specified by f->len */ for (i = 1, curloop = head->next; i < len; i++, curloop = curloop->next) { - if (curloop->f != f) return 0; - if (curloop == head) return 0; + if ( (curloop->f != f) || + (curloop == head)) + { + return FALSE; + } } - if (curloop != head) return 0; - + if (curloop != head) { + return FALSE; + } + /* Validate the loop->prev links also form a cycle of length f->len */ for (i = 1, curloop = head->prev; i < len; i++, curloop = curloop->prev) { - if (curloop == head) return 0; + if (curloop == head) { + return FALSE; + } } - if (curloop != head) return 0; - - return 1; + if (curloop != head) { + return FALSE; + } + + return TRUE; } @@ -630,7 +654,7 @@ int bmesh_cycle_remove(void *h, void *remn) if (len == 1 && head == remnode) { head->next = NULL; head->prev = NULL; - return 1; + return TRUE; } else { for (i = 0, curnode = head; i < len; curnode = curnode->next) { @@ -640,12 +664,12 @@ int bmesh_cycle_remove(void *h, void *remn) /* zero out remnode pointers, important */ //remnode->next = NULL; //remnode->prev = NULL; - return 1; + return TRUE; } } } - return 0; + return FALSE; } /** @@ -668,16 +692,16 @@ int bmesh_cycle_validate(int len, void *h) /* forward validatio */ for (i = 0, curnode = head; i < len; i++, curnode = curnode->next); if (curnode != head) { - return 0; + return FALSE; } /* reverse validatio */ for (i = 0, curnode = head; i < len; i++, curnode = curnode->prev); if (curnode != head) { - return 0; + return FALSE; } - return 1; + return TRUE; } /* Begin Disk Cycle routine */ @@ -694,8 +718,12 @@ int bmesh_cycle_validate(int len, void *h) BMEdge *bmesh_disk_nextedge(BMEdge *e, BMVert *v) { if (bmesh_vert_in_edge(e, v)) { - if (e->v1 == v) return e->d1.next->data; - else if (e->v2 == v) return e->d2.next->data; + if (e->v1 == v) { + return e->d1.next->data; + } + else if (e->v2 == v) { + return e->d2.next->data; + } } return NULL; } @@ -711,8 +739,12 @@ 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 dis */ - if (e->v1 == v) return &(e->d1); - else if (e->v2 == v) return &(e->d2); + if (e->v1 == v) { + return &(e->d1); + } + else if (e->v2 == v) { + return &(e->d2); + } return NULL; } @@ -732,7 +764,7 @@ int bmesh_disk_append_edge(BMEdge *e, BMVert *v) /* check to make sure v is in */ if (bmesh_vert_in_edge(e, v) == 0) { - return 0; + return FALSE; } /* check for loose vert firs */ @@ -740,14 +772,14 @@ int bmesh_disk_append_edge(BMEdge *e, BMVert *v) v->e = e; base = tail = bmesh_disk_getpointer(e, v); bmesh_cycle_append(base, tail); /* circular reference is ok */ - return 1; + return TRUE; } /* 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); - return 1; + return TRUE; } /** @@ -797,8 +829,10 @@ BMEdge *bmesh_disk_next_edgeflag(BMEdge *e, BMVert *v, int eflag, int tflag) BMEdge *curedge; int len, ok; - if (eflag && tflag) return NULL; - + if (eflag && tflag) { + return NULL; + } + ok = bmesh_vert_in_edge(e, v); if (ok) { diskbase = bmesh_disk_getpointer(e, v); @@ -806,8 +840,11 @@ BMEdge *bmesh_disk_next_edgeflag(BMEdge *e, BMVert *v, int eflag, int tflag) curedge = bmesh_disk_nextedge(e, v); while (curedge != e) { if (eflag) { - if (curedge->head.eflag1 == eflag) return curedge; + if (curedge->head.eflag1 == eflag) { + return curedge; + } } + curedge = bmesh_disk_nextedge(curedge, v); } } @@ -862,11 +899,13 @@ int bmesh_disk_hasedge(BMVert *v, BMEdge *e) len = bmesh_cycle_length(diskbase); for (i = 0, curedge = v->e; i < len; i++) { - if (curedge == e) return 1; + if (curedge == e) { + return TRUE; + } else curedge = bmesh_disk_nextedge(curedge, v); } } - return 0; + return FALSE; } BMEdge *bmesh_disk_existedge(BMVert *v1, BMVert *v2) @@ -880,7 +919,9 @@ BMEdge *bmesh_disk_existedge(BMVert *v1, BMVert *v2) len = bmesh_cycle_length(diskbase); for (i = 0, curedge = v1->e; i < len; i++, curedge = bmesh_disk_nextedge(curedge, v1)) { - if (bmesh_verts_in_edge(v1, v2, curedge)) return curedge; + if (bmesh_verts_in_edge(v1, v2, curedge)) { + return curedge; + } } } @@ -923,9 +964,11 @@ int bmesh_radial_find_face(BMEdge *e, BMFace *f) len = bmesh_cycle_length(&(e->l->radial)); for (i = 0, curloop = e->l; i < len; i++, curloop = curloop->radial_next) { - if (curloop->f == f) return 1; + if (curloop->f == f) { + return TRUE; + } } - return 0; + return FALSE; } diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 0576a83b6ba..960f193f8f0 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -540,14 +540,16 @@ static void *loopWalker_step(BMWalker *walker) static int faceloopWalker_include_face(BMWalker *walker, BMLoop *l) { /* face must have degree 4 */ - if (l->f->len != 4) - return 0; + if (l->f->len != 4) { + return FALSE; + } /* the face must not have been already visite */ - if (BLI_ghash_haskey(walker->visithash, l->f)) - return 0; + if (BLI_ghash_haskey(walker->visithash, l->f)) { + return FALSE; + } - return 1; + return TRUE; } /* Check whether the face loop can start from the given edge */ @@ -557,22 +559,23 @@ static int faceloopWalker_edge_begins_loop(BMWalker *walker, BMEdge *e) /* There is no face loop starting from a wire edge */ if (BM_Wire_Edge(bm, e)) { - return 0; + return FALSE; } /* 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; + if (!faceloopWalker_include_face(walker, e->l)) { + return FALSE; + } } /* Don't start a face loop from non-manifold edges */ if (BM_Nonmanifold_Edge(bm, e)) { - return 0; + return FALSE; } - return 1; + return TRUE; } static void faceloopWalker_begin(BMWalker *walker, void *data) diff --git a/source/blender/bmesh/intern/in-progress/BME_conversions.c b/source/blender/bmesh/intern/in-progress/BME_conversions.c index cb703be0138..f173355ee77 100644 --- a/source/blender/bmesh/intern/in-progress/BME_conversions.c +++ b/source/blender/bmesh/intern/in-progress/BME_conversions.c @@ -384,9 +384,9 @@ static int bmeshface_to_mface(BMMesh *bm, BMFace *f, MFace *mf, int index, Custo if(bmesh_test_flag(f, BMESH_SELECT)) mf->flag |= 1; if(bmesh_test_flag(f, BMESH_HIDDEN)) mf->flag |= ME_HIDE; CustomData_from_bmesh_block(&bm->pdata, data, &f->data, index); - return 1; + return TRUE; } - return 0; + return FALSE; } /* diff --git a/source/blender/bmesh/operators/createops.c b/source/blender/bmesh/operators/createops.c index 85d980f10af..04bc9be5fab 100644 --- a/source/blender/bmesh/operators/createops.c +++ b/source/blender/bmesh/operators/createops.c @@ -87,10 +87,14 @@ static int count_edge_faces(BMesh *bm, BMEdge *e); /**** rotation system code * */ -#define RS_GET_EDGE_LINK(e, v, ed) \ - ((v) == ((BMEdge *)(e))->v1 ? (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, + +static int rotsys_append_edge(struct BMEdge *e, struct BMVert *v, EdgeData *edata, VertData *vdata) { EdgeData *ed = &edata[BM_GetIndex(e)]; @@ -118,7 +122,7 @@ static int rotsys_append_edge(struct BMEdge *e, struct BMVert *v, e3->next = (Link *)e; } - return 1; + return TRUE; } static void UNUSED_FUNCTION(rotsys_remove_edge)(struct BMEdge *e, struct BMVert *v, diff --git a/source/blender/bmesh/operators/dissolveops.c b/source/blender/bmesh/operators/dissolveops.c index 7b0f39376ac..6d2e025ba83 100644 --- a/source/blender/bmesh/operators/dissolveops.c +++ b/source/blender/bmesh/operators/dissolveops.c @@ -58,18 +58,18 @@ static int UNUSED_FUNCTION(check_hole_in_region)(BMesh *bm, BMFace *f) l2 = BMIter_New(&liter2, bm, BM_LOOPS_OF_FACE, f2); 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)) + if ( BMO_TestFlag(bm, l3->f, FACE_MARK) != + BMO_TestFlag(bm, l2->f, FACE_MARK)) { if (!BMO_TestFlag(bm, l2->e, EDGE_MARK)) { - return 0; + return FALSE; } } } } BMW_End(®walker); - return 1; + return TRUE; } void dissolvefaces_exec(BMesh *bm, BMOperator *op) diff --git a/source/blender/bmesh/operators/join_triangles.c b/source/blender/bmesh/operators/join_triangles.c index dae4ef56d10..1a67843ba99 100644 --- a/source/blender/bmesh/operators/join_triangles.c +++ b/source/blender/bmesh/operators/join_triangles.c @@ -86,7 +86,9 @@ static float measure_facepair(BMesh *UNUSED(bm), BMVert *v1, BMVert *v2, else angle2 = angle_v3v3(n1, n2); measure += (angle1 + angle2) * 0.5f; - if (measure > limit) return measure; + if (measure > limit) { + return measure; + } /* Second test: Colinearit */ sub_v3_v3v3(edgeVec1, v1->co, v2->co); @@ -103,7 +105,9 @@ static float measure_facepair(BMesh *UNUSED(bm), BMVert *v1, BMVert *v2, if (!diff) return 0.0; measure += diff; - if (measure > limit) return measure; + if (measure > limit) { + return measure; + } /* Third test: Concavit */ areaA = area_tri_v3(v1->co, v2->co, v3->co) + area_tri_v3(v1->co, v3->co, v4->co); @@ -204,9 +208,11 @@ static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols) } } - if (douvs == mergeok_uvs && dovcols == mergeok_vcols) - return 1; - return 0; + if (douvs == mergeok_uvs && dovcols == mergeok_vcols) { + return TRUE; + } + + return FALSE; } typedef struct JoinEdge { diff --git a/source/blender/bmesh/operators/removedoubles.c b/source/blender/bmesh/operators/removedoubles.c index 602e84d3e5a..2a275cd8d3d 100644 --- a/source/blender/bmesh/operators/removedoubles.c +++ b/source/blender/bmesh/operators/removedoubles.c @@ -90,12 +90,12 @@ int remdoubles_face_overlaps(BMesh *bm, BMVert **varr, amount = BM_Verts_In_Face(bm, f, varr, len); if (amount >= len) { if (overlapface) *overlapface = f; - return 1; + return TRUE; } f = BMIter_Step(&vertfaces); } } - return 0; + return FALSE; } #endif diff --git a/source/blender/bmesh/operators/subdivideop.c b/source/blender/bmesh/operators/subdivideop.c index 6e653228e65..cb46441ffd3 100644 --- a/source/blender/bmesh/operators/subdivideop.c +++ b/source/blender/bmesh/operators/subdivideop.c @@ -815,7 +815,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) /* first go through and tag edge */ BMO_Flag_To_Slot(bmesh, op, "edges", - SUBD_SPLIT, BM_EDGE); + SUBD_SPLIT, BM_EDGE); params.numcuts = numcuts; params.op = op; @@ -880,16 +880,15 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) } if (BMO_TestFlag(bmesh, face, FACE_CUSTOMFILL)) { - pat = BMO_Get_MapData(bmesh, op, - "custompatterns", face); + pat = BMO_Get_MapData(bmesh, op, + "custompatterns", face); for (i = 0; i < pat->len; i++) { matched = 1; for (j = 0; j < pat->len; j++) { a = (j + i) % pat->len; - if ((!!BMO_TestFlag(bmesh, edges[a], SUBD_SPLIT)) - != (!!pat->seledges[j])) { - matched = 0; - break; + if ((!!BMO_TestFlag(bmesh, edges[a], SUBD_SPLIT)) != (!!pat->seledges[j])) { + matched = 0; + break; } } if (matched) { @@ -912,18 +911,19 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) pat = patterns[i]; if (!pat) continue; - if (pat->len == face->len) { + if (pat->len == face->len) { for (a = 0; a < pat->len; a++) { matched = 1; for (b = 0; b < pat->len; b++) { j = (b + a) % pat->len; - if ((!!BMO_TestFlag(bmesh, edges[j], SUBD_SPLIT)) - != (!!pat->seledges[b])) { - matched = 0; - break; + if ((!!BMO_TestFlag(bmesh, edges[j], SUBD_SPLIT)) != (!!pat->seledges[b])) { + matched = 0; + break; } } - if (matched) break; + if (matched) { + break; + } } if (matched) { BLI_array_growone(facedata); @@ -938,7 +938,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) break; } } - + } if (!matched && totesel) { @@ -1055,7 +1055,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) verts[b] = nl->v; j += 1; } - + BM_CHECK_ELEMENT(bmesh, face); pat->connectexec(bmesh, face, verts, ¶ms); } @@ -1075,12 +1075,12 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op) BLI_array_free(loops); BMO_Flag_To_Slot(bmesh, op, "outinner", - ELE_INNER, BM_ALL); + ELE_INNER, BM_ALL); BMO_Flag_To_Slot(bmesh, op, "outsplit", - ELE_SPLIT, BM_ALL); + ELE_SPLIT, BM_ALL); BMO_Flag_To_Slot(bmesh, op, "geomout", - ELE_INNER|ELE_SPLIT|SUBD_SPLIT, BM_ALL); + ELE_INNER|ELE_SPLIT|SUBD_SPLIT, BM_ALL); } /* editmesh-emulating functio */