diff options
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 31 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh_runtime.c | 7 |
2 files changed, 12 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 53f2a85fdad..950885d2114 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -845,9 +845,7 @@ static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata) Mesh *BKE_mesh_add(Main *bmain, const char *name) { - Mesh *me; - - me = BKE_id_new(bmain, ID_ME, name); + Mesh *me = BKE_id_new(bmain, ID_ME, name); return me; } @@ -1007,10 +1005,9 @@ BMesh *BKE_mesh_to_bmesh_ex(const Mesh *me, const struct BMeshCreateParams *create_params, const struct BMeshFromMeshParams *convert_params) { - BMesh *bm; const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(me); - bm = BM_mesh_create(&allocsize, create_params); + BMesh *bm = BM_mesh_create(&allocsize, create_params); BM_mesh_bm_from_me(bm, me, convert_params); return bm; @@ -1162,17 +1159,14 @@ void BKE_mesh_texspace_copy_from_object(Mesh *me, Object *ob) float (*BKE_mesh_orco_verts_get(Object *ob))[3] { Mesh *me = ob->data; - MVert *mvert = NULL; Mesh *tme = me->texcomesh ? me->texcomesh : me; - int a, totvert; - float(*vcos)[3] = NULL; /* Get appropriate vertex coordinates */ - vcos = MEM_calloc_arrayN(me->totvert, sizeof(*vcos), "orco mesh"); - mvert = tme->mvert; - totvert = min_ii(tme->totvert, me->totvert); + float(*vcos)[3] = MEM_calloc_arrayN(me->totvert, sizeof(*vcos), "orco mesh"); + MVert *mvert = tme->mvert; + int totvert = min_ii(tme->totvert, me->totvert); - for (a = 0; a < totvert; a++, mvert++) { + for (int a = 0; a < totvert; a++, mvert++) { copy_v3_v3(vcos[a], mvert->co); } @@ -1182,18 +1176,17 @@ float (*BKE_mesh_orco_verts_get(Object *ob))[3] void BKE_mesh_orco_verts_transform(Mesh *me, float (*orco)[3], int totvert, int invert) { float loc[3], size[3]; - int a; BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, loc, size); if (invert) { - for (a = 0; a < totvert; a++) { + for (int a = 0; a < totvert; a++) { float *co = orco[a]; madd_v3_v3v3v3(co, loc, co, size); } } else { - for (a = 0; a < totvert; a++) { + for (int a = 0; a < totvert; a++) { float *co = orco[a]; co[0] = (co[0] - loc[0]) / size[0]; co[1] = (co[1] - loc[1]) / size[1]; @@ -1274,7 +1267,6 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) Mesh *BKE_mesh_from_object(Object *ob) { - if (ob == NULL) { return NULL; } @@ -1414,8 +1406,7 @@ void BKE_mesh_smooth_flag_set(Mesh *me, const bool use_smooth) */ int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, uint vert) { - int j; - for (j = 0; j < poly->totloop; j++, loopstart++) { + for (int j = 0; j < poly->totloop; j++, loopstart++) { if (loopstart->v == vert) { return j; } @@ -1682,11 +1673,9 @@ void BKE_mesh_mselect_validate(Mesh *me) */ int BKE_mesh_mselect_find(Mesh *me, int index, int type) { - int i; - BLI_assert(ELEM(type, ME_VSEL, ME_ESEL, ME_FSEL)); - for (i = 0; i < me->totselect; i++) { + for (int i = 0; i < me->totselect; i++) { if ((me->mselect[i].index == index) && (me->mselect[i].type == type)) { return i; } diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c index b5257983b8c..22f29bef97e 100644 --- a/source/blender/blenkernel/intern/mesh_runtime.c +++ b/source/blender/blenkernel/intern/mesh_runtime.c @@ -154,12 +154,10 @@ int BKE_mesh_runtime_looptri_len(const Mesh *mesh) /* This is a ported copy of dm_getLoopTriArray(dm). */ const MLoopTri *BKE_mesh_runtime_looptri_ensure(Mesh *mesh) { - MLoopTri *looptri; - ThreadMutex *mesh_eval_mutex = (ThreadMutex *)mesh->runtime.eval_mutex; BLI_mutex_lock(mesh_eval_mutex); - looptri = mesh->runtime.looptris.array; + MLoopTri *looptri = mesh->runtime.looptris.array; if (looptri != NULL) { BLI_assert(BKE_mesh_runtime_looptri_len(mesh) == mesh->runtime.looptris.len); @@ -180,8 +178,7 @@ void BKE_mesh_runtime_verttri_from_looptri(MVertTri *r_verttri, const MLoopTri *looptri, int looptri_num) { - int i; - for (i = 0; i < looptri_num; i++) { + for (int i = 0; i < looptri_num; i++) { r_verttri[i].tri[0] = mloop[looptri[i].tri[0]].v; r_verttri[i].tri[1] = mloop[looptri[i].tri[1]].v; r_verttri[i].tri[2] = mloop[looptri[i].tri[2]].v; |