diff options
author | Campbell Barton <campbell@blender.org> | 2022-03-28 04:29:47 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-03-28 06:41:31 +0300 |
commit | 6f305577b346030249bdb762f887136ff02624e3 (patch) | |
tree | 207b1cbba07e8a0f864ff854d6d1a74c26c6beaf /source/blender/modifiers | |
parent | 24839fdefa89339e77465c27d89c86cd5ac0cdd9 (diff) |
Cleanup: use "num" as a suffix in: source/blender/modifiers
Also rename DNA struct members.
Diffstat (limited to 'source/blender/modifiers')
46 files changed, 1319 insertions, 1284 deletions
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 5d37ac79fa6..f6e8a26f0e1 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -132,7 +132,7 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { ArmatureModifierData *amd = (ArmatureModifierData *)md; @@ -142,7 +142,7 @@ static void deformVerts(ModifierData *md, ctx->object, vertexCos, NULL, - numVerts, + verts_num, amd->deformflag, amd->vert_coords_prev, amd->defgrp_name, @@ -157,10 +157,10 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *em, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { if (mesh != NULL) { - deformVerts(md, ctx, mesh, vertexCos, numVerts); + deformVerts(md, ctx, mesh, vertexCos, verts_num); return; } @@ -172,7 +172,7 @@ static void deformVertsEM(ModifierData *md, ctx->object, vertexCos, NULL, - numVerts, + verts_num, amd->deformflag, amd->vert_coords_prev, amd->defgrp_name, @@ -188,7 +188,7 @@ static void deformMatricesEM(ModifierData *md, Mesh *UNUSED(mesh), float (*vertexCos)[3], float (*defMats)[3][3], - int numVerts) + int verts_num) { ArmatureModifierData *amd = (ArmatureModifierData *)md; @@ -196,7 +196,7 @@ static void deformMatricesEM(ModifierData *md, ctx->object, vertexCos, defMats, - numVerts, + verts_num, amd->deformflag, NULL, amd->defgrp_name, @@ -208,16 +208,17 @@ static void deformMatrices(ModifierData *md, Mesh *mesh, float (*vertexCos)[3], float (*defMats)[3][3], - int numVerts) + int verts_num) { ArmatureModifierData *amd = (ArmatureModifierData *)md; - Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get( + ctx->object, NULL, mesh, NULL, verts_num, false, false); BKE_armature_deform_coords_with_mesh(amd->object, ctx->object, vertexCos, defMats, - numVerts, + verts_num, amd->deformflag, NULL, amd->defgrp_name, diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index b237f952287..758858c8b1d 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -139,17 +139,17 @@ static void svert_from_mvert(SortVertsElem *sv, /** * Take as inputs two sets of verts, to be processed for detection of doubles and mapping. - * Each set of verts is defined by its start within mverts array and its num_verts; + * Each set of verts is defined by its start within mverts array and its verts_num; * It builds a mapping for all vertices within source, * to vertices within target, or -1 if no double found. - * The int doubles_map[num_verts_source] array must have been allocated by caller. + * The `int doubles_map[verts_source_num]` array must have been allocated by caller. */ static void dm_mvert_map_doubles(int *doubles_map, const MVert *mverts, const int target_start, - const int target_num_verts, + const int target_verts_num, const int source_start, - const int source_num_verts, + const int source_verts_num, const float dist) { const float dist3 = ((float)M_SQRT3 + 0.00005f) * dist; /* Just above sqrt(3) */ @@ -158,12 +158,12 @@ static void dm_mvert_map_doubles(int *doubles_map, SortVertsElem *sve_source, *sve_target, *sve_target_low_bound; bool target_scan_completed; - target_end = target_start + target_num_verts; - source_end = source_start + source_num_verts; + target_end = target_start + target_verts_num; + source_end = source_start + source_verts_num; /* build array of MVerts to be tested for merging */ - sorted_verts_target = MEM_malloc_arrayN(target_num_verts, sizeof(SortVertsElem), __func__); - sorted_verts_source = MEM_malloc_arrayN(source_num_verts, sizeof(SortVertsElem), __func__); + sorted_verts_target = MEM_malloc_arrayN(target_verts_num, sizeof(SortVertsElem), __func__); + sorted_verts_source = MEM_malloc_arrayN(source_verts_num, sizeof(SortVertsElem), __func__); /* Copy target vertices index and cos into SortVertsElem array */ svert_from_mvert(sorted_verts_target, mverts + target_start, target_start, target_end); @@ -172,8 +172,8 @@ static void dm_mvert_map_doubles(int *doubles_map, svert_from_mvert(sorted_verts_source, mverts + source_start, source_start, source_end); /* sort arrays according to sum of vertex coordinates (sumco) */ - qsort(sorted_verts_target, target_num_verts, sizeof(SortVertsElem), svert_sum_cmp); - qsort(sorted_verts_source, source_num_verts, sizeof(SortVertsElem), svert_sum_cmp); + qsort(sorted_verts_target, target_verts_num, sizeof(SortVertsElem), svert_sum_cmp); + qsort(sorted_verts_source, source_verts_num, sizeof(SortVertsElem), svert_sum_cmp); sve_target_low_bound = sorted_verts_target; i_target_low_bound = 0; @@ -181,7 +181,7 @@ static void dm_mvert_map_doubles(int *doubles_map, /* Scan source vertices, in #SortVertsElem sorted array, * all the while maintaining the lower bound of possible doubles in target vertices. */ - for (i_source = 0, sve_source = sorted_verts_source; i_source < source_num_verts; + for (i_source = 0, sve_source = sorted_verts_source; i_source < source_verts_num; i_source++, sve_source++) { int best_target_vertex = -1; float best_dist_sq = dist * dist; @@ -202,13 +202,13 @@ static void dm_mvert_map_doubles(int *doubles_map, /* Skip all target vertices that are more than dist3 lower in terms of sumco */ /* and advance the overall lower bound, applicable to all remaining vertices as well. */ - while ((i_target_low_bound < target_num_verts) && + while ((i_target_low_bound < target_verts_num) && (sve_target_low_bound->sum_co < sve_source_sumco - dist3)) { i_target_low_bound++; sve_target_low_bound++; } /* If end of target list reached, then no more possible doubles */ - if (i_target_low_bound >= target_num_verts) { + if (i_target_low_bound >= target_verts_num) { doubles_map[sve_source->vertex_num] = -1; target_scan_completed = true; continue; @@ -221,7 +221,7 @@ static void dm_mvert_map_doubles(int *doubles_map, /* i_target will scan vertices in the * [v_source_sumco - dist3; v_source_sumco + dist3] range */ - while ((i_target < target_num_verts) && (sve_target->sum_co <= sve_source_sumco + dist3)) { + while ((i_target < target_verts_num) && (sve_target->sum_co <= sve_source_sumco + dist3)) { /* Testing distance for candidate double in target */ /* v_target is within dist3 of v_source in terms of sumco; check real distance */ float dist_sq; @@ -478,7 +478,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, } /* About 67 million vertices max seems a decent limit for now. */ - const size_t max_num_vertices = 1 << 26; + const size_t max_vertices_num = 1 << 26; /* calculate the maximum number of copies which will fit within the * prescribed length */ @@ -496,7 +496,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, * vertices. */ if (((size_t)count * (size_t)chunk_nverts + (size_t)start_cap_nverts + - (size_t)end_cap_nverts) > max_num_vertices) { + (size_t)end_cap_nverts) > max_vertices_num) { count = 1; offset_is_too_small = true; } @@ -518,7 +518,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, * vertices. */ else if (((size_t)count * (size_t)chunk_nverts + (size_t)start_cap_nverts + - (size_t)end_cap_nverts) > max_num_vertices) { + (size_t)end_cap_nverts) > max_vertices_num) { count = 1; BKE_modifier_set_error(ctx->object, &amd->modifier, diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index cd77abfca50..d7baea7887d 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -58,7 +58,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct Mesh *result; BuildModifierData *bmd = (BuildModifierData *)md; int i, j, k; - int numFaces_dst, numEdges_dst, numLoops_dst = 0; + int faces_dst_num, edges_dst_num, loops_dst_num = 0; int *vertMap, *edgeMap, *faceMap; float frac; MPoly *mpoly_dst; @@ -71,21 +71,21 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct /* maps edge indices in old mesh to indices in new mesh */ GHash *edgeHash2 = BLI_ghash_int_new("build ed apply gh"); - const int numVert_src = mesh->totvert; - const int numEdge_src = mesh->totedge; - const int numPoly_src = mesh->totpoly; + const int vert_src_num = mesh->totvert; + const int edge_src_num = mesh->totedge; + const int poly_src_num = mesh->totpoly; MPoly *mpoly_src = mesh->mpoly; MLoop *mloop_src = mesh->mloop; MEdge *medge_src = mesh->medge; MVert *mvert_src = mesh->mvert; - vertMap = MEM_malloc_arrayN(numVert_src, sizeof(*vertMap), "build modifier vertMap"); - edgeMap = MEM_malloc_arrayN(numEdge_src, sizeof(*edgeMap), "build modifier edgeMap"); - faceMap = MEM_malloc_arrayN(numPoly_src, sizeof(*faceMap), "build modifier faceMap"); + vertMap = MEM_malloc_arrayN(vert_src_num, sizeof(*vertMap), "build modifier vertMap"); + edgeMap = MEM_malloc_arrayN(edge_src_num, sizeof(*edgeMap), "build modifier edgeMap"); + faceMap = MEM_malloc_arrayN(poly_src_num, sizeof(*faceMap), "build modifier faceMap"); - range_vn_i(vertMap, numVert_src, 0); - range_vn_i(edgeMap, numEdge_src, 0); - range_vn_i(faceMap, numPoly_src, 0); + range_vn_i(vertMap, vert_src_num, 0); + range_vn_i(edgeMap, edge_src_num, 0); + range_vn_i(faceMap, poly_src_num, 0); struct Scene *scene = DEG_get_input_scene(ctx->depsgraph); frac = (BKE_scene_ctime_get(scene) - bmd->start) / bmd->length; @@ -94,17 +94,17 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct frac = 1.0f - frac; } - numFaces_dst = numPoly_src * frac; - numEdges_dst = numEdge_src * frac; + faces_dst_num = poly_src_num * frac; + edges_dst_num = edge_src_num * frac; /* if there's at least one face, build based on faces */ - if (numFaces_dst) { + if (faces_dst_num) { MPoly *mpoly, *mp; MLoop *ml, *mloop; uintptr_t hash_num, hash_num_alt; if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) { - BLI_array_randomize(faceMap, sizeof(*faceMap), numPoly_src, bmd->seed); + BLI_array_randomize(faceMap, sizeof(*faceMap), poly_src_num, bmd->seed); } /* get the set of all vert indices that will be in the final mesh, @@ -113,7 +113,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct mpoly = mpoly_src; mloop = mloop_src; hash_num = 0; - for (i = 0; i < numFaces_dst; i++) { + for (i = 0; i < faces_dst_num; i++) { mp = mpoly + faceMap[i]; ml = mloop + mp->loopstart; @@ -125,7 +125,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct } } - numLoops_dst += mp->totloop; + loops_dst_num += mp->totloop; } BLI_assert(hash_num == BLI_ghash_len(vertHash)); @@ -134,7 +134,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct */ hash_num = 0; hash_num_alt = 0; - for (i = 0; i < numEdge_src; i++, hash_num_alt++) { + for (i = 0; i < edge_src_num; i++, hash_num_alt++) { MEdge *me = medge_src + i; if (BLI_ghash_haskey(vertHash, POINTER_FROM_INT(me->v1)) && @@ -146,12 +146,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct } BLI_assert(hash_num == BLI_ghash_len(edgeHash)); } - else if (numEdges_dst) { + else if (edges_dst_num) { MEdge *medge, *me; uintptr_t hash_num; if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) { - BLI_array_randomize(edgeMap, sizeof(*edgeMap), numEdge_src, bmd->seed); + BLI_array_randomize(edgeMap, sizeof(*edgeMap), edge_src_num, bmd->seed); } /* get the set of all vert indices that will be in the final mesh, @@ -160,7 +160,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct medge = medge_src; hash_num = 0; BLI_assert(hash_num == BLI_ghash_len(vertHash)); - for (i = 0; i < numEdges_dst; i++) { + for (i = 0; i < edges_dst_num; i++) { void **val_p; me = medge + edgeMap[i]; @@ -176,7 +176,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct BLI_assert(hash_num == BLI_ghash_len(vertHash)); /* get the set of edges that will be in the new mesh */ - for (i = 0; i < numEdges_dst; i++) { + for (i = 0; i < edges_dst_num; i++) { j = BLI_ghash_len(edgeHash); BLI_ghash_insert(edgeHash, POINTER_FROM_INT(j), POINTER_FROM_INT(edgeMap[i])); @@ -184,23 +184,23 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct } } else { - int numVerts = numVert_src * frac; + int verts_num = vert_src_num * frac; if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) { - BLI_array_randomize(vertMap, sizeof(*vertMap), numVert_src, bmd->seed); + BLI_array_randomize(vertMap, sizeof(*vertMap), vert_src_num, bmd->seed); } /* get the set of all vert indices that will be in the final mesh, * mapped to the new indices */ - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { BLI_ghash_insert(vertHash, POINTER_FROM_INT(vertMap[i]), POINTER_FROM_INT(i)); } } /* now we know the number of verts, edges and faces, we can create the mesh. */ result = BKE_mesh_new_nomain_from_template( - mesh, BLI_ghash_len(vertHash), BLI_ghash_len(edgeHash), 0, numLoops_dst, numFaces_dst); + mesh, BLI_ghash_len(vertHash), BLI_ghash_len(edgeHash), 0, loops_dst_num, faces_dst_num); /* copy the vertices across */ GHASH_ITER (gh_iter, vertHash) { @@ -237,7 +237,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct /* copy the faces across, remapping indices */ k = 0; - for (i = 0; i < numFaces_dst; i++) { + for (i = 0; i < faces_dst_num; i++) { MPoly *source; MPoly *dest; diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index fb395631451..3916551bc90 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -96,7 +96,7 @@ static void sphere_do(CastModifierData *cmd, Object *ob, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { MDeformVert *dvert = NULL; const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0; @@ -159,17 +159,17 @@ static void sphere_do(CastModifierData *cmd, } if (len <= 0) { - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { len += len_v3v3(center, vertexCos[i]); } - len /= numVerts; + len /= verts_num; if (len == 0.0f) { len = 10.0f; } } - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { float tmp_co[3]; copy_v3_v3(tmp_co, vertexCos[i]); @@ -237,7 +237,7 @@ static void cuboid_do(CastModifierData *cmd, Object *ob, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { MDeformVert *dvert = NULL; int defgrp_index; @@ -312,13 +312,13 @@ static void cuboid_do(CastModifierData *cmd, /* let the center of the ctrl_ob be part of the bound box: */ minmax_v3v3_v3(min, max, center); - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { sub_v3_v3v3(vec, vertexCos[i], center); minmax_v3v3_v3(min, max, vec); } } else { - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { minmax_v3v3_v3(min, max, vertexCos[i]); } } @@ -347,7 +347,7 @@ static void cuboid_do(CastModifierData *cmd, bb[4][2] = bb[5][2] = bb[6][2] = bb[7][2] = max[2]; /* ready to apply the effect, one vertex at a time */ - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { int octant, coord; float d[3], dmax, apex[3], fbb; float tmp_co[3]; @@ -460,21 +460,21 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { CastModifierData *cmd = (CastModifierData *)md; Mesh *mesh_src = NULL; if (ctx->object->type == OB_MESH && cmd->defgrp_name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); } if (cmd->type == MOD_CAST_TYPE_CUBOID) { - cuboid_do(cmd, ctx, ctx->object, mesh_src, vertexCos, numVerts); + cuboid_do(cmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); } else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */ - sphere_do(cmd, ctx, ctx->object, mesh_src, vertexCos, numVerts); + sphere_do(cmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); } if (!ELEM(mesh_src, NULL, mesh)) { @@ -487,17 +487,18 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { CastModifierData *cmd = (CastModifierData *)md; Mesh *mesh_src = NULL; if (cmd->defgrp_name[0] != '\0') { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get( + ctx->object, editData, mesh, NULL, verts_num, false, false); } if (mesh && mesh->runtime.wrapper_type == ME_WRAPPER_TYPE_MDATA) { - BLI_assert(mesh->totvert == numVerts); + BLI_assert(mesh->totvert == verts_num); } /* TODO(Campbell): use edit-mode data only (remove this line). */ @@ -506,10 +507,10 @@ static void deformVertsEM(ModifierData *md, } if (cmd->type == MOD_CAST_TYPE_CUBOID) { - cuboid_do(cmd, ctx, ctx->object, mesh_src, vertexCos, numVerts); + cuboid_do(cmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); } else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */ - sphere_do(cmd, ctx, ctx->object, mesh_src, vertexCos, numVerts); + sphere_do(cmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); } if (!ELEM(mesh_src, NULL, mesh)) { diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 4bc79a9dd45..6389f420588 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -78,7 +78,7 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { Mesh *mesh_src; ClothModifierData *clmd = (ClothModifierData *)md; @@ -94,7 +94,7 @@ static void deformVerts(ModifierData *md, } if (mesh == NULL) { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, verts_num, false, false); } else { /* Not possible to use get_mesh() in this case as we'll modify its vertices @@ -118,7 +118,7 @@ static void deformVerts(ModifierData *md, &mesh_src->vdata, CD_CLOTH_ORCO, CD_CALLOC, NULL, mesh_src->totvert); } - memcpy(layerorco, kb->data, sizeof(float[3]) * numVerts); + memcpy(layerorco, kb->data, sizeof(float[3]) * verts_num); } } diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 33a5934d2b0..9791b046e00 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -91,7 +91,7 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { CollisionModifierData *collmd = (CollisionModifierData *)md; Mesh *mesh_src; @@ -109,7 +109,7 @@ static void deformVerts(ModifierData *md, } if (mesh == NULL) { - mesh_src = MOD_deform_mesh_eval_get(ob, NULL, NULL, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ob, NULL, NULL, NULL, verts_num, false, false); } else { /* Not possible to use get_mesh() in this case as we'll modify its vertices @@ -268,9 +268,9 @@ static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md) collmd->xnew = newdataadr(fd, collmd->xnew); collmd->mfaces = newdataadr(fd, collmd->mfaces); - collmd->current_x = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_x"); - collmd->current_xnew = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_xnew"); - collmd->current_v = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_v"); + collmd->current_x = MEM_calloc_arrayN(collmd->mvert_num, sizeof(MVert), "current_x"); + collmd->current_xnew = MEM_calloc_arrayN(collmd->mvert_num, sizeof(MVert), "current_xnew"); + collmd->current_v = MEM_calloc_arrayN(collmd->mvert_num, sizeof(MVert), "current_v"); #endif collmd->x = NULL; diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c index b61419eb663..52162eaacc5 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.c +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c @@ -111,13 +111,13 @@ static void requiredDataMask(Object *UNUSED(ob), /* check individual weights for changes and cache values */ static void mesh_get_weights(MDeformVert *dvert, const int defgrp_index, - const uint numVerts, + const uint verts_num, const bool use_invert_vgroup, float *smooth_weights) { uint i; - for (i = 0; i < numVerts; i++, dvert++) { + for (i = 0; i < verts_num; i++, dvert++) { const float w = BKE_defvert_find_weight(dvert, defgrp_index); if (use_invert_vgroup == false) { @@ -170,25 +170,25 @@ static void mesh_get_boundaries(Mesh *mesh, float *smooth_weights) static void smooth_iter__simple(CorrectiveSmoothModifierData *csmd, Mesh *mesh, float (*vertexCos)[3], - uint numVerts, + uint verts_num, const float *smooth_weights, uint iterations) { const float lambda = csmd->lambda; uint i; - const uint numEdges = (uint)mesh->totedge; + const uint edges_num = (uint)mesh->totedge; const MEdge *edges = mesh->medge; float *vertex_edge_count_div; struct SmoothingData_Simple { float delta[3]; - } *smooth_data = MEM_calloc_arrayN(numVerts, sizeof(*smooth_data), __func__); + } *smooth_data = MEM_calloc_arrayN(verts_num, sizeof(*smooth_data), __func__); - vertex_edge_count_div = MEM_calloc_arrayN(numVerts, sizeof(float), __func__); + vertex_edge_count_div = MEM_calloc_arrayN(verts_num, sizeof(float), __func__); /* calculate as floats to avoid int->float conversion in #smooth_iter */ - for (i = 0; i < numEdges; i++) { + for (i = 0; i < edges_num; i++) { vertex_edge_count_div[edges[i].v1] += 1.0f; vertex_edge_count_div[edges[i].v2] += 1.0f; } @@ -196,14 +196,14 @@ static void smooth_iter__simple(CorrectiveSmoothModifierData *csmd, /* a little confusing, but we can include 'lambda' and smoothing weight * here to avoid multiplying for every iteration */ if (smooth_weights == NULL) { - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { vertex_edge_count_div[i] = lambda * (vertex_edge_count_div[i] ? (1.0f / vertex_edge_count_div[i]) : 1.0f); } } else { - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { vertex_edge_count_div[i] = smooth_weights[i] * lambda * (vertex_edge_count_div[i] ? (1.0f / vertex_edge_count_div[i]) : 1.0f); @@ -214,7 +214,7 @@ static void smooth_iter__simple(CorrectiveSmoothModifierData *csmd, /* Main Smoothing Loop */ while (iterations--) { - for (i = 0; i < numEdges; i++) { + for (i = 0; i < edges_num; i++) { struct SmoothingData_Simple *sd_v1; struct SmoothingData_Simple *sd_v2; float edge_dir[3]; @@ -228,7 +228,7 @@ static void smooth_iter__simple(CorrectiveSmoothModifierData *csmd, sub_v3_v3(sd_v2->delta, edge_dir); } - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { struct SmoothingData_Simple *sd = &smooth_data[i]; madd_v3_v3fl(vertexCos[i], sd->delta, vertex_edge_count_div[i]); /* zero for the next iteration (saves memset on entire array) */ @@ -246,12 +246,12 @@ static void smooth_iter__simple(CorrectiveSmoothModifierData *csmd, static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd, Mesh *mesh, float (*vertexCos)[3], - uint numVerts, + uint verts_num, const float *smooth_weights, uint iterations) { const float eps = FLT_EPSILON * 10.0f; - const uint numEdges = (uint)mesh->totedge; + const uint edges_num = (uint)mesh->totedge; /* NOTE: the way this smoothing method works, its approx half as strong as the simple-smooth, * and 2.0 rarely spikes, double the value for consistent behavior. */ const float lambda = csmd->lambda * 2.0f; @@ -262,11 +262,11 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd, struct SmoothingData_Weighted { float delta[3]; float edge_length_sum; - } *smooth_data = MEM_calloc_arrayN(numVerts, sizeof(*smooth_data), __func__); + } *smooth_data = MEM_calloc_arrayN(verts_num, sizeof(*smooth_data), __func__); /* calculate as floats to avoid int->float conversion in #smooth_iter */ - vertex_edge_count = MEM_calloc_arrayN(numVerts, sizeof(float), __func__); - for (i = 0; i < numEdges; i++) { + vertex_edge_count = MEM_calloc_arrayN(verts_num, sizeof(float), __func__); + for (i = 0; i < edges_num; i++) { vertex_edge_count[edges[i].v1] += 1.0f; vertex_edge_count[edges[i].v2] += 1.0f; } @@ -275,7 +275,7 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd, /* Main Smoothing Loop */ while (iterations--) { - for (i = 0; i < numEdges; i++) { + for (i = 0; i < edges_num; i++) { struct SmoothingData_Weighted *sd_v1; struct SmoothingData_Weighted *sd_v2; float edge_dir[3]; @@ -299,7 +299,7 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd, if (smooth_weights == NULL) { /* fast-path */ - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { struct SmoothingData_Weighted *sd = &smooth_data[i]; /* Divide by sum of all neighbor distances (weighted) and amount of neighbors, * (mean average). */ @@ -320,7 +320,7 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd, } } else { - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { struct SmoothingData_Weighted *sd = &smooth_data[i]; const float div = sd->edge_length_sum * vertex_edge_count[i]; if (div > eps) { @@ -340,18 +340,18 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd, static void smooth_iter(CorrectiveSmoothModifierData *csmd, Mesh *mesh, float (*vertexCos)[3], - uint numVerts, + uint verts_num, const float *smooth_weights, uint iterations) { switch (csmd->smooth_type) { case MOD_CORRECTIVESMOOTH_SMOOTH_LENGTH_WEIGHT: - smooth_iter__length_weight(csmd, mesh, vertexCos, numVerts, smooth_weights, iterations); + smooth_iter__length_weight(csmd, mesh, vertexCos, verts_num, smooth_weights, iterations); break; /* case MOD_CORRECTIVESMOOTH_SMOOTH_SIMPLE: */ default: - smooth_iter__simple(csmd, mesh, vertexCos, numVerts, smooth_weights, iterations); + smooth_iter__simple(csmd, mesh, vertexCos, verts_num, smooth_weights, iterations); break; } } @@ -361,23 +361,23 @@ static void smooth_verts(CorrectiveSmoothModifierData *csmd, MDeformVert *dvert, const int defgrp_index, float (*vertexCos)[3], - uint numVerts) + uint verts_num) { float *smooth_weights = NULL; if (dvert || (csmd->flag & MOD_CORRECTIVESMOOTH_PIN_BOUNDARY)) { - smooth_weights = MEM_malloc_arrayN(numVerts, sizeof(float), __func__); + smooth_weights = MEM_malloc_arrayN(verts_num, sizeof(float), __func__); if (dvert) { mesh_get_weights(dvert, defgrp_index, - numVerts, + verts_num, (csmd->flag & MOD_CORRECTIVESMOOTH_INVERT_VGROUP) != 0, smooth_weights); } else { - copy_vn_fl(smooth_weights, (int)numVerts, 1.0f); + copy_vn_fl(smooth_weights, (int)verts_num, 1.0f); } if (csmd->flag & MOD_CORRECTIVESMOOTH_PIN_BOUNDARY) { @@ -385,7 +385,7 @@ static void smooth_verts(CorrectiveSmoothModifierData *csmd, } } - smooth_iter(csmd, mesh, vertexCos, numVerts, smooth_weights, (uint)csmd->repeat); + smooth_iter(csmd, mesh, vertexCos, verts_num, smooth_weights, (uint)csmd->repeat); if (smooth_weights) { MEM_freeN(smooth_weights); @@ -522,29 +522,29 @@ static void calc_deltas(CorrectiveSmoothModifierData *csmd, MDeformVert *dvert, const int defgrp_index, const float (*rest_coords)[3], - uint numVerts) + uint verts_num) { float(*smooth_vertex_coords)[3] = MEM_dupallocN(rest_coords); float(*tangent_spaces)[3][3]; uint i; - tangent_spaces = MEM_calloc_arrayN(numVerts, sizeof(float[3][3]), __func__); + tangent_spaces = MEM_calloc_arrayN(verts_num, sizeof(float[3][3]), __func__); - if (csmd->delta_cache.totverts != numVerts) { + if (csmd->delta_cache.totverts != verts_num) { MEM_SAFE_FREE(csmd->delta_cache.deltas); } /* allocate deltas if they have not yet been allocated, otherwise we will just write over them */ if (!csmd->delta_cache.deltas) { - csmd->delta_cache.totverts = numVerts; - csmd->delta_cache.deltas = MEM_malloc_arrayN(numVerts, sizeof(float[3]), __func__); + csmd->delta_cache.totverts = verts_num; + csmd->delta_cache.deltas = MEM_malloc_arrayN(verts_num, sizeof(float[3]), __func__); } - smooth_verts(csmd, mesh, dvert, defgrp_index, smooth_vertex_coords, numVerts); + smooth_verts(csmd, mesh, dvert, defgrp_index, smooth_vertex_coords, verts_num); calc_tangent_spaces(mesh, smooth_vertex_coords, tangent_spaces); - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { float imat[3][3], delta[3]; #ifdef USE_TANGENT_CALC_INLINE @@ -567,7 +567,7 @@ static void correctivesmooth_modifier_do(ModifierData *md, Object *ob, Mesh *mesh, float (*vertexCos)[3], - uint numVerts, + uint verts_num, struct BMEditMesh *em) { CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md; @@ -591,7 +591,7 @@ static void correctivesmooth_modifier_do(ModifierData *md, if (DEG_is_active(depsgraph)) { BLI_assert(csmd->bind_coords == NULL); csmd->bind_coords = MEM_dupallocN(vertexCos); - csmd->bind_coords_num = numVerts; + csmd->bind_coords_num = verts_num; BLI_assert(csmd->bind_coords != NULL); /* Copy bound data to the original modifier. */ CorrectiveSmoothModifierData *csmd_orig = (CorrectiveSmoothModifierData *) @@ -605,7 +605,7 @@ static void correctivesmooth_modifier_do(ModifierData *md, } if (UNLIKELY(use_only_smooth)) { - smooth_verts(csmd, mesh, dvert, defgrp_index, vertexCos, numVerts); + smooth_verts(csmd, mesh, dvert, defgrp_index, vertexCos, verts_num); return; } @@ -616,9 +616,9 @@ static void correctivesmooth_modifier_do(ModifierData *md, /* If the number of verts has changed, the bind is invalid, so we do nothing */ if (csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) { - if (csmd->bind_coords_num != numVerts) { + if (csmd->bind_coords_num != verts_num) { BKE_modifier_set_error( - ob, md, "Bind vertex count mismatch: %u to %u", csmd->bind_coords_num, numVerts); + ob, md, "Bind vertex count mismatch: %u to %u", csmd->bind_coords_num, verts_num); goto error; } } @@ -631,16 +631,16 @@ static void correctivesmooth_modifier_do(ModifierData *md, else { uint me_numVerts = (uint)((em) ? em->bm->totvert : ((Mesh *)ob->data)->totvert); - if (me_numVerts != numVerts) { + if (me_numVerts != verts_num) { BKE_modifier_set_error( - ob, md, "Original vertex count mismatch: %u to %u", me_numVerts, numVerts); + ob, md, "Original vertex count mismatch: %u to %u", me_numVerts, verts_num); goto error; } } } /* check to see if our deltas are still valid */ - if (!csmd->delta_cache.deltas || (csmd->delta_cache.totverts != numVerts) || + if (!csmd->delta_cache.deltas || (csmd->delta_cache.totverts != verts_num) || force_delta_cache_update) { const float(*rest_coords)[3]; bool is_rest_coords_alloc = false; @@ -649,7 +649,7 @@ static void correctivesmooth_modifier_do(ModifierData *md, if (csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) { /* caller needs to do sanity check here */ - csmd->bind_coords_num = numVerts; + csmd->bind_coords_num = verts_num; rest_coords = csmd->bind_coords; } else { @@ -657,7 +657,7 @@ static void correctivesmooth_modifier_do(ModifierData *md, rest_coords = em ? BKE_editmesh_vert_coords_alloc_orco(em, &me_numVerts) : BKE_mesh_vert_coords_alloc(ob->data, &me_numVerts); - BLI_assert((uint)me_numVerts == numVerts); + BLI_assert((uint)me_numVerts == verts_num); is_rest_coords_alloc = true; } @@ -665,7 +665,7 @@ static void correctivesmooth_modifier_do(ModifierData *md, TIMEIT_START(corrective_smooth_deltas); #endif - calc_deltas(csmd, mesh, dvert, defgrp_index, rest_coords, numVerts); + calc_deltas(csmd, mesh, dvert, defgrp_index, rest_coords, verts_num); #ifdef DEBUG_TIME TIMEIT_END(corrective_smooth_deltas); @@ -677,7 +677,7 @@ static void correctivesmooth_modifier_do(ModifierData *md, if (csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) { /* this could be a check, but at this point it _must_ be valid */ - BLI_assert(csmd->bind_coords_num == numVerts && csmd->delta_cache.deltas); + BLI_assert(csmd->bind_coords_num == verts_num && csmd->delta_cache.deltas); } #ifdef DEBUG_TIME @@ -685,7 +685,7 @@ static void correctivesmooth_modifier_do(ModifierData *md, #endif /* do the actual delta mush */ - smooth_verts(csmd, mesh, dvert, defgrp_index, vertexCos, numVerts); + smooth_verts(csmd, mesh, dvert, defgrp_index, vertexCos, verts_num); { uint i; @@ -693,11 +693,11 @@ static void correctivesmooth_modifier_do(ModifierData *md, float(*tangent_spaces)[3][3]; const float scale = csmd->scale; /* calloc, since values are accumulated */ - tangent_spaces = MEM_calloc_arrayN(numVerts, sizeof(float[3][3]), __func__); + tangent_spaces = MEM_calloc_arrayN(verts_num, sizeof(float[3][3]), __func__); calc_tangent_spaces(mesh, vertexCos, tangent_spaces); - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { float delta[3]; #ifdef USE_TANGENT_CALC_INLINE @@ -727,12 +727,13 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get( + ctx->object, NULL, mesh, NULL, verts_num, false, false); correctivesmooth_modifier_do( - md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, (uint)numVerts, NULL); + md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, (uint)verts_num, NULL); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -744,10 +745,10 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, numVerts, false, false); + ctx->object, editData, mesh, NULL, verts_num, false, false); /* TODO(Campbell): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { @@ -755,7 +756,7 @@ static void deformVertsEM(ModifierData *md, } correctivesmooth_modifier_do( - md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, (uint)numVerts, editData); + md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, (uint)verts_num, editData); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index 5b22b933823..a82b999f4dc 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -104,14 +104,14 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { CurveModifierData *cmd = (CurveModifierData *)md; Mesh *mesh_src = NULL; if (ctx->object->type == OB_MESH && cmd->name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); } struct MDeformVert *dvert = NULL; @@ -124,7 +124,7 @@ static void deformVerts(ModifierData *md, BKE_curve_deform_coords(cmd->object, ctx->object, vertexCos, - numVerts, + verts_num, dvert, defgrp_index, cmd->flag, @@ -140,10 +140,10 @@ static void deformVertsEM(ModifierData *md, BMEditMesh *em, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { if (mesh != NULL) { - deformVerts(md, ctx, mesh, vertexCos, numVerts); + deformVerts(md, ctx, mesh, vertexCos, verts_num); return; } @@ -162,7 +162,7 @@ static void deformVertsEM(ModifierData *md, BKE_curve_deform_coords_with_editmesh(cmd->object, ctx->object, vertexCos, - numVerts, + verts_num, defgrp_index, cmd->flag, cmd->defaxis - 1, @@ -172,7 +172,7 @@ static void deformVertsEM(ModifierData *md, BKE_curve_deform_coords(cmd->object, ctx->object, vertexCos, - numVerts, + verts_num, NULL, defgrp_index, cmd->flag, diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 2f35ffb3e18..ca48d4fedd8 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -269,7 +269,7 @@ static void displaceModifier_do(DisplaceModifierData *dmd, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - const int numVerts) + const int verts_num) { Object *ob = ctx->object; MVert *mvert; @@ -299,7 +299,7 @@ static void displaceModifier_do(DisplaceModifierData *dmd, Tex *tex_target = dmd->texture; if (tex_target != NULL) { - tex_co = MEM_calloc_arrayN((size_t)numVerts, sizeof(*tex_co), "displaceModifier_do tex_co"); + tex_co = MEM_calloc_arrayN((size_t)verts_num, sizeof(*tex_co), "displaceModifier_do tex_co"); MOD_get_texture_coords((MappingInfoModifierData *)dmd, ctx, ob, mesh, vertexCos, tex_co); MOD_init_texture((MappingInfoModifierData *)dmd, ctx); @@ -319,9 +319,9 @@ static void displaceModifier_do(DisplaceModifierData *dmd, } clnors = CustomData_get_layer(ldata, CD_NORMAL); - vert_clnors = MEM_malloc_arrayN(numVerts, sizeof(*vert_clnors), __func__); + vert_clnors = MEM_malloc_arrayN(verts_num, sizeof(*vert_clnors), __func__); BKE_mesh_normals_loop_to_vertex( - numVerts, mesh->mloop, mesh->totloop, (const float(*)[3])clnors, vert_clnors); + verts_num, mesh->mloop, mesh->totloop, (const float(*)[3])clnors, vert_clnors); } else { direction = MOD_DISP_DIR_NOR; @@ -355,8 +355,8 @@ static void displaceModifier_do(DisplaceModifierData *dmd, } TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); - settings.use_threading = (numVerts > 512); - BLI_task_parallel_range(0, numVerts, &data, displaceModifier_do_task, &settings); + settings.use_threading = (verts_num > 512); + BLI_task_parallel_range(0, verts_num, &data, displaceModifier_do_task, &settings); if (data.pool != NULL) { BKE_image_pool_free(data.pool); @@ -375,11 +375,12 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get( + ctx->object, NULL, mesh, NULL, verts_num, false, false); - displaceModifier_do((DisplaceModifierData *)md, ctx, mesh_src, vertexCos, numVerts); + displaceModifier_do((DisplaceModifierData *)md, ctx, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -391,17 +392,17 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, numVerts, false, false); + ctx->object, editData, mesh, NULL, verts_num, false, false); /* TODO(Campbell): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } - displaceModifier_do((DisplaceModifierData *)md, ctx, mesh_src, vertexCos, numVerts); + displaceModifier_do((DisplaceModifierData *)md, ctx, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 33b090b9577..b3bcd181de9 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -279,12 +279,12 @@ static void remap_faces_3_6_9_12(Mesh *mesh, } static void remap_uvs_3_6_9_12( - Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3) + Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3) { MTFace *mf, *df1, *df2, *df3; int l; - for (l = 0; l < numlayer; l++) { + for (l = 0; l < layers_num; l++) { mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l); df1 = mf + cur; df2 = df1 + 1; @@ -339,12 +339,12 @@ static void remap_faces_5_10(Mesh *mesh, } static void remap_uvs_5_10( - Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3) + Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3) { MTFace *mf, *df1, *df2; int l; - for (l = 0; l < numlayer; l++) { + for (l = 0; l < layers_num; l++) { mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l); df1 = mf + cur; df2 = df1 + 1; @@ -411,12 +411,12 @@ static void remap_faces_15(Mesh *mesh, } static void remap_uvs_15( - Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3) + Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3) { MTFace *mf, *df1, *df2, *df3, *df4; int l; - for (l = 0; l < numlayer; l++) { + for (l = 0; l < layers_num; l++) { mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l); df1 = mf + cur; df2 = df1 + 1; @@ -487,12 +487,12 @@ static void remap_faces_7_11_13_14(Mesh *mesh, } static void remap_uvs_7_11_13_14( - Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2, int c3) + Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2, int c3) { MTFace *mf, *df1, *df2, *df3; int l; - for (l = 0; l < numlayer; l++) { + for (l = 0; l < layers_num; l++) { mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l); df1 = mf + cur; df2 = df1 + 1; @@ -547,12 +547,12 @@ static void remap_faces_19_21_22(Mesh *mesh, } static void remap_uvs_19_21_22( - Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2) + Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2) { MTFace *mf, *df1, *df2; int l; - for (l = 0; l < numlayer; l++) { + for (l = 0; l < layers_num; l++) { mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l); df1 = mf + cur; df2 = df1 + 1; @@ -609,12 +609,12 @@ static void remap_faces_23(Mesh *mesh, } static void remap_uvs_23( - Mesh *mesh, Mesh *split, int numlayer, int i, int cur, int c0, int c1, int c2) + Mesh *mesh, Mesh *split, int layers_num, int i, int cur, int c0, int c1, int c2) { MTFace *mf, *df1, *df2; int l; - for (l = 0; l < numlayer; l++) { + for (l = 0; l < layers_num; l++) { mf = CustomData_get_layer_n(&split->fdata, CD_MTFACE, l); df1 = mf + cur; df2 = df1 + 1; @@ -653,7 +653,7 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh) int *fs, totesplit = 0, totfsplit = 0, curdupface = 0; int i, v1, v2, v3, v4, esplit, v[4] = {0, 0, 0, 0}, /* To quite gcc barking... */ uv[4] = {0, 0, 0, 0}; /* To quite gcc barking... */ - int numlayer; + int layers_num; uint ed_v1, ed_v2; edgehash = BLI_edgehash_new(__func__); @@ -728,7 +728,7 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh) split_m = BKE_mesh_new_nomain_from_template(mesh, totesplit, 0, totface + totfsplit, 0, 0); - numlayer = CustomData_number_of_layers(&split_m->fdata, CD_MTFACE); + layers_num = CustomData_number_of_layers(&split_m->fdata, CD_MTFACE); /* copy new faces & verts (is it really this painful with custom data??) */ for (i = 0; i < totvert; i++) { @@ -814,23 +814,23 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh) case 12: remap_faces_3_6_9_12( mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) { - remap_uvs_3_6_9_12(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + if (layers_num) { + remap_uvs_3_6_9_12(mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2], uv[3]); } break; case 5: case 10: remap_faces_5_10( mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) { - remap_uvs_5_10(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + if (layers_num) { + remap_uvs_5_10(mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2], uv[3]); } break; case 15: remap_faces_15( mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) { - remap_uvs_15(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + if (layers_num) { + remap_uvs_15(mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2], uv[3]); } break; case 7: @@ -839,8 +839,9 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh) case 14: remap_faces_7_11_13_14( mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) { - remap_uvs_7_11_13_14(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + if (layers_num) { + remap_uvs_7_11_13_14( + mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2], uv[3]); } break; case 19: @@ -848,15 +849,15 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh) case 22: remap_faces_19_21_22( mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]); - if (numlayer) { - remap_uvs_19_21_22(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2]); + if (layers_num) { + remap_uvs_19_21_22(mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2]); } break; case 23: remap_faces_23( mesh, split_m, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]); - if (numlayer) { - remap_uvs_23(mesh, split_m, numlayer, i, curdupface, uv[0], uv[1], uv[2]); + if (layers_num) { + remap_uvs_23(mesh, split_m, layers_num, i, curdupface, uv[0], uv[1], uv[2]); } break; case 0: diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 513000e3ad6..1000bbf45d6 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -152,14 +152,14 @@ struct HookData_cb { bool invert_vgroup; }; -static BLI_bitmap *hook_index_array_to_bitmap(HookModifierData *hmd, const int numVerts) +static BLI_bitmap *hook_index_array_to_bitmap(HookModifierData *hmd, const int verts_num) { - BLI_bitmap *indexar_used = BLI_BITMAP_NEW(numVerts, __func__); + BLI_bitmap *indexar_used = BLI_BITMAP_NEW(verts_num, __func__); int i; int *index_pt; - for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) { + for (i = 0, index_pt = hmd->indexar; i < hmd->indexar_num; i++, index_pt++) { const int j = *index_pt; - if (j < numVerts) { + if (j < verts_num) { BLI_BITMAP_ENABLE(indexar_used, i); } } @@ -275,7 +275,7 @@ static void deformVerts_do(HookModifierData *hmd, Mesh *mesh, BMEditMesh *em, float (*vertexCos)[3], - int numVerts) + int verts_num) { Object *ob_target = hmd->object; bPoseChannel *pchan = BKE_pose_channel_find_name(ob_target->pose, hmd->subtarget); @@ -365,15 +365,15 @@ static void deformVerts_do(HookModifierData *hmd, const int *origindex_ar; /* if mesh is present and has original index data, use it */ if (mesh && (origindex_ar = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX))) { - int numVerts_orig = numVerts; + int verts_orig_num = verts_num; if (ob->type == OB_MESH) { const Mesh *me_orig = ob->data; - numVerts_orig = me_orig->totvert; + verts_orig_num = me_orig->totvert; } - BLI_bitmap *indexar_used = hook_index_array_to_bitmap(hmd, numVerts_orig); - for (i = 0; i < numVerts; i++) { + BLI_bitmap *indexar_used = hook_index_array_to_bitmap(hmd, verts_orig_num); + for (i = 0; i < verts_num; i++) { int i_orig = origindex_ar[i]; - BLI_assert(i_orig < numVerts_orig); + BLI_assert(i_orig < verts_orig_num); if (BLI_BITMAP_TEST(indexar_used, i_orig)) { hook_co_apply(&hd, i, dvert ? &dvert[i] : NULL); } @@ -382,8 +382,8 @@ static void deformVerts_do(HookModifierData *hmd, } else { /* missing mesh or ORIGINDEX */ if ((em != NULL) && (hd.defgrp_index != -1)) { - BLI_assert(em->bm->totvert == numVerts); - BLI_bitmap *indexar_used = hook_index_array_to_bitmap(hmd, numVerts); + BLI_assert(em->bm->totvert == verts_num); + BLI_bitmap *indexar_used = hook_index_array_to_bitmap(hmd, verts_num); BMIter iter; BMVert *v; BM_ITER_MESH_INDEX (v, &iter, em->bm, BM_VERTS_OF_MESH, i) { @@ -395,9 +395,9 @@ static void deformVerts_do(HookModifierData *hmd, MEM_freeN(indexar_used); } else { - for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) { + for (i = 0, index_pt = hmd->indexar; i < hmd->indexar_num; i++, index_pt++) { const int j = *index_pt; - if (j < numVerts) { + if (j < verts_num) { hook_co_apply(&hd, j, dvert ? &dvert[j] : NULL); } } @@ -406,7 +406,7 @@ static void deformVerts_do(HookModifierData *hmd, } else if (hd.defgrp_index != -1) { /* vertex group hook */ if (em != NULL) { - BLI_assert(em->bm->totvert == numVerts); + BLI_assert(em->bm->totvert == verts_num); BMIter iter; BMVert *v; BM_ITER_MESH_INDEX (v, &iter, em->bm, BM_VERTS_OF_MESH, i) { @@ -416,7 +416,7 @@ static void deformVerts_do(HookModifierData *hmd, } else { BLI_assert(dvert != NULL); - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { hook_co_apply(&hd, i, &dvert[i]); } } @@ -427,12 +427,13 @@ static void deformVerts(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { HookModifierData *hmd = (HookModifierData *)md; - Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get( + ctx->object, NULL, mesh, NULL, verts_num, false, false); - deformVerts_do(hmd, ctx, ctx->object, mesh_src, NULL, vertexCos, numVerts); + deformVerts_do(hmd, ctx, ctx->object, mesh_src, NULL, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -444,11 +445,11 @@ static void deformVertsEM(struct ModifierData *md, struct BMEditMesh *editData, struct Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { HookModifierData *hmd = (HookModifierData *)md; - deformVerts_do(hmd, ctx, ctx->object, mesh, mesh ? NULL : editData, vertexCos, numVerts); + deformVerts_do(hmd, ctx, ctx->object, mesh, mesh ? NULL : editData, vertexCos, verts_num); } static void panel_draw(const bContext *UNUSED(C), Panel *panel) @@ -526,7 +527,7 @@ static void blendWrite(BlendWriter *writer, const ModifierData *md) BKE_curvemapping_blend_write(writer, hmd->curfalloff); } - BLO_write_int32_array(writer, hmd->totindex, hmd->indexar); + BLO_write_int32_array(writer, hmd->indexar_num, hmd->indexar); } static void blendRead(BlendDataReader *reader, ModifierData *md) @@ -538,7 +539,7 @@ static void blendRead(BlendDataReader *reader, ModifierData *md) BKE_curvemapping_blend_read(reader, hmd->curfalloff); } - BLO_read_int32_array(reader, hmd->totindex, &hmd->indexar); + BLO_read_int32_array(reader, hmd->indexar_num, &hmd->indexar); } ModifierTypeInfo modifierType_Hook = { diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c index d5f3902379d..239cb7f5a5a 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.c +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c @@ -58,10 +58,10 @@ enum { typedef struct LaplacianSystem { bool is_matrix_computed; bool has_solution; - int total_verts; - int total_edges; - int total_tris; - int total_anchors; + int verts_num; + int edges_num; + int tris_num; + int anchors_num; int repeat; char anchor_grp_name[64]; /* Vertex Group name */ float (*co)[3]; /* Original vertex coordinates */ @@ -84,20 +84,20 @@ static LaplacianSystem *newLaplacianSystem(void) sys->is_matrix_computed = false; sys->has_solution = false; - sys->total_verts = 0; - sys->total_edges = 0; - sys->total_anchors = 0; - sys->total_tris = 0; + sys->verts_num = 0; + sys->edges_num = 0; + sys->anchors_num = 0; + sys->tris_num = 0; sys->repeat = 1; sys->anchor_grp_name[0] = '\0'; return sys; } -static LaplacianSystem *initLaplacianSystem(int totalVerts, - int totalEdges, - int totalTris, - int totalAnchors, +static LaplacianSystem *initLaplacianSystem(int verts_num, + int edges_num, + int tris_num, + int anchors_num, const char defgrpName[64], int iterations) { @@ -105,18 +105,18 @@ static LaplacianSystem *initLaplacianSystem(int totalVerts, sys->is_matrix_computed = false; sys->has_solution = false; - sys->total_verts = totalVerts; - sys->total_edges = totalEdges; - sys->total_tris = totalTris; - sys->total_anchors = totalAnchors; + sys->verts_num = verts_num; + sys->edges_num = edges_num; + sys->tris_num = tris_num; + sys->anchors_num = anchors_num; sys->repeat = iterations; BLI_strncpy(sys->anchor_grp_name, defgrpName, sizeof(sys->anchor_grp_name)); - sys->co = MEM_malloc_arrayN(totalVerts, sizeof(float[3]), "DeformCoordinates"); - sys->no = MEM_calloc_arrayN(totalVerts, sizeof(float[3]), "DeformNormals"); - sys->delta = MEM_calloc_arrayN(totalVerts, sizeof(float[3]), "DeformDeltas"); - sys->tris = MEM_malloc_arrayN(totalTris, sizeof(int[3]), "DeformFaces"); - sys->index_anchors = MEM_malloc_arrayN((totalAnchors), sizeof(int), "DeformAnchors"); - sys->unit_verts = MEM_calloc_arrayN(totalVerts, sizeof(int), "DeformUnitVerts"); + sys->co = MEM_malloc_arrayN(verts_num, sizeof(float[3]), "DeformCoordinates"); + sys->no = MEM_calloc_arrayN(verts_num, sizeof(float[3]), "DeformNormals"); + sys->delta = MEM_calloc_arrayN(verts_num, sizeof(float[3]), "DeformDeltas"); + sys->tris = MEM_malloc_arrayN(tris_num, sizeof(int[3]), "DeformFaces"); + sys->index_anchors = MEM_malloc_arrayN((anchors_num), sizeof(int), "DeformAnchors"); + sys->unit_verts = MEM_calloc_arrayN(verts_num, sizeof(int), "DeformUnitVerts"); return sys; } @@ -146,7 +146,7 @@ static void createFaceRingMap(const int mvert_tot, MeshElemMap **r_map, int **r_indices) { - int i, j, totalr = 0; + int i, j, indices_num = 0; int *indices, *index_iter; MeshElemMap *map = MEM_calloc_arrayN(mvert_tot, sizeof(MeshElemMap), "DeformRingMap"); const MLoopTri *mlt; @@ -156,10 +156,10 @@ static void createFaceRingMap(const int mvert_tot, for (j = 0; j < 3; j++) { const uint v_index = mloop[mlt->tri[j]].v; map[v_index].count++; - totalr++; + indices_num++; } } - indices = MEM_calloc_arrayN(totalr, sizeof(int), "DeformRingIndex"); + indices = MEM_calloc_arrayN(indices_num, sizeof(int), "DeformRingIndex"); index_iter = indices; for (i = 0; i < mvert_tot; i++) { map[i].indices = index_iter; @@ -184,7 +184,7 @@ static void createVertRingMap(const int mvert_tot, int **r_indices) { MeshElemMap *map = MEM_calloc_arrayN(mvert_tot, sizeof(MeshElemMap), "DeformNeighborsMap"); - int i, vid[2], totalr = 0; + int i, vid[2], indices_num = 0; int *indices, *index_iter; const MEdge *me; @@ -193,9 +193,9 @@ static void createVertRingMap(const int mvert_tot, vid[1] = me->v2; map[vid[0]].count++; map[vid[1]].count++; - totalr += 2; + indices_num += 2; } - indices = MEM_calloc_arrayN(totalr, sizeof(int), "DeformNeighborsIndex"); + indices = MEM_calloc_arrayN(indices_num, sizeof(int), "DeformNeighborsIndex"); index_iter = indices; for (i = 0; i < mvert_tot; i++) { map[i].indices = index_iter; @@ -253,7 +253,7 @@ static void initLaplacianMatrix(LaplacianSystem *sys) int i = 3, j, ti; int idv[3]; - for (ti = 0; ti < sys->total_tris; ti++) { + for (ti = 0; ti < sys->tris_num; ti++) { const uint *vidt = sys->tris[ti]; const float *co[3]; @@ -305,7 +305,7 @@ static void computeImplictRotations(LaplacianSystem *sys) float minj, mjt, qj[3], vj[3]; int i, j, ln; - for (i = 0; i < sys->total_verts; i++) { + for (i = 0; i < sys->verts_num; i++) { normalize_v3(sys->no[i]); vidn = sys->ringv_map[i].indices; ln = sys->ringv_map[i].count; @@ -329,10 +329,10 @@ static void rotateDifferentialCoordinates(LaplacianSystem *sys) float alpha, beta, gamma; float pj[3], ni[3], di[3]; float uij[3], dun[3], e2[3], pi[3], fni[3], vn[3][3]; - int i, j, num_fni, k, fi; + int i, j, fidn_num, k, fi; int *fidn; - for (i = 0; i < sys->total_verts; i++) { + for (i = 0; i < sys->verts_num; i++) { copy_v3_v3(pi, sys->co[i]); copy_v3_v3(ni, sys->no[i]); k = sys->unit_verts[i]; @@ -351,8 +351,8 @@ static void rotateDifferentialCoordinates(LaplacianSystem *sys) pi[1] = EIG_linear_solver_variable_get(sys->context, 1, i); pi[2] = EIG_linear_solver_variable_get(sys->context, 2, i); zero_v3(ni); - num_fni = sys->ringf_map[i].count; - for (fi = 0; fi < num_fni; fi++) { + fidn_num = sys->ringf_map[i].count; + for (fi = 0; fi < fidn_num; fi++) { const uint *vin; fidn = sys->ringf_map[i].indices; vin = sys->tris[fidn[fi]]; @@ -395,8 +395,8 @@ static void rotateDifferentialCoordinates(LaplacianSystem *sys) static void laplacianDeformPreview(LaplacianSystem *sys, float (*vertexCos)[3]) { int vid, i, j, n, na; - n = sys->total_verts; - na = sys->total_anchors; + n = sys->verts_num; + na = sys->anchors_num; if (!sys->is_matrix_computed) { sys->context = EIG_linear_least_squares_solver_new(n + na, n, 3); @@ -447,7 +447,7 @@ static void laplacianDeformPreview(LaplacianSystem *sys, float (*vertexCos)[3]) } } if (sys->has_solution) { - for (vid = 0; vid < sys->total_verts; vid++) { + for (vid = 0; vid < sys->verts_num; vid++) { vertexCos[vid][0] = EIG_linear_solver_variable_get(sys->context, 0, vid); vertexCos[vid][1] = EIG_linear_solver_variable_get(sys->context, 1, vid); vertexCos[vid][2] = EIG_linear_solver_variable_get(sys->context, 2, vid); @@ -493,7 +493,7 @@ static void laplacianDeformPreview(LaplacianSystem *sys, float (*vertexCos)[3]) } } if (sys->has_solution) { - for (vid = 0; vid < sys->total_verts; vid++) { + for (vid = 0; vid < sys->verts_num; vid++) { vertexCos[vid][0] = EIG_linear_solver_variable_get(sys->context, 0, vid); vertexCos[vid][1] = EIG_linear_solver_variable_get(sys->context, 1, vid); vertexCos[vid][2] = EIG_linear_solver_variable_get(sys->context, 2, vid); @@ -520,11 +520,11 @@ static bool isValidVertexGroup(LaplacianDeformModifierData *lmd, Object *ob, Mes } static void initSystem( - LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int numVerts) + LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int verts_num) { int i; int defgrp_index; - int total_anchors; + int anchors_num; float wpaint; MDeformVert *dvert = NULL; MDeformVert *dv = NULL; @@ -532,18 +532,18 @@ static void initSystem( const bool invert_vgroup = (lmd->flag & MOD_LAPLACIANDEFORM_INVERT_VGROUP) != 0; if (isValidVertexGroup(lmd, ob, mesh)) { - int *index_anchors = MEM_malloc_arrayN(numVerts, sizeof(int), __func__); /* over-alloc */ + int *index_anchors = MEM_malloc_arrayN(verts_num, sizeof(int), __func__); /* over-alloc */ const MLoopTri *mlooptri; const MLoop *mloop; STACK_DECLARE(index_anchors); - STACK_INIT(index_anchors, numVerts); + STACK_INIT(index_anchors, verts_num); MOD_get_vgroup(ob, mesh, lmd->anchor_grp_name, &dvert, &defgrp_index); BLI_assert(dvert != NULL); dv = dvert; - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { wpaint = invert_vgroup ? 1.0f - BKE_defvert_find_weight(dv, defgrp_index) : BKE_defvert_find_weight(dv, defgrp_index); dv++; @@ -552,20 +552,20 @@ static void initSystem( } } - total_anchors = STACK_SIZE(index_anchors); - lmd->cache_system = initLaplacianSystem(numVerts, + anchors_num = STACK_SIZE(index_anchors); + lmd->cache_system = initLaplacianSystem(verts_num, mesh->totedge, BKE_mesh_runtime_looptri_len(mesh), - total_anchors, + anchors_num, lmd->anchor_grp_name, lmd->repeat); sys = (LaplacianSystem *)lmd->cache_system; - memcpy(sys->index_anchors, index_anchors, sizeof(int) * total_anchors); - memcpy(sys->co, vertexCos, sizeof(float[3]) * numVerts); + memcpy(sys->index_anchors, index_anchors, sizeof(int) * anchors_num); + memcpy(sys->co, vertexCos, sizeof(float[3]) * verts_num); MEM_freeN(index_anchors); - lmd->vertexco = MEM_malloc_arrayN(numVerts, sizeof(float[3]), "ModDeformCoordinates"); - memcpy(lmd->vertexco, vertexCos, sizeof(float[3]) * numVerts); - lmd->total_verts = numVerts; + lmd->vertexco = MEM_malloc_arrayN(verts_num, sizeof(float[3]), "ModDeformCoordinates"); + memcpy(lmd->vertexco, vertexCos, sizeof(float[3]) * verts_num); + lmd->verts_num = verts_num; createFaceRingMap(mesh->totvert, BKE_mesh_runtime_looptri_ensure(mesh), @@ -579,7 +579,7 @@ static void initSystem( mlooptri = BKE_mesh_runtime_looptri_ensure(mesh); mloop = mesh->mloop; - for (i = 0; i < sys->total_tris; i++) { + for (i = 0; i < sys->tris_num; i++) { sys->tris[i][0] = mloop[mlooptri[i].tri[0]].v; sys->tris[i][1] = mloop[mlooptri[i].tri[1]].v; sys->tris[i][2] = mloop[mlooptri[i].tri[2]].v; @@ -590,21 +590,21 @@ static void initSystem( static int isSystemDifferent(LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh, - int numVerts) + int verts_num) { int i; int defgrp_index; - int total_anchors = 0; + int anchors_num = 0; float wpaint; MDeformVert *dvert = NULL; MDeformVert *dv = NULL; LaplacianSystem *sys = (LaplacianSystem *)lmd->cache_system; const bool invert_vgroup = (lmd->flag & MOD_LAPLACIANDEFORM_INVERT_VGROUP) != 0; - if (sys->total_verts != numVerts) { + if (sys->verts_num != verts_num) { return LAPDEFORM_SYSTEM_CHANGE_VERTEXES; } - if (sys->total_edges != mesh->totedge) { + if (sys->edges_num != mesh->totedge) { return LAPDEFORM_SYSTEM_CHANGE_EDGES; } if (!STREQ(lmd->anchor_grp_name, sys->anchor_grp_name)) { @@ -615,15 +615,15 @@ static int isSystemDifferent(LaplacianDeformModifierData *lmd, return LAPDEFORM_SYSTEM_CHANGE_NOT_VALID_GROUP; } dv = dvert; - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { wpaint = invert_vgroup ? 1.0f - BKE_defvert_find_weight(dv, defgrp_index) : BKE_defvert_find_weight(dv, defgrp_index); dv++; if (wpaint > 0.0f) { - total_anchors++; + anchors_num++; } } - if (sys->total_anchors != total_anchors) { + if (sys->anchors_num != anchors_num) { return LAPDEFORM_SYSTEM_ONLY_CHANGE_ANCHORS; } @@ -631,7 +631,7 @@ static int isSystemDifferent(LaplacianDeformModifierData *lmd, } static void LaplacianDeformModifier_do( - LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int numVerts) + LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int verts_num) { float(*filevertexCos)[3]; int sysdif; @@ -643,22 +643,22 @@ static void LaplacianDeformModifier_do( deleteLaplacianSystem(sys); lmd->cache_system = NULL; } - lmd->total_verts = 0; + lmd->verts_num = 0; MEM_SAFE_FREE(lmd->vertexco); return; } if (lmd->cache_system) { - sysdif = isSystemDifferent(lmd, ob, mesh, numVerts); + sysdif = isSystemDifferent(lmd, ob, mesh, verts_num); sys = lmd->cache_system; if (sysdif) { if (ELEM(sysdif, LAPDEFORM_SYSTEM_ONLY_CHANGE_ANCHORS, LAPDEFORM_SYSTEM_ONLY_CHANGE_GROUP)) { - filevertexCos = MEM_malloc_arrayN(numVerts, sizeof(float[3]), "TempModDeformCoordinates"); - memcpy(filevertexCos, lmd->vertexco, sizeof(float[3]) * numVerts); + filevertexCos = MEM_malloc_arrayN(verts_num, sizeof(float[3]), "TempModDeformCoordinates"); + memcpy(filevertexCos, lmd->vertexco, sizeof(float[3]) * verts_num); MEM_SAFE_FREE(lmd->vertexco); - lmd->total_verts = 0; + lmd->verts_num = 0; deleteLaplacianSystem(sys); lmd->cache_system = NULL; - initSystem(lmd, ob, mesh, filevertexCos, numVerts); + initSystem(lmd, ob, mesh, filevertexCos, verts_num); sys = lmd->cache_system; /* may have been reallocated */ MEM_SAFE_FREE(filevertexCos); if (sys) { @@ -668,11 +668,11 @@ static void LaplacianDeformModifier_do( else { if (sysdif == LAPDEFORM_SYSTEM_CHANGE_VERTEXES) { BKE_modifier_set_error( - ob, &lmd->modifier, "Vertices changed from %d to %d", lmd->total_verts, numVerts); + ob, &lmd->modifier, "Vertices changed from %d to %d", lmd->verts_num, verts_num); } else if (sysdif == LAPDEFORM_SYSTEM_CHANGE_EDGES) { BKE_modifier_set_error( - ob, &lmd->modifier, "Edges changed from %d to %d", sys->total_edges, mesh->totedge); + ob, &lmd->modifier, "Edges changed from %d to %d", sys->edges_num, mesh->totedge); } else if (sysdif == LAPDEFORM_SYSTEM_CHANGE_NOT_VALID_GROUP) { BKE_modifier_set_error(ob, @@ -695,18 +695,18 @@ static void LaplacianDeformModifier_do( lmd->anchor_grp_name); lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND; } - else if (lmd->total_verts > 0 && lmd->total_verts == numVerts) { - filevertexCos = MEM_malloc_arrayN(numVerts, sizeof(float[3]), "TempDeformCoordinates"); - memcpy(filevertexCos, lmd->vertexco, sizeof(float[3]) * numVerts); + else if (lmd->verts_num > 0 && lmd->verts_num == verts_num) { + filevertexCos = MEM_malloc_arrayN(verts_num, sizeof(float[3]), "TempDeformCoordinates"); + memcpy(filevertexCos, lmd->vertexco, sizeof(float[3]) * verts_num); MEM_SAFE_FREE(lmd->vertexco); - lmd->total_verts = 0; - initSystem(lmd, ob, mesh, filevertexCos, numVerts); + lmd->verts_num = 0; + initSystem(lmd, ob, mesh, filevertexCos, verts_num); sys = lmd->cache_system; MEM_SAFE_FREE(filevertexCos); laplacianDeformPreview(sys, vertexCos); } else { - initSystem(lmd, ob, mesh, vertexCos, numVerts); + initSystem(lmd, ob, mesh, vertexCos, verts_num); sys = lmd->cache_system; laplacianDeformPreview(sys, vertexCos); } @@ -762,12 +762,13 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get( + ctx->object, NULL, mesh, NULL, verts_num, false, false); LaplacianDeformModifier_do( - (LaplacianDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); + (LaplacianDeformModifierData *)md, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -779,10 +780,10 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, numVerts, false, false); + ctx->object, editData, mesh, NULL, verts_num, false, false); /* TODO(Campbell): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { @@ -790,7 +791,7 @@ static void deformVertsEM(ModifierData *md, } LaplacianDeformModifier_do( - (LaplacianDeformModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); + (LaplacianDeformModifierData *)md, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -805,7 +806,7 @@ static void freeData(ModifierData *md) deleteLaplacianSystem(sys); } MEM_SAFE_FREE(lmd->vertexco); - lmd->total_verts = 0; + lmd->verts_num = 0; } static void panel_draw(const bContext *UNUSED(C), Panel *panel) @@ -846,14 +847,14 @@ static void blendWrite(BlendWriter *writer, const ModifierData *md) { LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md; - BLO_write_float3_array(writer, lmd->total_verts, lmd->vertexco); + BLO_write_float3_array(writer, lmd->verts_num, lmd->vertexco); } static void blendRead(BlendDataReader *reader, ModifierData *md) { LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md; - BLO_read_float3_array(reader, lmd->total_verts, &lmd->vertexco); + BLO_read_float3_array(reader, lmd->verts_num, &lmd->vertexco); lmd->cache_system = NULL; } diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c index effe2a5af90..11abe9a4d0a 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c @@ -45,12 +45,12 @@ struct BLaplacianSystem { float *ring_areas; /* Total area per ring. */ float *vlengths; /* Total sum of lengths(edges) per vertex. */ float *vweights; /* Total sum of weights per vertex. */ - int numEdges; /* Number of edges. */ - int numLoops; /* Number of edges. */ - int numPolys; /* Number of faces. */ - int numVerts; /* Number of verts. */ - short *numNeFa; /* Number of neighbors faces around vertex. */ - short *numNeEd; /* Number of neighbors Edges around vertex. */ + int edges_num; /* Number of edges. */ + int loops_num; /* Number of edges. */ + int polys_num; /* Number of faces. */ + int verts_num; /* Number of verts. */ + short *ne_fa_num; /* Number of neighbors faces around vertex. */ + short *ne_ed_num; /* Number of neighbors Edges around vertex. */ bool *zerola; /* Is zero area or length. */ /* Pointers to data. */ @@ -71,7 +71,7 @@ static bool is_disabled(const struct Scene *scene, ModifierData *md, bool useRen static float compute_volume(const float center[3], float (*vertexCos)[3], const MPoly *mpoly, - int numPolys, + int polys_num, const MLoop *mloop); static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numPolys, @@ -89,8 +89,8 @@ static void delete_laplacian_system(LaplacianSystem *sys) { MEM_SAFE_FREE(sys->eweights); MEM_SAFE_FREE(sys->fweights); - MEM_SAFE_FREE(sys->numNeEd); - MEM_SAFE_FREE(sys->numNeFa); + MEM_SAFE_FREE(sys->ne_ed_num); + MEM_SAFE_FREE(sys->ne_fa_num); MEM_SAFE_FREE(sys->ring_areas); MEM_SAFE_FREE(sys->vlengths); MEM_SAFE_FREE(sys->vweights); @@ -108,14 +108,14 @@ static void delete_laplacian_system(LaplacianSystem *sys) static void memset_laplacian_system(LaplacianSystem *sys, int val) { - memset(sys->eweights, val, sizeof(float) * sys->numEdges); - memset(sys->fweights, val, sizeof(float[3]) * sys->numLoops); - memset(sys->numNeEd, val, sizeof(short) * sys->numVerts); - memset(sys->numNeFa, val, sizeof(short) * sys->numVerts); - memset(sys->ring_areas, val, sizeof(float) * sys->numVerts); - memset(sys->vlengths, val, sizeof(float) * sys->numVerts); - memset(sys->vweights, val, sizeof(float) * sys->numVerts); - memset(sys->zerola, val, sizeof(bool) * sys->numVerts); + memset(sys->eweights, val, sizeof(float) * sys->edges_num); + memset(sys->fweights, val, sizeof(float[3]) * sys->loops_num); + memset(sys->ne_ed_num, val, sizeof(short) * sys->verts_num); + memset(sys->ne_fa_num, val, sizeof(short) * sys->verts_num); + memset(sys->ring_areas, val, sizeof(float) * sys->verts_num); + memset(sys->vlengths, val, sizeof(float) * sys->verts_num); + memset(sys->vweights, val, sizeof(float) * sys->verts_num); + memset(sys->zerola, val, sizeof(bool) * sys->verts_num); } static LaplacianSystem *init_laplacian_system(int a_numEdges, @@ -125,19 +125,19 @@ static LaplacianSystem *init_laplacian_system(int a_numEdges, { LaplacianSystem *sys; sys = MEM_callocN(sizeof(LaplacianSystem), "ModLaplSmoothSystem"); - sys->numEdges = a_numEdges; - sys->numPolys = a_numPolys; - sys->numLoops = a_numLoops; - sys->numVerts = a_numVerts; - - sys->eweights = MEM_calloc_arrayN(sys->numEdges, sizeof(float), __func__); - sys->fweights = MEM_calloc_arrayN(sys->numLoops, sizeof(float[3]), __func__); - sys->numNeEd = MEM_calloc_arrayN(sys->numVerts, sizeof(short), __func__); - sys->numNeFa = MEM_calloc_arrayN(sys->numVerts, sizeof(short), __func__); - sys->ring_areas = MEM_calloc_arrayN(sys->numVerts, sizeof(float), __func__); - sys->vlengths = MEM_calloc_arrayN(sys->numVerts, sizeof(float), __func__); - sys->vweights = MEM_calloc_arrayN(sys->numVerts, sizeof(float), __func__); - sys->zerola = MEM_calloc_arrayN(sys->numVerts, sizeof(bool), __func__); + sys->edges_num = a_numEdges; + sys->polys_num = a_numPolys; + sys->loops_num = a_numLoops; + sys->verts_num = a_numVerts; + + sys->eweights = MEM_calloc_arrayN(sys->edges_num, sizeof(float), __func__); + sys->fweights = MEM_calloc_arrayN(sys->loops_num, sizeof(float[3]), __func__); + sys->ne_ed_num = MEM_calloc_arrayN(sys->verts_num, sizeof(short), __func__); + sys->ne_fa_num = MEM_calloc_arrayN(sys->verts_num, sizeof(short), __func__); + sys->ring_areas = MEM_calloc_arrayN(sys->verts_num, sizeof(float), __func__); + sys->vlengths = MEM_calloc_arrayN(sys->verts_num, sizeof(float), __func__); + sys->vweights = MEM_calloc_arrayN(sys->verts_num, sizeof(float), __func__); + sys->zerola = MEM_calloc_arrayN(sys->verts_num, sizeof(bool), __func__); return sys; } @@ -145,13 +145,13 @@ static LaplacianSystem *init_laplacian_system(int a_numEdges, static float compute_volume(const float center[3], float (*vertexCos)[3], const MPoly *mpoly, - int numPolys, + int polys_num, const MLoop *mloop) { int i; float vol = 0.0f; - for (i = 0; i < numPolys; i++) { + for (i = 0; i < polys_num; i++) { const MPoly *mp = &mpoly[i]; const MLoop *l_first = &mloop[mp->loopstart]; const MLoop *l_prev = l_first + 1; @@ -174,7 +174,7 @@ static void volume_preservation(LaplacianSystem *sys, float vini, float vend, sh if (vend != 0.0f) { beta = pow(vini / vend, 1.0f / 3.0f); - for (i = 0; i < sys->numVerts; i++) { + for (i = 0; i < sys->verts_num; i++) { if (flag & MOD_LAPLACIANSMOOTH_X) { sys->vertexCos[i][0] = (sys->vertexCos[i][0] - sys->vert_centroid[0]) * beta + sys->vert_centroid[0]; @@ -199,15 +199,15 @@ static void init_laplacian_matrix(LaplacianSystem *sys) int i; uint idv1, idv2; - for (i = 0; i < sys->numEdges; i++) { + for (i = 0; i < sys->edges_num; i++) { idv1 = sys->medges[i].v1; idv2 = sys->medges[i].v2; v1 = sys->vertexCos[idv1]; v2 = sys->vertexCos[idv2]; - sys->numNeEd[idv1] = sys->numNeEd[idv1] + 1; - sys->numNeEd[idv2] = sys->numNeEd[idv2] + 1; + sys->ne_ed_num[idv1] = sys->ne_ed_num[idv1] + 1; + sys->ne_ed_num[idv2] = sys->ne_ed_num[idv2] + 1; w1 = len_v3v3(v1, v2); if (w1 < sys->min_area) { sys->zerola[idv1] = true; @@ -220,7 +220,7 @@ static void init_laplacian_matrix(LaplacianSystem *sys) sys->eweights[i] = w1; } - for (i = 0; i < sys->numPolys; i++) { + for (i = 0; i < sys->polys_num; i++) { const MPoly *mp = &sys->mpoly[i]; const MLoop *l_next = &sys->mloop[mp->loopstart]; const MLoop *l_term = l_next + mp->totloop; @@ -233,7 +233,7 @@ static void init_laplacian_matrix(LaplacianSystem *sys) const float *v_next = sys->vertexCos[l_next->v]; const uint l_curr_index = l_curr - sys->mloop; - sys->numNeFa[l_curr->v] += 1; + sys->ne_fa_num[l_curr->v] += 1; areaf = area_tri_v3(v_prev, v_curr, v_next); @@ -258,11 +258,12 @@ static void init_laplacian_matrix(LaplacianSystem *sys) sys->vweights[l_prev->v] += w1 + w2; } } - for (i = 0; i < sys->numEdges; i++) { + for (i = 0; i < sys->edges_num; i++) { idv1 = sys->medges[i].v1; idv2 = sys->medges[i].v2; /* if is boundary, apply scale-dependent umbrella operator only with neighbors in boundary */ - if (sys->numNeEd[idv1] != sys->numNeFa[idv1] && sys->numNeEd[idv2] != sys->numNeFa[idv2]) { + if (sys->ne_ed_num[idv1] != sys->ne_fa_num[idv1] && + sys->ne_ed_num[idv2] != sys->ne_fa_num[idv2]) { sys->vlengths[idv1] += sys->eweights[i]; sys->vlengths[idv2] += sys->eweights[i]; } @@ -274,7 +275,7 @@ static void fill_laplacian_matrix(LaplacianSystem *sys) int i; uint idv1, idv2; - for (i = 0; i < sys->numPolys; i++) { + for (i = 0; i < sys->polys_num; i++) { const MPoly *mp = &sys->mpoly[i]; const MLoop *l_next = &sys->mloop[mp->loopstart]; const MLoop *l_term = l_next + mp->totloop; @@ -285,7 +286,8 @@ static void fill_laplacian_matrix(LaplacianSystem *sys) const uint l_curr_index = l_curr - sys->mloop; /* Is ring if number of faces == number of edges around vertex. */ - if (sys->numNeEd[l_curr->v] == sys->numNeFa[l_curr->v] && sys->zerola[l_curr->v] == false) { + if (sys->ne_ed_num[l_curr->v] == sys->ne_fa_num[l_curr->v] && + sys->zerola[l_curr->v] == false) { EIG_linear_solver_matrix_add(sys->context, l_curr->v, l_next->v, @@ -295,7 +297,8 @@ static void fill_laplacian_matrix(LaplacianSystem *sys) l_prev->v, sys->fweights[l_curr_index][1] * sys->vweights[l_curr->v]); } - if (sys->numNeEd[l_next->v] == sys->numNeFa[l_next->v] && sys->zerola[l_next->v] == false) { + if (sys->ne_ed_num[l_next->v] == sys->ne_fa_num[l_next->v] && + sys->zerola[l_next->v] == false) { EIG_linear_solver_matrix_add(sys->context, l_next->v, l_curr->v, @@ -305,7 +308,8 @@ static void fill_laplacian_matrix(LaplacianSystem *sys) l_prev->v, sys->fweights[l_curr_index][0] * sys->vweights[l_next->v]); } - if (sys->numNeEd[l_prev->v] == sys->numNeFa[l_prev->v] && sys->zerola[l_prev->v] == false) { + if (sys->ne_ed_num[l_prev->v] == sys->ne_fa_num[l_prev->v] && + sys->zerola[l_prev->v] == false) { EIG_linear_solver_matrix_add(sys->context, l_prev->v, l_curr->v, @@ -318,12 +322,13 @@ static void fill_laplacian_matrix(LaplacianSystem *sys) } } - for (i = 0; i < sys->numEdges; i++) { + for (i = 0; i < sys->edges_num; i++) { idv1 = sys->medges[i].v1; idv2 = sys->medges[i].v2; /* Is boundary */ - if (sys->numNeEd[idv1] != sys->numNeFa[idv1] && sys->numNeEd[idv2] != sys->numNeFa[idv2] && - sys->zerola[idv1] == false && sys->zerola[idv2] == false) { + if (sys->ne_ed_num[idv1] != sys->ne_fa_num[idv1] && + sys->ne_ed_num[idv2] != sys->ne_fa_num[idv2] && sys->zerola[idv1] == false && + sys->zerola[idv2] == false) { EIG_linear_solver_matrix_add( sys->context, idv1, idv2, sys->eweights[i] * sys->vlengths[idv1]); EIG_linear_solver_matrix_add( @@ -340,12 +345,12 @@ static void validate_solution(LaplacianSystem *sys, short flag, float lambda, fl if (flag & MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME) { vini = compute_volume( - sys->vert_centroid, sys->vertexCos, sys->mpoly, sys->numPolys, sys->mloop); + sys->vert_centroid, sys->vertexCos, sys->mpoly, sys->polys_num, sys->mloop); } - for (i = 0; i < sys->numVerts; i++) { + for (i = 0; i < sys->verts_num; i++) { if (sys->zerola[i] == false) { - lam = sys->numNeEd[i] == sys->numNeFa[i] ? (lambda >= 0.0f ? 1.0f : -1.0f) : - (lambda_border >= 0.0f ? 1.0f : -1.0f); + lam = sys->ne_ed_num[i] == sys->ne_fa_num[i] ? (lambda >= 0.0f ? 1.0f : -1.0f) : + (lambda_border >= 0.0f ? 1.0f : -1.0f); if (flag & MOD_LAPLACIANSMOOTH_X) { sys->vertexCos[i][0] += lam * ((float)EIG_linear_solver_variable_get(sys->context, 0, i) - sys->vertexCos[i][0]); @@ -362,13 +367,13 @@ static void validate_solution(LaplacianSystem *sys, short flag, float lambda, fl } if (flag & MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME) { vend = compute_volume( - sys->vert_centroid, sys->vertexCos, sys->mpoly, sys->numPolys, sys->mloop); + sys->vert_centroid, sys->vertexCos, sys->mpoly, sys->polys_num, sys->mloop); volume_preservation(sys, vini, vend, flag); } } static void laplaciansmoothModifier_do( - LaplacianSmoothModifierData *smd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int numVerts) + LaplacianSmoothModifierData *smd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int verts_num) { LaplacianSystem *sys; MDeformVert *dvert = NULL; @@ -378,7 +383,7 @@ static void laplaciansmoothModifier_do( int defgrp_index; const bool invert_vgroup = (smd->flag & MOD_LAPLACIANSMOOTH_INVERT_VGROUP) != 0; - sys = init_laplacian_system(mesh->totedge, mesh->totpoly, mesh->totloop, numVerts); + sys = init_laplacian_system(mesh->totedge, mesh->totpoly, mesh->totloop, verts_num); if (!sys) { return; } @@ -395,12 +400,12 @@ static void laplaciansmoothModifier_do( sys->vert_centroid[2] = 0.0f; memset_laplacian_system(sys, 0); - sys->context = EIG_linear_least_squares_solver_new(numVerts, numVerts, 3); + sys->context = EIG_linear_least_squares_solver_new(verts_num, verts_num, 3); init_laplacian_matrix(sys); for (iter = 0; iter < smd->repeat; iter++) { - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { EIG_linear_solver_variable_set(sys->context, 0, i, vertexCos[i][0]); EIG_linear_solver_variable_set(sys->context, 1, i, vertexCos[i][1]); EIG_linear_solver_variable_set(sys->context, 2, i, vertexCos[i][2]); @@ -408,12 +413,12 @@ static void laplaciansmoothModifier_do( add_v3_v3(sys->vert_centroid, vertexCos[i]); } } - if (iter == 0 && numVerts > 0) { - mul_v3_fl(sys->vert_centroid, 1.0f / (float)numVerts); + if (iter == 0 && verts_num > 0) { + mul_v3_fl(sys->vert_centroid, 1.0f / (float)verts_num); } dv = dvert; - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { EIG_linear_solver_right_hand_side_add(sys->context, 0, i, vertexCos[i][0]); EIG_linear_solver_right_hand_side_add(sys->context, 1, i, vertexCos[i][1]); EIG_linear_solver_right_hand_side_add(sys->context, 2, i, vertexCos[i][2]); @@ -433,7 +438,7 @@ static void laplaciansmoothModifier_do( sys->vweights[i] = (w == 0.0f) ? 0.0f : -fabsf(smd->lambda) * wpaint / w; w = sys->vlengths[i]; sys->vlengths[i] = (w == 0.0f) ? 0.0f : -fabsf(smd->lambda_border) * wpaint * 2.0f / w; - if (sys->numNeEd[i] == sys->numNeFa[i]) { + if (sys->ne_ed_num[i] == sys->ne_fa_num[i]) { EIG_linear_solver_matrix_add(sys->context, i, i, 1.0f + fabsf(smd->lambda) * wpaint); } else { @@ -447,7 +452,7 @@ static void laplaciansmoothModifier_do( w = sys->vlengths[i]; sys->vlengths[i] = (w == 0.0f) ? 0.0f : -fabsf(smd->lambda_border) * wpaint * 2.0f / w; - if (sys->numNeEd[i] == sys->numNeFa[i]) { + if (sys->ne_ed_num[i] == sys->ne_fa_num[i]) { EIG_linear_solver_matrix_add(sys->context, i, i, @@ -522,18 +527,18 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { Mesh *mesh_src; - if (numVerts == 0) { + if (verts_num == 0) { return; } - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); laplaciansmoothModifier_do( - (LaplacianSmoothModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); + (LaplacianSmoothModifierData *)md, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -545,15 +550,15 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { Mesh *mesh_src; - if (numVerts == 0) { + if (verts_num == 0) { return; } - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false, false); /* TODO(Campbell): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { @@ -561,7 +566,7 @@ static void deformVertsEM(ModifierData *md, } laplaciansmoothModifier_do( - (LaplacianSmoothModifierData *)md, ctx->object, mesh_src, vertexCos, numVerts); + (LaplacianSmoothModifierData *)md, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index 1017f6cca1a..832372304a0 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -94,18 +94,18 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, struct Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { LatticeModifierData *lmd = (LatticeModifierData *)md; struct Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, NULL, mesh, NULL, numVerts, false, false); + ctx->object, NULL, mesh, NULL, verts_num, false, false); MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ BKE_lattice_deform_coords_with_mesh(lmd->object, ctx->object, vertexCos, - numVerts, + verts_num, lmd->flag, lmd->name, lmd->strength, @@ -121,10 +121,10 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *em, struct Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { if (mesh != NULL) { - deformVerts(md, ctx, mesh, vertexCos, numVerts); + deformVerts(md, ctx, mesh, vertexCos, verts_num); return; } @@ -133,7 +133,7 @@ static void deformVertsEM(ModifierData *md, MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ BKE_lattice_deform_coords_with_editmesh( - lmd->object, ctx->object, vertexCos, numVerts, lmd->flag, lmd->name, lmd->strength, em); + lmd->object, ctx->object, vertexCos, verts_num, lmd->flag, lmd->name, lmd->strength, em); } static void panel_draw(const bContext *UNUSED(C), Panel *panel) diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc index 1cb720f4b02..cb26bd1b26b 100644 --- a/source/blender/modifiers/intern/MOD_mask.cc +++ b/source/blender/modifiers/intern/MOD_mask.cc @@ -145,58 +145,58 @@ static void invert_boolean_array(MutableSpan<bool> array) static void compute_masked_vertices(Span<bool> vertex_mask, MutableSpan<int> r_vertex_map, - uint *r_num_masked_vertices) + uint *r_verts_masked_num) { BLI_assert(vertex_mask.size() == r_vertex_map.size()); - uint num_masked_vertices = 0; + uint verts_masked_num = 0; for (uint i_src : r_vertex_map.index_range()) { if (vertex_mask[i_src]) { - r_vertex_map[i_src] = num_masked_vertices; - num_masked_vertices++; + r_vertex_map[i_src] = verts_masked_num; + verts_masked_num++; } else { r_vertex_map[i_src] = -1; } } - *r_num_masked_vertices = num_masked_vertices; + *r_verts_masked_num = verts_masked_num; } static void computed_masked_edges(const Mesh *mesh, Span<bool> vertex_mask, MutableSpan<int> r_edge_map, - uint *r_num_masked_edges) + uint *r_edges_masked_num) { BLI_assert(mesh->totedge == r_edge_map.size()); - uint num_masked_edges = 0; + uint edges_masked_num = 0; for (int i : IndexRange(mesh->totedge)) { const MEdge &edge = mesh->medge[i]; /* only add if both verts will be in new mesh */ if (vertex_mask[edge.v1] && vertex_mask[edge.v2]) { - r_edge_map[i] = num_masked_edges; - num_masked_edges++; + r_edge_map[i] = edges_masked_num; + edges_masked_num++; } else { r_edge_map[i] = -1; } } - *r_num_masked_edges = num_masked_edges; + *r_edges_masked_num = edges_masked_num; } static void computed_masked_edges_smooth(const Mesh *mesh, Span<bool> vertex_mask, MutableSpan<int> r_edge_map, - uint *r_num_masked_edges, - uint *r_num_add_vertices) + uint *r_edges_masked_num, + uint *r_verts_add_num) { BLI_assert(mesh->totedge == r_edge_map.size()); - uint num_masked_edges = 0; - uint num_add_vertices = 0; + uint edges_masked_num = 0; + uint verts_add_num = 0; for (int i : IndexRange(mesh->totedge)) { const MEdge &edge = mesh->medge[i]; @@ -204,36 +204,36 @@ static void computed_masked_edges_smooth(const Mesh *mesh, bool v1 = vertex_mask[edge.v1]; bool v2 = vertex_mask[edge.v2]; if (v1 && v2) { - r_edge_map[i] = num_masked_edges; - num_masked_edges++; + r_edge_map[i] = edges_masked_num; + edges_masked_num++; } else if (v1 != v2) { r_edge_map[i] = -2; - num_add_vertices++; + verts_add_num++; } else { r_edge_map[i] = -1; } } - num_masked_edges += num_add_vertices; - *r_num_masked_edges = num_masked_edges; - *r_num_add_vertices = num_add_vertices; + edges_masked_num += verts_add_num; + *r_edges_masked_num = edges_masked_num; + *r_verts_add_num = verts_add_num; } static void computed_masked_polygons(const Mesh *mesh, Span<bool> vertex_mask, Vector<int> &r_masked_poly_indices, Vector<int> &r_loop_starts, - uint *r_num_masked_polys, - uint *r_num_masked_loops) + uint *r_polys_masked_num, + uint *r_loops_masked_num) { BLI_assert(mesh->totvert == vertex_mask.size()); r_masked_poly_indices.reserve(mesh->totpoly); r_loop_starts.reserve(mesh->totpoly); - uint num_masked_loops = 0; + uint loops_masked_num = 0; for (int i : IndexRange(mesh->totpoly)) { const MPoly &poly_src = mesh->mpoly[i]; @@ -248,35 +248,35 @@ static void computed_masked_polygons(const Mesh *mesh, if (all_verts_in_mask) { r_masked_poly_indices.append_unchecked(i); - r_loop_starts.append_unchecked(num_masked_loops); - num_masked_loops += poly_src.totloop; + r_loop_starts.append_unchecked(loops_masked_num); + loops_masked_num += poly_src.totloop; } } - *r_num_masked_polys = r_masked_poly_indices.size(); - *r_num_masked_loops = num_masked_loops; + *r_polys_masked_num = r_masked_poly_indices.size(); + *r_loops_masked_num = loops_masked_num; } static void compute_interpolated_polygons(const Mesh *mesh, Span<bool> vertex_mask, - uint num_add_vertices, - uint num_masked_loops, + uint verts_add_num, + uint loops_masked_num, Vector<int> &r_masked_poly_indices, Vector<int> &r_loop_starts, - uint *r_num_add_edges, - uint *r_num_add_polys, - uint *r_num_add_loops) + uint *r_edges_add_num, + uint *r_polys_add_num, + uint *r_loops_add_num) { BLI_assert(mesh->totvert == vertex_mask.size()); /* Can't really know ahead of time how much space to use exactly. Estimate limit instead. */ /* NOTE: this reserve can only lift the capacity if there are ngons, which get split. */ - r_masked_poly_indices.reserve(r_masked_poly_indices.size() + num_add_vertices); - r_loop_starts.reserve(r_loop_starts.size() + num_add_vertices); + r_masked_poly_indices.reserve(r_masked_poly_indices.size() + verts_add_num); + r_loop_starts.reserve(r_loop_starts.size() + verts_add_num); - uint num_add_edges = 0; - uint num_add_polys = 0; - uint num_add_loops = 0; + uint edges_add_num = 0; + uint polys_add_num = 0; + uint loops_add_num = 0; for (int i : IndexRange(mesh->totpoly)) { const MPoly &poly_src = mesh->mpoly[i]; @@ -306,10 +306,10 @@ static void compute_interpolated_polygons(const Mesh *mesh, else if (!v_loop_in_mask && v_loop_in_mask_last) { BLI_assert(dst_totloop > 2); r_masked_poly_indices.append(i); - r_loop_starts.append(num_masked_loops + num_add_loops); - num_add_loops += dst_totloop; - num_add_polys++; - num_add_edges++; + r_loop_starts.append(loops_masked_num + loops_add_num); + loops_add_num += dst_totloop; + polys_add_num++; + edges_add_num++; dst_totloop = -1; } else if (v_loop_in_mask && v_loop_in_mask_last) { @@ -322,9 +322,9 @@ static void compute_interpolated_polygons(const Mesh *mesh, } } - *r_num_add_edges = num_add_edges; - *r_num_add_polys = num_add_polys; - *r_num_add_loops = num_add_loops; + *r_edges_add_num = edges_add_num; + *r_polys_add_num = polys_add_num; + *r_loops_add_num = loops_add_num; } static void copy_masked_vertices_to_new_mesh(const Mesh &src_mesh, @@ -363,15 +363,15 @@ static void add_interp_verts_copy_edges_to_new_mesh(const Mesh &src_mesh, MDeformVert *dvert, int defgrp_index, float threshold, - uint num_masked_edges, - uint num_add_verts, + uint edges_masked_num, + uint verts_add_num, MutableSpan<int> r_edge_map) { BLI_assert(src_mesh.totvert == vertex_mask.size()); BLI_assert(src_mesh.totedge == r_edge_map.size()); - uint vert_index = dst_mesh.totvert - num_add_verts; - uint edge_index = num_masked_edges - num_add_verts; + uint vert_index = dst_mesh.totvert - verts_add_num; + uint edge_index = edges_masked_num - verts_add_num; for (int i_src : IndexRange(src_mesh.totedge)) { if (r_edge_map[i_src] != -1) { int i_dst = r_edge_map[i_src]; @@ -416,7 +416,7 @@ static void add_interp_verts_copy_edges_to_new_mesh(const Mesh &src_mesh, } } BLI_assert(vert_index == dst_mesh.totvert); - BLI_assert(edge_index == num_masked_edges); + BLI_assert(edge_index == edges_masked_num); } static void copy_masked_edges_to_new_mesh(const Mesh &src_mesh, @@ -448,9 +448,9 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh, Span<int> edge_map, Span<int> masked_poly_indices, Span<int> new_loop_starts, - int num_masked_polys) + int polys_masked_num) { - for (const int i_dst : IndexRange(num_masked_polys)) { + for (const int i_dst : IndexRange(polys_masked_num)) { const int i_src = masked_poly_indices[i_dst]; const MPoly &mp_src = src_mesh.mpoly[i_src]; @@ -483,14 +483,14 @@ static void add_interpolated_polys_to_new_mesh(const Mesh &src_mesh, float threshold, Span<int> masked_poly_indices, Span<int> new_loop_starts, - int num_masked_polys, - int num_add_edges) + int polys_masked_num, + int edges_add_num) { - int edge_index = dst_mesh.totedge - num_add_edges; + int edge_index = dst_mesh.totedge - edges_add_num; int sub_poly_index = 0; int last_i_src = -1; for (const int i_dst : - IndexRange(num_masked_polys, masked_poly_indices.size() - num_masked_polys)) { + IndexRange(polys_masked_num, masked_poly_indices.size() - polys_masked_num)) { const int i_src = masked_poly_indices[i_dst]; if (i_src == last_i_src) { sub_poly_index++; @@ -662,53 +662,52 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx) } Array<int> vertex_map(mesh->totvert); - uint num_masked_vertices; - compute_masked_vertices(vertex_mask, vertex_map, &num_masked_vertices); + uint verts_masked_num; + compute_masked_vertices(vertex_mask, vertex_map, &verts_masked_num); Array<int> edge_map(mesh->totedge); - uint num_masked_edges; - uint num_add_vertices; + uint edges_masked_num; + uint verts_add_num; if (use_interpolation) { - computed_masked_edges_smooth( - mesh, vertex_mask, edge_map, &num_masked_edges, &num_add_vertices); + computed_masked_edges_smooth(mesh, vertex_mask, edge_map, &edges_masked_num, &verts_add_num); } else { - computed_masked_edges(mesh, vertex_mask, edge_map, &num_masked_edges); - num_add_vertices = 0; + computed_masked_edges(mesh, vertex_mask, edge_map, &edges_masked_num); + verts_add_num = 0; } Vector<int> masked_poly_indices; Vector<int> new_loop_starts; - uint num_masked_polys; - uint num_masked_loops; + uint polys_masked_num; + uint loops_masked_num; computed_masked_polygons(mesh, vertex_mask, masked_poly_indices, new_loop_starts, - &num_masked_polys, - &num_masked_loops); + &polys_masked_num, + &loops_masked_num); - uint num_add_edges = 0; - uint num_add_polys = 0; - uint num_add_loops = 0; + uint edges_add_num = 0; + uint polys_add_num = 0; + uint loops_add_num = 0; if (use_interpolation) { compute_interpolated_polygons(mesh, vertex_mask, - num_add_vertices, - num_masked_loops, + verts_add_num, + loops_masked_num, masked_poly_indices, new_loop_starts, - &num_add_edges, - &num_add_polys, - &num_add_loops); + &edges_add_num, + &polys_add_num, + &loops_add_num); } Mesh *result = BKE_mesh_new_nomain_from_template(mesh, - num_masked_vertices + num_add_vertices, - num_masked_edges + num_add_edges, + verts_masked_num + verts_add_num, + edges_masked_num + edges_add_num, 0, - num_masked_loops + num_add_loops, - num_masked_polys + num_add_polys); + loops_masked_num + loops_add_num, + polys_masked_num + polys_add_num); copy_masked_vertices_to_new_mesh(*mesh, *result, vertex_map); if (use_interpolation) { @@ -719,8 +718,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx) dvert, defgrp_index, mmd->threshold, - num_masked_edges, - num_add_vertices, + edges_masked_num, + verts_add_num, edge_map); } else { @@ -732,7 +731,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx) edge_map, masked_poly_indices, new_loop_starts, - num_masked_polys); + polys_masked_num); if (use_interpolation) { add_interpolated_polys_to_new_mesh(*mesh, *result, @@ -744,8 +743,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx) mmd->threshold, masked_poly_indices, new_loop_starts, - num_masked_polys, - num_add_edges); + polys_masked_num, + edges_add_num); } BKE_mesh_calc_edges_loose(result); diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c index 3e022a5951d..e5a62ba96b6 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.c +++ b/source/blender/modifiers/intern/MOD_meshcache.c @@ -77,7 +77,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd, Object *ob, Mesh *mesh, float (*vertexCos_Real)[3], - int numVerts) + int verts_num) { const bool use_factor = mcmd->factor < 1.0f; int influence_group_index; @@ -87,7 +87,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd, float(*vertexCos_Store)[3] = (use_factor || influence_group_index != -1 || (mcmd->deform_mode == MOD_MESHCACHE_DEFORM_INTEGRATE)) ? MEM_malloc_arrayN( - numVerts, sizeof(*vertexCos_Store), __func__) : + verts_num, sizeof(*vertexCos_Store), __func__) : NULL; float(*vertexCos)[3] = vertexCos_Store ? vertexCos_Store : vertexCos_Real; @@ -151,11 +151,11 @@ static void meshcache_do(MeshCacheModifierData *mcmd, switch (mcmd->type) { case MOD_MESHCACHE_TYPE_MDD: ok = MOD_meshcache_read_mdd_times( - filepath, vertexCos, numVerts, mcmd->interp, time, fps, mcmd->time_mode, &err_str); + filepath, vertexCos, verts_num, mcmd->interp, time, fps, mcmd->time_mode, &err_str); break; case MOD_MESHCACHE_TYPE_PC2: ok = MOD_meshcache_read_pc2_times( - filepath, vertexCos, numVerts, mcmd->interp, time, fps, mcmd->time_mode, &err_str); + filepath, vertexCos, verts_num, mcmd->interp, time, fps, mcmd->time_mode, &err_str); break; default: ok = false; @@ -171,7 +171,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd, if (UNLIKELY(ob->type != OB_MESH)) { BKE_modifier_set_error(ob, &mcmd->modifier, "'Integrate' only valid for Mesh objects"); } - else if (UNLIKELY(me->totvert != numVerts)) { + else if (UNLIKELY(me->totvert != verts_num)) { BKE_modifier_set_error(ob, &mcmd->modifier, "'Integrate' original mesh vertex mismatch"); } else if (UNLIKELY(me->totpoly == 0)) { @@ -182,11 +182,11 @@ static void meshcache_do(MeshCacheModifierData *mcmd, int i; float(*vertexCos_Source)[3] = MEM_malloc_arrayN( - numVerts, sizeof(*vertexCos_Source), __func__); - float(*vertexCos_New)[3] = MEM_malloc_arrayN(numVerts, sizeof(*vertexCos_New), __func__); + verts_num, sizeof(*vertexCos_Source), __func__); + float(*vertexCos_New)[3] = MEM_malloc_arrayN(verts_num, sizeof(*vertexCos_New), __func__); MVert *mv = me->mvert; - for (i = 0; i < numVerts; i++, mv++) { + for (i = 0; i < verts_num; i++, mv++) { copy_v3_v3(vertexCos_Source[i], mv->co); } @@ -204,7 +204,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd, ); /* write the corrected locations back into the result */ - memcpy(vertexCos, vertexCos_New, sizeof(*vertexCos) * numVerts); + memcpy(vertexCos, vertexCos_New, sizeof(*vertexCos) * verts_num); MEM_freeN(vertexCos_Source); MEM_freeN(vertexCos_New); @@ -244,7 +244,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd, if (use_matrix) { int i; - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { mul_m3_v3(mat, vertexCos[i]); } } @@ -260,7 +260,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd, mcmd->factor : 0.0f; if (mesh->dvert != NULL) { - for (int i = 0; i < numVerts; i++) { + for (int i = 0; i < verts_num; i++) { /* For each vertex, compute its blending factor between the mesh cache (for `fac = 0`) * and the former position of the vertex (for `fac = 1`). */ const MDeformVert *currentIndexDVert = dvert + i; @@ -275,10 +275,10 @@ static void meshcache_do(MeshCacheModifierData *mcmd, } else if (use_factor) { /* Influence_group_index is -1. */ - interp_vn_vn(*vertexCos_Real, *vertexCos_Store, mcmd->factor, numVerts * 3); + interp_vn_vn(*vertexCos_Real, *vertexCos_Store, mcmd->factor, verts_num * 3); } else { - memcpy(vertexCos_Real, vertexCos_Store, sizeof(*vertexCos_Store) * numVerts); + memcpy(vertexCos_Real, vertexCos_Store, sizeof(*vertexCos_Store) * verts_num); } } @@ -290,7 +290,7 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md; Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); @@ -299,9 +299,9 @@ static void deformVerts(ModifierData *md, if (ctx->object->type == OB_MESH && mcmd->defgrp_name[0] != '\0') { /* `mesh_src` is only needed for vertex groups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); } - meshcache_do(mcmd, scene, ctx->object, mesh_src, vertexCos, numVerts); + meshcache_do(mcmd, scene, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -313,7 +313,7 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { MeshCacheModifierData *mcmd = (MeshCacheModifierData *)md; Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); @@ -322,13 +322,14 @@ static void deformVertsEM(ModifierData *md, if (ctx->object->type == OB_MESH && mcmd->defgrp_name[0] != '\0') { /* `mesh_src` is only needed for vertex groups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get( + ctx->object, editData, mesh, NULL, verts_num, false, false); } if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } - meshcache_do(mcmd, scene, ctx->object, mesh_src, vertexCos, numVerts); + meshcache_do(mcmd, scene, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_meshcache_mdd.c b/source/blender/modifiers/intern/MOD_meshcache_mdd.c index 66b5f3ff9b2..67a01b1c8d5 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_mdd.c +++ b/source/blender/modifiers/intern/MOD_meshcache_mdd.c @@ -96,22 +96,22 @@ static bool meshcache_read_mdd_range_from_time(FILE *fp, return false; } - size_t num_frames_read = 0; - size_t num_frames_expect = mdd_head.frame_tot; + size_t frames_num_read = 0; + size_t frames_num_expect = mdd_head.frame_tot; errno = 0; for (i = 0; i < mdd_head.frame_tot; i++) { - num_frames_read += fread(&f_time, sizeof(float), 1, fp); + frames_num_read += fread(&f_time, sizeof(float), 1, fp); #ifdef __LITTLE_ENDIAN__ BLI_endian_switch_float(&f_time); #endif if (f_time >= time) { - num_frames_expect = i + 1; + frames_num_expect = i + 1; break; } f_time_prev = f_time; } - if (num_frames_read != num_frames_expect) { + if (frames_num_read != frames_num_expect) { *err_str = errno ? strerror(errno) : "Timestamp read failed"; return false; } @@ -160,14 +160,14 @@ bool MOD_meshcache_read_mdd_index(FILE *fp, return false; } - size_t num_verts_read = 0; + size_t verts_read_num = 0; errno = 0; if (factor >= 1.0f) { #if 1 float *vco = *vertexCos; uint i; for (i = mdd_head.verts_tot; i != 0; i--, vco += 3) { - num_verts_read += fread(vco, sizeof(float[3]), 1, fp); + verts_read_num += fread(vco, sizeof(float[3]), 1, fp); # ifdef __LITTLE_ENDIAN__ BLI_endian_switch_float(vco + 0); @@ -192,7 +192,7 @@ bool MOD_meshcache_read_mdd_index(FILE *fp, uint i; for (i = mdd_head.verts_tot; i != 0; i--, vco += 3) { float tvec[3]; - num_verts_read += fread(tvec, sizeof(float[3]), 1, fp); + verts_read_num += fread(tvec, sizeof(float[3]), 1, fp); #ifdef __LITTLE_ENDIAN__ BLI_endian_switch_float(tvec + 0); @@ -206,7 +206,7 @@ bool MOD_meshcache_read_mdd_index(FILE *fp, } } - if (num_verts_read != mdd_head.verts_tot) { + if (verts_read_num != mdd_head.verts_tot) { *err_str = errno ? strerror(errno) : "Vertex coordinate read failed"; return false; } diff --git a/source/blender/modifiers/intern/MOD_meshcache_pc2.c b/source/blender/modifiers/intern/MOD_meshcache_pc2.c index 54ea27d0085..27fea20bb13 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_pc2.c +++ b/source/blender/modifiers/intern/MOD_meshcache_pc2.c @@ -137,13 +137,13 @@ bool MOD_meshcache_read_pc2_index(FILE *fp, return false; } - size_t num_verts_read = 0; + size_t verts_read_num = 0; errno = 0; if (factor >= 1.0f) { float *vco = *vertexCos; uint i; for (i = pc2_head.verts_tot; i != 0; i--, vco += 3) { - num_verts_read += fread(vco, sizeof(float[3]), 1, fp); + verts_read_num += fread(vco, sizeof(float[3]), 1, fp); #ifdef __BIG_ENDIAN__ BLI_endian_switch_float(vco + 0); @@ -158,7 +158,7 @@ bool MOD_meshcache_read_pc2_index(FILE *fp, uint i; for (i = pc2_head.verts_tot; i != 0; i--, vco += 3) { float tvec[3]; - num_verts_read += fread(tvec, sizeof(float[3]), 1, fp); + verts_read_num += fread(tvec, sizeof(float[3]), 1, fp); #ifdef __BIG_ENDIAN__ BLI_endian_switch_float(tvec + 0); @@ -172,7 +172,7 @@ bool MOD_meshcache_read_pc2_index(FILE *fp, } } - if (num_verts_read != pc2_head.verts_tot) { + if (verts_read_num != pc2_head.verts_tot) { *err_str = errno ? strerror(errno) : "Vertex coordinate read failed"; return false; } diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index f15cdfe0c4e..09e6819a2ae 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -222,7 +222,7 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 cell = &mmd->dyngrid[a]; inf = mmd->dyninfluences + cell->offset; - for (j = 0; j < cell->totinfluence; j++, inf++) { + for (j = 0; j < cell->influences_num; j++, inf++) { cageco = dco[inf->vertex]; cageweight = weight * inf->weight; #ifdef BLI_HAVE_SSE2 @@ -324,7 +324,7 @@ static void meshdeformModifier_do(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + const int verts_num) { MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; Object *ob = ctx->object; @@ -333,7 +333,7 @@ static void meshdeformModifier_do(ModifierData *md, MDeformVert *dvert = NULL; float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4]; float(*dco)[3] = NULL, (*bindcagecos)[3]; - int a, totvert, totcagevert, defgrp_index; + int a, cage_verts_num, defgrp_index; MeshdeformUserdata data; static int recursive_bind_sentinel = 0; @@ -375,7 +375,7 @@ static void meshdeformModifier_do(ModifierData *md, } if (!recursive_bind_sentinel) { recursive_bind_sentinel = 1; - mmd->bindfunc(ob, mmd, cagemesh, (float *)vertexCos, numVerts, cagemat); + mmd->bindfunc(ob, mmd, cagemesh, (float *)vertexCos, verts_num, cagemat); recursive_bind_sentinel = 0; } @@ -383,16 +383,15 @@ static void meshdeformModifier_do(ModifierData *md, } /* verify we have compatible weights */ - totvert = numVerts; - totcagevert = BKE_mesh_wrapper_vert_len(cagemesh); + cage_verts_num = BKE_mesh_wrapper_vert_len(cagemesh); - if (mmd->totvert != totvert) { - BKE_modifier_set_error(ob, md, "Vertices changed from %d to %d", mmd->totvert, totvert); + if (mmd->verts_num != verts_num) { + BKE_modifier_set_error(ob, md, "Vertices changed from %d to %d", mmd->verts_num, verts_num); goto finally; } - else if (mmd->totcagevert != totcagevert) { + else if (mmd->cage_verts_num != cage_verts_num) { BKE_modifier_set_error( - ob, md, "Cage vertices changed from %d to %d", mmd->totcagevert, totcagevert); + ob, md, "Cage vertices changed from %d to %d", mmd->cage_verts_num, cage_verts_num); goto finally; } else if (mmd->bindcagecos == NULL) { @@ -403,14 +402,14 @@ static void meshdeformModifier_do(ModifierData *md, /* We allocate 1 element extra to make it possible to * load the values to SSE registers, which are float4. */ - dco = MEM_calloc_arrayN((totcagevert + 1), sizeof(*dco), "MDefDco"); - zero_v3(dco[totcagevert]); + dco = MEM_calloc_arrayN((cage_verts_num + 1), sizeof(*dco), "MDefDco"); + zero_v3(dco[cage_verts_num]); /* setup deformation data */ - BKE_mesh_wrapper_vert_coords_copy(cagemesh, dco, totcagevert); + BKE_mesh_wrapper_vert_coords_copy(cagemesh, dco, cage_verts_num); bindcagecos = (float(*)[3])mmd->bindcagecos; - for (a = 0; a < totcagevert; a++) { + for (a = 0; a < cage_verts_num; a++) { /* Get cage vertex in world-space with binding transform. */ float co[3]; mul_v3_m4v3(co, mmd->bindmat, dco[a]); @@ -433,7 +432,7 @@ static void meshdeformModifier_do(ModifierData *md, TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.min_iter_per_thread = 16; - BLI_task_parallel_range(0, totvert, &data, meshdeform_vert_task, &settings); + BLI_task_parallel_range(0, verts_num, &data, meshdeform_vert_task, &settings); finally: MEM_SAFE_FREE(dco); @@ -443,13 +442,14 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get( + ctx->object, NULL, mesh, NULL, verts_num, false, false); MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ - meshdeformModifier_do(md, ctx, mesh_src, vertexCos, numVerts); + meshdeformModifier_do(md, ctx, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -461,17 +461,17 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, numVerts, false, false); + ctx->object, editData, mesh, NULL, verts_num, false, false); /* TODO(Campbell): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } - meshdeformModifier_do(md, ctx, mesh_src, vertexCos, numVerts); + meshdeformModifier_do(md, ctx, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -484,42 +484,42 @@ void BKE_modifier_mdef_compact_influences(ModifierData *md) { MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; float weight, *weights, totweight; - int totinfluence, totvert, totcagevert, a, b; + int influences_num, verts_num, cage_verts_num, a, b; weights = mmd->bindweights; if (!weights) { return; } - totvert = mmd->totvert; - totcagevert = mmd->totcagevert; + verts_num = mmd->verts_num; + cage_verts_num = mmd->cage_verts_num; /* count number of influences above threshold */ - for (b = 0; b < totvert; b++) { - for (a = 0; a < totcagevert; a++) { - weight = weights[a + b * totcagevert]; + for (b = 0; b < verts_num; b++) { + for (a = 0; a < cage_verts_num; a++) { + weight = weights[a + b * cage_verts_num]; if (weight > MESHDEFORM_MIN_INFLUENCE) { - mmd->totinfluence++; + mmd->influences_num++; } } } /* allocate bind influences */ mmd->bindinfluences = MEM_calloc_arrayN( - mmd->totinfluence, sizeof(MDefInfluence), "MDefBindInfluence"); - mmd->bindoffsets = MEM_calloc_arrayN((totvert + 1), sizeof(int), "MDefBindOffset"); + mmd->influences_num, sizeof(MDefInfluence), "MDefBindInfluence"); + mmd->bindoffsets = MEM_calloc_arrayN((verts_num + 1), sizeof(int), "MDefBindOffset"); /* write influences */ - totinfluence = 0; + influences_num = 0; - for (b = 0; b < totvert; b++) { - mmd->bindoffsets[b] = totinfluence; + for (b = 0; b < verts_num; b++) { + mmd->bindoffsets[b] = influences_num; totweight = 0.0f; /* sum total weight */ - for (a = 0; a < totcagevert; a++) { - weight = weights[a + b * totcagevert]; + for (a = 0; a < cage_verts_num; a++) { + weight = weights[a + b * cage_verts_num]; if (weight > MESHDEFORM_MIN_INFLUENCE) { totweight += weight; @@ -527,18 +527,18 @@ void BKE_modifier_mdef_compact_influences(ModifierData *md) } /* assign weights normalized */ - for (a = 0; a < totcagevert; a++) { - weight = weights[a + b * totcagevert]; + for (a = 0; a < cage_verts_num; a++) { + weight = weights[a + b * cage_verts_num]; if (weight > MESHDEFORM_MIN_INFLUENCE) { - mmd->bindinfluences[totinfluence].weight = weight / totweight; - mmd->bindinfluences[totinfluence].vertex = a; - totinfluence++; + mmd->bindinfluences[influences_num].weight = weight / totweight; + mmd->bindinfluences[influences_num].vertex = a; + influences_num++; } } } - mmd->bindoffsets[b] = totinfluence; + mmd->bindoffsets[b] = influences_num; /* free */ MEM_freeN(mmd->bindweights); @@ -586,12 +586,12 @@ static void blendWrite(BlendWriter *writer, const ModifierData *md) MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; int size = mmd->dyngridsize; - BLO_write_struct_array(writer, MDefInfluence, mmd->totinfluence, mmd->bindinfluences); - BLO_write_int32_array(writer, mmd->totvert + 1, mmd->bindoffsets); - BLO_write_float3_array(writer, mmd->totcagevert, mmd->bindcagecos); + BLO_write_struct_array(writer, MDefInfluence, mmd->influences_num, mmd->bindinfluences); + BLO_write_int32_array(writer, mmd->verts_num + 1, mmd->bindoffsets); + BLO_write_float3_array(writer, mmd->cage_verts_num, mmd->bindcagecos); BLO_write_struct_array(writer, MDefCell, size * size * size, mmd->dyngrid); - BLO_write_struct_array(writer, MDefInfluence, mmd->totinfluence, mmd->dyninfluences); - BLO_write_int32_array(writer, mmd->totvert, mmd->dynverts); + BLO_write_struct_array(writer, MDefInfluence, mmd->influences_num, mmd->dyninfluences); + BLO_write_int32_array(writer, mmd->verts_num, mmd->dynverts); } static void blendRead(BlendDataReader *reader, ModifierData *md) @@ -599,15 +599,15 @@ static void blendRead(BlendDataReader *reader, ModifierData *md) MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; BLO_read_data_address(reader, &mmd->bindinfluences); - BLO_read_int32_array(reader, mmd->totvert + 1, &mmd->bindoffsets); - BLO_read_float3_array(reader, mmd->totcagevert, &mmd->bindcagecos); + BLO_read_int32_array(reader, mmd->verts_num + 1, &mmd->bindoffsets); + BLO_read_float3_array(reader, mmd->cage_verts_num, &mmd->bindcagecos); BLO_read_data_address(reader, &mmd->dyngrid); BLO_read_data_address(reader, &mmd->dyninfluences); - BLO_read_int32_array(reader, mmd->totvert, &mmd->dynverts); + BLO_read_int32_array(reader, mmd->verts_num, &mmd->dynverts); /* Deprecated storage. */ - BLO_read_float_array(reader, mmd->totvert, &mmd->bindweights); - BLO_read_float3_array(reader, mmd->totcagevert, &mmd->bindcos); + BLO_read_float_array(reader, mmd->verts_num, &mmd->bindweights); + BLO_read_float3_array(reader, mmd->cage_verts_num, &mmd->bindcos); } ModifierTypeInfo modifierType_MeshDeform = { diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index cc6f23073a3..a4c5ddac5c9 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -281,7 +281,7 @@ static void deformMatrices(ModifierData *md, Mesh *mesh, float (*vertex_cos)[3], float (*deform_matrices)[3][3], - int num_verts) + int verts_num) { #if !defined(WITH_OPENSUBDIV) @@ -313,7 +313,7 @@ static void deformMatrices(ModifierData *md, return; } BKE_subdiv_displacement_attach_from_multires(subdiv, mesh, mmd); - BKE_subdiv_deform_coarse_vertices(subdiv, mesh, vertex_cos, num_verts); + BKE_subdiv_deform_coarse_vertices(subdiv, mesh, vertex_cos, verts_num); if (subdiv != runtime_data->subdiv) { BKE_subdiv_free(subdiv); } diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c index 94b35c42247..fe05f48a868 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.c +++ b/source/blender/modifiers/intern/MOD_normal_edit.c @@ -43,7 +43,7 @@ static void generate_vert_coordinates(Mesh *mesh, Object *ob, Object *ob_center, const float offset[3], - const int num_verts, + const int verts_num, float (*r_cos)[3], float r_size[3]) { @@ -108,7 +108,7 @@ static void generate_vert_coordinates(Mesh *mesh, /* Else, no need to change coordinates! */ if (do_diff) { - int i = num_verts; + int i = verts_num; while (i--) { add_v3_v3(r_cos[i], diff); } @@ -122,11 +122,11 @@ static void mix_normals(const float mix_factor, const bool use_invert_vgroup, const float mix_limit, const short mix_mode, - const int num_verts, + const int verts_num, MLoop *mloop, float (*nos_old)[3], float (*nos_new)[3], - const int num_loops) + const int loops_num) { /* Mix with org normals... */ float *facs = NULL, *wfac; @@ -134,12 +134,12 @@ static void mix_normals(const float mix_factor, int i; if (dvert) { - facs = MEM_malloc_arrayN((size_t)num_loops, sizeof(*facs), __func__); + facs = MEM_malloc_arrayN((size_t)loops_num, sizeof(*facs), __func__); BKE_defvert_extract_vgroup_to_loopweights( - dvert, defgrp_index, num_verts, mloop, num_loops, facs, use_invert_vgroup); + dvert, defgrp_index, verts_num, mloop, loops_num, facs, use_invert_vgroup); } - for (i = num_loops, no_new = nos_new, no_old = nos_old, wfac = facs; i--; + for (i = loops_num, no_new = nos_new, no_old = nos_old, wfac = facs; i--; no_new++, no_old++, wfac++) { const float fac = facs ? *wfac * mix_factor : mix_factor; @@ -177,14 +177,14 @@ static bool polygons_check_flip(MLoop *mloop, CustomData *ldata, MPoly *mpoly, float (*polynors)[3], - const int num_polys) + const int polys_num) { MPoly *mp; MDisps *mdisp = CustomData_get_layer(ldata, CD_MDISPS); int i; bool flipped = false; - for (i = 0, mp = mpoly; i < num_polys; i++, mp++) { + for (i = 0, mp = mpoly; i < polys_num; i++, mp++) { float norsum[3] = {0.0f}; float(*no)[3]; int j; @@ -222,26 +222,26 @@ static void normalEditModifier_do_radial(NormalEditModifierData *enmd, const int defgrp_index, const bool use_invert_vgroup, MVert *mvert, - const int num_verts, + const int verts_num, MEdge *medge, - const int num_edges, + const int edges_num, MLoop *mloop, - const int num_loops, + const int loops_num, MPoly *mpoly, - const int num_polys) + const int polys_num) { Object *ob_target = enmd->target; const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; int i; - float(*cos)[3] = MEM_malloc_arrayN((size_t)num_verts, sizeof(*cos), __func__); - float(*nos)[3] = MEM_malloc_arrayN((size_t)num_loops, sizeof(*nos), __func__); + float(*cos)[3] = MEM_malloc_arrayN((size_t)verts_num, sizeof(*cos), __func__); + float(*nos)[3] = MEM_malloc_arrayN((size_t)loops_num, sizeof(*nos), __func__); float size[3]; - BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)num_verts, __func__); + BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)verts_num, __func__); - generate_vert_coordinates(mesh, ob, ob_target, enmd->offset, num_verts, cos, size); + generate_vert_coordinates(mesh, ob, ob_target, enmd->offset, verts_num, cos, size); /** * size gives us our spheroid coefficients `(A, B, C)`. @@ -283,7 +283,7 @@ static void normalEditModifier_do_radial(NormalEditModifierData *enmd, float(*no)[3]; /* We reuse cos to now store the ellipsoid-normal of the verts! */ - for (i = num_loops, ml = mloop, no = nos; i--; ml++, no++) { + for (i = loops_num, ml = mloop, no = nos; i--; ml++, no++) { const int vidx = ml->v; float *co = cos[vidx]; @@ -313,31 +313,31 @@ static void normalEditModifier_do_radial(NormalEditModifierData *enmd, use_invert_vgroup, mix_limit, mix_mode, - num_verts, + verts_num, mloop, loopnors, nos, - num_loops); + loops_num); } if (do_polynors_fix && polygons_check_flip( - mloop, nos, &mesh->ldata, mpoly, BKE_mesh_poly_normals_for_write(mesh), num_polys)) { + mloop, nos, &mesh->ldata, mpoly, BKE_mesh_poly_normals_for_write(mesh), polys_num)) { /* We need to recompute vertex normals! */ BKE_mesh_normals_tag_dirty(mesh); } BKE_mesh_normals_loop_custom_set(mvert, BKE_mesh_vertex_normals_ensure(mesh), - num_verts, + verts_num, medge, - num_edges, + edges_num, mloop, nos, - num_loops, + loops_num, mpoly, polynors, - num_polys, + polys_num, clnors); MEM_freeN(cos); @@ -359,20 +359,20 @@ static void normalEditModifier_do_directional(NormalEditModifierData *enmd, const int defgrp_index, const bool use_invert_vgroup, MVert *mvert, - const int num_verts, + const int verts_num, MEdge *medge, - const int num_edges, + const int edges_num, MLoop *mloop, - const int num_loops, + const int loops_num, MPoly *mpoly, - const int num_polys) + const int polys_num) { Object *ob_target = enmd->target; const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; const bool use_parallel_normals = (enmd->flag & MOD_NORMALEDIT_USE_DIRECTION_PARALLEL) != 0; - float(*nos)[3] = MEM_malloc_arrayN((size_t)num_loops, sizeof(*nos), __func__); + float(*nos)[3] = MEM_malloc_arrayN((size_t)loops_num, sizeof(*nos), __func__); float target_co[3]; int i; @@ -390,20 +390,20 @@ static void normalEditModifier_do_directional(NormalEditModifierData *enmd, sub_v3_v3v3(no, target_co, enmd->offset); normalize_v3(no); - for (i = num_loops; i--;) { + for (i = loops_num; i--;) { copy_v3_v3(nos[i], no); } } else { - float(*cos)[3] = MEM_malloc_arrayN((size_t)num_verts, sizeof(*cos), __func__); - generate_vert_coordinates(mesh, ob, ob_target, NULL, num_verts, cos, NULL); + float(*cos)[3] = MEM_malloc_arrayN((size_t)verts_num, sizeof(*cos), __func__); + generate_vert_coordinates(mesh, ob, ob_target, NULL, verts_num, cos, NULL); - BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)num_verts, __func__); + BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)verts_num, __func__); MLoop *ml; float(*no)[3]; /* We reuse cos to now store the 'to target' normal of the verts! */ - for (i = num_loops, no = nos, ml = mloop; i--; no++, ml++) { + for (i = loops_num, no = nos, ml = mloop; i--; no++, ml++) { const int vidx = ml->v; float *co = cos[vidx]; @@ -428,30 +428,30 @@ static void normalEditModifier_do_directional(NormalEditModifierData *enmd, use_invert_vgroup, mix_limit, mix_mode, - num_verts, + verts_num, mloop, loopnors, nos, - num_loops); + loops_num); } if (do_polynors_fix && polygons_check_flip( - mloop, nos, &mesh->ldata, mpoly, BKE_mesh_poly_normals_for_write(mesh), num_polys)) { + mloop, nos, &mesh->ldata, mpoly, BKE_mesh_poly_normals_for_write(mesh), polys_num)) { BKE_mesh_normals_tag_dirty(mesh); } BKE_mesh_normals_loop_custom_set(mvert, BKE_mesh_vertex_normals_ensure(mesh), - num_verts, + verts_num, medge, - num_edges, + edges_num, mloop, nos, - num_loops, + loops_num, mpoly, polynors, - num_polys, + polys_num, clnors); MEM_freeN(nos); @@ -519,10 +519,10 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, result = mesh; } - const int num_verts = result->totvert; - const int num_edges = result->totedge; - const int num_loops = result->totloop; - const int num_polys = result->totpoly; + const int verts_num = result->totvert; + const int edges_num = result->totedge; + const int loops_num = result->totloop; + const int polys_num = result->totpoly; MVert *mvert = result->mvert; MEdge *medge = result->medge; MLoop *mloop = result->mloop; @@ -541,20 +541,20 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL); if (use_current_clnors) { - clnors = CustomData_duplicate_referenced_layer(ldata, CD_CUSTOMLOOPNORMAL, num_loops); - loopnors = MEM_malloc_arrayN((size_t)num_loops, sizeof(*loopnors), __func__); + clnors = CustomData_duplicate_referenced_layer(ldata, CD_CUSTOMLOOPNORMAL, loops_num); + loopnors = MEM_malloc_arrayN((size_t)loops_num, sizeof(*loopnors), __func__); BKE_mesh_normals_loop_split(mvert, vert_normals, - num_verts, + verts_num, medge, - num_edges, + edges_num, mloop, loopnors, - num_loops, + loops_num, mpoly, poly_normals, - num_polys, + polys_num, true, result->smoothresh, NULL, @@ -563,7 +563,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, } if (clnors == NULL) { - clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, num_loops); + clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, loops_num); } MOD_get_vgroup(ob, result, enmd->defgrp_name, &dvert, &defgrp_index); @@ -583,13 +583,13 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, defgrp_index, use_invert_vgroup, mvert, - num_verts, + verts_num, medge, - num_edges, + edges_num, mloop, - num_loops, + loops_num, mpoly, - num_polys); + polys_num); } else if (enmd->mode == MOD_NORMALEDIT_MODE_DIRECTIONAL) { normalEditModifier_do_directional(enmd, @@ -606,13 +606,13 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, defgrp_index, use_invert_vgroup, mvert, - num_verts, + verts_num, medge, - num_edges, + edges_num, mloop, - num_loops, + loops_num, mpoly, - num_polys); + polys_num); } MEM_SAFE_FREE(loopnors); diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index c1423347413..6ded702ceda 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -249,8 +249,8 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co GenerateOceanGeometryData gogd; - int num_verts; - int num_polys; + int verts_num; + int polys_num; const bool use_threading = resolution > 4; @@ -259,8 +259,8 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co gogd.res_x = gogd.rx * omd->repeat_x; gogd.res_y = gogd.ry * omd->repeat_y; - num_verts = (gogd.res_x + 1) * (gogd.res_y + 1); - num_polys = gogd.res_x * gogd.res_y; + verts_num = (gogd.res_x + 1) * (gogd.res_y + 1); + polys_num = gogd.res_x * gogd.res_y; gogd.sx = omd->size * omd->spatial_size; gogd.sy = omd->size * omd->spatial_size; @@ -270,7 +270,7 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co gogd.sx /= gogd.rx; gogd.sy /= gogd.ry; - result = BKE_mesh_new_nomain(num_verts, 0, 0, num_polys * 4, num_polys); + result = BKE_mesh_new_nomain(verts_num, 0, 0, polys_num * 4, polys_num); BKE_mesh_copy_parameters_for_eval(result, mesh_orig); gogd.mverts = result->mvert; @@ -292,7 +292,7 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co /* add uvs */ if (CustomData_number_of_layers(&result->ldata, CD_MLOOPUV) < MAX_MTFACE) { gogd.mloopuvs = CustomData_add_layer( - &result->ldata, CD_MLOOPUV, CD_CALLOC, NULL, num_polys * 4); + &result->ldata, CD_MLOOPUV, CD_CALLOC, NULL, polys_num * 4); if (gogd.mloopuvs) { /* unlikely to fail */ gogd.ix = 1.0 / gogd.rx; @@ -377,23 +377,23 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes if (omd->flag & MOD_OCEAN_GENERATE_FOAM) { if (CustomData_number_of_layers(&result->ldata, CD_MLOOPCOL) < MAX_MCOL) { - const int num_polys = result->totpoly; - const int num_loops = result->totloop; + const int polys_num = result->totpoly; + const int loops_num = result->totloop; MLoop *mloops = result->mloop; MLoopCol *mloopcols = CustomData_add_layer_named( - &result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, num_loops, omd->foamlayername); + &result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, loops_num, omd->foamlayername); MLoopCol *mloopcols_spray = NULL; if (omd->flag & MOD_OCEAN_GENERATE_SPRAY) { mloopcols_spray = CustomData_add_layer_named( - &result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, num_loops, omd->spraylayername); + &result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, loops_num, omd->spraylayername); } if (mloopcols) { /* unlikely to fail */ MPoly *mpolys = result->mpoly; MPoly *mp; - for (i = 0, mp = mpolys; i < num_polys; i++, mp++) { + for (i = 0, mp = mpolys; i < polys_num; i++, mp++) { MLoop *ml = &mloops[mp->loopstart]; MLoopCol *mlcol = &mloopcols[mp->loopstart]; @@ -449,9 +449,9 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes /* NOTE: tried to parallelized that one and previous foam loop, * but gives 20% slower results... odd. */ { - const int num_verts = result->totvert; + const int verts_num = result->totvert; - for (i = 0; i < num_verts; i++) { + for (i = 0; i < verts_num; i++) { float *vco = mverts[i].co; const float u = OCEAN_CO(size_co_inv, vco[0]); const float v = OCEAN_CO(size_co_inv, vco[1]); diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index 6c2651bae1f..7df7ba7c1db 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -100,7 +100,7 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { Mesh *mesh_src = mesh; ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; @@ -118,7 +118,8 @@ static void deformVerts(ModifierData *md, } if (mesh_src == NULL) { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, vertexCos, numVerts, false, true); + mesh_src = MOD_deform_mesh_eval_get( + ctx->object, NULL, NULL, vertexCos, verts_num, false, true); if (mesh_src == NULL) { return; } @@ -235,7 +236,7 @@ static void deformVertsEM(ModifierData *md, BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { const bool do_temp_mesh = (mesh == NULL); if (do_temp_mesh) { @@ -243,7 +244,7 @@ static void deformVertsEM(ModifierData *md, BM_mesh_bm_to_me(NULL, editData->bm, mesh, &((BMeshToMeshParams){0})); } - deformVerts(md, ob, mesh, vertexCos, numVerts); + deformVerts(md, ob, mesh, vertexCos, verts_num); if (derivedData) { BKE_id_free(NULL, mesh); diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index 5d6be527b2d..6953e89dfc2 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -27,14 +27,14 @@ static void deformVerts(ModifierData *UNUSED(md), const ModifierEvalContext *ctx, Mesh *UNUSED(mesh), float (*vertexCos)[3], - int numVerts) + int verts_num) { Key *key = BKE_key_from_object(ctx->object); if (key && key->block.first) { int deformedVerts_tot; BKE_key_evaluate_object_ex( - ctx->object, &deformedVerts_tot, (float *)vertexCos, sizeof(*vertexCos) * numVerts); + ctx->object, &deformedVerts_tot, (float *)vertexCos, sizeof(*vertexCos) * verts_num); } } @@ -43,7 +43,7 @@ static void deformMatrices(ModifierData *md, Mesh *mesh, float (*vertexCos)[3], float (*defMats)[3][3], - int numVerts) + int verts_num) { Key *key = BKE_key_from_object(ctx->object); KeyBlock *kb = BKE_keyblock_from_object(ctx->object); @@ -51,7 +51,7 @@ static void deformMatrices(ModifierData *md, (void)vertexCos; /* unused */ - if (kb && kb->totelem == numVerts && kb != key->refkey) { + if (kb && kb->totelem == verts_num && kb != key->refkey) { int a; if (ctx->object->shapeflag & OB_SHAPE_LOCK) { @@ -61,12 +61,12 @@ static void deformMatrices(ModifierData *md, scale_m3_fl(scale, kb->curval); } - for (a = 0; a < numVerts; a++) { + for (a = 0; a < verts_num; a++) { copy_m3_m3(defMats[a], scale); } } - deformVerts(md, ctx, mesh, vertexCos, numVerts); + deformVerts(md, ctx, mesh, vertexCos, verts_num); } static void deformVertsEM(ModifierData *md, @@ -74,12 +74,12 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *UNUSED(editData), Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { Key *key = BKE_key_from_object(ctx->object); if (key && key->type == KEY_RELATIVE) { - deformVerts(md, ctx, mesh, vertexCos, numVerts); + deformVerts(md, ctx, mesh, vertexCos, verts_num); } } @@ -89,7 +89,7 @@ static void deformMatricesEM(ModifierData *UNUSED(md), Mesh *UNUSED(mesh), float (*vertexCos)[3], float (*defMats)[3][3], - int numVerts) + int verts_num) { Key *key = BKE_key_from_object(ctx->object); KeyBlock *kb = BKE_keyblock_from_object(ctx->object); @@ -97,11 +97,11 @@ static void deformMatricesEM(ModifierData *UNUSED(md), (void)vertexCos; /* unused */ - if (kb && kb->totelem == numVerts && kb != key->refkey) { + if (kb && kb->totelem == verts_num && kb != key->refkey) { int a; scale_m3_fl(scale, kb->curval); - for (a = 0; a < numVerts; a++) { + for (a = 0; a < verts_num; a++) { copy_m3_m3(defMats[a], scale); } } diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c index 21f8f90585d..488df3d6f4c 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -98,7 +98,7 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { ShrinkwrapModifierData *swmd = (ShrinkwrapModifierData *)md; struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); @@ -108,7 +108,7 @@ static void deformVerts(ModifierData *md, (swmd->shrinkType == MOD_SHRINKWRAP_PROJECT)) { /* mesh_src is needed for vgroups, but also used as ShrinkwrapCalcData.vert when projecting. * Avoid time-consuming mesh conversion for curves when not projecting. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); } struct MDeformVert *dvert = NULL; @@ -116,7 +116,7 @@ static void deformVerts(ModifierData *md, MOD_get_vgroup(ctx->object, mesh_src, swmd->vgroup_name, &dvert, &defgrp_index); shrinkwrapModifier_deform( - swmd, ctx, scene, ctx->object, mesh_src, dvert, defgrp_index, vertexCos, numVerts); + swmd, ctx, scene, ctx->object, mesh_src, dvert, defgrp_index, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -128,14 +128,15 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { ShrinkwrapModifierData *swmd = (ShrinkwrapModifierData *)md; struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); Mesh *mesh_src = NULL; if ((swmd->vgroup_name[0] != '\0') || (swmd->shrinkType == MOD_SHRINKWRAP_PROJECT)) { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get( + ctx->object, editData, mesh, NULL, verts_num, false, false); } /* TODO(Campbell): use edit-mode data only (remove this line). */ @@ -150,7 +151,7 @@ static void deformVertsEM(ModifierData *md, } shrinkwrapModifier_deform( - swmd, ctx, scene, ctx->object, mesh_src, dvert, defgrp_index, vertexCos, numVerts); + swmd, ctx, scene, ctx->object, mesh_src, dvert, defgrp_index, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 4fbef6f54ae..e3c7f1c423b 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -288,7 +288,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, struct Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { int i; float smd_limit[2], smd_factor; @@ -355,7 +355,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, float lower = FLT_MAX; float upper = -FLT_MAX; - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { float tmp[3]; copy_v3_v3(tmp, vertexCos[i]); @@ -401,7 +401,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, /* Do deformation. */ TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); - BLI_task_parallel_range(0, numVerts, (void *)&deform_pool_data, simple_helper, &settings); + BLI_task_parallel_range(0, verts_num, (void *)&deform_pool_data, simple_helper, &settings); } /* SimpleDeform */ @@ -446,17 +446,17 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, struct Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { SimpleDeformModifierData *sdmd = (SimpleDeformModifierData *)md; Mesh *mesh_src = NULL; if (ctx->object->type == OB_MESH && sdmd->vgroup_name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); } - SimpleDeformModifier_do(sdmd, ctx, ctx->object, mesh_src, vertexCos, numVerts); + SimpleDeformModifier_do(sdmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -468,14 +468,15 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, struct Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { SimpleDeformModifierData *sdmd = (SimpleDeformModifierData *)md; Mesh *mesh_src = NULL; if (ctx->object->type == OB_MESH && sdmd->vgroup_name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get( + ctx->object, editData, mesh, NULL, verts_num, false, false); } /* TODO(Campbell): use edit-mode data only (remove this line). */ @@ -483,7 +484,7 @@ static void deformVertsEM(ModifierData *md, BKE_mesh_wrapper_ensure_mdata(mesh_src); } - SimpleDeformModifier_do(sdmd, ctx, ctx->object, mesh_src, vertexCos, numVerts); + SimpleDeformModifier_do(sdmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 6ab6dc5d4c8..b950578ff1b 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -649,14 +649,14 @@ static void connection_node_frames(int v, } static SkinNode *build_frames( - const MVert *mvert, int totvert, const MVertSkin *nodes, const MeshElemMap *emap, EMat *emat) + const MVert *mvert, int verts_num, const MVertSkin *nodes, const MeshElemMap *emap, EMat *emat) { SkinNode *skin_nodes; int v; - skin_nodes = MEM_calloc_arrayN(totvert, sizeof(SkinNode), "build_frames.skin_nodes"); + skin_nodes = MEM_calloc_arrayN(verts_num, sizeof(SkinNode), "build_frames.skin_nodes"); - for (v = 0; v < totvert; v++) { + for (v = 0; v < verts_num; v++) { if (emap[v].count <= 1) { end_node_frames(v, skin_nodes, mvert, nodes, emap, emat); } @@ -766,10 +766,10 @@ static void build_emats_stack(BLI_Stack *stack, static EMat *build_edge_mats(const MVertSkin *vs, const MVert *mvert, - int totvert, + const int verts_num, const MEdge *medge, const MeshElemMap *emap, - int totedge, + const int edges_num, bool *has_valid_root) { BLI_Stack *stack; @@ -780,12 +780,12 @@ static EMat *build_edge_mats(const MVertSkin *vs, stack = BLI_stack_new(sizeof(stack_elem), "build_edge_mats.stack"); - visited_e = BLI_BITMAP_NEW(totedge, "build_edge_mats.visited_e"); - emat = MEM_calloc_arrayN(totedge, sizeof(EMat), "build_edge_mats.emat"); + visited_e = BLI_BITMAP_NEW(edges_num, "build_edge_mats.visited_e"); + emat = MEM_calloc_arrayN(edges_num, sizeof(EMat), "build_edge_mats.emat"); /* Edge matrices are built from the root nodes, add all roots with * children to the stack */ - for (v = 0; v < totvert; v++) { + for (v = 0; v < verts_num; v++) { if (vs[v].flag & MVERT_SKIN_ROOT) { if (emap[v].count >= 1) { const MEdge *e = &medge[emap[v].indices[0]]; @@ -800,7 +800,7 @@ static EMat *build_edge_mats(const MVertSkin *vs, *has_valid_root = true; } - else if (totedge == 0) { + else if (edges_num == 0) { /* Vertex-only mesh is valid, mark valid root as well (will display error otherwise). */ *has_valid_root = true; break; @@ -837,7 +837,7 @@ static int calc_edge_subdivisions(const MVert *mvert, float avg_radius; const bool v1_branch = degree[e->v1] > 2; const bool v2_branch = degree[e->v2] > 2; - int num_subdivisions; + int subdivisions_num; /* If either end is a branch node marked 'loose', don't subdivide * the edge (or subdivide just twice if both are branches) */ @@ -854,27 +854,27 @@ static int calc_edge_subdivisions(const MVert *mvert, if (avg_radius != 0.0f) { /* possible (but unlikely) that we overflow INT_MAX */ - float num_subdivisions_fl; + float subdivisions_num_fl; const float edge_len = len_v3v3(mvert[e->v1].co, mvert[e->v2].co); - num_subdivisions_fl = (edge_len / avg_radius); - if (num_subdivisions_fl < NUM_SUBDIVISIONS_MAX) { - num_subdivisions = (int)num_subdivisions_fl; + subdivisions_num_fl = (edge_len / avg_radius); + if (subdivisions_num_fl < NUM_SUBDIVISIONS_MAX) { + subdivisions_num = (int)subdivisions_num_fl; } else { - num_subdivisions = NUM_SUBDIVISIONS_MAX; + subdivisions_num = NUM_SUBDIVISIONS_MAX; } } else { - num_subdivisions = 0; + subdivisions_num = 0; } /* If both ends are branch nodes, two intermediate nodes are * required */ - if (num_subdivisions < 2 && v1_branch && v2_branch) { - num_subdivisions = 2; + if (subdivisions_num < 2 && v1_branch && v2_branch) { + subdivisions_num = 2; } - return num_subdivisions; + return subdivisions_num; #undef NUM_SUBDIVISIONS_MAX } @@ -888,8 +888,8 @@ static Mesh *subdivide_base(Mesh *orig) MVert *origvert, *outvert; MEdge *origedge, *outedge, *e; MDeformVert *origdvert, *outdvert; - int totorigvert, totorigedge; - int totsubd, *degree, *edge_subd; + int orig_vert_num, orig_edge_num; + int subd_num, *degree, *edge_subd; int i, j, k, u, v; float radrat; @@ -897,29 +897,29 @@ static Mesh *subdivide_base(Mesh *orig) origvert = orig->mvert; origedge = orig->medge; origdvert = orig->dvert; - totorigvert = orig->totvert; - totorigedge = orig->totedge; + orig_vert_num = orig->totvert; + orig_edge_num = orig->totedge; /* Get degree of all vertices */ - degree = MEM_calloc_arrayN(totorigvert, sizeof(int), "degree"); - for (i = 0; i < totorigedge; i++) { + degree = MEM_calloc_arrayN(orig_vert_num, sizeof(int), "degree"); + for (i = 0; i < orig_edge_num; i++) { degree[origedge[i].v1]++; degree[origedge[i].v2]++; } /* Per edge, store how many subdivisions are needed */ - edge_subd = MEM_calloc_arrayN((uint)totorigedge, sizeof(int), "edge_subd"); - for (i = 0, totsubd = 0; i < totorigedge; i++) { + edge_subd = MEM_calloc_arrayN((uint)orig_edge_num, sizeof(int), "edge_subd"); + for (i = 0, subd_num = 0; i < orig_edge_num; i++) { edge_subd[i] += calc_edge_subdivisions(origvert, orignode, &origedge[i], degree); BLI_assert(edge_subd[i] >= 0); - totsubd += edge_subd[i]; + subd_num += edge_subd[i]; } MEM_freeN(degree); /* Allocate output mesh */ result = BKE_mesh_new_nomain_from_template( - orig, totorigvert + totsubd, totorigedge + totsubd, 0, 0, 0); + orig, orig_vert_num + subd_num, orig_edge_num + subd_num, 0, 0, 0); outvert = result->mvert; outedge = result->medge; @@ -927,16 +927,16 @@ static Mesh *subdivide_base(Mesh *orig) outdvert = result->dvert; /* Copy original vertex data */ - CustomData_copy_data(&orig->vdata, &result->vdata, 0, 0, totorigvert); + CustomData_copy_data(&orig->vdata, &result->vdata, 0, 0, orig_vert_num); /* Subdivide edges */ - for (i = 0, v = totorigvert; i < totorigedge; i++) { + for (i = 0, v = orig_vert_num; i < orig_edge_num; i++) { struct { /* Vertex group number */ int def_nr; float w1, w2; } *vgroups = NULL, *vg; - int totvgroup = 0; + int vgroups_num = 0; e = &origedge[i]; @@ -950,8 +950,8 @@ static Mesh *subdivide_base(Mesh *orig) vg = NULL; for (k = 0; k < dv2->totweight; k++) { if (dv1->dw[j].def_nr == dv2->dw[k].def_nr) { - vg = &vgroups[totvgroup]; - totvgroup++; + vg = &vgroups[vgroups_num]; + vgroups_num++; break; } } @@ -986,7 +986,7 @@ static Mesh *subdivide_base(Mesh *orig) interp_v3_v3v3(outnode[v].radius, orignode[e->v1].radius, orignode[e->v2].radius, t); /* Interpolate vertex group weights */ - for (k = 0; k < totvgroup; k++) { + for (k = 0; k < vgroups_num; k++) { float weight; vg = &vgroups[k]; @@ -1561,14 +1561,14 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd) } static void skin_merge_close_frame_verts(SkinNode *skin_nodes, - int totvert, + int verts_num, const MeshElemMap *emap, const MEdge *medge) { Frame **hull_frames; int v, tothullframe; - for (v = 0; v < totvert; v++) { + for (v = 0; v < verts_num; v++) { /* Only check branch nodes */ if (!skin_nodes[v].totframe) { hull_frames = collect_hull_frames(v, skin_nodes, emap, medge, &tothullframe); @@ -1578,11 +1578,11 @@ static void skin_merge_close_frame_verts(SkinNode *skin_nodes, } } -static void skin_update_merged_vertices(SkinNode *skin_nodes, int totvert) +static void skin_update_merged_vertices(SkinNode *skin_nodes, int verts_num) { int v; - for (v = 0; v < totvert; v++) { + for (v = 0; v < verts_num; v++) { SkinNode *sn = &skin_nodes[v]; int i, j; @@ -1601,11 +1601,11 @@ static void skin_update_merged_vertices(SkinNode *skin_nodes, int totvert) } } -static void skin_fix_hull_topology(BMesh *bm, SkinNode *skin_nodes, int totvert) +static void skin_fix_hull_topology(BMesh *bm, SkinNode *skin_nodes, int verts_num) { int v; - for (v = 0; v < totvert; v++) { + for (v = 0; v < verts_num; v++) { SkinNode *sn = &skin_nodes[v]; int j; @@ -1626,11 +1626,11 @@ static void skin_fix_hull_topology(BMesh *bm, SkinNode *skin_nodes, int totvert) } } -static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, int totvert) +static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, int verts_num) { int v; - for (v = 0; v < totvert; v++) { + for (v = 0; v < verts_num; v++) { SkinNode *sn = &skin_nodes[v]; /* Assuming here just two frames */ if (sn->flag & SEAM_FRAME) { @@ -1676,11 +1676,11 @@ static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, int totv static void skin_output_connections(SkinOutput *so, SkinNode *skin_nodes, const MEdge *medge, - int totedge) + int edges_num) { int e; - for (e = 0; e < totedge; e++) { + for (e = 0; e < edges_num; e++) { SkinNode *a, *b; a = &skin_nodes[medge[e].v1]; b = &skin_nodes[medge[e].v2]; @@ -1713,7 +1713,7 @@ static void skin_output_connections(SkinOutput *so, static void skin_smooth_hulls(BMesh *bm, SkinNode *skin_nodes, - int totvert, + int verts_num, const SkinModifierData *smd) { BMIter iter, eiter; @@ -1726,7 +1726,7 @@ static void skin_smooth_hulls(BMesh *bm, /* Mark all frame vertices */ BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false); - for (i = 0; i < totvert; i++) { + for (i = 0; i < verts_num; i++) { for (j = 0; j < skin_nodes[i].totframe; j++) { Frame *frame = &skin_nodes[i].frames[j]; @@ -1780,13 +1780,16 @@ static void skin_smooth_hulls(BMesh *bm, } /* Returns true if all hulls are successfully built, false otherwise */ -static bool skin_output_branch_hulls( - SkinOutput *so, SkinNode *skin_nodes, int totvert, const MeshElemMap *emap, const MEdge *medge) +static bool skin_output_branch_hulls(SkinOutput *so, + SkinNode *skin_nodes, + int verts_num, + const MeshElemMap *emap, + const MEdge *medge) { bool result = true; int v; - for (v = 0; v < totvert; v++) { + for (v = 0; v < verts_num; v++) { SkinNode *sn = &skin_nodes[v]; /* Branch node hulls */ @@ -1812,10 +1815,10 @@ typedef enum eSkinErrorFlag { } eSkinErrorFlag; static BMesh *build_skin(SkinNode *skin_nodes, - int totvert, + int verts_num, const MeshElemMap *emap, const MEdge *medge, - int totedge, + int edges_num, const MDeformVert *input_dvert, SkinModifierData *smd, eSkinErrorFlag *r_error) @@ -1841,19 +1844,19 @@ static BMesh *build_skin(SkinNode *skin_nodes, /* Check for mergeable frame corners around hulls before * outputting vertices */ - skin_merge_close_frame_verts(skin_nodes, totvert, emap, medge); + skin_merge_close_frame_verts(skin_nodes, verts_num, emap, medge); /* Write out all frame vertices to the mesh */ - for (v = 0; v < totvert; v++) { + for (v = 0; v < verts_num; v++) { if (skin_nodes[v].totframe) { output_frames(so.bm, &skin_nodes[v], input_dvert ? &input_dvert[v] : NULL); } } /* Update vertex pointers for merged frame corners */ - skin_update_merged_vertices(skin_nodes, totvert); + skin_update_merged_vertices(skin_nodes, verts_num); - if (!skin_output_branch_hulls(&so, skin_nodes, totvert, emap, medge)) { + if (!skin_output_branch_hulls(&so, skin_nodes, verts_num, emap, medge)) { *r_error |= SKIN_ERROR_HULL; } @@ -1871,12 +1874,12 @@ static BMesh *build_skin(SkinNode *skin_nodes, * creating all hull faces, but before creating any other * faces. */ - skin_fix_hull_topology(so.bm, skin_nodes, totvert); + skin_fix_hull_topology(so.bm, skin_nodes, verts_num); - skin_smooth_hulls(so.bm, skin_nodes, totvert, smd); + skin_smooth_hulls(so.bm, skin_nodes, verts_num, smd); - skin_output_end_nodes(&so, skin_nodes, totvert); - skin_output_connections(&so, skin_nodes, medge, totedge); + skin_output_end_nodes(&so, skin_nodes, verts_num); + skin_output_connections(&so, skin_nodes, medge, edges_num); hull_merge_triangles(&so, smd); bmesh_edit_end(so.bm, 0); @@ -1912,7 +1915,7 @@ static Mesh *base_skin(Mesh *origmesh, SkinModifierData *smd, eSkinErrorFlag *r_ MVert *mvert; MEdge *medge; MDeformVert *dvert; - int totvert, totedge; + int verts_num, edges_num; bool has_valid_root = false; nodes = CustomData_get_layer(&origmesh->vdata, CD_MVERT_SKIN); @@ -1920,17 +1923,17 @@ static Mesh *base_skin(Mesh *origmesh, SkinModifierData *smd, eSkinErrorFlag *r_ mvert = origmesh->mvert; dvert = origmesh->dvert; medge = origmesh->medge; - totvert = origmesh->totvert; - totedge = origmesh->totedge; + verts_num = origmesh->totvert; + edges_num = origmesh->totedge; - BKE_mesh_vert_edge_map_create(&emap, &emapmem, medge, totvert, totedge); + BKE_mesh_vert_edge_map_create(&emap, &emapmem, medge, verts_num, edges_num); - emat = build_edge_mats(nodes, mvert, totvert, medge, emap, totedge, &has_valid_root); - skin_nodes = build_frames(mvert, totvert, nodes, emap, emat); + emat = build_edge_mats(nodes, mvert, verts_num, medge, emap, edges_num, &has_valid_root); + skin_nodes = build_frames(mvert, verts_num, nodes, emap, emat); MEM_freeN(emat); emat = NULL; - bm = build_skin(skin_nodes, totvert, emap, medge, totedge, dvert, smd, r_error); + bm = build_skin(skin_nodes, verts_num, emap, medge, edges_num, dvert, smd, r_error); MEM_freeN(skin_nodes); MEM_freeN(emap); diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index 4236147c1f3..5439083d9a7 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -76,21 +76,21 @@ static void requiredDataMask(Object *UNUSED(ob), } static void smoothModifier_do( - SmoothModifierData *smd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int numVerts) + SmoothModifierData *smd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int verts_num) { if (mesh == NULL) { return; } float(*accumulated_vecs)[3] = MEM_calloc_arrayN( - (size_t)numVerts, sizeof(*accumulated_vecs), __func__); + (size_t)verts_num, sizeof(*accumulated_vecs), __func__); if (!accumulated_vecs) { return; } - uint *num_accumulated_vecs = MEM_calloc_arrayN( - (size_t)numVerts, sizeof(*num_accumulated_vecs), __func__); - if (!num_accumulated_vecs) { + uint *accumulated_vecs_count = MEM_calloc_arrayN( + (size_t)verts_num, sizeof(*accumulated_vecs_count), __func__); + if (!accumulated_vecs_count) { MEM_freeN(accumulated_vecs); return; } @@ -100,7 +100,7 @@ static void smoothModifier_do( const bool invert_vgroup = (smd->flag & MOD_SMOOTH_INVERT_VGROUP) != 0; MEdge *medges = mesh->medge; - const int num_edges = mesh->totedge; + const int edges_num = mesh->totedge; MDeformVert *dvert; int defgrp_index; @@ -108,31 +108,31 @@ static void smoothModifier_do( for (int j = 0; j < smd->repeat; j++) { if (j != 0) { - memset(accumulated_vecs, 0, sizeof(*accumulated_vecs) * (size_t)numVerts); - memset(num_accumulated_vecs, 0, sizeof(*num_accumulated_vecs) * (size_t)numVerts); + memset(accumulated_vecs, 0, sizeof(*accumulated_vecs) * (size_t)verts_num); + memset(accumulated_vecs_count, 0, sizeof(*accumulated_vecs_count) * (size_t)verts_num); } - for (int i = 0; i < num_edges; i++) { + for (int i = 0; i < edges_num; i++) { float fvec[3]; const uint idx1 = medges[i].v1; const uint idx2 = medges[i].v2; mid_v3_v3v3(fvec, vertexCos[idx1], vertexCos[idx2]); - num_accumulated_vecs[idx1]++; + accumulated_vecs_count[idx1]++; add_v3_v3(accumulated_vecs[idx1], fvec); - num_accumulated_vecs[idx2]++; + accumulated_vecs_count[idx2]++; add_v3_v3(accumulated_vecs[idx2], fvec); } const short flag = smd->flag; if (dvert) { MDeformVert *dv = dvert; - for (int i = 0; i < numVerts; i++, dv++) { + for (int i = 0; i < verts_num; i++, dv++) { float *vco_orig = vertexCos[i]; - if (num_accumulated_vecs[i] > 0) { - mul_v3_fl(accumulated_vecs[i], 1.0f / (float)num_accumulated_vecs[i]); + if (accumulated_vecs_count[i] > 0) { + mul_v3_fl(accumulated_vecs[i], 1.0f / (float)accumulated_vecs_count[i]); } float *vco_new = accumulated_vecs[i]; @@ -156,10 +156,10 @@ static void smoothModifier_do( } } else { /* no vertex group */ - for (int i = 0; i < numVerts; i++) { + for (int i = 0; i < verts_num; i++) { float *vco_orig = vertexCos[i]; - if (num_accumulated_vecs[i] > 0) { - mul_v3_fl(accumulated_vecs[i], 1.0f / (float)num_accumulated_vecs[i]); + if (accumulated_vecs_count[i] > 0) { + mul_v3_fl(accumulated_vecs[i], 1.0f / (float)accumulated_vecs_count[i]); } float *vco_new = accumulated_vecs[i]; @@ -177,22 +177,22 @@ static void smoothModifier_do( } MEM_freeN(accumulated_vecs); - MEM_freeN(num_accumulated_vecs); + MEM_freeN(accumulated_vecs_count); } static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { SmoothModifierData *smd = (SmoothModifierData *)md; Mesh *mesh_src = NULL; /* mesh_src is needed for vgroups, and taking edges into account. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); - smoothModifier_do(smd, ctx->object, mesh_src, vertexCos, numVerts); + smoothModifier_do(smd, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -204,18 +204,18 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { SmoothModifierData *smd = (SmoothModifierData *)md; Mesh *mesh_src = NULL; /* mesh_src is needed for vgroups, and taking edges into account. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false, false); /* TODO(campbell): use edit-mode data only (remove this line). */ BKE_mesh_wrapper_ensure_mdata(mesh_src); - smoothModifier_do(smd, ctx->object, mesh_src, vertexCos, numVerts); + smoothModifier_do(smd, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c index ae90240dd3f..d43e26f25e1 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.c @@ -40,11 +40,11 @@ static void deformVerts(ModifierData *UNUSED(md), const ModifierEvalContext *ctx, Mesh *UNUSED(derivedData), float (*vertexCos)[3], - int numVerts) + int verts_num) { Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); sbObjectStep( - ctx->depsgraph, scene, ctx->object, DEG_get_ctime(ctx->depsgraph), vertexCos, numVerts); + ctx->depsgraph, scene, ctx->object, DEG_get_ctime(ctx->depsgraph), vertexCos, verts_num); } static bool dependsOnTime(struct Scene *UNUSED(scene), diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c index fdaf7bd41d1..80af23054e4 100644 --- a/source/blender/modifiers/intern/MOD_solidify_extrude.c +++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c @@ -55,14 +55,14 @@ BLI_INLINE bool edgeref_is_init(const EdgeFaceRef *edge_ref) */ static void mesh_calc_hq_normal(Mesh *mesh, const float (*poly_nors)[3], float (*r_vert_nors)[3]) { - int i, numVerts, numEdges, numPolys; + int i, verts_num, edges_num, polys_num; MPoly *mpoly, *mp; MLoop *mloop, *ml; MEdge *medge, *ed; - numVerts = mesh->totvert; - numEdges = mesh->totedge; - numPolys = mesh->totpoly; + verts_num = mesh->totvert; + edges_num = mesh->totedge; + polys_num = mesh->totpoly; mpoly = mesh->mpoly; medge = mesh->medge; mloop = mesh->mloop; @@ -71,7 +71,7 @@ static void mesh_calc_hq_normal(Mesh *mesh, const float (*poly_nors)[3], float ( /* Doesn't work here! */ #if 0 - mv = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, numVerts); + mv = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, verts_num); cddm->mvert = mv; #endif @@ -79,12 +79,12 @@ static void mesh_calc_hq_normal(Mesh *mesh, const float (*poly_nors)[3], float ( { EdgeFaceRef *edge_ref_array = MEM_calloc_arrayN( - (size_t)numEdges, sizeof(EdgeFaceRef), "Edge Connectivity"); + (size_t)edges_num, sizeof(EdgeFaceRef), "Edge Connectivity"); EdgeFaceRef *edge_ref; float edge_normal[3]; /* Add an edge reference if it's not there, pointing back to the face index. */ - for (i = 0; i < numPolys; i++, mp++) { + for (i = 0; i < polys_num; i++, mp++) { int j; ml = mloop + mp->loopstart; @@ -110,7 +110,7 @@ static void mesh_calc_hq_normal(Mesh *mesh, const float (*poly_nors)[3], float ( } } - for (i = 0, ed = medge, edge_ref = edge_ref_array; i < numEdges; i++, ed++, edge_ref++) { + for (i = 0, ed = medge, edge_ref = edge_ref_array; i < edges_num; i++, ed++, edge_ref++) { /* Get the edge vert indices, and edge value (the face indices that use it) */ if (edgeref_is_init(edge_ref) && (edge_ref->p1 != -1)) { @@ -141,7 +141,7 @@ static void mesh_calc_hq_normal(Mesh *mesh, const float (*poly_nors)[3], float ( /* normalize vertex normals and assign */ const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(mesh); - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { if (normalize_v3(r_vert_nors[i]) == 0.0f) { copy_v3_v3(r_vert_nors[i], vert_normals[i]); } @@ -164,10 +164,10 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex MEdge *ed, *medge, *orig_medge; MLoop *ml, *mloop, *orig_mloop; MPoly *mp, *mpoly, *orig_mpoly; - const uint numVerts = (uint)mesh->totvert; - const uint numEdges = (uint)mesh->totedge; - const uint numPolys = (uint)mesh->totpoly; - const uint numLoops = (uint)mesh->totloop; + const uint verts_num = (uint)mesh->totvert; + const uint edges_num = (uint)mesh->totedge; + const uint polys_num = (uint)mesh->totpoly; + const uint loops_num = (uint)mesh->totloop; uint newLoops = 0, newPolys = 0, newEdges = 0, newVerts = 0, rimVerts = 0; /* Only use material offsets if we have 2 or more materials. */ @@ -184,7 +184,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex STACK_DECLARE(new_edge_arr); uint *old_vert_arr = MEM_calloc_arrayN( - numVerts, sizeof(*old_vert_arr), "old_vert_arr in solidify"); + verts_num, sizeof(*old_vert_arr), "old_vert_arr in solidify"); uint *edge_users = NULL; int *edge_order = NULL; @@ -233,33 +233,34 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex poly_nors = BKE_mesh_poly_normals_ensure(mesh); } - STACK_INIT(new_vert_arr, numVerts * 2); - STACK_INIT(new_edge_arr, numEdges * 2); + STACK_INIT(new_vert_arr, verts_num * 2); + STACK_INIT(new_edge_arr, edges_num * 2); if (do_rim) { - BLI_bitmap *orig_mvert_tag = BLI_BITMAP_NEW(numVerts, __func__); + BLI_bitmap *orig_mvert_tag = BLI_BITMAP_NEW(verts_num, __func__); uint eidx; uint i; #define INVALID_UNUSED ((uint)-1) #define INVALID_PAIR ((uint)-2) - new_vert_arr = MEM_malloc_arrayN(numVerts, 2 * sizeof(*new_vert_arr), __func__); - new_edge_arr = MEM_malloc_arrayN(((numEdges * 2) + numVerts), sizeof(*new_edge_arr), __func__); + new_vert_arr = MEM_malloc_arrayN(verts_num, 2 * sizeof(*new_vert_arr), __func__); + new_edge_arr = MEM_malloc_arrayN( + ((edges_num * 2) + verts_num), sizeof(*new_edge_arr), __func__); - edge_users = MEM_malloc_arrayN(numEdges, sizeof(*edge_users), "solid_mod edges"); - edge_order = MEM_malloc_arrayN(numEdges, sizeof(*edge_order), "solid_mod order"); + edge_users = MEM_malloc_arrayN(edges_num, sizeof(*edge_users), "solid_mod edges"); + edge_order = MEM_malloc_arrayN(edges_num, sizeof(*edge_order), "solid_mod order"); /* save doing 2 loops here... */ #if 0 - copy_vn_i(edge_users, numEdges, INVALID_UNUSED); + copy_vn_i(edge_users, edges_num, INVALID_UNUSED); #endif - for (eidx = 0, ed = orig_medge; eidx < numEdges; eidx++, ed++) { + for (eidx = 0, ed = orig_medge; eidx < edges_num; eidx++, ed++) { edge_users[eidx] = INVALID_UNUSED; } - for (i = 0, mp = orig_mpoly; i < numPolys; i++, mp++) { + for (i = 0, mp = orig_mpoly; i < polys_num; i++, mp++) { MLoop *ml_prev; int j; @@ -272,7 +273,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex if (edge_users[eidx] == INVALID_UNUSED) { ed = orig_medge + eidx; BLI_assert(ELEM(ml_prev->v, ed->v1, ed->v2) && ELEM(ml->v, ed->v1, ed->v2)); - edge_users[eidx] = (ml_prev->v > ml->v) == (ed->v1 < ed->v2) ? i : (i + numPolys); + edge_users[eidx] = (ml_prev->v > ml->v) == (ed->v1 < ed->v2) ? i : (i + polys_num); edge_order[eidx] = j; } else { @@ -282,7 +283,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex } } - for (eidx = 0, ed = orig_medge; eidx < numEdges; eidx++, ed++) { + for (eidx = 0, ed = orig_medge; eidx < edges_num; eidx++, ed++) { if (!ELEM(edge_users[eidx], INVALID_UNUSED, INVALID_PAIR)) { BLI_BITMAP_ENABLE(orig_mvert_tag, ed->v1); BLI_BITMAP_ENABLE(orig_mvert_tag, ed->v2); @@ -292,7 +293,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex } } - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { if (BLI_BITMAP_TEST(orig_mvert_tag, i)) { old_vert_arr[i] = STACK_SIZE(new_vert_arr); STACK_PUSH(new_vert_arr, i); @@ -319,16 +320,16 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex } if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) { - vert_nors = MEM_calloc_arrayN(numVerts, sizeof(float[3]), "mod_solid_vno_hq"); + vert_nors = MEM_calloc_arrayN(verts_num, sizeof(float[3]), "mod_solid_vno_hq"); mesh_calc_hq_normal(mesh, poly_nors, vert_nors); } result = BKE_mesh_new_nomain_from_template(mesh, - (int)((numVerts * stride) + newVerts), - (int)((numEdges * stride) + newEdges + rimVerts), + (int)((verts_num * stride) + newVerts), + (int)((edges_num * stride) + newEdges + rimVerts), 0, - (int)((numLoops * stride) + newLoops), - (int)((numPolys * stride) + newPolys)); + (int)((loops_num * stride) + newLoops), + (int)((polys_num * stride) + newPolys)); mpoly = result->mpoly; mloop = result->mloop; @@ -341,69 +342,69 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex } if (do_shell) { - CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, (int)numVerts); - CustomData_copy_data(&mesh->vdata, &result->vdata, 0, (int)numVerts, (int)numVerts); + CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, (int)verts_num); + CustomData_copy_data(&mesh->vdata, &result->vdata, 0, (int)verts_num, (int)verts_num); - CustomData_copy_data(&mesh->edata, &result->edata, 0, 0, (int)numEdges); - CustomData_copy_data(&mesh->edata, &result->edata, 0, (int)numEdges, (int)numEdges); + CustomData_copy_data(&mesh->edata, &result->edata, 0, 0, (int)edges_num); + CustomData_copy_data(&mesh->edata, &result->edata, 0, (int)edges_num, (int)edges_num); - CustomData_copy_data(&mesh->ldata, &result->ldata, 0, 0, (int)numLoops); + CustomData_copy_data(&mesh->ldata, &result->ldata, 0, 0, (int)loops_num); /* DO NOT copy here the 'copied' part of loop data, we want to reverse loops * (so that winding of copied face get reversed, so that normals get reversed * and point in expected direction...). * If we also copy data here, then this data get overwritten * (and allocated memory becomes memleak). */ - CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)numPolys); - CustomData_copy_data(&mesh->pdata, &result->pdata, 0, (int)numPolys, (int)numPolys); + CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)polys_num); + CustomData_copy_data(&mesh->pdata, &result->pdata, 0, (int)polys_num, (int)polys_num); } else { int i, j; - CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, (int)numVerts); - for (i = 0, j = (int)numVerts; i < numVerts; i++) { + CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, (int)verts_num); + for (i = 0, j = (int)verts_num; i < verts_num; i++) { if (old_vert_arr[i] != INVALID_UNUSED) { CustomData_copy_data(&mesh->vdata, &result->vdata, i, j, 1); j++; } } - CustomData_copy_data(&mesh->edata, &result->edata, 0, 0, (int)numEdges); + CustomData_copy_data(&mesh->edata, &result->edata, 0, 0, (int)edges_num); - for (i = 0, j = (int)numEdges; i < numEdges; i++) { + for (i = 0, j = (int)edges_num; i < edges_num; i++) { if (!ELEM(edge_users[i], INVALID_UNUSED, INVALID_PAIR)) { MEdge *ed_src, *ed_dst; CustomData_copy_data(&mesh->edata, &result->edata, i, j, 1); ed_src = &medge[i]; ed_dst = &medge[j]; - ed_dst->v1 = old_vert_arr[ed_src->v1] + numVerts; - ed_dst->v2 = old_vert_arr[ed_src->v2] + numVerts; + ed_dst->v1 = old_vert_arr[ed_src->v1] + verts_num; + ed_dst->v2 = old_vert_arr[ed_src->v2] + verts_num; j++; } } /* will be created later */ - CustomData_copy_data(&mesh->ldata, &result->ldata, 0, 0, (int)numLoops); - CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)numPolys); + CustomData_copy_data(&mesh->ldata, &result->ldata, 0, 0, (int)loops_num); + CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)polys_num); } /* initializes: (i_end, do_shell_align, mv). */ #define INIT_VERT_ARRAY_OFFSETS(test) \ if (((ofs_new >= ofs_orig) == do_flip) == test) { \ - i_end = numVerts; \ + i_end = verts_num; \ do_shell_align = true; \ mv = mvert; \ } \ else { \ if (do_shell) { \ - i_end = numVerts; \ + i_end = verts_num; \ do_shell_align = true; \ } \ else { \ i_end = newVerts; \ do_shell_align = false; \ } \ - mv = &mvert[numVerts]; \ + mv = &mvert[verts_num]; \ } \ (void)0 @@ -412,7 +413,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex if (do_shell) { uint i; - mp = mpoly + numPolys; + mp = mpoly + polys_num; for (i = 0; i < mesh->totpoly; i++, mp++) { const int loop_end = mp->totloop - 1; MLoop *ml2; @@ -457,14 +458,14 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex mp->loopstart += mesh->totloop; for (j = 0; j < mp->totloop; j++) { - ml2[j].e += numEdges; - ml2[j].v += numVerts; + ml2[j].e += edges_num; + ml2[j].v += verts_num; } } - for (i = 0, ed = medge + numEdges; i < numEdges; i++, ed++) { - ed->v1 += numVerts; - ed->v2 += numVerts; + for (i = 0, ed = medge + edges_num; i < edges_num; i++, ed++) { + ed->v1 += verts_num; + ed->v2 += verts_num; } } @@ -483,9 +484,9 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex float *edge_angs = NULL; if (do_clamp) { - vert_lens = MEM_malloc_arrayN(numVerts, sizeof(float), "vert_lens"); - copy_vn_fl(vert_lens, (int)numVerts, FLT_MAX); - for (uint i = 0; i < numEdges; i++) { + vert_lens = MEM_malloc_arrayN(verts_num, sizeof(float), "vert_lens"); + copy_vn_fl(vert_lens, (int)verts_num, FLT_MAX); + for (uint i = 0; i < edges_num; i++) { const float ed_len_sq = len_squared_v3v3(mvert[medge[i].v1].co, mvert[medge[i].v2].co); vert_lens[medge[i].v1] = min_ff(vert_lens[medge[i].v1], ed_len_sq); vert_lens[medge[i].v2] = min_ff(vert_lens[medge[i].v2], ed_len_sq); @@ -495,23 +496,23 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex if (do_angle_clamp || do_bevel_convex) { uint eidx; if (do_angle_clamp) { - vert_angs = MEM_malloc_arrayN(numVerts, sizeof(float), "vert_angs"); - copy_vn_fl(vert_angs, (int)numVerts, 0.5f * M_PI); + vert_angs = MEM_malloc_arrayN(verts_num, sizeof(float), "vert_angs"); + copy_vn_fl(vert_angs, (int)verts_num, 0.5f * M_PI); } if (do_bevel_convex) { - edge_angs = MEM_malloc_arrayN(numEdges, sizeof(float), "edge_angs"); + edge_angs = MEM_malloc_arrayN(edges_num, sizeof(float), "edge_angs"); if (!do_rim) { - edge_users = MEM_malloc_arrayN(numEdges, sizeof(*edge_users), "solid_mod edges"); + edge_users = MEM_malloc_arrayN(edges_num, sizeof(*edge_users), "solid_mod edges"); } } uint(*edge_user_pairs)[2] = MEM_malloc_arrayN( - numEdges, sizeof(*edge_user_pairs), "edge_user_pairs"); - for (eidx = 0; eidx < numEdges; eidx++) { + edges_num, sizeof(*edge_user_pairs), "edge_user_pairs"); + for (eidx = 0; eidx < edges_num; eidx++) { edge_user_pairs[eidx][0] = INVALID_UNUSED; edge_user_pairs[eidx][1] = INVALID_UNUSED; } mp = orig_mpoly; - for (uint i = 0; i < numPolys; i++, mp++) { + for (uint i = 0; i < polys_num; i++, mp++) { ml = orig_mloop + mp->loopstart; MLoop *ml_prev = ml + (mp->totloop - 1); @@ -533,7 +534,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex } ed = orig_medge; float e[3]; - for (uint i = 0; i < numEdges; i++, ed++) { + for (uint i = 0; i < edges_num; i++, ed++) { if (!ELEM(edge_user_pairs[i][0], INVALID_UNUSED, INVALID_PAIR) && !ELEM(edge_user_pairs[i][1], INVALID_UNUSED, INVALID_PAIR)) { const float *n0 = poly_nors[edge_user_pairs[i][0]]; @@ -658,7 +659,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex } if (do_bevel_convex) { - for (uint i = 0; i < numEdges; i++) { + for (uint i = 0; i < edges_num; i++) { if (edge_users[i] == INVALID_PAIR) { float angle = edge_angs[i]; medge[i].bweight = (char)clamp_i( @@ -668,8 +669,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex 0, 255); if (do_shell) { - medge[i + numEdges].bweight = (char)clamp_i( - (int)medge[i + numEdges].bweight + + medge[i + edges_num].bweight = (char)clamp_i( + (int)medge[i + edges_num].bweight + (int)((angle > M_PI ? clamp_f(bevel_convex, 0.0f, 1.0f) : clamp_f(bevel_convex, -1.0f, 0.0f)) * 255), @@ -697,19 +698,19 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex #endif /* same as EM_solidify() in editmesh_lib.c */ float *vert_angles = MEM_calloc_arrayN( - numVerts, sizeof(float[2]), "mod_solid_pair"); /* 2 in 1 */ - float *vert_accum = vert_angles + numVerts; + verts_num, sizeof(float[2]), "mod_solid_pair"); /* 2 in 1 */ + float *vert_accum = vert_angles + verts_num; uint vidx; uint i; if (vert_nors == NULL) { - vert_nors = MEM_malloc_arrayN(numVerts, sizeof(float[3]), "mod_solid_vno"); - for (i = 0, mv = mvert; i < numVerts; i++, mv++) { + vert_nors = MEM_malloc_arrayN(verts_num, sizeof(float[3]), "mod_solid_vno"); + for (i = 0, mv = mvert; i < verts_num; i++, mv++) { copy_v3_v3(vert_nors[i], mesh_vert_normals[i]); } } - for (i = 0, mp = mpoly; i < numPolys; i++, mp++) { + for (i = 0, mp = mpoly; i < polys_num; i++, mp++) { /* #BKE_mesh_calc_poly_angles logic is inlined here */ float nor_prev[3]; float nor_next[3]; @@ -765,14 +766,14 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex float scalar; if (defgrp_invert) { - for (i = 0; i < numVerts; i++, dv++) { + for (i = 0; i < verts_num; i++, dv++) { scalar = 1.0f - BKE_defvert_find_weight(dv, defgrp_index); scalar = offset_fac_vg + (scalar * offset_fac_vg_inv); vert_angles[i] *= scalar; } } else { - for (i = 0; i < numVerts; i++, dv++) { + for (i = 0; i < verts_num; i++, dv++) { scalar = BKE_defvert_find_weight(dv, defgrp_index); scalar = offset_fac_vg + (scalar * offset_fac_vg_inv); vert_angles[i] *= scalar; @@ -788,22 +789,22 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex if (do_angle_clamp || do_bevel_convex) { uint eidx; if (do_angle_clamp) { - vert_angs = MEM_malloc_arrayN(numVerts, sizeof(float), "vert_angs even"); - copy_vn_fl(vert_angs, (int)numVerts, 0.5f * M_PI); + vert_angs = MEM_malloc_arrayN(verts_num, sizeof(float), "vert_angs even"); + copy_vn_fl(vert_angs, (int)verts_num, 0.5f * M_PI); } if (do_bevel_convex) { - edge_angs = MEM_malloc_arrayN(numEdges, sizeof(float), "edge_angs even"); + edge_angs = MEM_malloc_arrayN(edges_num, sizeof(float), "edge_angs even"); if (!do_rim) { - edge_users = MEM_malloc_arrayN(numEdges, sizeof(*edge_users), "solid_mod edges"); + edge_users = MEM_malloc_arrayN(edges_num, sizeof(*edge_users), "solid_mod edges"); } } uint(*edge_user_pairs)[2] = MEM_malloc_arrayN( - numEdges, sizeof(*edge_user_pairs), "edge_user_pairs"); - for (eidx = 0; eidx < numEdges; eidx++) { + edges_num, sizeof(*edge_user_pairs), "edge_user_pairs"); + for (eidx = 0; eidx < edges_num; eidx++) { edge_user_pairs[eidx][0] = INVALID_UNUSED; edge_user_pairs[eidx][1] = INVALID_UNUSED; } - for (i = 0, mp = orig_mpoly; i < numPolys; i++, mp++) { + for (i = 0, mp = orig_mpoly; i < polys_num; i++, mp++) { ml = orig_mloop + mp->loopstart; MLoop *ml_prev = ml + (mp->totloop - 1); @@ -825,7 +826,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex } ed = orig_medge; float e[3]; - for (i = 0; i < numEdges; i++, ed++) { + for (i = 0; i < edges_num; i++, ed++) { if (!ELEM(edge_user_pairs[i][0], INVALID_UNUSED, INVALID_PAIR) && !ELEM(edge_user_pairs[i][1], INVALID_UNUSED, INVALID_PAIR)) { const float *n0 = poly_nors[edge_user_pairs[i][0]]; @@ -852,16 +853,16 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex const float clamp_fac = 1 + (do_angle_clamp ? fabsf(smd->offset_fac) : 0); const float offset = fabsf(smd->offset) * smd->offset_clamp * clamp_fac; if (offset > FLT_EPSILON) { - float *vert_lens_sq = MEM_malloc_arrayN(numVerts, sizeof(float), "vert_lens_sq"); + float *vert_lens_sq = MEM_malloc_arrayN(verts_num, sizeof(float), "vert_lens_sq"); const float offset_sq = offset * offset; - copy_vn_fl(vert_lens_sq, (int)numVerts, FLT_MAX); - for (i = 0; i < numEdges; i++) { + copy_vn_fl(vert_lens_sq, (int)verts_num, FLT_MAX); + for (i = 0; i < edges_num; i++) { const float ed_len = len_squared_v3v3(mvert[medge[i].v1].co, mvert[medge[i].v2].co); vert_lens_sq[medge[i].v1] = min_ff(vert_lens_sq[medge[i].v1], ed_len); vert_lens_sq[medge[i].v2] = min_ff(vert_lens_sq[medge[i].v2], ed_len); } if (do_angle_clamp) { - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { float cos_ang = cosf(vert_angs[i] * 0.5f); if (cos_ang > 0) { float max_off = sqrtf(vert_lens_sq[i]) * 0.5f / cos_ang; @@ -873,7 +874,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex MEM_freeN(vert_angs); } else { - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { if (vert_lens_sq[i] < offset_sq) { float scalar = sqrtf(vert_lens_sq[i]) / offset; vert_angles[i] *= scalar; @@ -885,7 +886,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex } if (do_bevel_convex) { - for (i = 0; i < numEdges; i++) { + for (i = 0; i < edges_num; i++) { if (edge_users[i] == INVALID_PAIR) { float angle = edge_angs[i]; medge[i].bweight = (char)clamp_i( @@ -895,8 +896,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex 0, 255); if (do_shell) { - medge[i + numEdges].bweight = (char)clamp_i( - (int)medge[i + numEdges].bweight + + medge[i + edges_num].bweight = (char)clamp_i( + (int)medge[i + edges_num].bweight + (int)((angle > M_PI ? clamp_f(bevel_convex, 0, 1) : clamp_f(bevel_convex, -1, 0)) * 255), @@ -959,8 +960,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex else if (do_shell) { uint i; /* flip vertex normals for copied verts */ - mv = mvert + numVerts; - for (i = 0; i < numVerts; i++) { + mv = mvert + verts_num; + for (i = 0; i < verts_num; i++) { negate_v3((float *)mesh_vert_normals[i]); } } @@ -982,14 +983,14 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex for (uint i = 0; i < rimVerts; i++) { BKE_defvert_ensure_index(&result->dvert[new_vert_arr[i]], rim_defgrp_index)->weight = 1.0f; - BKE_defvert_ensure_index(&result->dvert[(do_shell ? new_vert_arr[i] : i) + numVerts], + BKE_defvert_ensure_index(&result->dvert[(do_shell ? new_vert_arr[i] : i) + verts_num], rim_defgrp_index) ->weight = 1.0f; } } if (shell_defgrp_index != -1) { - for (uint i = numVerts; i < result->totvert; i++) { + for (uint i = verts_num; i < result->totvert; i++) { BKE_defvert_ensure_index(&result->dvert[i], shell_defgrp_index)->weight = 1.0f; } } @@ -1014,7 +1015,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex const bool do_side_normals = !BKE_mesh_vertex_normals_are_dirty(result); /* annoying to allocate these since we only need the edge verts, */ float(*edge_vert_nos)[3] = do_side_normals ? - MEM_calloc_arrayN(numVerts, sizeof(float[3]), __func__) : + MEM_calloc_arrayN(verts_num, sizeof(float[3]), __func__) : NULL; float nor[3]; #endif @@ -1032,11 +1033,11 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex /* add faces & edges */ origindex_edge = CustomData_get_layer(&result->edata, CD_ORIGINDEX); - orig_ed = (origindex_edge) ? &origindex_edge[(numEdges * stride) + newEdges] : NULL; - ed = &medge[(numEdges * stride) + newEdges]; /* start after copied edges */ + orig_ed = (origindex_edge) ? &origindex_edge[(edges_num * stride) + newEdges] : NULL; + ed = &medge[(edges_num * stride) + newEdges]; /* start after copied edges */ for (i = 0; i < rimVerts; i++, ed++) { ed->v1 = new_vert_arr[i]; - ed->v2 = (do_shell ? new_vert_arr[i] : i) + numVerts; + ed->v2 = (do_shell ? new_vert_arr[i] : i) + verts_num; ed->flag |= ME_EDGEDRAW | ME_EDGERENDER; if (orig_ed) { @@ -1050,8 +1051,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex } /* faces */ - mp = mpoly + (numPolys * stride); - ml = mloop + (numLoops * stride); + mp = mpoly + (polys_num * stride); + ml = mloop + (loops_num * stride); j = 0; for (i = 0; i < newPolys; i++, mp++) { uint eidx = new_edge_arr[i]; @@ -1059,8 +1060,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex int k1, k2; bool flip; - if (pidx >= numPolys) { - pidx -= numPolys; + if (pidx >= polys_num) { + pidx -= polys_num; flip = true; } else { @@ -1071,8 +1072,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex /* copy most of the face settings */ CustomData_copy_data( - &mesh->pdata, &result->pdata, (int)pidx, (int)((numPolys * stride) + i), 1); - mp->loopstart = (int)(j + (numLoops * stride)); + &mesh->pdata, &result->pdata, (int)pidx, (int)((polys_num * stride) + i), 1); + mp->loopstart = (int)(j + (loops_num * stride)); mp->flag = mpoly[pidx].flag; /* notice we use 'mp->totloop' which is later overwritten, @@ -1087,39 +1088,39 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex mp->totloop = 4; CustomData_copy_data( - &mesh->ldata, &result->ldata, k2, (int)((numLoops * stride) + j + 0), 1); + &mesh->ldata, &result->ldata, k2, (int)((loops_num * stride) + j + 0), 1); CustomData_copy_data( - &mesh->ldata, &result->ldata, k1, (int)((numLoops * stride) + j + 1), 1); + &mesh->ldata, &result->ldata, k1, (int)((loops_num * stride) + j + 1), 1); CustomData_copy_data( - &mesh->ldata, &result->ldata, k1, (int)((numLoops * stride) + j + 2), 1); + &mesh->ldata, &result->ldata, k1, (int)((loops_num * stride) + j + 2), 1); CustomData_copy_data( - &mesh->ldata, &result->ldata, k2, (int)((numLoops * stride) + j + 3), 1); + &mesh->ldata, &result->ldata, k2, (int)((loops_num * stride) + j + 3), 1); if (flip == false) { ml[j].v = ed->v1; ml[j++].e = eidx; ml[j].v = ed->v2; - ml[j++].e = (numEdges * stride) + old_vert_arr[ed->v2] + newEdges; + ml[j++].e = (edges_num * stride) + old_vert_arr[ed->v2] + newEdges; - ml[j].v = (do_shell ? ed->v2 : old_vert_arr[ed->v2]) + numVerts; - ml[j++].e = (do_shell ? eidx : i) + numEdges; + ml[j].v = (do_shell ? ed->v2 : old_vert_arr[ed->v2]) + verts_num; + ml[j++].e = (do_shell ? eidx : i) + edges_num; - ml[j].v = (do_shell ? ed->v1 : old_vert_arr[ed->v1]) + numVerts; - ml[j++].e = (numEdges * stride) + old_vert_arr[ed->v1] + newEdges; + ml[j].v = (do_shell ? ed->v1 : old_vert_arr[ed->v1]) + verts_num; + ml[j++].e = (edges_num * stride) + old_vert_arr[ed->v1] + newEdges; } else { ml[j].v = ed->v2; ml[j++].e = eidx; ml[j].v = ed->v1; - ml[j++].e = (numEdges * stride) + old_vert_arr[ed->v1] + newEdges; + ml[j++].e = (edges_num * stride) + old_vert_arr[ed->v1] + newEdges; - ml[j].v = (do_shell ? ed->v1 : old_vert_arr[ed->v1]) + numVerts; - ml[j++].e = (do_shell ? eidx : i) + numEdges; + ml[j].v = (do_shell ? ed->v1 : old_vert_arr[ed->v1]) + verts_num; + ml[j++].e = (do_shell ? eidx : i) + edges_num; - ml[j].v = (do_shell ? ed->v2 : old_vert_arr[ed->v2]) + numVerts; - ml[j++].e = (numEdges * stride) + old_vert_arr[ed->v2] + newEdges; + ml[j].v = (do_shell ? ed->v2 : old_vert_arr[ed->v2]) + verts_num; + ml[j++].e = (edges_num * stride) + old_vert_arr[ed->v2] + newEdges; } if (origindex_edge) { @@ -1141,7 +1142,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex if (crease_inner) { /* crease += crease_inner; without wrapping */ - char *cr = &(medge[numEdges + (do_shell ? eidx : i)].crease); + char *cr = &(medge[edges_num + (do_shell ? eidx : i)].crease); int tcr = *cr + crease_inner; *cr = tcr > 255 ? 255 : tcr; } @@ -1163,13 +1164,13 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex #ifdef SOLIDIFY_SIDE_NORMALS if (do_side_normals) { const MEdge *ed_orig = medge; - ed = medge + (numEdges * stride); + ed = medge + (edges_num * stride); for (i = 0; i < rimVerts; i++, ed++, ed_orig++) { float nor_cpy[3]; int k; /* NOTE: only the first vertex (lower half of the index) is calculated. */ - BLI_assert(ed->v1 < numVerts); + BLI_assert(ed->v1 < verts_num); normalize_v3_v3(nor_cpy, edge_vert_nos[ed_orig->v1]); for (k = 0; k < 2; k++) { /* loop over both verts of the edge */ diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c index d896cab4688..8a84cd0a3bf 100644 --- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c +++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c @@ -141,11 +141,11 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, MEdge *ed, *medge, *orig_medge; MLoop *ml, *mloop, *orig_mloop; MPoly *mp, *mpoly, *orig_mpoly; - const uint numVerts = (uint)mesh->totvert; - const uint numEdges = (uint)mesh->totedge; - const uint numPolys = (uint)mesh->totpoly; + const uint verts_num = (uint)mesh->totvert; + const uint edges_num = (uint)mesh->totedge; + const uint polys_num = (uint)mesh->totpoly; - if (numPolys == 0 && numVerts != 0) { + if (polys_num == 0 && verts_num != 0) { return mesh; } @@ -193,28 +193,28 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, orig_mloop = mesh->mloop; orig_mpoly = mesh->mpoly; - uint numNewVerts = 0; - uint numNewEdges = 0; - uint numNewLoops = 0; - uint numNewPolys = 0; + uint new_verts_num = 0; + uint new_edges_num = 0; + uint new_loops_num = 0; + uint new_polys_num = 0; #define MOD_SOLIDIFY_EMPTY_TAG ((uint)-1) /* Calculate only face normals. Copied because they are modified directly below. */ - float(*poly_nors)[3] = MEM_malloc_arrayN(numPolys, sizeof(float[3]), __func__); - memcpy(poly_nors, BKE_mesh_poly_normals_ensure(mesh), sizeof(float[3]) * numPolys); + float(*poly_nors)[3] = MEM_malloc_arrayN(polys_num, sizeof(float[3]), __func__); + memcpy(poly_nors, BKE_mesh_poly_normals_ensure(mesh), sizeof(float[3]) * polys_num); NewFaceRef *face_sides_arr = MEM_malloc_arrayN( - numPolys * 2, sizeof(*face_sides_arr), "face_sides_arr in solidify"); + polys_num * 2, sizeof(*face_sides_arr), "face_sides_arr in solidify"); bool *null_faces = (smd->nonmanifold_offset_mode == MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_CONSTRAINTS) ? - MEM_calloc_arrayN(numPolys, sizeof(*null_faces), "null_faces in solidify") : + MEM_calloc_arrayN(polys_num, sizeof(*null_faces), "null_faces in solidify") : NULL; uint largest_ngon = 3; /* Calculate face to #NewFaceRef map. */ { mp = orig_mpoly; - for (uint i = 0; i < numPolys; i++, mp++) { + for (uint i = 0; i < polys_num; i++, mp++) { /* Make normals for faces without area (should really be avoided though). */ if (len_squared_v3(poly_nors[i]) < 0.5f) { MEdge *e = orig_medge + orig_mloop[mp->loopstart].e; @@ -244,18 +244,18 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, } /* add to final mesh face count */ if (do_shell) { - numNewPolys += 2; - numNewLoops += (uint)mp->totloop * 2; + new_polys_num += 2; + new_loops_num += (uint)mp->totloop * 2; } } } uint *edge_adj_faces_len = MEM_calloc_arrayN( - numEdges, sizeof(*edge_adj_faces_len), "edge_adj_faces_len in solidify"); + edges_num, sizeof(*edge_adj_faces_len), "edge_adj_faces_len in solidify"); /* Count for each edge how many faces it has adjacent. */ { mp = orig_mpoly; - for (uint i = 0; i < numPolys; i++, mp++) { + for (uint i = 0; i < polys_num; i++, mp++) { ml = orig_mloop + mp->loopstart; for (uint j = 0; j < mp->totloop; j++, ml++) { edge_adj_faces_len[ml->e]++; @@ -265,16 +265,16 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, /* Original edge to #NewEdgeRef map. */ NewEdgeRef ***orig_edge_data_arr = MEM_calloc_arrayN( - numEdges, sizeof(*orig_edge_data_arr), "orig_edge_data_arr in solidify"); + edges_num, sizeof(*orig_edge_data_arr), "orig_edge_data_arr in solidify"); /* Original edge length cache. */ float *orig_edge_lengths = MEM_calloc_arrayN( - numEdges, sizeof(*orig_edge_lengths), "orig_edge_lengths in solidify"); + edges_num, sizeof(*orig_edge_lengths), "orig_edge_lengths in solidify"); /* Edge groups for every original vert. */ EdgeGroup **orig_vert_groups_arr = MEM_calloc_arrayN( - numVerts, sizeof(*orig_vert_groups_arr), "orig_vert_groups_arr in solidify"); + verts_num, sizeof(*orig_vert_groups_arr), "orig_vert_groups_arr in solidify"); /* vertex map used to map duplicates. */ - uint *vm = MEM_malloc_arrayN(numVerts, sizeof(*vm), "orig_vert_map in solidify"); - for (uint i = 0; i < numVerts; i++) { + uint *vm = MEM_malloc_arrayN(verts_num, sizeof(*vm), "orig_vert_map in solidify"); + for (uint i = 0; i < verts_num; i++) { vm[i] = i; } @@ -286,12 +286,12 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, /* Vert edge adjacent map. */ OldVertEdgeRef **vert_adj_edges = MEM_calloc_arrayN( - numVerts, sizeof(*vert_adj_edges), "vert_adj_edges in solidify"); + verts_num, sizeof(*vert_adj_edges), "vert_adj_edges in solidify"); /* Original vertex positions (changed for degenerated geometry). */ float(*orig_mvert_co)[3] = MEM_malloc_arrayN( - numVerts, sizeof(*orig_mvert_co), "orig_mvert_co in solidify"); + verts_num, sizeof(*orig_mvert_co), "orig_mvert_co in solidify"); /* Fill in the original vertex positions. */ - for (uint i = 0; i < numVerts; i++) { + for (uint i = 0; i < verts_num; i++) { orig_mvert_co[i][0] = orig_mvert[i].co[0]; orig_mvert_co[i][1] = orig_mvert[i].co[1]; orig_mvert_co[i][2] = orig_mvert[i].co[2]; @@ -300,12 +300,12 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, /* Create edge to #NewEdgeRef map. */ { OldEdgeFaceRef **edge_adj_faces = MEM_calloc_arrayN( - numEdges, sizeof(*edge_adj_faces), "edge_adj_faces in solidify"); + edges_num, sizeof(*edge_adj_faces), "edge_adj_faces in solidify"); /* Create link_faces for edges. */ { mp = orig_mpoly; - for (uint i = 0; i < numPolys; i++, mp++) { + for (uint i = 0; i < polys_num; i++, mp++) { ml = orig_mloop + mp->loopstart; for (uint j = 0; j < mp->totloop; j++, ml++) { const uint edge = ml->e; @@ -342,19 +342,19 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, float edgedir[3] = {0, 0, 0}; uint *vert_adj_edges_len = MEM_calloc_arrayN( - numVerts, sizeof(*vert_adj_edges_len), "vert_adj_edges_len in solidify"); + verts_num, sizeof(*vert_adj_edges_len), "vert_adj_edges_len in solidify"); /* Calculate edge lengths and len vert_adj edges. */ { bool *face_singularity = MEM_calloc_arrayN( - numPolys, sizeof(*face_singularity), "face_sides_arr in solidify"); + polys_num, sizeof(*face_singularity), "face_sides_arr in solidify"); const float merge_tolerance_sqr = smd->merge_tolerance * smd->merge_tolerance; uint *combined_verts = MEM_calloc_arrayN( - numVerts, sizeof(*combined_verts), "combined_verts in solidify"); + verts_num, sizeof(*combined_verts), "combined_verts in solidify"); ed = orig_medge; - for (uint i = 0; i < numEdges; i++, ed++) { + for (uint i = 0; i < edges_num; i++, ed++) { if (edge_adj_faces_len[i] > 0) { uint v1 = vm[ed->v1]; uint v2 = vm[ed->v2]; @@ -373,7 +373,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, /* This check is very slow. It would need the vertex edge links to get * accelerated that are not yet available at this point. */ bool can_merge = true; - for (uint k = 0; k < numEdges && can_merge; k++) { + for (uint k = 0; k < edges_num && can_merge; k++) { if (k != i && edge_adj_faces_len[k] > 0 && (ELEM(vm[orig_medge[k].v1], v1, v2) != ELEM(vm[orig_medge[k].v2], v1, v2))) { for (uint j = 0; j < edge_adj_faces[k]->faces_len && can_merge; j++) { @@ -402,7 +402,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, (combined_verts[v2] + 1) / (float)(combined_verts[v1] + combined_verts[v2] + 2)); add_v3_v3(orig_mvert_co[v1], edgedir); - for (uint j = v2; j < numVerts; j++) { + for (uint j = v2; j < verts_num; j++) { if (vm[j] == v2) { vm[j] = v1; } @@ -412,7 +412,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, combined_verts[v1] += combined_verts[v2] + 1; if (do_shell) { - numNewLoops -= edge_adj_faces_len[i] * 2; + new_loops_num -= edge_adj_faces_len[i] * 2; } edge_adj_faces_len[i] = 0; @@ -430,7 +430,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, } /* remove zero faces in a second pass */ ed = orig_medge; - for (uint i = 0; i < numEdges; i++, ed++) { + for (uint i = 0; i < edges_num; i++, ed++) { const uint v1 = vm[ed->v1]; const uint v2 = vm[ed->v2]; if (v1 == v2 && edge_adj_faces[i]) { @@ -449,14 +449,14 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, face_singularity[face] = true; /* remove from final mesh poly count */ if (do_shell) { - numNewPolys -= 2; + new_polys_num -= 2; } } } } if (do_shell) { - numNewLoops -= edge_adj_faces_len[i] * 2; + new_loops_num -= edge_adj_faces_len[i] * 2; } edge_adj_faces_len[i] = 0; @@ -474,7 +474,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, /* Create vert_adj_edges for verts. */ { ed = orig_medge; - for (uint i = 0; i < numEdges; i++, ed++) { + for (uint i = 0; i < edges_num; i++, ed++) { if (edge_adj_faces_len[i] > 0) { const uint vs[2] = {vm[ed->v1], vm[ed->v2]}; uint invalid_edge_index = 0; @@ -545,8 +545,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, } /* remove from final face count */ if (do_shell) { - numNewPolys -= 2 * j; - numNewLoops -= 4 * j; + new_polys_num -= 2 * j; + new_loops_num -= 4 * j; } const uint len = i_adj_faces->faces_len + invalid_adj_faces->faces_len - 2 * j; uint *adj_faces = MEM_malloc_arrayN( @@ -595,7 +595,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, ed = orig_medge; /* Iterate over edges and only check the faces around an edge for duplicates * (performance optimization). */ - for (uint i = 0; i < numEdges; i++, ed++) { + for (uint i = 0; i < edges_num; i++, ed++) { if (edge_adj_faces_len[i] > 0) { const OldEdgeFaceRef *adj_faces = edge_adj_faces[i]; uint adj_len = adj_faces->faces_len; @@ -674,7 +674,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, } } else if (e_adj_faces->used > 1) { - for (uint n = 0; n < numEdges; n++) { + for (uint n = 0; n < edges_num; n++) { if (edge_adj_faces[n] == e_adj_faces && edge_adj_faces_len[n] > 0) { edge_adj_faces_len[n]--; if (edge_adj_faces_len[n] == 0) { @@ -689,8 +689,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, } } if (do_shell) { - numNewPolys -= 2; - numNewLoops -= 2 * (uint)del_loops; + new_polys_num -= 2; + new_loops_num -= 2 * (uint)del_loops; } break; } @@ -704,7 +704,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, /* Create #NewEdgeRef array. */ { ed = orig_medge; - for (uint i = 0; i < numEdges; i++, ed++) { + for (uint i = 0; i < edges_num; i++, ed++) { const uint v1 = vm[ed->v1]; const uint v2 = vm[ed->v2]; if (edge_adj_faces_len[i] > 0) { @@ -807,8 +807,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, (adj_faces_reversed[0] ? 1 : 0); if (do_rim) { /* Only add the loops parallel to the edge for now. */ - numNewLoops += 2; - numNewPolys++; + new_loops_num += 2; + new_polys_num++; } } @@ -864,13 +864,13 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, MEM_freeN(sorted_faces); orig_edge_data_arr[i] = new_edges; if (do_shell || (adj_len == 1 && do_rim)) { - numNewEdges += new_edges_len; + new_edges_num += new_edges_len; } } } } - for (uint i = 0; i < numEdges; i++) { + for (uint i = 0; i < edges_num; i++) { if (edge_adj_faces[i]) { if (edge_adj_faces[i]->used > 1) { edge_adj_faces[i]->used--; @@ -888,7 +888,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, /* Create sorted edge groups for every vert. */ { OldVertEdgeRef **adj_edges_ptr = vert_adj_edges; - for (uint i = 0; i < numVerts; i++, adj_edges_ptr++) { + for (uint i = 0; i < verts_num; i++, adj_edges_ptr++) { if (*adj_edges_ptr != NULL && (*adj_edges_ptr)->edges_len >= 2) { EdgeGroup *edge_groups; @@ -1305,7 +1305,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, uint added = 0; if (do_shell || (do_rim && !g->is_orig_closed)) { BLI_assert(g->new_vert == MOD_SOLIDIFY_EMPTY_TAG); - g->new_vert = numNewVerts++; + g->new_vert = new_verts_num++; if (do_rim || (do_shell && g->split)) { new_verts++; contains_splits += (g->split != 0); @@ -1321,23 +1321,23 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, last_added = added; if (!(g + 1)->valid || g->topo_group != (g + 1)->topo_group) { if (new_verts > 2) { - numNewPolys++; - numNewEdges += new_verts; + new_polys_num++; + new_edges_num += new_verts; open_edges += (uint)(first_added < last_added); open_edges -= (uint)(open_edges && !contains_open_splits); if (do_shell && do_rim) { - numNewLoops += new_verts * 2; + new_loops_num += new_verts * 2; } else if (do_shell) { - numNewLoops += new_verts * 2 - open_edges; + new_loops_num += new_verts * 2 - open_edges; } else { // do_rim - numNewLoops += new_verts * 2 + open_edges - contains_splits; + new_loops_num += new_verts * 2 + open_edges - contains_splits; } } else if (new_verts == 2) { - numNewEdges++; - numNewLoops += 2u - (uint)(!(do_rim && do_shell) && contains_open_splits); + new_edges_num++; + new_loops_num += 2u - (uint)(!(do_rim && do_shell) && contains_open_splits); } new_verts = 0; contains_open_splits = false; @@ -1356,7 +1356,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, /* Free vert_adj_edges memory. */ { uint i = 0; - for (OldVertEdgeRef **p = vert_adj_edges; i < numVerts; i++, p++) { + for (OldVertEdgeRef **p = vert_adj_edges; i < verts_num; i++, p++) { if (*p) { MEM_freeN((*p)->edges); MEM_freeN(*p); @@ -1375,10 +1375,10 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, float *face_weight = NULL; if (do_flat_faces) { - face_weight = MEM_malloc_arrayN(numPolys, sizeof(*face_weight), "face_weight in solidify"); + face_weight = MEM_malloc_arrayN(polys_num, sizeof(*face_weight), "face_weight in solidify"); mp = orig_mpoly; - for (uint i = 0; i < numPolys; i++, mp++) { + for (uint i = 0; i < polys_num; i++, mp++) { float scalar_vgroup = 1.0f; int loopend = mp->loopstart + mp->totloop; ml = orig_mloop + mp->loopstart; @@ -1399,7 +1399,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, mv = orig_mvert; gs_ptr = orig_vert_groups_arr; - for (uint i = 0; i < numVerts; i++, mv++, gs_ptr++) { + for (uint i = 0; i < verts_num; i++, mv++, gs_ptr++) { if (*gs_ptr) { EdgeGroup *g = *gs_ptr; for (uint j = 0; g->valid; j++, g++) { @@ -1912,7 +1912,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, uint singularity_edges_len = 1; singularity_edges = MEM_malloc_arrayN( singularity_edges_len, sizeof(*singularity_edges), "singularity_edges in solidify"); - for (NewEdgeRef ***new_edges = orig_edge_data_arr; i < numEdges; i++, new_edges++) { + for (NewEdgeRef ***new_edges = orig_edge_data_arr; i < edges_num; i++, new_edges++) { if (*new_edges && (do_shell || edge_adj_faces_len[i] == 1) && (**new_edges)->old_edge == i) { for (NewEdgeRef **l = *new_edges; *l; l++) { if ((*l)->link_edge_groups[0]->is_singularity && @@ -1940,12 +1940,12 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, singularity_edges[totsingularity][1] = v2; totsingularity++; if (edge_adj_faces_len[i] == 1 && do_rim) { - numNewLoops -= 2; - numNewPolys--; + new_loops_num -= 2; + new_polys_num--; } } else { - numNewEdges--; + new_edges_num--; } } } @@ -1954,8 +1954,12 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, } /* Create Mesh *result with proper capacity. */ - result = BKE_mesh_new_nomain_from_template( - mesh, (int)(numNewVerts), (int)(numNewEdges), 0, (int)(numNewLoops), (int)(numNewPolys)); + result = BKE_mesh_new_nomain_from_template(mesh, + (int)(new_verts_num), + (int)(new_edges_num), + 0, + (int)(new_loops_num), + (int)(new_polys_num)); mpoly = result->mpoly; mloop = result->mloop; @@ -1997,7 +2001,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, /* Make_new_verts. */ { gs_ptr = orig_vert_groups_arr; - for (uint i = 0; i < numVerts; i++, gs_ptr++) { + for (uint i = 0; i < verts_num; i++, gs_ptr++) { EdgeGroup *gs = *gs_ptr; if (gs) { EdgeGroup *g = gs; @@ -2018,7 +2022,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, { uint i = 0; edge_index += totsingularity; - for (NewEdgeRef ***new_edges = orig_edge_data_arr; i < numEdges; i++, new_edges++) { + for (NewEdgeRef ***new_edges = orig_edge_data_arr; i < edges_num; i++, new_edges++) { if (*new_edges && (do_shell || edge_adj_faces_len[i] == 1) && (**new_edges)->old_edge == i) { for (NewEdgeRef **l = *new_edges; *l; l++) { if ((*l)->new_edge != MOD_SOLIDIFY_EMPTY_TAG) { @@ -2089,7 +2093,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, * } */ gs_ptr = orig_vert_groups_arr; - for (uint i = 0; i < numVerts; i++, gs_ptr++) { + for (uint i = 0; i < verts_num; i++, gs_ptr++) { EdgeGroup *gs = *gs_ptr; /* check if the vertex is present (may be dissolved because of proximity) */ if (gs) { @@ -2110,7 +2114,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, { gs_ptr = orig_vert_groups_arr; mv = orig_mvert; - for (uint i = 0; i < numVerts; i++, gs_ptr++, mv++) { + for (uint i = 0; i < verts_num; i++, gs_ptr++, mv++) { EdgeGroup *gs = *gs_ptr; if (gs) { EdgeGroup *g = gs; @@ -2317,7 +2321,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, /* Make boundary faces. */ if (do_rim) { - for (uint i = 0; i < numEdges; i++) { + for (uint i = 0; i < edges_num; i++) { if (edge_adj_faces_len[i] == 1 && orig_edge_data_arr[i] && (*orig_edge_data_arr[i])->old_edge == i) { NewEdgeRef **new_edges = orig_edge_data_arr[i]; @@ -2473,7 +2477,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, largest_ngon * 2, sizeof(*face_verts), "face_verts in solidify"); uint *face_edges = MEM_malloc_arrayN( largest_ngon * 2, sizeof(*face_edges), "face_edges in solidify"); - for (uint i = 0; i < numPolys * 2; i++, fr++) { + for (uint i = 0; i < polys_num * 2; i++, fr++) { const uint loopstart = (uint)fr->face->loopstart; uint totloop = (uint)fr->face->totloop; uint valid_edges = 0; @@ -2561,37 +2565,37 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, MEM_freeN(face_verts); MEM_freeN(face_edges); } - if (edge_index != numNewEdges) { + if (edge_index != new_edges_num) { BKE_modifier_set_error(ctx->object, md, "Internal Error: edges array wrong size: %u instead of %u", - numNewEdges, + new_edges_num, edge_index); } - if (poly_index != numNewPolys) { + if (poly_index != new_polys_num) { BKE_modifier_set_error(ctx->object, md, "Internal Error: polys array wrong size: %u instead of %u", - numNewPolys, + new_polys_num, poly_index); } - if (loop_index != numNewLoops) { + if (loop_index != new_loops_num) { BKE_modifier_set_error(ctx->object, md, "Internal Error: loops array wrong size: %u instead of %u", - numNewLoops, + new_loops_num, loop_index); } - BLI_assert(edge_index == numNewEdges); - BLI_assert(poly_index == numNewPolys); - BLI_assert(loop_index == numNewLoops); + BLI_assert(edge_index == new_edges_num); + BLI_assert(poly_index == new_polys_num); + BLI_assert(loop_index == new_loops_num); /* Free remaining memory */ { MEM_freeN(vm); MEM_freeN(edge_adj_faces_len); uint i = 0; - for (EdgeGroup **p = orig_vert_groups_arr; i < numVerts; i++, p++) { + for (EdgeGroup **p = orig_vert_groups_arr; i < verts_num; i++, p++) { if (*p) { for (EdgeGroup *eg = *p; eg->valid; eg++) { MEM_freeN(eg->edges); @@ -2600,8 +2604,8 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, } } MEM_freeN(orig_vert_groups_arr); - i = numEdges; - for (NewEdgeRef ***p = orig_edge_data_arr + (numEdges - 1); i > 0; i--, p--) { + i = edges_num; + for (NewEdgeRef ***p = orig_edge_data_arr + (edges_num - 1); i > 0; i--, p--) { if (*p && (**p)->old_edge == i - 1) { for (NewEdgeRef **l = *p; *l; l++) { MEM_freeN(*l); @@ -2612,7 +2616,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, MEM_freeN(orig_edge_data_arr); MEM_freeN(orig_edge_lengths); i = 0; - for (NewFaceRef *p = face_sides_arr; i < numPolys * 2; i++, p++) { + for (NewFaceRef *p = face_sides_arr; i < polys_num * 2; i++, p++) { MEM_freeN(p->link_edges); } MEM_freeN(face_sides_arr); diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index 973009236ec..249d09e5d2e 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -283,7 +283,7 @@ static void deformMatrices(ModifierData *md, Mesh *mesh, float (*vertex_cos)[3], float (*deform_matrices)[3][3], - int num_verts) + int verts_num) { #if !defined(WITH_OPENSUBDIV) BKE_modifier_set_error(ctx->object, md, "Disabled, built without OpenSubdiv"); @@ -307,7 +307,7 @@ static void deformMatrices(ModifierData *md, /* Happens on bad topology, but also on empty input mesh. */ return; } - BKE_subdiv_deform_coarse_vertices(subdiv, mesh, vertex_cos, num_verts); + BKE_subdiv_deform_coarse_vertices(subdiv, mesh, vertex_cos, verts_num); if (subdiv != runtime_data->subdiv) { BKE_subdiv_free(subdiv); } diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c index 4ca2e67c334..f3811d98cd1 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.c @@ -94,7 +94,7 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { SurfaceModifierData *surmd = (SurfaceModifierData *)md; const int cfra = (int)DEG_get_ctime(ctx->depsgraph); @@ -116,7 +116,7 @@ static void deformVerts(ModifierData *md, surmd->mesh = (Mesh *)BKE_id_copy_ex(NULL, (ID *)mesh, NULL, LIB_ID_COPY_LOCALIZE); } else { - surmd->mesh = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, numVerts, false, false); + surmd->mesh = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, verts_num, false, false); } if (!ctx->object->pd) { @@ -125,7 +125,7 @@ static void deformVerts(ModifierData *md, } if (surmd->mesh) { - uint numverts = 0, i = 0; + uint mesh_verts_num = 0, i = 0; int init = 0; float *vec; MVert *x, *v; @@ -133,9 +133,9 @@ static void deformVerts(ModifierData *md, BKE_mesh_vert_coords_apply(surmd->mesh, vertexCos); BKE_mesh_calc_normals(surmd->mesh); - numverts = surmd->mesh->totvert; + mesh_verts_num = surmd->mesh->totvert; - if (numverts != surmd->numverts || surmd->x == NULL || surmd->v == NULL || + if (mesh_verts_num != surmd->verts_num || surmd->x == NULL || surmd->v == NULL || cfra != surmd->cfra + 1) { if (surmd->x) { MEM_freeN(surmd->x); @@ -146,16 +146,16 @@ static void deformVerts(ModifierData *md, surmd->v = NULL; } - surmd->x = MEM_calloc_arrayN(numverts, sizeof(MVert), "MVert"); - surmd->v = MEM_calloc_arrayN(numverts, sizeof(MVert), "MVert"); + surmd->x = MEM_calloc_arrayN(mesh_verts_num, sizeof(MVert), "MVert"); + surmd->v = MEM_calloc_arrayN(mesh_verts_num, sizeof(MVert), "MVert"); - surmd->numverts = numverts; + surmd->verts_num = mesh_verts_num; init = 1; } /* convert to global coordinates and calculate velocity */ - for (i = 0, x = surmd->x, v = surmd->v; i < numverts; i++, x++, v++) { + for (i = 0, x = surmd->x, v = surmd->v; i < mesh_verts_num; i++, x++, v++) { vec = surmd->mesh->mvert[i].co; mul_m4_v3(ctx->object->obmat, vec); @@ -210,7 +210,7 @@ static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md) surmd->bvhtree = NULL; surmd->x = NULL; surmd->v = NULL; - surmd->numverts = 0; + surmd->verts_num = 0; } ModifierTypeInfo modifierType_Surface = { diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index 6926893e188..a80918b8d2b 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -135,7 +135,7 @@ typedef struct SDefBindPoly { /** Index of the input polygon. */ uint index; /** Number of vertices in this face. */ - uint numverts; + uint verts_num; /** * This polygons loop-start. * \note that we could look this up from the polygon. @@ -152,8 +152,8 @@ typedef struct SDefBindPoly { typedef struct SDefBindWeightData { SDefBindPoly *bind_polys; - uint numpoly; - uint numbinds; + uint polys_num; + uint binds_num; } SDefBindWeightData; typedef struct SDefDeformData { @@ -209,9 +209,9 @@ static void freeData(ModifierData *md) SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; if (smd->verts) { - for (int i = 0; i < smd->num_bind_verts; i++) { + for (int i = 0; i < smd->bind_verts_num; i++) { if (smd->verts[i].binds) { - for (int j = 0; j < smd->verts[i].numbinds; j++) { + for (int j = 0; j < smd->verts[i].binds_num; j++) { MEM_SAFE_FREE(smd->verts[i].binds[j].vert_inds); MEM_SAFE_FREE(smd->verts[i].binds[j].vert_weights); } @@ -234,11 +234,11 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla if (smd->verts) { tsmd->verts = MEM_dupallocN(smd->verts); - for (int i = 0; i < smd->num_bind_verts; i++) { + for (int i = 0; i < smd->bind_verts_num; i++) { if (smd->verts[i].binds) { tsmd->verts[i].binds = MEM_dupallocN(smd->verts[i].binds); - for (int j = 0; j < smd->verts[i].numbinds; j++) { + for (int j = 0; j < smd->verts[i].binds_num; j++) { if (smd->verts[i].binds[j].vert_inds) { tsmd->verts[i].binds[j].vert_inds = MEM_dupallocN(smd->verts[i].binds[j].vert_inds); } @@ -283,8 +283,8 @@ static void freeAdjacencyMap(SDefAdjacencyArray *const vert_edges, static int buildAdjacencyMap(const MPoly *poly, const MEdge *edge, const MLoop *const mloop, - const uint numpoly, - const uint numedges, + const uint polys_num, + const uint edges_num, SDefAdjacencyArray *const vert_edges, SDefAdjacency *adj, SDefEdgePolys *const edge_polys) @@ -292,7 +292,7 @@ static int buildAdjacencyMap(const MPoly *poly, const MLoop *loop; /* Find polygons adjacent to edges. */ - for (int i = 0; i < numpoly; i++, poly++) { + for (int i = 0; i < polys_num; i++, poly++) { loop = &mloop[poly->loopstart]; for (int j = 0; j < poly->totloop; j++, loop++) { @@ -312,7 +312,7 @@ static int buildAdjacencyMap(const MPoly *poly, } /* Find edges adjacent to vertices */ - for (int i = 0; i < numedges; i++, edge++) { + for (int i = 0; i < edges_num; i++, edge++) { adj->next = vert_edges[edge->v1].first; adj->index = i; vert_edges[edge->v1].first = adj; @@ -457,7 +457,7 @@ static void freeBindData(SDefBindWeightData *const bwdata) SDefBindPoly *bpoly = bwdata->bind_polys; if (bwdata->bind_polys) { - for (int i = 0; i < bwdata->numpoly; bpoly++, i++) { + for (int i = 0; i < bwdata->polys_num; bpoly++, i++) { MEM_SAFE_FREE(bpoly->coords); MEM_SAFE_FREE(bpoly->coords_v2); } @@ -498,9 +498,9 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, return NULL; } - bwdata->numpoly = data->vert_edges[nearest].num / 2; + bwdata->polys_num = data->vert_edges[nearest].num / 2; - bpoly = MEM_calloc_arrayN(bwdata->numpoly, sizeof(*bpoly), "SDefBindPoly"); + bpoly = MEM_calloc_arrayN(bwdata->polys_num, sizeof(*bpoly), "SDefBindPoly"); if (bpoly == NULL) { freeBindData(bwdata); data->success = MOD_SDEF_BIND_RESULT_MEM_ERR; @@ -518,7 +518,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, { bpoly = bwdata->bind_polys; - for (int j = 0; j < bwdata->numpoly; bpoly++, j++) { + for (int j = 0; j < bwdata->polys_num; bpoly++, j++) { /* If coords isn't allocated, we have reached the first uninitialized `bpoly`. */ if ((bpoly->index == edge_polys[edge_ind].polys[i]) || (!bpoly->coords)) { break; @@ -541,7 +541,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, poly = &data->mpoly[bpoly->index]; loop = &data->mloop[poly->loopstart]; - bpoly->numverts = poly->totloop; + bpoly->verts_num = poly->totloop; bpoly->loopstart = poly->loopstart; bpoly->coords = MEM_malloc_arrayN( @@ -719,7 +719,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, } } - avg_point_dist /= bwdata->numpoly; + avg_point_dist /= bwdata->polys_num; /* If weights 1 and 2 are not infinite, loop over all adjacent edges again, * and build adjacency dependent angle data (depends on all polygons having been computed) */ @@ -736,7 +736,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, /* Find bind polys corresponding to the edge's adjacent polys */ bpoly = bwdata->bind_polys; - for (int i = 0, j = 0; (i < bwdata->numpoly) && (j < epolys->num); bpoly++, i++) { + for (int i = 0, j = 0; (i < bwdata->polys_num) && (j < epolys->num); bpoly++, i++) { if (ELEM(bpoly->index, epolys->polys[0], epolys->polys[1])) { bpolys[j] = bpoly; @@ -776,7 +776,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, if (!inf_weight_flags) { bpoly = bwdata->bind_polys; - for (int i = 0; i < bwdata->numpoly; bpoly++, i++) { + for (int i = 0; i < bwdata->polys_num; bpoly++, i++) { float corner_angle_weights[2]; float scale_weight, sqr, inv_sqr; @@ -856,7 +856,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, else if (!(inf_weight_flags & MOD_SDEF_INFINITE_WEIGHT_DIST)) { bpoly = bwdata->bind_polys; - for (int i = 0; i < bwdata->numpoly; bpoly++, i++) { + for (int i = 0; i < bwdata->polys_num; bpoly++, i++) { /* Scale the point distance weight by average point distance, and introduce falloff */ bpoly->weight_dist /= avg_point_dist; bpoly->weight_dist = powf(bpoly->weight_dist, data->falloff); @@ -871,7 +871,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, /* Final loop, to compute actual weights */ bpoly = bwdata->bind_polys; - for (int i = 0; i < bwdata->numpoly; bpoly++, i++) { + for (int i = 0; i < bwdata->polys_num; bpoly++, i++) { /* Weight computation from components */ if (inf_weight_flags & MOD_SDEF_INFINITE_WEIGHT_DIST) { bpoly->weight = bpoly->weight_dist < FLT_EPSILON ? 1.0f : 0.0f; @@ -898,7 +898,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, bpoly = bwdata->bind_polys; - for (int i = 0; i < bwdata->numpoly; bpoly++, i++) { + for (int i = 0; i < bwdata->polys_num; bpoly++, i++) { bpoly->weight /= tot_weight; /* Evaluate if this poly is relevant to bind */ @@ -907,15 +907,15 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, * should be negligible... */ if (bpoly->weight >= FLT_EPSILON) { if (bpoly->inside) { - bwdata->numbinds += 1; + bwdata->binds_num += 1; } else { if (bpoly->dominant_angle_weight < FLT_EPSILON || 1.0f - bpoly->dominant_angle_weight < FLT_EPSILON) { - bwdata->numbinds += 1; + bwdata->binds_num += 1; } else { - bwdata->numbinds += 2; + bwdata->binds_num += 2; } } } @@ -958,7 +958,7 @@ static void bindVert(void *__restrict userdata, if (data->success != MOD_SDEF_BIND_RESULT_SUCCESS) { sdvert->binds = NULL; - sdvert->numbinds = 0; + sdvert->binds_num = 0; return; } @@ -975,7 +975,7 @@ static void bindVert(void *__restrict userdata, if (weight <= 0) { sdvert->binds = NULL; - sdvert->numbinds = 0; + sdvert->binds_num = 0; return; } } @@ -985,53 +985,53 @@ static void bindVert(void *__restrict userdata, if (bwdata == NULL) { sdvert->binds = NULL; - sdvert->numbinds = 0; + sdvert->binds_num = 0; return; } - sdvert->binds = MEM_calloc_arrayN(bwdata->numbinds, sizeof(*sdvert->binds), "SDefVertBindData"); + sdvert->binds = MEM_calloc_arrayN(bwdata->binds_num, sizeof(*sdvert->binds), "SDefVertBindData"); if (sdvert->binds == NULL) { data->success = MOD_SDEF_BIND_RESULT_MEM_ERR; - sdvert->numbinds = 0; + sdvert->binds_num = 0; return; } - sdvert->numbinds = bwdata->numbinds; + sdvert->binds_num = bwdata->binds_num; sdbind = sdvert->binds; bpoly = bwdata->bind_polys; - for (int i = 0; i < bwdata->numbinds; bpoly++) { + for (int i = 0; i < bwdata->binds_num; bpoly++) { if (bpoly->weight >= FLT_EPSILON) { if (bpoly->inside) { const MLoop *loop = &data->mloop[bpoly->loopstart]; sdbind->influence = bpoly->weight; - sdbind->numverts = bpoly->numverts; + sdbind->verts_num = bpoly->verts_num; sdbind->mode = MOD_SDEF_MODE_NGON; sdbind->vert_weights = MEM_malloc_arrayN( - bpoly->numverts, sizeof(*sdbind->vert_weights), "SDefNgonVertWeights"); + bpoly->verts_num, sizeof(*sdbind->vert_weights), "SDefNgonVertWeights"); if (sdbind->vert_weights == NULL) { data->success = MOD_SDEF_BIND_RESULT_MEM_ERR; return; } sdbind->vert_inds = MEM_malloc_arrayN( - bpoly->numverts, sizeof(*sdbind->vert_inds), "SDefNgonVertInds"); + bpoly->verts_num, sizeof(*sdbind->vert_inds), "SDefNgonVertInds"); if (sdbind->vert_inds == NULL) { data->success = MOD_SDEF_BIND_RESULT_MEM_ERR; return; } interp_weights_poly_v2( - sdbind->vert_weights, bpoly->coords_v2, bpoly->numverts, bpoly->point_v2); + sdbind->vert_weights, bpoly->coords_v2, bpoly->verts_num, bpoly->point_v2); /* Re-project vert based on weights and original poly verts, * to reintroduce poly non-planarity */ zero_v3(point_co_proj); - for (int j = 0; j < bpoly->numverts; j++, loop++) { + for (int j = 0; j < bpoly->verts_num; j++, loop++) { madd_v3_v3fl(point_co_proj, bpoly->coords[j], sdbind->vert_weights[j]); sdbind->vert_inds[j] = loop->v; } @@ -1048,7 +1048,7 @@ static void bindVert(void *__restrict userdata, if (1.0f - bpoly->dominant_angle_weight >= FLT_EPSILON) { sdbind->influence = bpoly->weight * (1.0f - bpoly->dominant_angle_weight); - sdbind->numverts = bpoly->numverts; + sdbind->verts_num = bpoly->verts_num; sdbind->mode = MOD_SDEF_MODE_CENTROID; sdbind->vert_weights = MEM_malloc_arrayN( @@ -1059,7 +1059,7 @@ static void bindVert(void *__restrict userdata, } sdbind->vert_inds = MEM_malloc_arrayN( - bpoly->numverts, sizeof(*sdbind->vert_inds), "SDefCentVertInds"); + bpoly->verts_num, sizeof(*sdbind->vert_inds), "SDefCentVertInds"); if (sdbind->vert_inds == NULL) { data->success = MOD_SDEF_BIND_RESULT_MEM_ERR; return; @@ -1068,7 +1068,7 @@ static void bindVert(void *__restrict userdata, sortPolyVertsEdge(sdbind->vert_inds, &data->mloop[bpoly->loopstart], bpoly->edge_inds[bpoly->dominant_edge], - bpoly->numverts); + bpoly->verts_num); copy_v3_v3(v1, data->targetCos[sdbind->vert_inds[0]]); copy_v3_v3(v2, data->targetCos[sdbind->vert_inds[1]]); @@ -1095,7 +1095,7 @@ static void bindVert(void *__restrict userdata, if (bpoly->dominant_angle_weight >= FLT_EPSILON) { sdbind->influence = bpoly->weight * bpoly->dominant_angle_weight; - sdbind->numverts = bpoly->numverts; + sdbind->verts_num = bpoly->verts_num; sdbind->mode = MOD_SDEF_MODE_LOOPTRI; sdbind->vert_weights = MEM_malloc_arrayN( @@ -1106,7 +1106,7 @@ static void bindVert(void *__restrict userdata, } sdbind->vert_inds = MEM_malloc_arrayN( - bpoly->numverts, sizeof(*sdbind->vert_inds), "SDefTriVertInds"); + bpoly->verts_num, sizeof(*sdbind->vert_inds), "SDefTriVertInds"); if (sdbind->vert_inds == NULL) { data->success = MOD_SDEF_BIND_RESULT_MEM_ERR; return; @@ -1115,7 +1115,7 @@ static void bindVert(void *__restrict userdata, sortPolyVertsTri(sdbind->vert_inds, &data->mloop[bpoly->loopstart], bpoly->edge_vert_inds[0], - bpoly->numverts); + bpoly->verts_num); copy_v3_v3(v1, data->targetCos[sdbind->vert_inds[0]]); copy_v3_v3(v2, data->targetCos[sdbind->vert_inds[1]]); @@ -1149,25 +1149,25 @@ static void bindVert(void *__restrict userdata, /* Remove vertices without bind data from the bind array. */ static void compactSparseBinds(SurfaceDeformModifierData *smd) { - smd->num_bind_verts = 0; + smd->bind_verts_num = 0; - for (uint i = 0; i < smd->num_mesh_verts; i++) { - if (smd->verts[i].numbinds > 0) { - smd->verts[smd->num_bind_verts++] = smd->verts[i]; + for (uint i = 0; i < smd->mesh_verts_num; i++) { + if (smd->verts[i].binds_num > 0) { + smd->verts[smd->bind_verts_num++] = smd->verts[i]; } } smd->verts = MEM_reallocN_id( - smd->verts, sizeof(*smd->verts) * smd->num_bind_verts, "SDefBindVerts (sparse)"); + smd->verts, sizeof(*smd->verts) * smd->bind_verts_num, "SDefBindVerts (sparse)"); } static bool surfacedeformBind(Object *ob, SurfaceDeformModifierData *smd_orig, SurfaceDeformModifierData *smd_eval, float (*vertexCos)[3], - uint numverts, - uint tnumpoly, - uint tnumverts, + uint verts_num, + uint tpolys_num, + uint tverts_num, Mesh *target, Mesh *mesh) { @@ -1176,26 +1176,26 @@ static bool surfacedeformBind(Object *ob, const MPoly *mpoly = target->mpoly; const MEdge *medge = target->medge; const MLoop *mloop = target->mloop; - uint tnumedges = target->totedge; + uint tedges_num = target->totedge; int adj_result; SDefAdjacencyArray *vert_edges; SDefAdjacency *adj_array; SDefEdgePolys *edge_polys; - vert_edges = MEM_calloc_arrayN(tnumverts, sizeof(*vert_edges), "SDefVertEdgeMap"); + vert_edges = MEM_calloc_arrayN(tverts_num, sizeof(*vert_edges), "SDefVertEdgeMap"); if (vert_edges == NULL) { BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory"); return false; } - adj_array = MEM_malloc_arrayN(tnumedges, 2 * sizeof(*adj_array), "SDefVertEdge"); + adj_array = MEM_malloc_arrayN(tedges_num, 2 * sizeof(*adj_array), "SDefVertEdge"); if (adj_array == NULL) { BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory"); MEM_freeN(vert_edges); return false; } - edge_polys = MEM_calloc_arrayN(tnumedges, sizeof(*edge_polys), "SDefEdgeFaceMap"); + edge_polys = MEM_calloc_arrayN(tedges_num, sizeof(*edge_polys), "SDefEdgeFaceMap"); if (edge_polys == NULL) { BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory"); MEM_freeN(vert_edges); @@ -1203,7 +1203,7 @@ static bool surfacedeformBind(Object *ob, return false; } - smd_orig->verts = MEM_malloc_arrayN(numverts, sizeof(*smd_orig->verts), "SDefBindVerts"); + smd_orig->verts = MEM_malloc_arrayN(verts_num, sizeof(*smd_orig->verts), "SDefBindVerts"); if (smd_orig->verts == NULL) { BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory"); freeAdjacencyMap(vert_edges, adj_array, edge_polys); @@ -1220,7 +1220,7 @@ static bool surfacedeformBind(Object *ob, } adj_result = buildAdjacencyMap( - mpoly, medge, mloop, tnumpoly, tnumedges, vert_edges, adj_array, edge_polys); + mpoly, medge, mloop, tpolys_num, tedges_num, vert_edges, adj_array, edge_polys); if (adj_result == MOD_SDEF_BIND_RESULT_NONMANY_ERR) { BKE_modifier_set_error( @@ -1232,8 +1232,8 @@ static bool surfacedeformBind(Object *ob, return false; } - smd_orig->num_mesh_verts = numverts; - smd_orig->numpoly = tnumpoly; + smd_orig->mesh_verts_num = verts_num; + smd_orig->polys_num = tpolys_num; int defgrp_index; MDeformVert *dvert; @@ -1249,7 +1249,7 @@ static bool surfacedeformBind(Object *ob, .medge = medge, .mloop = mloop, .looptri = BKE_mesh_runtime_looptri_ensure(target), - .targetCos = MEM_malloc_arrayN(tnumverts, sizeof(float[3]), "SDefTargetBindVertArray"), + .targetCos = MEM_malloc_arrayN(tverts_num, sizeof(float[3]), "SDefTargetBindVertArray"), .bind_verts = smd_orig->verts, .vertexCos = vertexCos, .falloff = smd_orig->falloff, @@ -1268,14 +1268,14 @@ static bool surfacedeformBind(Object *ob, invert_m4_m4(data.imat, smd_orig->mat); - for (int i = 0; i < tnumverts; i++) { + for (int i = 0; i < tverts_num; i++) { mul_v3_m4v3(data.targetCos[i], smd_orig->mat, mvert[i].co); } TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); - settings.use_threading = (numverts > 10000); - BLI_task_parallel_range(0, numverts, &data, bindVert, &settings); + settings.use_threading = (verts_num > 10000); + BLI_task_parallel_range(0, verts_num, &data, bindVert, &settings); MEM_freeN(data.targetCos); @@ -1283,7 +1283,7 @@ static bool surfacedeformBind(Object *ob, compactSparseBinds(smd_orig); } else { - smd_orig->num_bind_verts = numverts; + smd_orig->bind_verts_num = verts_num; } if (data.success == MOD_SDEF_BIND_RESULT_MEM_ERR) { @@ -1311,7 +1311,7 @@ static bool surfacedeformBind(Object *ob, BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Target contains invalid polygons"); freeData((ModifierData *)smd_orig); } - else if (smd_orig->num_bind_verts == 0 || !smd_orig->verts) { + else if (smd_orig->bind_verts_num == 0 || !smd_orig->verts) { data.success = MOD_SDEF_BIND_RESULT_GENERIC_ERR; BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "No vertices were bound"); freeData((ModifierData *)smd_orig); @@ -1329,7 +1329,7 @@ static void deformVert(void *__restrict userdata, { const SDefDeformData *const data = (SDefDeformData *)userdata; const SDefBind *sdbind = data->bind_verts[index].binds; - const int num_binds = data->bind_verts[index].numbinds; + const int sdbind_num = data->bind_verts[index].binds_num; const unsigned int vertex_idx = data->bind_verts[index].vertex_idx; float *const vertexCos = data->vertexCos[vertex_idx]; float norm[3], temp[3], offset[3]; @@ -1355,8 +1355,8 @@ static void deformVert(void *__restrict userdata, /* Allocate a `coords_buffer` that fits all the temp-data. */ int max_verts = 0; - for (int j = 0; j < num_binds; j++) { - max_verts = MAX2(max_verts, sdbind[j].numverts); + for (int j = 0; j < sdbind_num; j++) { + max_verts = MAX2(max_verts, sdbind[j].verts_num); } const bool big_buffer = max_verts > 256; @@ -1369,12 +1369,12 @@ static void deformVert(void *__restrict userdata, coords_buffer = BLI_array_alloca(coords_buffer, max_verts); } - for (int j = 0; j < num_binds; j++, sdbind++) { - for (int k = 0; k < sdbind->numverts; k++) { + for (int j = 0; j < sdbind_num; j++, sdbind++) { + for (int k = 0; k < sdbind->verts_num; k++) { copy_v3_v3(coords_buffer[k], data->targetCos[sdbind->vert_inds[k]]); } - normal_poly_v3(norm, coords_buffer, sdbind->numverts); + normal_poly_v3(norm, coords_buffer, sdbind->verts_num); zero_v3(temp); switch (sdbind->mode) { @@ -1388,7 +1388,7 @@ static void deformVert(void *__restrict userdata, /* ---------- ngon mode ---------- */ case MOD_SDEF_MODE_NGON: { - for (int k = 0; k < sdbind->numverts; k++) { + for (int k = 0; k < sdbind->verts_num; k++) { madd_v3_v3fl(temp, coords_buffer[k], sdbind->vert_weights[k]); } break; @@ -1397,7 +1397,7 @@ static void deformVert(void *__restrict userdata, /* ---------- centroid mode ---------- */ case MOD_SDEF_MODE_CENTROID: { float cent[3]; - mid_v3_v3_array(cent, coords_buffer, sdbind->numverts); + mid_v3_v3_array(cent, coords_buffer, sdbind->verts_num); madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[0]], sdbind->vert_weights[0]); madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[1]], sdbind->vert_weights[1]); @@ -1425,13 +1425,13 @@ static void deformVert(void *__restrict userdata, static void surfacedeformModifier_do(ModifierData *md, const ModifierEvalContext *ctx, float (*vertexCos)[3], - uint numverts, + uint verts_num, Object *ob, Mesh *mesh) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; Mesh *target; - uint tnumverts, tnumpoly; + uint tverts_num, tpolys_num; /* Exit function if bind flag is not set (free bind data if any). */ if (!(smd->flags & MOD_SDEF_BIND)) { @@ -1453,8 +1453,8 @@ static void surfacedeformModifier_do(ModifierData *md, return; } - tnumverts = BKE_mesh_wrapper_vert_len(target); - tnumpoly = BKE_mesh_wrapper_poly_len(target); + tverts_num = BKE_mesh_wrapper_vert_len(target); + tpolys_num = BKE_mesh_wrapper_poly_len(target); /* If not bound, execute bind. */ if (smd->verts == NULL) { @@ -1474,7 +1474,7 @@ static void surfacedeformModifier_do(ModifierData *md, BKE_mesh_wrapper_ensure_mdata(target); if (!surfacedeformBind( - ob, smd_orig, smd, vertexCos, numverts, tnumpoly, tnumverts, target, mesh)) { + ob, smd_orig, smd, vertexCos, verts_num, tpolys_num, tverts_num, target, mesh)) { smd->flags &= ~MOD_SDEF_BIND; } /* Early abort, this is binding 'call', no need to perform whole evaluation. */ @@ -1482,14 +1482,14 @@ static void surfacedeformModifier_do(ModifierData *md, } /* Poly count checks */ - if (smd->num_mesh_verts != numverts) { + if (smd->mesh_verts_num != verts_num) { BKE_modifier_set_error( - ob, md, "Vertices changed from %u to %u", smd->num_mesh_verts, numverts); + ob, md, "Vertices changed from %u to %u", smd->mesh_verts_num, verts_num); return; } - if (smd->numpoly != tnumpoly) { + if (smd->polys_num != tpolys_num) { BKE_modifier_set_error( - ob, md, "Target polygons changed from %u to %u", smd->numpoly, tnumpoly); + ob, md, "Target polygons changed from %u to %u", smd->polys_num, tpolys_num); return; } @@ -1507,7 +1507,7 @@ static void surfacedeformModifier_do(ModifierData *md, /* Actual vertex location update starts here */ SDefDeformData data = { .bind_verts = smd->verts, - .targetCos = MEM_malloc_arrayN(tnumverts, sizeof(float[3]), "SDefTargetVertArray"), + .targetCos = MEM_malloc_arrayN(tverts_num, sizeof(float[3]), "SDefTargetVertArray"), .vertexCos = vertexCos, .dvert = dvert, .defgrp_index = defgrp_index, @@ -1516,12 +1516,12 @@ static void surfacedeformModifier_do(ModifierData *md, }; if (data.targetCos != NULL) { - BKE_mesh_wrapper_vert_coords_copy_with_mat4(target, data.targetCos, tnumverts, smd->mat); + BKE_mesh_wrapper_vert_coords_copy_with_mat4(target, data.targetCos, tverts_num, smd->mat); TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); - settings.use_threading = (smd->num_bind_verts > 10000); - BLI_task_parallel_range(0, smd->num_bind_verts, &data, deformVert, &settings); + settings.use_threading = (smd->bind_verts_num > 10000); + BLI_task_parallel_range(0, smd->bind_verts_num, &data, deformVert, &settings); MEM_freeN(data.targetCos); } @@ -1531,17 +1531,17 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; Mesh *mesh_src = NULL; if (smd->defgrp_name[0] != '\0') { /* Only need to use mesh_src when a vgroup is used. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); } - surfacedeformModifier_do(md, ctx, vertexCos, numVerts, ctx->object, mesh_src); + surfacedeformModifier_do(md, ctx, vertexCos, verts_num, ctx->object, mesh_src); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -1553,17 +1553,17 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *em, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; Mesh *mesh_src = NULL; if (smd->defgrp_name[0] != '\0') { /* Only need to use mesh_src when a vgroup is used. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, verts_num, false, false); } - surfacedeformModifier_do(md, ctx, vertexCos, numVerts, ctx->object, mesh_src); + surfacedeformModifier_do(md, ctx, vertexCos, verts_num, ctx->object, mesh_src); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -1633,23 +1633,23 @@ static void blendWrite(BlendWriter *writer, const ModifierData *md) { const SurfaceDeformModifierData *smd = (const SurfaceDeformModifierData *)md; - BLO_write_struct_array(writer, SDefVert, smd->num_bind_verts, smd->verts); + BLO_write_struct_array(writer, SDefVert, smd->bind_verts_num, smd->verts); if (smd->verts) { - for (int i = 0; i < smd->num_bind_verts; i++) { - BLO_write_struct_array(writer, SDefBind, smd->verts[i].numbinds, smd->verts[i].binds); + for (int i = 0; i < smd->bind_verts_num; i++) { + BLO_write_struct_array(writer, SDefBind, smd->verts[i].binds_num, smd->verts[i].binds); if (smd->verts[i].binds) { - for (int j = 0; j < smd->verts[i].numbinds; j++) { + for (int j = 0; j < smd->verts[i].binds_num; j++) { BLO_write_uint32_array( - writer, smd->verts[i].binds[j].numverts, smd->verts[i].binds[j].vert_inds); + writer, smd->verts[i].binds[j].verts_num, smd->verts[i].binds[j].vert_inds); if (ELEM(smd->verts[i].binds[j].mode, MOD_SDEF_MODE_CENTROID, MOD_SDEF_MODE_LOOPTRI)) { BLO_write_float3_array(writer, 1, smd->verts[i].binds[j].vert_weights); } else { BLO_write_float_array( - writer, smd->verts[i].binds[j].numverts, smd->verts[i].binds[j].vert_weights); + writer, smd->verts[i].binds[j].verts_num, smd->verts[i].binds[j].vert_weights); } } } @@ -1664,20 +1664,20 @@ static void blendRead(BlendDataReader *reader, ModifierData *md) BLO_read_data_address(reader, &smd->verts); if (smd->verts) { - for (int i = 0; i < smd->num_bind_verts; i++) { + for (int i = 0; i < smd->bind_verts_num; i++) { BLO_read_data_address(reader, &smd->verts[i].binds); if (smd->verts[i].binds) { - for (int j = 0; j < smd->verts[i].numbinds; j++) { + for (int j = 0; j < smd->verts[i].binds_num; j++) { BLO_read_uint32_array( - reader, smd->verts[i].binds[j].numverts, &smd->verts[i].binds[j].vert_inds); + reader, smd->verts[i].binds[j].verts_num, &smd->verts[i].binds[j].vert_inds); if (ELEM(smd->verts[i].binds[j].mode, MOD_SDEF_MODE_CENTROID, MOD_SDEF_MODE_LOOPTRI)) { BLO_read_float3_array(reader, 1, &smd->verts[i].binds[j].vert_weights); } else { BLO_read_float_array( - reader, smd->verts[i].binds[j].numverts, &smd->verts[i].binds[j].vert_weights); + reader, smd->verts[i].binds[j].verts_num, &smd->verts[i].binds[j].vert_weights); } } } diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c index e560a859735..d7e57c1f6e5 100644 --- a/source/blender/modifiers/intern/MOD_triangulate.c +++ b/source/blender/modifiers/intern/MOD_triangulate.c @@ -43,7 +43,7 @@ static Mesh *triangulate_mesh(Mesh *mesh, { Mesh *result; BMesh *bm; - int total_edges, i; + int edges_num, i; MEdge *me; CustomData_MeshMasks cd_mask_extra = { .vmask = CD_MASK_ORIGINDEX, .emask = CD_MASK_ORIGINDEX, .pmask = CD_MASK_ORIGINDEX}; @@ -81,11 +81,11 @@ static Mesh *triangulate_mesh(Mesh *mesh, CustomData_set_layer_flag(&result->ldata, CD_NORMAL, CD_FLAG_TEMPORARY); } - total_edges = result->totedge; + edges_num = result->totedge; me = result->medge; /* force drawing of all edges (seems to be omitted in CDDM_from_bmesh) */ - for (i = 0; i < total_edges; i++, me++) { + for (i = 0; i < edges_num; i++, me++) { me->flag |= ME_EDGEDRAW | ME_EDGERENDER; } diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index a8c52108cc0..a58e8e23147 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -63,7 +63,7 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd, float (*cos)[3], float (*r_texco)[3]) { - const int numVerts = mesh->totvert; + const int verts_num = mesh->totvert; int i; int texmapping = dmd->texmapping; float mapref_imat[4][4]; @@ -97,8 +97,8 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd, MPoly *mpoly = mesh->mpoly; MPoly *mp; MLoop *mloop = mesh->mloop; - BLI_bitmap *done = BLI_BITMAP_NEW(numVerts, __func__); - const int numPolys = mesh->totpoly; + BLI_bitmap *done = BLI_BITMAP_NEW(verts_num, __func__); + const int polys_num = mesh->totpoly; char uvname[MAX_CUSTOMDATA_LAYER_NAME]; MLoopUV *mloop_uv; @@ -106,7 +106,7 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd, mloop_uv = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPUV, uvname); /* verts are given the UV from the first face that uses them */ - for (i = 0, mp = mpoly; i < numPolys; i++, mp++) { + for (i = 0, mp = mpoly; i < polys_num; i++, mp++) { uint fidx = mp->totloop - 1; do { @@ -132,7 +132,7 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd, } MVert *mv = mesh->mvert; - for (i = 0; i < numVerts; i++, mv++, r_texco++) { + for (i = 0; i < verts_num; i++, mv++, r_texco++) { switch (texmapping) { case MOD_DISP_MAP_LOCAL: copy_v3_v3(*r_texco, cos != NULL ? *cos : mv->co); @@ -169,7 +169,7 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob, struct BMEditMesh *em, Mesh *mesh, const float (*vertexCos)[3], - const int num_verts, + const int verts_num, const bool use_normals, const bool use_orco) { @@ -212,7 +212,7 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob, /* Currently, that may not be the case every time * (texts e.g. tend to give issues, * also when deforming curve points instead of generated curve geometry... ). */ - if (mesh != NULL && mesh->totvert != num_verts) { + if (mesh != NULL && mesh->totvert != verts_num) { BKE_id_free(NULL, mesh); mesh = NULL; } @@ -227,7 +227,7 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob, } if (mesh && mesh->runtime.wrapper_type == ME_WRAPPER_TYPE_MDATA) { - BLI_assert(mesh->totvert == num_verts); + BLI_assert(mesh->totvert == verts_num); } return mesh; diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h index 4578d2c4862..aef254b1103 100644 --- a/source/blender/modifiers/intern/MOD_util.h +++ b/source/blender/modifiers/intern/MOD_util.h @@ -37,7 +37,7 @@ struct Mesh *MOD_deform_mesh_eval_get(struct Object *ob, struct BMEditMesh *em, struct Mesh *mesh, const float (*vertexCos)[3], - int num_verts, + int verts_num, bool use_normals, bool use_orco); diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 642aac17efd..d4d7ecef283 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -72,7 +72,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte { UVProjectModifierData *umd = (UVProjectModifierData *)md; bool do_add_own_transform = false; - for (int i = 0; i < umd->num_projectors; i++) { + for (int i = 0; i < umd->projectors_num; i++) { if (umd->projectors[i] != NULL) { DEG_add_object_relation( ctx->node, umd->projectors[i], DEG_OB_COMP_TRANSFORM, "UV Project Modifier"); @@ -98,11 +98,11 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, { float(*coords)[3], (*co)[3]; MLoopUV *mloop_uv; - int i, numVerts, numPolys, numLoops; + int i, verts_num, polys_num, loops_num; MPoly *mpoly, *mp; MLoop *mloop; Projector projectors[MOD_UVPROJECT_MAXPROJECTORS]; - int num_projectors = 0; + int projectors_num = 0; char uvname[MAX_CUSTOMDATA_LAYER_NAME]; float aspx = umd->aspectx ? umd->aspectx : 1.0f; float aspy = umd->aspecty ? umd->aspecty : 1.0f; @@ -110,13 +110,13 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, float scay = umd->scaley ? umd->scaley : 1.0f; int free_uci = 0; - for (i = 0; i < umd->num_projectors; i++) { + for (i = 0; i < umd->projectors_num; i++) { if (umd->projectors[i] != NULL) { - projectors[num_projectors++].ob = umd->projectors[i]; + projectors[projectors_num++].ob = umd->projectors[i]; } } - if (num_projectors == 0) { + if (projectors_num == 0) { return mesh; } @@ -131,7 +131,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, umd->uvlayer_name, uvname); /* calculate a projection matrix and normal for each projector */ - for (i = 0; i < num_projectors; i++) { + for (i = 0; i < projectors_num; i++) { float tmpmat[4][4]; float offsetmat[4][4]; Camera *cam = NULL; @@ -184,23 +184,23 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, mul_mat3_m4_v3(projectors[i].ob->obmat, projectors[i].normal); } - numPolys = mesh->totpoly; - numLoops = mesh->totloop; + polys_num = mesh->totpoly; + loops_num = mesh->totloop; /* make sure we are not modifying the original UV map */ mloop_uv = CustomData_duplicate_referenced_layer_named( - &mesh->ldata, CD_MLOOPUV, uvname, numLoops); + &mesh->ldata, CD_MLOOPUV, uvname, loops_num); - coords = BKE_mesh_vert_coords_alloc(mesh, &numVerts); + coords = BKE_mesh_vert_coords_alloc(mesh, &verts_num); /* Convert coords to world-space. */ - for (i = 0, co = coords; i < numVerts; i++, co++) { + for (i = 0, co = coords; i < verts_num; i++, co++) { mul_m4_v3(ob->obmat, *co); } /* if only one projector, project coords to UVs */ - if (num_projectors == 1 && projectors[0].uci == NULL) { - for (i = 0, co = coords; i < numVerts; i++, co++) { + if (projectors_num == 1 && projectors[0].uci == NULL) { + for (i = 0, co = coords; i < verts_num; i++, co++) { mul_project_m4_v3(projectors[0].projmat, *co); } } @@ -209,8 +209,8 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, mloop = mesh->mloop; /* apply coords as UVs */ - for (i = 0, mp = mpoly; i < numPolys; i++, mp++) { - if (num_projectors == 1) { + for (i = 0, mp = mpoly; i < polys_num; i++, mp++) { + if (projectors_num == 1) { if (projectors[0].uci) { uint fidx = mp->totloop - 1; do { @@ -246,7 +246,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, best_dot = dot_v3v3(projectors[0].normal, face_no); best_projector = &projectors[0]; - for (j = 1; j < num_projectors; j++) { + for (j = 1; j < projectors_num; j++) { float tmp_dot = dot_v3v3(projectors[j].normal, face_no); if (tmp_dot > best_dot) { best_dot = tmp_dot; @@ -277,7 +277,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, if (free_uci) { int j; - for (j = 0; j < num_projectors; j++) { + for (j = 0; j < projectors_num; j++) { if (projectors[j].uci) { MEM_freeN(projectors[j].uci); } diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c index 0574b1897de..a15efdaa381 100644 --- a/source/blender/modifiers/intern/MOD_uvwarp.c +++ b/source/blender/modifiers/intern/MOD_uvwarp.c @@ -130,7 +130,7 @@ static void uv_warp_compute(void *__restrict userdata, static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) { UVWarpModifierData *umd = (UVWarpModifierData *)md; - int numPolys, numLoops; + int polys_num, loops_num; MPoly *mpoly; MLoop *mloop; MLoopUV *mloopuv; @@ -196,14 +196,14 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* make sure we're using an existing layer */ CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, umd->uvlayer_name, uvname); - numPolys = mesh->totpoly; - numLoops = mesh->totloop; + polys_num = mesh->totpoly; + loops_num = mesh->totloop; mpoly = mesh->mpoly; mloop = mesh->mloop; /* make sure we are not modifying the original UV map */ mloopuv = CustomData_duplicate_referenced_layer_named( - &mesh->ldata, CD_MLOOPUV, uvname, numLoops); + &mesh->ldata, CD_MLOOPUV, uvname, loops_num); MOD_get_vgroup(ctx->object, mesh, umd->vgroup_name, &dvert, &defgrp_index); UVWarpData data = { @@ -217,8 +217,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * }; TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); - settings.use_threading = (numPolys > 1000); - BLI_task_parallel_range(0, numPolys, &data, uv_warp_compute, &settings); + settings.use_threading = (polys_num > 1000); + BLI_task_parallel_range(0, polys_num, &data, uv_warp_compute, &settings); mesh->runtime.is_original = false; diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 045b8e16736..8042172f204 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -181,7 +181,7 @@ static void warpModifier_do(WarpModifierData *wmd, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { Object *ob = ctx->object; float obinv[4][4]; @@ -245,13 +245,13 @@ static void warpModifier_do(WarpModifierData *wmd, Tex *tex_target = wmd->texture; if (mesh != NULL && tex_target != NULL) { - tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "warpModifier_do tex_co"); + tex_co = MEM_malloc_arrayN(verts_num, sizeof(*tex_co), "warpModifier_do tex_co"); MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co); MOD_init_texture((MappingInfoModifierData *)wmd, ctx); } - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { float *co = vertexCos[i]; if (wmd->falloff_type == eWarp_Falloff_None || @@ -344,17 +344,17 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { WarpModifierData *wmd = (WarpModifierData *)md; Mesh *mesh_src = NULL; if (wmd->defgrp_name[0] != '\0' || wmd->texture != NULL) { /* mesh_src is only needed for vgroups and textures. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); } - warpModifier_do(wmd, ctx, mesh_src, vertexCos, numVerts); + warpModifier_do(wmd, ctx, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -366,14 +366,14 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *em, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { WarpModifierData *wmd = (WarpModifierData *)md; Mesh *mesh_src = NULL; if (wmd->defgrp_name[0] != '\0' || wmd->texture != NULL) { /* mesh_src is only needed for vgroups and textures. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, verts_num, false, false); } /* TODO(Campbell): use edit-mode data only (remove this line). */ @@ -381,7 +381,7 @@ static void deformVertsEM(ModifierData *md, BKE_mesh_wrapper_ensure_mdata(mesh_src); } - warpModifier_do(wmd, ctx, mesh_src, vertexCos, numVerts); + warpModifier_do(wmd, ctx, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 9518cc253e7..4da2d67b8a6 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -133,7 +133,7 @@ static void waveModifier_do(WaveModifierData *md, Object *ob, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { WaveModifierData *wmd = (WaveModifierData *)md; MVert *mvert = NULL; @@ -188,7 +188,7 @@ static void waveModifier_do(WaveModifierData *md, Tex *tex_target = wmd->texture; if (mesh != NULL && tex_target != NULL) { - tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "waveModifier_do tex_co"); + tex_co = MEM_malloc_arrayN(verts_num, sizeof(*tex_co), "waveModifier_do tex_co"); MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co); MOD_init_texture((MappingInfoModifierData *)wmd, ctx); @@ -199,7 +199,7 @@ static void waveModifier_do(WaveModifierData *md, float falloff_inv = falloff != 0.0f ? 1.0f / falloff : 1.0f; int i; - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { float *co = vertexCos[i]; float x = co[0] - wmd->startx; float y = co[1] - wmd->starty; @@ -299,19 +299,20 @@ static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { WaveModifierData *wmd = (WaveModifierData *)md; Mesh *mesh_src = NULL; if (wmd->flag & MOD_WAVE_NORM) { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, vertexCos, numVerts, true, false); + mesh_src = MOD_deform_mesh_eval_get( + ctx->object, NULL, mesh, vertexCos, verts_num, true, false); } else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); } - waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, numVerts); + waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); @@ -323,17 +324,18 @@ static void deformVertsEM(ModifierData *md, struct BMEditMesh *editData, Mesh *mesh, float (*vertexCos)[3], - int numVerts) + int verts_num) { WaveModifierData *wmd = (WaveModifierData *)md; Mesh *mesh_src = NULL; if (wmd->flag & MOD_WAVE_NORM) { mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, vertexCos, numVerts, true, false); + ctx->object, editData, mesh, vertexCos, verts_num, true, false); } else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false); + mesh_src = MOD_deform_mesh_eval_get( + ctx->object, editData, mesh, NULL, verts_num, false, false); } /* TODO(Campbell): use edit-mode data only (remove this line). */ @@ -341,7 +343,7 @@ static void deformVertsEM(ModifierData *md, BKE_mesh_wrapper_ensure_mdata(mesh_src); } - waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, numVerts); + waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); if (!ELEM(mesh_src, NULL, mesh)) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c index 873372a35b8..c79dbdb0b1a 100644 --- a/source/blender/modifiers/intern/MOD_weighted_normal.c +++ b/source/blender/modifiers/intern/MOD_weighted_normal.c @@ -58,7 +58,7 @@ static int modepair_cmp_by_val_inverse(const void *p1, const void *p2) typedef struct WeightedNormalDataAggregateItem { float normal[3]; - int num_loops; /* Count number of loops using this item so far. */ + int loops_num; /* Count number of loops using this item so far. */ float curr_val; /* Current max val for this item. */ int curr_strength; /* Current max strength encountered for this item. */ } WeightedNormalDataAggregateItem; @@ -66,10 +66,10 @@ typedef struct WeightedNormalDataAggregateItem { #define NUM_CACHED_INVERSE_POWERS_OF_WEIGHT 128 typedef struct WeightedNormalData { - const int numVerts; - const int numEdges; - const int numLoops; - const int numPolys; + const int verts_num; + const int edges_num; + const int loops_num; + const int polys_num; MVert *mvert; const float (*vert_normals)[3]; @@ -116,7 +116,7 @@ static bool check_item_poly_strength(WeightedNormalData *wn_data, if (mp_strength > item_data->curr_strength) { item_data->curr_strength = mp_strength; item_data->curr_val = 0.0f; - item_data->num_loops = 0; + item_data->loops_num = 0; zero_v3(item_data->normal); } @@ -160,20 +160,20 @@ static void aggregate_item_normal(WeightedNormalModifierData *wnmd, } if (!compare_ff(item_data->curr_val, curr_val, wnmd->thresh)) { /* item's curr_val and present value differ more than threshold, update. */ - item_data->num_loops++; + item_data->loops_num++; item_data->curr_val = curr_val; } /* Exponentially divided weight for each normal * (since a few values will be used by most cases, we cache those). */ - const int num_loops = item_data->num_loops; - if (num_loops < NUM_CACHED_INVERSE_POWERS_OF_WEIGHT && - cached_inverse_powers_of_weight[num_loops] == 0.0f) { - cached_inverse_powers_of_weight[num_loops] = 1.0f / powf(weight, num_loops); + const int loops_num = item_data->loops_num; + if (loops_num < NUM_CACHED_INVERSE_POWERS_OF_WEIGHT && + cached_inverse_powers_of_weight[loops_num] == 0.0f) { + cached_inverse_powers_of_weight[loops_num] = 1.0f / powf(weight, loops_num); } - const float inverted_n_weight = num_loops < NUM_CACHED_INVERSE_POWERS_OF_WEIGHT ? - cached_inverse_powers_of_weight[num_loops] : - 1.0f / powf(weight, num_loops); + const float inverted_n_weight = loops_num < NUM_CACHED_INVERSE_POWERS_OF_WEIGHT ? + cached_inverse_powers_of_weight[loops_num] : + 1.0f / powf(weight, loops_num); madd_v3_v3fl(item_data->normal, polynors[mp_index], curr_val * inverted_n_weight); } @@ -181,10 +181,10 @@ static void aggregate_item_normal(WeightedNormalModifierData *wnmd, static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, WeightedNormalData *wn_data) { - const int numVerts = wn_data->numVerts; - const int numEdges = wn_data->numEdges; - const int numLoops = wn_data->numLoops; - const int numPolys = wn_data->numPolys; + const int verts_num = wn_data->verts_num; + const int edges_num = wn_data->edges_num; + const int loops_num = wn_data->loops_num; + const int polys_num = wn_data->polys_num; MVert *mvert = wn_data->mvert; MEdge *medge = wn_data->medge; @@ -214,39 +214,39 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, float(*loop_normals)[3] = NULL; WeightedNormalDataAggregateItem *items_data = NULL; - int num_items = 0; + int items_num = 0; if (keep_sharp) { - BLI_bitmap *done_loops = BLI_BITMAP_NEW(numLoops, __func__); + BLI_bitmap *done_loops = BLI_BITMAP_NEW(loops_num, __func__); /* This will give us loop normal spaces, * we do not actually care about computed loop_normals for now... */ - loop_normals = MEM_calloc_arrayN((size_t)numLoops, sizeof(*loop_normals), __func__); + loop_normals = MEM_calloc_arrayN((size_t)loops_num, sizeof(*loop_normals), __func__); BKE_mesh_normals_loop_split(mvert, wn_data->vert_normals, - numVerts, + verts_num, medge, - numEdges, + edges_num, mloop, loop_normals, - numLoops, + loops_num, mpoly, polynors, - numPolys, + polys_num, true, split_angle, &lnors_spacearr, has_clnors ? clnors : NULL, loop_to_poly); - num_items = lnors_spacearr.num_spaces; - items_data = MEM_calloc_arrayN((size_t)num_items, sizeof(*items_data), __func__); + items_num = lnors_spacearr.spaces_num; + items_data = MEM_calloc_arrayN((size_t)items_num, sizeof(*items_data), __func__); /* In this first loop, we assign each WeightedNormalDataAggregateItem * to its smooth fan of loops (aka lnor space). */ MPoly *mp; int mp_index; int item_index; - for (mp = mpoly, mp_index = 0, item_index = 0; mp_index < numPolys; mp++, mp_index++) { + for (mp = mpoly, mp_index = 0, item_index = 0; mp_index < polys_num; mp++, mp_index++) { int ml_index = mp->loopstart; const int ml_end_index = ml_index + mp->totloop; @@ -255,7 +255,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, /* Smooth fan of this loop has already been processed, skip it. */ continue; } - BLI_assert(item_index < num_items); + BLI_assert(item_index < items_num); WeightedNormalDataAggregateItem *itdt = &items_data[item_index]; itdt->curr_strength = FACE_STRENGTH_WEAK; @@ -280,10 +280,10 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, MEM_freeN(done_loops); } else { - num_items = numVerts; - items_data = MEM_calloc_arrayN((size_t)num_items, sizeof(*items_data), __func__); + items_num = verts_num; + items_data = MEM_calloc_arrayN((size_t)items_num, sizeof(*items_data), __func__); if (use_face_influence) { - for (int item_index = 0; item_index < num_items; item_index++) { + for (int item_index = 0; item_index < items_num; item_index++) { items_data[item_index].curr_strength = FACE_STRENGTH_WEAK; } } @@ -292,7 +292,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, switch (mode) { case MOD_WEIGHTEDNORMAL_MODE_FACE: - for (int i = 0; i < numPolys; i++) { + for (int i = 0; i < polys_num; i++) { const int mp_index = mode_pair[i].index; const float mp_val = mode_pair[i].val; @@ -312,7 +312,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, case MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE: BLI_assert(loop_to_poly != NULL); - for (int i = 0; i < numLoops; i++) { + for (int i = 0; i < loops_num; i++) { const int ml_index = mode_pair[i].index; const float ml_val = mode_pair[i].val; @@ -330,7 +330,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, } /* Validate computed weighted normals. */ - for (int item_index = 0; item_index < num_items; item_index++) { + for (int item_index = 0; item_index < items_num; item_index++) { if (normalize_v3(items_data[item_index].normal) < CLNORS_VALID_VEC_LEN) { zero_v3(items_data[item_index].normal); } @@ -341,7 +341,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, * Note that loop_normals is already populated with clnors * (before this modifier is applied, at start of this function), * so no need to recompute them here. */ - for (int ml_index = 0; ml_index < numLoops; ml_index++) { + for (int ml_index = 0; ml_index < loops_num; ml_index++) { WeightedNormalDataAggregateItem *item_data = lnors_spacearr.lspacearr[ml_index]->user_data; if (!is_zero_v3(item_data->normal)) { copy_v3_v3(loop_normals[ml_index], item_data->normal); @@ -350,15 +350,15 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, BKE_mesh_normals_loop_custom_set(mvert, wn_data->vert_normals, - numVerts, + verts_num, medge, - numEdges, + edges_num, mloop, loop_normals, - numLoops, + loops_num, mpoly, polynors, - numPolys, + polys_num, clnors); } else { @@ -372,9 +372,9 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, * But think we can live with it for now, * and it makes code simpler & cleaner. */ float(*vert_normals)[3] = MEM_calloc_arrayN( - (size_t)numVerts, sizeof(*loop_normals), __func__); + (size_t)verts_num, sizeof(*loop_normals), __func__); - for (int ml_index = 0; ml_index < numLoops; ml_index++) { + for (int ml_index = 0; ml_index < loops_num; ml_index++) { const int mv_index = mloop[ml_index].v; copy_v3_v3(vert_normals[mv_index], items_data[mv_index].normal); } @@ -382,39 +382,39 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, BKE_mesh_normals_loop_custom_from_vertices_set(mvert, wn_data->vert_normals, vert_normals, - numVerts, + verts_num, medge, - numEdges, + edges_num, mloop, - numLoops, + loops_num, mpoly, polynors, - numPolys, + polys_num, clnors); MEM_freeN(vert_normals); } else { - loop_normals = MEM_calloc_arrayN((size_t)numLoops, sizeof(*loop_normals), __func__); + loop_normals = MEM_calloc_arrayN((size_t)loops_num, sizeof(*loop_normals), __func__); BKE_mesh_normals_loop_split(mvert, wn_data->vert_normals, - numVerts, + verts_num, medge, - numEdges, + edges_num, mloop, loop_normals, - numLoops, + loops_num, mpoly, polynors, - numPolys, + polys_num, true, split_angle, NULL, has_clnors ? clnors : NULL, loop_to_poly); - for (int ml_index = 0; ml_index < numLoops; ml_index++) { + for (int ml_index = 0; ml_index < loops_num; ml_index++) { const int item_index = mloop[ml_index].v; if (!is_zero_v3(items_data[item_index].normal)) { copy_v3_v3(loop_normals[ml_index], items_data[item_index].normal); @@ -423,15 +423,15 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, BKE_mesh_normals_loop_custom_set(mvert, wn_data->vert_normals, - numVerts, + verts_num, medge, - numEdges, + edges_num, mloop, loop_normals, - numLoops, + loops_num, mpoly, polynors, - numPolys, + polys_num, clnors); } } @@ -444,7 +444,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd, static void wn_face_area(WeightedNormalModifierData *wnmd, WeightedNormalData *wn_data) { - const int numPolys = wn_data->numPolys; + const int polys_num = wn_data->polys_num; MVert *mvert = wn_data->mvert; MLoop *mloop = wn_data->mloop; @@ -453,15 +453,15 @@ static void wn_face_area(WeightedNormalModifierData *wnmd, WeightedNormalData *w MPoly *mp; int mp_index; - ModePair *face_area = MEM_malloc_arrayN((size_t)numPolys, sizeof(*face_area), __func__); + ModePair *face_area = MEM_malloc_arrayN((size_t)polys_num, sizeof(*face_area), __func__); ModePair *f_area = face_area; - for (mp_index = 0, mp = mpoly; mp_index < numPolys; mp_index++, mp++, f_area++) { + for (mp_index = 0, mp = mpoly; mp_index < polys_num; mp_index++, mp++, f_area++) { f_area->val = BKE_mesh_calc_poly_area(mp, &mloop[mp->loopstart], mvert); f_area->index = mp_index; } - qsort(face_area, numPolys, sizeof(*face_area), modepair_cmp_by_val_inverse); + qsort(face_area, polys_num, sizeof(*face_area), modepair_cmp_by_val_inverse); wn_data->mode_pair = face_area; apply_weights_vertex_normal(wnmd, wn_data); @@ -469,8 +469,8 @@ static void wn_face_area(WeightedNormalModifierData *wnmd, WeightedNormalData *w static void wn_corner_angle(WeightedNormalModifierData *wnmd, WeightedNormalData *wn_data) { - const int numLoops = wn_data->numLoops; - const int numPolys = wn_data->numPolys; + const int loops_num = wn_data->loops_num; + const int polys_num = wn_data->polys_num; MVert *mvert = wn_data->mvert; MLoop *mloop = wn_data->mloop; @@ -479,11 +479,11 @@ static void wn_corner_angle(WeightedNormalModifierData *wnmd, WeightedNormalData MPoly *mp; int mp_index; - int *loop_to_poly = MEM_malloc_arrayN((size_t)numLoops, sizeof(*loop_to_poly), __func__); + int *loop_to_poly = MEM_malloc_arrayN((size_t)loops_num, sizeof(*loop_to_poly), __func__); - ModePair *corner_angle = MEM_malloc_arrayN((size_t)numLoops, sizeof(*corner_angle), __func__); + ModePair *corner_angle = MEM_malloc_arrayN((size_t)loops_num, sizeof(*corner_angle), __func__); - for (mp_index = 0, mp = mpoly; mp_index < numPolys; mp_index++, mp++) { + for (mp_index = 0, mp = mpoly; mp_index < polys_num; mp_index++, mp++) { MLoop *ml_start = &mloop[mp->loopstart]; float *index_angle = MEM_malloc_arrayN((size_t)mp->totloop, sizeof(*index_angle), __func__); @@ -501,7 +501,7 @@ static void wn_corner_angle(WeightedNormalModifierData *wnmd, WeightedNormalData MEM_freeN(index_angle); } - qsort(corner_angle, numLoops, sizeof(*corner_angle), modepair_cmp_by_val_inverse); + qsort(corner_angle, loops_num, sizeof(*corner_angle), modepair_cmp_by_val_inverse); wn_data->loop_to_poly = loop_to_poly; wn_data->mode_pair = corner_angle; @@ -510,8 +510,8 @@ static void wn_corner_angle(WeightedNormalModifierData *wnmd, WeightedNormalData static void wn_face_with_angle(WeightedNormalModifierData *wnmd, WeightedNormalData *wn_data) { - const int numLoops = wn_data->numLoops; - const int numPolys = wn_data->numPolys; + const int loops_num = wn_data->loops_num; + const int polys_num = wn_data->polys_num; MVert *mvert = wn_data->mvert; MLoop *mloop = wn_data->mloop; @@ -520,11 +520,11 @@ static void wn_face_with_angle(WeightedNormalModifierData *wnmd, WeightedNormalD MPoly *mp; int mp_index; - int *loop_to_poly = MEM_malloc_arrayN((size_t)numLoops, sizeof(*loop_to_poly), __func__); + int *loop_to_poly = MEM_malloc_arrayN((size_t)loops_num, sizeof(*loop_to_poly), __func__); - ModePair *combined = MEM_malloc_arrayN((size_t)numLoops, sizeof(*combined), __func__); + ModePair *combined = MEM_malloc_arrayN((size_t)loops_num, sizeof(*combined), __func__); - for (mp_index = 0, mp = mpoly; mp_index < numPolys; mp_index++, mp++) { + for (mp_index = 0, mp = mpoly; mp_index < polys_num; mp_index++, mp++) { MLoop *ml_start = &mloop[mp->loopstart]; float face_area = BKE_mesh_calc_poly_area(mp, ml_start, mvert); @@ -544,7 +544,7 @@ static void wn_face_with_angle(WeightedNormalModifierData *wnmd, WeightedNormalD MEM_freeN(index_angle); } - qsort(combined, numLoops, sizeof(*combined), modepair_cmp_by_val_inverse); + qsort(combined, loops_num, sizeof(*combined), modepair_cmp_by_val_inverse); wn_data->loop_to_poly = loop_to_poly; wn_data->mode_pair = combined; @@ -575,10 +575,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * Mesh *result; result = (Mesh *)BKE_id_copy_ex(NULL, &mesh->id, NULL, LIB_ID_COPY_LOCALIZE); - const int numVerts = result->totvert; - const int numEdges = result->totedge; - const int numLoops = result->totloop; - const int numPolys = result->totpoly; + const int verts_num = result->totvert; + const int edges_num = result->totedge; + const int loops_num = result->totloop; + const int polys_num = result->totpoly; MEdge *medge = result->medge; MPoly *mpoly = result->mpoly; @@ -611,7 +611,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * * it helps when generating clnor spaces and default normals. */ const bool has_clnors = clnors != NULL; if (!clnors) { - clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops); + clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, loops_num); } MDeformVert *dvert; @@ -619,10 +619,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * MOD_get_vgroup(ctx->object, mesh, wnmd->defgrp_name, &dvert, &defgrp_index); WeightedNormalData wn_data = { - .numVerts = numVerts, - .numEdges = numEdges, - .numLoops = numLoops, - .numPolys = numPolys, + .verts_num = verts_num, + .edges_num = edges_num, + .loops_num = loops_num, + .polys_num = polys_num, .mvert = mvert, .vert_normals = BKE_mesh_vertex_normals_ensure(result), diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index a5c901dbe7a..b251825cd95 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -135,7 +135,7 @@ void weightvg_do_mask(const ModifierEvalContext *ctx, float(*tex_co)[3]; /* See mapping note below... */ MappingInfoModifierData t_map; - const int numVerts = mesh->totvert; + const int verts_num = mesh->totvert; /* Use new generic get_texture_coords, but do not modify our DNA struct for it... * XXX Why use a ModifierData stuff here ? Why not a simple, generic struct for parameters? @@ -148,7 +148,7 @@ void weightvg_do_mask(const ModifierEvalContext *ctx, BLI_strncpy(t_map.uvlayer_name, tex_uvlayer_name, sizeof(t_map.uvlayer_name)); t_map.texmapping = tex_mapping; - tex_co = MEM_calloc_arrayN(numVerts, sizeof(*tex_co), "WeightVG Modifier, TEX mode, tex_co"); + tex_co = MEM_calloc_arrayN(verts_num, sizeof(*tex_co), "WeightVG Modifier, TEX mode, tex_co"); MOD_get_texture_coords(&t_map, ctx, ob, mesh, NULL, tex_co); MOD_init_texture(&t_map, ctx); diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index bce8ce82423..02991558c18 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -176,12 +176,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * #endif /* Get number of verts. */ - const int numVerts = mesh->totvert; + const int verts_num = mesh->totvert; /* Check if we can just return the original mesh. * Must have verts and therefore verts assigned to vgroups to do anything useful! */ - if ((numVerts == 0) || BLI_listbase_is_empty(&mesh->vertex_group_names)) { + if ((verts_num == 0) || BLI_listbase_is_empty(&mesh->vertex_group_names)) { return mesh; } @@ -201,11 +201,11 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * } if (has_mdef) { - dvert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MDEFORMVERT, numVerts); + dvert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MDEFORMVERT, verts_num); } else { /* Add a valid data layer! */ - dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, numVerts); + dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, verts_num); } /* Ultimate security check. */ if (!dvert) { @@ -214,10 +214,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * mesh->dvert = dvert; /* Get org weights, assuming 0.0 for vertices not in given vgroup. */ - org_w = MEM_malloc_arrayN(numVerts, sizeof(float), "WeightVGEdit Modifier, org_w"); - new_w = MEM_malloc_arrayN(numVerts, sizeof(float), "WeightVGEdit Modifier, new_w"); - dw = MEM_malloc_arrayN(numVerts, sizeof(MDeformWeight *), "WeightVGEdit Modifier, dw"); - for (i = 0; i < numVerts; i++) { + org_w = MEM_malloc_arrayN(verts_num, sizeof(float), "WeightVGEdit Modifier, org_w"); + new_w = MEM_malloc_arrayN(verts_num, sizeof(float), "WeightVGEdit Modifier, new_w"); + dw = MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), "WeightVGEdit Modifier, dw"); + for (i = 0; i < verts_num; i++) { dw[i] = BKE_defvert_find_index(&dvert[i], defgrp_index); if (dw[i]) { org_w[i] = new_w[i] = dw[i]->weight; @@ -237,7 +237,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * rng = BLI_rng_new_srandom(BLI_ghashutil_strhash(ctx->object->id.name + 2)); } - weightvg_do_map(numVerts, new_w, wmd->falloff_type, do_invert_mapping, wmd->cmap_curve, rng); + weightvg_do_map(verts_num, new_w, wmd->falloff_type, do_invert_mapping, wmd->cmap_curve, rng); if (rng) { BLI_rng_free(rng); @@ -247,7 +247,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* Do masking. */ struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); weightvg_do_mask(ctx, - numVerts, + verts_num, NULL, org_w, new_w, @@ -268,7 +268,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * weightvg_update_vg(dvert, defgrp_index, dw, - numVerts, + verts_num, NULL, org_w, do_add, diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 7f9bf9d1e80..52c5e96c68e 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -213,7 +213,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * float *org_w; float *new_w; int *tidx, *indices = NULL; - int numIdx = 0; + int index_num = 0; int i; const bool invert_vgroup_mask = (wmd->flag & MOD_WVG_MIX_INVERT_VGROUP_MASK) != 0; const bool do_normalize = (wmd->flag & MOD_WVG_MIX_WEIGHTS_NORMALIZE) != 0; @@ -233,12 +233,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * #endif /* Get number of verts. */ - const int numVerts = mesh->totvert; + const int verts_num = mesh->totvert; /* Check if we can just return the original mesh. * Must have verts and therefore verts assigned to vgroups to do anything useful! */ - if ((numVerts == 0) || BLI_listbase_is_empty(&mesh->vertex_group_names)) { + if ((verts_num == 0) || BLI_listbase_is_empty(&mesh->vertex_group_names)) { return mesh; } @@ -266,11 +266,11 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * } if (has_mdef) { - dvert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MDEFORMVERT, numVerts); + dvert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MDEFORMVERT, verts_num); } else { /* Add a valid data layer! */ - dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, numVerts); + dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, verts_num); } /* Ultimate security check. */ if (!dvert) { @@ -279,107 +279,107 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * mesh->dvert = dvert; /* Find out which vertices to work on. */ - tidx = MEM_malloc_arrayN(numVerts, sizeof(int), "WeightVGMix Modifier, tidx"); - tdw1 = MEM_malloc_arrayN(numVerts, sizeof(MDeformWeight *), "WeightVGMix Modifier, tdw1"); - tdw2 = MEM_malloc_arrayN(numVerts, sizeof(MDeformWeight *), "WeightVGMix Modifier, tdw2"); + tidx = MEM_malloc_arrayN(verts_num, sizeof(int), "WeightVGMix Modifier, tidx"); + tdw1 = MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), "WeightVGMix Modifier, tdw1"); + tdw2 = MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), "WeightVGMix Modifier, tdw2"); switch (wmd->mix_set) { case MOD_WVG_SET_A: /* All vertices in first vgroup. */ - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { MDeformWeight *dw = BKE_defvert_find_index(&dvert[i], defgrp_index); if (dw) { - tdw1[numIdx] = dw; - tdw2[numIdx] = (defgrp_index_other >= 0) ? - BKE_defvert_find_index(&dvert[i], defgrp_index_other) : - NULL; - tidx[numIdx++] = i; + tdw1[index_num] = dw; + tdw2[index_num] = (defgrp_index_other >= 0) ? + BKE_defvert_find_index(&dvert[i], defgrp_index_other) : + NULL; + tidx[index_num++] = i; } } break; case MOD_WVG_SET_B: /* All vertices in second vgroup. */ - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { MDeformWeight *dw = (defgrp_index_other >= 0) ? BKE_defvert_find_index(&dvert[i], defgrp_index_other) : NULL; if (dw) { - tdw1[numIdx] = BKE_defvert_find_index(&dvert[i], defgrp_index); - tdw2[numIdx] = dw; - tidx[numIdx++] = i; + tdw1[index_num] = BKE_defvert_find_index(&dvert[i], defgrp_index); + tdw2[index_num] = dw; + tidx[index_num++] = i; } } break; case MOD_WVG_SET_OR: /* All vertices in one vgroup or the other. */ - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { MDeformWeight *adw = BKE_defvert_find_index(&dvert[i], defgrp_index); MDeformWeight *bdw = (defgrp_index_other >= 0) ? BKE_defvert_find_index(&dvert[i], defgrp_index_other) : NULL; if (adw || bdw) { - tdw1[numIdx] = adw; - tdw2[numIdx] = bdw; - tidx[numIdx++] = i; + tdw1[index_num] = adw; + tdw2[index_num] = bdw; + tidx[index_num++] = i; } } break; case MOD_WVG_SET_AND: /* All vertices in both vgroups. */ - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { MDeformWeight *adw = BKE_defvert_find_index(&dvert[i], defgrp_index); MDeformWeight *bdw = (defgrp_index_other >= 0) ? BKE_defvert_find_index(&dvert[i], defgrp_index_other) : NULL; if (adw && bdw) { - tdw1[numIdx] = adw; - tdw2[numIdx] = bdw; - tidx[numIdx++] = i; + tdw1[index_num] = adw; + tdw2[index_num] = bdw; + tidx[index_num++] = i; } } break; case MOD_WVG_SET_ALL: default: /* Use all vertices. */ - for (i = 0; i < numVerts; i++) { + for (i = 0; i < verts_num; i++) { tdw1[i] = BKE_defvert_find_index(&dvert[i], defgrp_index); tdw2[i] = (defgrp_index_other >= 0) ? BKE_defvert_find_index(&dvert[i], defgrp_index_other) : NULL; } - numIdx = -1; + index_num = -1; break; } - if (numIdx == 0) { + if (index_num == 0) { /* Use no vertices! Hence, return org data. */ MEM_freeN(tdw1); MEM_freeN(tdw2); MEM_freeN(tidx); return mesh; } - if (numIdx != -1) { - indices = MEM_malloc_arrayN(numIdx, sizeof(int), "WeightVGMix Modifier, indices"); - memcpy(indices, tidx, sizeof(int) * numIdx); - dw1 = MEM_malloc_arrayN(numIdx, sizeof(MDeformWeight *), "WeightVGMix Modifier, dw1"); - memcpy(dw1, tdw1, sizeof(MDeformWeight *) * numIdx); + if (index_num != -1) { + indices = MEM_malloc_arrayN(index_num, sizeof(int), "WeightVGMix Modifier, indices"); + memcpy(indices, tidx, sizeof(int) * index_num); + dw1 = MEM_malloc_arrayN(index_num, sizeof(MDeformWeight *), "WeightVGMix Modifier, dw1"); + memcpy(dw1, tdw1, sizeof(MDeformWeight *) * index_num); MEM_freeN(tdw1); - dw2 = MEM_malloc_arrayN(numIdx, sizeof(MDeformWeight *), "WeightVGMix Modifier, dw2"); - memcpy(dw2, tdw2, sizeof(MDeformWeight *) * numIdx); + dw2 = MEM_malloc_arrayN(index_num, sizeof(MDeformWeight *), "WeightVGMix Modifier, dw2"); + memcpy(dw2, tdw2, sizeof(MDeformWeight *) * index_num); MEM_freeN(tdw2); } else { /* Use all vertices. */ - numIdx = numVerts; + index_num = verts_num; /* Just copy MDeformWeight pointers arrays, they will be freed at the end. */ dw1 = tdw1; dw2 = tdw2; } MEM_freeN(tidx); - org_w = MEM_malloc_arrayN(numIdx, sizeof(float), "WeightVGMix Modifier, org_w"); - new_w = MEM_malloc_arrayN(numIdx, sizeof(float), "WeightVGMix Modifier, new_w"); + org_w = MEM_malloc_arrayN(index_num, sizeof(float), "WeightVGMix Modifier, org_w"); + new_w = MEM_malloc_arrayN(index_num, sizeof(float), "WeightVGMix Modifier, new_w"); /* Mix weights. */ - for (i = 0; i < numIdx; i++) { + for (i = 0; i < index_num; i++) { float weight2; if (invert_vgroup_a) { org_w[i] = 1.0f - (dw1[i] ? dw1[i]->weight : wmd->default_weight_a); @@ -400,7 +400,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* Do masking. */ struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); weightvg_do_mask(ctx, - numIdx, + index_num, indices, org_w, new_w, @@ -420,13 +420,22 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* Update (add to) vgroup. * XXX Depending on the MOD_WVG_SET_xxx option chosen, we might have to add vertices to vgroup. */ - weightvg_update_vg( - dvert, defgrp_index, dw1, numIdx, indices, org_w, true, -FLT_MAX, false, 0.0f, do_normalize); + weightvg_update_vg(dvert, + defgrp_index, + dw1, + index_num, + indices, + org_w, + true, + -FLT_MAX, + false, + 0.0f, + do_normalize); /* If weight preview enabled... */ #if 0 /* XXX Currently done in mod stack :/ */ if (do_prev) { - DM_update_weight_mcol(ob, dm, 0, org_w, numIdx, indices); + DM_update_weight_mcol(ob, dm, 0, org_w, index_num, indices); } #endif diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 647db5c5aa4..7f11d348eff 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -143,7 +143,7 @@ static void vert2geom_task_cb_ex(void *__restrict userdata, /** * Find nearest vertex and/or edge and/or face, for each vertex (adapted from shrinkwrap.c). */ -static void get_vert2geom_distance(int numVerts, +static void get_vert2geom_distance(int verts_num, float (*v_cos)[3], float *dist_v, float *dist_e, @@ -194,10 +194,10 @@ static void get_vert2geom_distance(int numVerts, TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); - settings.use_threading = (numVerts > 10000); + settings.use_threading = (verts_num > 10000); settings.userdata_chunk = &data_chunk; settings.userdata_chunk_size = sizeof(data_chunk); - BLI_task_parallel_range(0, numVerts, &data, vert2geom_task_cb_ex, &settings); + BLI_task_parallel_range(0, verts_num, &data, vert2geom_task_cb_ex, &settings); if (dist_v) { free_bvhtree_from_mesh(&treeData_v); @@ -215,11 +215,11 @@ static void get_vert2geom_distance(int numVerts, * Note that it works in final world space (i.e. with constraints etc. applied). */ static void get_vert2ob_distance( - int numVerts, float (*v_cos)[3], float *dist, Object *ob, Object *obr) + int verts_num, float (*v_cos)[3], float *dist, Object *ob, Object *obr) { /* Vertex and ref object coordinates. */ float v_wco[3]; - uint i = numVerts; + uint i = verts_num; while (i-- > 0) { /* Get world-coordinates of the vertex (constraints and anim included). */ @@ -435,7 +435,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * float *org_w = NULL; float *new_w = NULL; int *tidx, *indices = NULL; - int numIdx = 0; + int index_num = 0; int i; const bool invert_vgroup_mask = (wmd->proximity_flags & MOD_WVG_PROXIMITY_INVERT_VGROUP_MASK) != 0; @@ -450,12 +450,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * #endif /* Get number of verts. */ - const int numVerts = mesh->totvert; + const int verts_num = mesh->totvert; /* Check if we can just return the original mesh. * Must have verts and therefore verts assigned to vgroups to do anything useful! */ - if ((numVerts == 0) || BLI_listbase_is_empty(&mesh->vertex_group_names)) { + if ((verts_num == 0) || BLI_listbase_is_empty(&mesh->vertex_group_names)) { return mesh; } @@ -477,7 +477,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * return mesh; } - dvert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MDEFORMVERT, numVerts); + dvert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MDEFORMVERT, verts_num); /* Ultimate security check. */ if (!dvert) { return mesh; @@ -485,31 +485,31 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * mesh->dvert = dvert; /* Find out which vertices to work on (all vertices in vgroup), and get their relevant weight. */ - tidx = MEM_malloc_arrayN(numVerts, sizeof(int), "WeightVGProximity Modifier, tidx"); - tw = MEM_malloc_arrayN(numVerts, sizeof(float), "WeightVGProximity Modifier, tw"); - tdw = MEM_malloc_arrayN(numVerts, sizeof(MDeformWeight *), "WeightVGProximity Modifier, tdw"); - for (i = 0; i < numVerts; i++) { + tidx = MEM_malloc_arrayN(verts_num, sizeof(int), "WeightVGProximity Modifier, tidx"); + tw = MEM_malloc_arrayN(verts_num, sizeof(float), "WeightVGProximity Modifier, tw"); + tdw = MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), "WeightVGProximity Modifier, tdw"); + for (i = 0; i < verts_num; i++) { MDeformWeight *_dw = BKE_defvert_find_index(&dvert[i], defgrp_index); if (_dw) { - tidx[numIdx] = i; - tw[numIdx] = _dw->weight; - tdw[numIdx++] = _dw; + tidx[index_num] = i; + tw[index_num] = _dw->weight; + tdw[index_num++] = _dw; } } /* If no vertices found, return org data! */ - if (numIdx == 0) { + if (index_num == 0) { MEM_freeN(tidx); MEM_freeN(tw); MEM_freeN(tdw); return mesh; } - if (numIdx != numVerts) { - indices = MEM_malloc_arrayN(numIdx, sizeof(int), "WeightVGProximity Modifier, indices"); - memcpy(indices, tidx, sizeof(int) * numIdx); - org_w = MEM_malloc_arrayN(numIdx, sizeof(float), "WeightVGProximity Modifier, org_w"); - memcpy(org_w, tw, sizeof(float) * numIdx); - dw = MEM_malloc_arrayN(numIdx, sizeof(MDeformWeight *), "WeightVGProximity Modifier, dw"); - memcpy(dw, tdw, sizeof(MDeformWeight *) * numIdx); + if (index_num != verts_num) { + indices = MEM_malloc_arrayN(index_num, sizeof(int), "WeightVGProximity Modifier, indices"); + memcpy(indices, tidx, sizeof(int) * index_num); + org_w = MEM_malloc_arrayN(index_num, sizeof(float), "WeightVGProximity Modifier, org_w"); + memcpy(org_w, tw, sizeof(float) * index_num); + dw = MEM_malloc_arrayN(index_num, sizeof(MDeformWeight *), "WeightVGProximity Modifier, dw"); + memcpy(dw, tdw, sizeof(MDeformWeight *) * index_num); MEM_freeN(tw); MEM_freeN(tdw); } @@ -517,14 +517,14 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * org_w = tw; dw = tdw; } - new_w = MEM_malloc_arrayN(numIdx, sizeof(float), "WeightVGProximity Modifier, new_w"); + new_w = MEM_malloc_arrayN(index_num, sizeof(float), "WeightVGProximity Modifier, new_w"); MEM_freeN(tidx); /* Get our vertex coordinates. */ - if (numIdx != numVerts) { + if (index_num != verts_num) { float(*tv_cos)[3] = BKE_mesh_vert_coords_alloc(mesh, NULL); - v_cos = MEM_malloc_arrayN(numIdx, sizeof(float[3]), "WeightVGProximity Modifier, v_cos"); - for (i = 0; i < numIdx; i++) { + v_cos = MEM_malloc_arrayN(index_num, sizeof(float[3]), "WeightVGProximity Modifier, v_cos"); + for (i = 0; i < index_num; i++) { copy_v3_v3(v_cos[i], tv_cos[indices[i]]); } MEM_freeN(tv_cos); @@ -536,7 +536,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* Compute wanted distances. */ if (wmd->proximity_mode == MOD_WVG_PROXIMITY_OBJECT) { const float dist = get_ob2ob_distance(ob, obr); - for (i = 0; i < numIdx; i++) { + for (i = 0; i < index_num; i++) { new_w[i] = dist; } } @@ -556,16 +556,17 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * BKE_mesh_wrapper_ensure_mdata(target_mesh); SpaceTransform loc2trgt; - float *dists_v = use_trgt_verts ? MEM_malloc_arrayN(numIdx, sizeof(float), "dists_v") : + float *dists_v = use_trgt_verts ? MEM_malloc_arrayN(index_num, sizeof(float), "dists_v") : NULL; - float *dists_e = use_trgt_edges ? MEM_malloc_arrayN(numIdx, sizeof(float), "dists_e") : + float *dists_e = use_trgt_edges ? MEM_malloc_arrayN(index_num, sizeof(float), "dists_e") : NULL; - float *dists_f = use_trgt_faces ? MEM_malloc_arrayN(numIdx, sizeof(float), "dists_f") : + float *dists_f = use_trgt_faces ? MEM_malloc_arrayN(index_num, sizeof(float), "dists_f") : NULL; BLI_SPACE_TRANSFORM_SETUP(&loc2trgt, ob, obr); - get_vert2geom_distance(numIdx, v_cos, dists_v, dists_e, dists_f, target_mesh, &loc2trgt); - for (i = 0; i < numIdx; i++) { + get_vert2geom_distance( + index_num, v_cos, dists_v, dists_e, dists_f, target_mesh, &loc2trgt); + for (i = 0; i < index_num; i++) { new_w[i] = dists_v ? dists_v[i] : FLT_MAX; if (dists_e) { new_w[i] = min_ff(dists_e[i], new_w[i]); @@ -581,18 +582,18 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * } /* Else, fall back to default obj2vert behavior. */ else { - get_vert2ob_distance(numIdx, v_cos, new_w, ob, obr); + get_vert2ob_distance(index_num, v_cos, new_w, ob, obr); } } else { - get_vert2ob_distance(numIdx, v_cos, new_w, ob, obr); + get_vert2ob_distance(index_num, v_cos, new_w, ob, obr); } } /* Map distances to weights. */ do_map(ob, new_w, - numIdx, + index_num, wmd->min_dist, wmd->max_dist, wmd->falloff_type, @@ -602,7 +603,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* Do masking. */ struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); weightvg_do_mask(ctx, - numIdx, + index_num, indices, org_w, new_w, @@ -621,12 +622,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* Update vgroup. Note we never add nor remove vertices from vgroup here. */ weightvg_update_vg( - dvert, defgrp_index, dw, numIdx, indices, org_w, false, 0.0f, false, 0.0f, do_normalize); + dvert, defgrp_index, dw, index_num, indices, org_w, false, 0.0f, false, 0.0f, do_normalize); /* If weight preview enabled... */ #if 0 /* XXX Currently done in mod stack :/ */ if (do_prev) { - DM_update_weight_mcol(ob, dm, 0, org_w, numIdx, indices); + DM_update_weight_mcol(ob, dm, 0, org_w, index_num, indices); } #endif |