From 286073fb4e2d3753da39cbd7104c243f2fa2fe4a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Feb 2012 00:13:29 +0000 Subject: [PATCH] Style Cleanup --- source/blender/bmesh/intern/bmesh_interp.c | 26 ++++++++-------- source/blender/bmesh/intern/bmesh_marking.c | 2 +- source/blender/bmesh/intern/bmesh_mods.c | 2 +- source/blender/bmesh/intern/bmesh_newcore.c | 2 +- source/blender/bmesh/intern/bmesh_operators.c | 6 ++-- source/blender/bmesh/intern/bmesh_polygon.c | 31 ++++++++++++------- source/blender/bmesh/intern/bmesh_walkers.c | 4 +-- source/blender/bmesh/operators/createops.c | 8 ++--- source/blender/bmesh/operators/mesh_conv.c | 10 +++--- source/blender/bmesh/operators/primitiveops.c | 6 ++-- source/blender/bmesh/operators/subdivideop.c | 8 ++--- source/blender/bmesh/tools/BME_bevel.c | 8 ++--- 12 files changed, 60 insertions(+), 53 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 94e1f80d3a9..f33a1ef571e 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -317,14 +317,14 @@ static double UNUSED_FUNCTION(dist_to_line_segment_v2_d)(double v1[3], double v2 rc[0] = v3[0] - v2[0]; rc[1] = v3[1] - v2[1]; - len = rc[0]*rc[0]+ rc[1]*rc[1]; + 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; + 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]; @@ -334,20 +334,20 @@ static double UNUSED_FUNCTION(dist_to_line_segment_v2_d)(double v1[3], double v2 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]; - return sqrt(rc[0]*rc[0]+ rc[1]*rc[1]); + rc[0] = pt[0] - v1[0]; + rc[1] = pt[1] - v1[1]; + return sqrt(rc[0] * rc[0] + rc[1] * rc[1]); } MINLINE double line_point_side_v2_d(const double *l1, const double *l2, const double *pt) { - return ((l1[0]-pt[0]) * (l2[1]-pt[1])) - - ((l2[0]-pt[0]) * (l1[1]-pt[1])); + return ((l1[0] - pt[0]) * (l2[1] - pt[1])) - + ((l2[0] - pt[0]) * (l1[1] - pt[1])); } /* point in quad - only convex quads */ @@ -650,10 +650,10 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f) sides = (int)sqrt(mdp->totdisp); for (y = 0; y < sides; y++) { - add_v3_v3v3(co1, mdn->disps[y*sides], mdl->disps[y]); + add_v3_v3v3(co1, mdn->disps[y * sides], mdl->disps[y]); mul_v3_fl(co1, 0.5); - copy_v3_v3(mdn->disps[y*sides], co1); + copy_v3_v3(mdn->disps[y * sides], co1); copy_v3_v3(mdl->disps[y], co1); } } @@ -692,8 +692,8 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f) int a1, a2, o1, o2; if (l->v != l->radial_next->v) { - a1 = sides*y + sides-2; - a2 = (sides-2)*sides + y; + a1 = sides * y + sides - 2; + a2 = (sides - 2) * sides + y; o1 = sides * y + sides - 1; o2 = (sides - 1) * sides + y; diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 15f1925fc1c..73c57053d99 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -62,7 +62,7 @@ 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; diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index ecbf47a961c..07718b401b4 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -410,7 +410,7 @@ BMFace *BM_Split_Face(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **nl, * @returns The New Edge */ -BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, const int join_faces) +BMEdge *BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, const int join_faces) { BMEdge *ne = NULL; BMVert *tv = bmesh_edge_getothervert(ke, kv); diff --git a/source/blender/bmesh/intern/bmesh_newcore.c b/source/blender/bmesh/intern/bmesh_newcore.c index 6108c6fe607..59765900bb1 100644 --- a/source/blender/bmesh/intern/bmesh_newcore.c +++ b/source/blender/bmesh/intern/bmesh_newcore.c @@ -523,7 +523,7 @@ void BM_Kill_Face_Edges(BMesh *bm, BMFace *f) void BM_Kill_Face_Verts(BMesh *bm, BMFace *f) { - BMVert**verts = NULL; + BMVert **verts = NULL; BLI_array_staticdeclare(verts, BM_NGON_STACK_SIZE); BMLoop *l_iter; BMLoop *l_first; diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 45cf78c9094..6728226d0ab 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1216,7 +1216,7 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) def = opdefines[i]; i = 0; - state = 1; //0: not inside slotcode name, 1: inside slotcode name + state = 1; /* 0: not inside slotcode name, 1: inside slotcode name */ while (*fmt) { if (state) { @@ -1336,7 +1336,7 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) default: fprintf(stderr, "%s: unrecognized bmop format char: %c, %d in '%s'\n", - __func__, *fmt, (int)(fmt-ofmt), ofmt); + __func__, *fmt, (int)(fmt - ofmt), ofmt); break; } } @@ -1350,7 +1350,7 @@ error: /* non urgent todo - explain exactly what is failing */ fprintf(stderr, "%s: error parsing formatting string, %d in '%s'\n see - %s:%d\n", - __func__, (int)(fmt-ofmt), _fmt, __FILE__, lineno); + __func__, (int)(fmt - ofmt), _fmt, __FILE__, lineno); MEM_freeN(ofmt); BMO_Finish_Op(bm, op); diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index c1ea94582a6..f8dcb24ed92 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -60,13 +60,15 @@ 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[0] - v1[0]) * (v1[1] - v3[1]) + (v1[1] - v2[1]) * (v1[0] - v3[0]); - if (inp < 0.0) 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; @@ -76,10 +78,10 @@ static short testedgeside(const double v1[2], const double v2[2], const double v 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[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) { @@ -662,15 +664,17 @@ static int linecrossesf(const float v1[2], const float v2[2], const float v3[2], /* 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) + 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 axi */ - if (ABS(v1[0]-v2[0]) < T && ABS(v3[0]-v4[0]) < T && - ABS(v1[0]-v3[0]) < T) + if ( ABS(v1[0] - v2[0]) < T && + ABS(v3[0] - v4[0]) < T && + ABS(v1[0] - v3[0]) < T) { return (mv4[1] >= mv1[1] && mv3[1] <= mv2[1]); } @@ -809,15 +813,18 @@ static BMLoop *find_ear(BMesh *UNUSED(bm), BMFace *f, float (*verts)[3], const i } if (isear) { - /* angle = angle_v3v3v3(verts[v1->head.eflag2], verts[v2->head.eflag2], verts[v3->head.eflag2]); +#if 0 + 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); + bestangle = ABS(45.0f - angle); } if (angle > 20 && angle < 90) break; if (angle < 100 && i > 5) break; - i += 1; */ + i += 1; +#endif + bestear = l_iter; break; } diff --git a/source/blender/bmesh/intern/bmesh_walkers.c b/source/blender/bmesh/intern/bmesh_walkers.c index 488f5cfa6b0..280ac1c1913 100644 --- a/source/blender/bmesh/intern/bmesh_walkers.c +++ b/source/blender/bmesh/intern/bmesh_walkers.c @@ -193,7 +193,7 @@ void *BMW_walk(BMWalker *walker) * worklist for processing. */ -void* BMW_currentstate(BMWalker *walker) +void *BMW_currentstate(BMWalker *walker) { bmesh_walkerGeneric *currentstate = walker->states.first; if (currentstate) { @@ -237,7 +237,7 @@ void BMW_removestate(BMWalker *walker) * breadth-first walks. */ -void* BMW_addstate(BMWalker *walker) +void *BMW_addstate(BMWalker *walker) { bmesh_walkerGeneric *newstate; newstate = BLI_mempool_alloc(walker->worklist); diff --git a/source/blender/bmesh/operators/createops.c b/source/blender/bmesh/operators/createops.c index 3e9c94f6b70..85d980f10af 100644 --- a/source/blender/bmesh/operators/createops.c +++ b/source/blender/bmesh/operators/createops.c @@ -181,7 +181,7 @@ static void rotsys_reverse(struct BMEdge *UNUSED(e), struct BMVert *v, EdgeData totedge = BLI_array_count(edges); for (i = 0; i < totedge / 2; i++) { - SWAP(BMEdge*, edges[i], edges[totedge - 1 - i]); + SWAP(BMEdge *, edges[i], edges[totedge - 1 - i]); } vdata[BM_GetIndex(v)].e = NULL; @@ -535,11 +535,11 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) } if (dot_v3v3(n1, n2) < 0.0f) { if (dot_v3v3(n1, n3) >= 0.0f + FLT_EPSILON * 10) { - SWAP(BMEdge*, edges[i], edges[(i + 1) % totedge]); + 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]) } } } diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c index 996ddf6e2b2..b435d67d384 100644 --- a/source/blender/bmesh/operators/mesh_conv.c +++ b/source/blender/bmesh/operators/mesh_conv.c @@ -469,16 +469,16 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) /* new Vertex block */ if (bm->totvert == 0) mvert = NULL; - else mvert = MEM_callocN(bm->totvert*sizeof(MVert), "loadeditbMesh vert"); + 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"); + else medge = MEM_callocN(bm->totedge * sizeof(MEdge), "loadeditbMesh edge"); /* build ngon dat */ /* new Ngon Face block */ if (bm->totface == 0) mpoly = NULL; - else mpoly = MEM_callocN(bm->totface*sizeof(MPoly), "loadeditbMesh poly"); + else mpoly = MEM_callocN(bm->totface * sizeof(MPoly), "loadeditbMesh poly"); /* find number of loops to allocat */ totloop = 0; @@ -487,7 +487,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) } if (totloop == 0) mloop = NULL; - else mloop = MEM_callocN(totloop*sizeof(MLoop), "loadeditbMesh loop"); + 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 */ @@ -862,7 +862,7 @@ 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); diff --git a/source/blender/bmesh/operators/primitiveops.c b/source/blender/bmesh/operators/primitiveops.c index 01bbab78d04..0af36dbfb11 100644 --- a/source/blender/bmesh/operators/primitiveops.c +++ b/source/blender/bmesh/operators/primitiveops.c @@ -321,7 +321,7 @@ void bmesh_create_uvsphere_exec(BMesh *bm, BMOperator *op) /* Going in this direction, then edge extruding, makes normals face outward */ vec[0] = -dia * sinf(phi); vec[1] = 0.0; - vec[2] = dia*cosf(phi); + vec[2] = dia * cosf(phi); eve = BM_Make_Vert(bm, vec, NULL); BMO_SetFlag(bm, eve, VERT_MARK); @@ -493,8 +493,8 @@ void bmesh_create_circle_exec(BMesh *bm, BMOperator *op) BMO_Get_Mat4(op, "mat", mat); - phid = 2.0f*(float)M_PI / segs; - phi = .25f*(float)M_PI; + phid = 2.0f * (float)M_PI / segs; + phi = .25f * (float)M_PI; if (cap_ends) { vec[0] = vec[1] = 0.0f; diff --git a/source/blender/bmesh/operators/subdivideop.c b/source/blender/bmesh/operators/subdivideop.c index b22423faae1..6e653228e65 100644 --- a/source/blender/bmesh/operators/subdivideop.c +++ b/source/blender/bmesh/operators/subdivideop.c @@ -90,7 +90,7 @@ BLI_srandom(seed); wid = (params->numcuts + 2); - dp = perc*wid; + dp = perc * wid; wid /= 2; d = lvl = 0; while (1) { @@ -183,7 +183,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const subdpar 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); @@ -197,7 +197,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const subdpar madd_v3_v3fl(tvec, nor2, fac); /* falloff for multi subdivide */ - smooth *= sqrtf(fabsf(1.0f - 2.0f*fabsf(0.5f-perc))); + smooth *= sqrtf(fabsf(1.0f - 2.0f * fabsf(0.5f-perc))); mul_v3_fl(tvec, smooth * len); @@ -212,7 +212,7 @@ 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); diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c index 0ca8b76ed00..8ab6c21ff12 100644 --- a/source/blender/bmesh/tools/BME_bevel.c +++ b/source/blender/bmesh/tools/BME_bevel.c @@ -378,15 +378,15 @@ 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; - if (is_edge || dis > maxfactor*value) { - dis = maxfactor*value; + if (is_edge || dis > maxfactor * value) { + dis = maxfactor * value; } madd_v3_v3v3fl(sv->co, v->co, vec1, dis); sub_v3_v3v3(vec1, sv->co, vtd1->org); @@ -1002,7 +1002,7 @@ BMesh *BME_bevel(BMEditMesh *em, float value, int res, int options, int defgrp_i else { d = value; } - madd_v3_v3v3fl(v->co, vtd->org, vtd->vec, vtd->factor*d); + madd_v3_v3v3fl(v->co, vtd->org, vtd->vec, vtd->factor * d); } }