diff options
author | Jacques Lucke <jacques@blender.org> | 2020-09-09 19:41:07 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-09-09 19:41:07 +0300 |
commit | 63916f5941b443dfc8566682bb75374e5abd553f (patch) | |
tree | fb0704701f1d4d9acbddf4a6fbc62c819d8d4c36 /source/blender/editors/mesh | |
parent | 0cff2c944f9c2cd3ac873fe826c4399fc2f32159 (diff) |
Cleanup: reduce variable scope
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editface.c | 5 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 26 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 24 |
3 files changed, 22 insertions, 33 deletions
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index b303c4c7e4e..b349def4637 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -58,7 +58,6 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag) MPoly *polys, *mp_orig; const int *index_array = NULL; int totpoly; - int i; BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0); @@ -87,7 +86,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag) if (me_orig != NULL && me_eval != NULL && me_orig->totpoly == me->totpoly) { /* Update the COW copy of the mesh. */ - for (i = 0; i < me->totpoly; i++) { + for (int i = 0; i < me->totpoly; i++) { me_orig->mpoly[i].flag = me->mpoly[i].flag; } @@ -101,7 +100,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag) totpoly = me_eval->totpoly; /* loop over final derived polys */ - for (i = 0; i < totpoly; i++) { + for (int i = 0; i < totpoly; i++) { if (index_array[i] != ORIGINDEX_NONE) { /* Copy flags onto the final derived poly from the original mesh poly */ mp_orig = me->mpoly + index_array[i]; diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 515fbab86bc..90ef42c6f48 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -672,12 +672,10 @@ static int linehit_compare(const void *vlh1, const void *vlh2) */ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) { - KnifeLineHit *linehits, *lhi, *lhj; - int i, j, n; bool is_double = false; - n = kcd->totlinehit; - linehits = kcd->linehits; + int n = kcd->totlinehit; + KnifeLineHit *linehits = kcd->linehits; if (n == 0) { return; } @@ -688,11 +686,11 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) * by a vertex hit that is very near. Mark such edge hits using * l == -1 and then do another pass to actually remove. * Also remove all but one of a series of vertex hits for the same vertex. */ - for (i = 0; i < n; i++) { - lhi = &linehits[i]; + for (int i = 0; i < n; i++) { + KnifeLineHit *lhi = &linehits[i]; if (lhi->v) { - for (j = i - 1; j >= 0; j--) { - lhj = &linehits[j]; + for (int j = i - 1; j >= 0; j--) { + KnifeLineHit *lhj = &linehits[j]; if (!lhj->kfe || fabsf(lhi->l - lhj->l) > KNIFE_FLT_EPSBIG || fabsf(lhi->m - lhj->m) > KNIFE_FLT_EPSBIG) { break; @@ -703,8 +701,8 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) is_double = true; } } - for (j = i + 1; j < n; j++) { - lhj = &linehits[j]; + for (int j = i + 1; j < n; j++) { + KnifeLineHit *lhj = &linehits[j]; if (fabsf(lhi->l - lhj->l) > KNIFE_FLT_EPSBIG || fabsf(lhi->m - lhj->m) > KNIFE_FLT_EPSBIG) { break; @@ -719,11 +717,11 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) if (is_double) { /* delete-in-place loop: copying from pos j to pos i+1 */ - i = 0; - j = 1; + int i = 0; + int j = 1; while (j < n) { - lhi = &linehits[i]; - lhj = &linehits[j]; + KnifeLineHit *lhi = &linehits[i]; + KnifeLineHit *lhj = &linehits[j]; if (lhj->l == -1.0f) { j++; /* skip copying this one */ } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 22ea222cf01..1537be0aef6 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -171,11 +171,10 @@ static void mesh_uv_reset_array(float **fuv, const int len) } else if (len > 2) { float fac = 0.0f, dfac = 1.0f / (float)len; - int i; dfac *= (float)M_PI * 2.0f; - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { fuv[i][0] = 0.5f * sinf(fac) + 0.5f; fuv[i][1] = 0.5f * cosf(fac) + 0.5f; @@ -201,9 +200,8 @@ static void mesh_uv_reset_bmface(BMFace *f, const int cd_loop_uv_offset) static void mesh_uv_reset_mface(MPoly *mp, MLoopUV *mloopuv) { float **fuv = BLI_array_alloca(fuv, mp->totloop); - int i; - for (i = 0; i < mp->totloop; i++) { + for (int i = 0; i < mp->totloop; i++) { fuv[i] = mloopuv[mp->loopstart + i].uv; } @@ -234,13 +232,10 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) } else { /* Collect Mesh UVs */ - MLoopUV *mloopuv; - int i; - BLI_assert(CustomData_has_layer(&me->ldata, CD_MLOOPUV)); - mloopuv = CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, layernum); + MLoopUV *mloopuv = CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, layernum); - for (i = 0; i < me->totpoly; i++) { + for (int i = 0; i < me->totpoly; i++) { mesh_uv_reset_mface(&me->mpoly[i], mloopuv); } } @@ -1061,15 +1056,12 @@ void ED_mesh_update(Mesh *mesh, bContext *C, bool calc_edges, bool calc_edges_lo static void mesh_add_verts(Mesh *mesh, int len) { - CustomData vdata; - MVert *mvert; - int i, totvert; - if (len == 0) { return; } - totvert = mesh->totvert + len; + int totvert = mesh->totvert + len; + CustomData vdata; CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert); CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert); @@ -1084,8 +1076,8 @@ static void mesh_add_verts(Mesh *mesh, int len) /* scan the input list and insert the new vertices */ /* set default flags */ - mvert = &mesh->mvert[mesh->totvert]; - for (i = 0; i < len; i++, mvert++) { + MVert *mvert = &mesh->mvert[mesh->totvert]; + for (int i = 0; i < len; i++, mvert++) { mvert->flag |= SELECT; } |