From a25a7714c592dff1fc1b3b4b0888bf984fa9e6fd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Apr 2019 09:15:10 +1000 Subject: Cleanup: style, use braces for modifiers --- source/blender/modifiers/intern/MOD_array.c | 18 ++- source/blender/modifiers/intern/MOD_bevel.c | 18 ++- source/blender/modifiers/intern/MOD_boolean.c | 3 +- source/blender/modifiers/intern/MOD_build.c | 3 +- source/blender/modifiers/intern/MOD_cast.c | 60 +++++--- source/blender/modifiers/intern/MOD_cloth.c | 27 ++-- source/blender/modifiers/intern/MOD_collision.c | 3 +- source/blender/modifiers/intern/MOD_displace.c | 6 +- source/blender/modifiers/intern/MOD_edgesplit.c | 3 +- source/blender/modifiers/intern/MOD_explode.c | 15 +- .../blender/modifiers/intern/MOD_laplaciandeform.c | 3 +- .../blender/modifiers/intern/MOD_laplaciansmooth.c | 9 +- source/blender/modifiers/intern/MOD_meshcache.c | 9 +- source/blender/modifiers/intern/MOD_meshdeform.c | 72 ++++++--- source/blender/modifiers/intern/MOD_mirror.c | 15 +- source/blender/modifiers/intern/MOD_ocean.c | 3 +- .../modifiers/intern/MOD_particleinstance.c | 57 ++++--- .../blender/modifiers/intern/MOD_particlesystem.c | 12 +- source/blender/modifiers/intern/MOD_screw.c | 21 ++- source/blender/modifiers/intern/MOD_shapekey.c | 15 +- source/blender/modifiers/intern/MOD_shrinkwrap.c | 3 +- source/blender/modifiers/intern/MOD_simpledeform.c | 15 +- source/blender/modifiers/intern/MOD_skin.c | 170 ++++++++++++++------- source/blender/modifiers/intern/MOD_smoke.c | 6 +- source/blender/modifiers/intern/MOD_smooth.c | 36 +++-- source/blender/modifiers/intern/MOD_solidify.c | 21 ++- source/blender/modifiers/intern/MOD_surface.c | 12 +- source/blender/modifiers/intern/MOD_util.c | 12 +- source/blender/modifiers/intern/MOD_uvproject.c | 18 ++- source/blender/modifiers/intern/MOD_uvwarp.c | 6 +- source/blender/modifiers/intern/MOD_warp.c | 6 +- source/blender/modifiers/intern/MOD_wave.c | 6 +- .../blender/modifiers/intern/MOD_weightvg_util.c | 3 +- source/blender/modifiers/intern/MOD_weightvgedit.c | 3 +- source/blender/modifiers/intern/MOD_weightvgmix.c | 30 ++-- .../modifiers/intern/MOD_weightvgproximity.c | 39 +++-- 36 files changed, 505 insertions(+), 253 deletions(-) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index c909f9dc076..3443d275c81 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -121,12 +121,15 @@ static int svert_sum_cmp(const void *e1, const void *e2) const SortVertsElem *sv1 = e1; const SortVertsElem *sv2 = e2; - if (sv1->sum_co > sv2->sum_co) + if (sv1->sum_co > sv2->sum_co) { return 1; - else if (sv1->sum_co < sv2->sum_co) + } + else if (sv1->sum_co < sv2->sum_co) { return -1; - else + } + else { return 0; + } } static void svert_from_mvert(SortVertsElem *sv, @@ -441,10 +444,12 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, float obinv[4][4]; float result_mat[4][4]; - if (ctx->object) + if (ctx->object) { invert_m4_m4(obinv, ctx->object->obmat); - else + } + else { unit_m4(obinv); + } mul_m4_series(result_mat, offset, obinv, amd->offset_ob->obmat); copy_m4_m4(offset, result_mat); @@ -482,8 +487,9 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, } } - if (count < 1) + if (count < 1) { count = 1; + } /* The number of verts, edges, loops, polys, before eventually merging doubles */ result_nverts = chunk_nverts * count + start_cap_nverts + end_cap_nverts; diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 32a020a35ff..02d3bd305be 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -124,24 +124,28 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes .pmask = CD_MASK_ORIGINDEX}, }); - if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0]) + if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0]) { MOD_get_vgroup(ctx->object, mesh, bmd->defgrp_name, &dvert, &vgroup); + } if (vertex_only) { BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - if (!BM_vert_is_manifold(v)) + if (!BM_vert_is_manifold(v)) { continue; + } if (bmd->lim_flags & MOD_BEVEL_WEIGHT) { weight = BM_elem_float_data_get(&bm->vdata, v, CD_BWEIGHT); - if (weight == 0.0f) + if (weight == 0.0f) { continue; + } } else if (vgroup != -1) { weight = defvert_array_find_weight_safe(dvert, BM_elem_index_get(v), vgroup); /* Check is against 0.5 rather than != 0.0 because cascaded bevel modifiers will * interpolate weights for newly created vertices, and may cause unexpected "selection" */ - if (weight < 0.5f) + if (weight < 0.5f) { continue; + } } BM_elem_flag_enable(v, BM_ELEM_TAG); } @@ -165,14 +169,16 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes if (BM_edge_is_manifold(e)) { if (bmd->lim_flags & MOD_BEVEL_WEIGHT) { weight = BM_elem_float_data_get(&bm->edata, e, CD_BWEIGHT); - if (weight == 0.0f) + if (weight == 0.0f) { continue; + } } else if (vgroup != -1) { weight = defvert_array_find_weight_safe(dvert, BM_elem_index_get(e->v1), vgroup); weight2 = defvert_array_find_weight_safe(dvert, BM_elem_index_get(e->v2), vgroup); - if (weight < 0.5f || weight2 < 0.5f) + if (weight < 0.5f || weight2 < 0.5f) { continue; + } } BM_elem_flag_enable(e, BM_ELEM_TAG); BM_elem_flag_enable(e->v1, BM_ELEM_TAG); diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 6e6f98e9889..107622e33c0 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -323,8 +323,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes /* if new mesh returned, return it; otherwise there was * an error, so delete the modifier object */ - if (result == NULL) + if (result == NULL) { modifier_setError(md, "Cannot execute boolean operation"); + } } return result; diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index 7c8470b26d9..e61f6877d09 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -152,8 +152,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, str MEdge *medge, *me; uintptr_t hash_num; - if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) + if (bmd->flag & MOD_BUILD_FLAG_RANDOMIZE) { BLI_array_randomize(edgeMap, sizeof(*edgeMap), numEdge_src, bmd->seed); + } /* get the set of all vert indices that will be in the final mesh, * mapped to the new indices diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index b0a8a8c955f..0bf1dd8e2b3 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -62,8 +62,9 @@ static bool isDisabled(const struct Scene *UNUSED(scene), flag = cmd->flag & (MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z); - if ((cmd->fac == 0.0f) || flag == 0) + if ((cmd->fac == 0.0f) || flag == 0) { return true; + } return false; } @@ -120,8 +121,9 @@ static void sphere_do(CastModifierData *cmd, flag = cmd->flag; type = cmd->type; /* projection type: sphere or cylinder */ - if (type == MOD_CAST_TYPE_CYLINDER) + if (type == MOD_CAST_TYPE_CYLINDER) { flag &= ~MOD_CAST_Z; + } ctrl_ob = cmd->object; @@ -144,8 +146,9 @@ static void sphere_do(CastModifierData *cmd, /* 1) (flag was checked in the "if (ctrl_ob)" block above) */ /* 2) cmd->radius > 0.0f: only the vertices within this radius from * the center of the effect should be deformed */ - if (cmd->radius > FLT_EPSILON) + if (cmd->radius > FLT_EPSILON) { has_radius = 1; + } /* 3) if we were given a vertex group name, * only those vertices should be affected */ @@ -164,8 +167,9 @@ static void sphere_do(CastModifierData *cmd, } len /= numVerts; - if (len == 0.0f) + if (len == 0.0f) { len = 10.0f; + } } for (i = 0; i < numVerts; i++) { @@ -183,12 +187,14 @@ static void sphere_do(CastModifierData *cmd, copy_v3_v3(vec, tmp_co); - if (type == MOD_CAST_TYPE_CYLINDER) + if (type == MOD_CAST_TYPE_CYLINDER) { vec[2] = 0.0f; + } if (has_radius) { - if (len_v3(vec) > cmd->radius) + if (len_v3(vec) > cmd->radius) { continue; + } } if (dvert) { @@ -203,12 +209,15 @@ static void sphere_do(CastModifierData *cmd, normalize_v3(vec); - if (flag & MOD_CAST_X) + if (flag & MOD_CAST_X) { tmp_co[0] = fac * vec[0] * len + facm * tmp_co[0]; - if (flag & MOD_CAST_Y) + } + if (flag & MOD_CAST_Y) { tmp_co[1] = fac * vec[1] * len + facm * tmp_co[1]; - if (flag & MOD_CAST_Z) + } + if (flag & MOD_CAST_Z) { tmp_co[2] = fac * vec[2] * len + facm * tmp_co[2]; + } if (ctrl_ob) { if (flag & MOD_CAST_USE_OB_TRANSFORM) { @@ -252,8 +261,9 @@ static void cuboid_do(CastModifierData *cmd, /* 1) (flag was checked in the "if (ctrl_ob)" block above) */ /* 2) cmd->radius > 0.0f: only the vertices within this radius from * the center of the effect should be deformed */ - if (cmd->radius > FLT_EPSILON) + if (cmd->radius > FLT_EPSILON) { has_radius = 1; + } /* 3) if we were given a vertex group name, * only those vertices should be affected */ @@ -309,12 +319,15 @@ static void cuboid_do(CastModifierData *cmd, } /* we want a symmetric bound box around the origin */ - if (fabsf(min[0]) > fabsf(max[0])) + if (fabsf(min[0]) > fabsf(max[0])) { max[0] = fabsf(min[0]); - if (fabsf(min[1]) > fabsf(max[1])) + } + if (fabsf(min[1]) > fabsf(max[1])) { max[1] = fabsf(min[1]); - if (fabsf(min[2]) > fabsf(max[2])) + } + if (fabsf(min[2]) > fabsf(max[2])) { max[2] = fabsf(min[2]); + } min[0] = -max[0]; min[1] = -max[1]; min[2] = -max[2]; @@ -371,12 +384,15 @@ static void cuboid_do(CastModifierData *cmd, /* find in which octant this vertex is in */ octant = 0; - if (tmp_co[0] > 0.0f) + if (tmp_co[0] > 0.0f) { octant += 1; - if (tmp_co[1] > 0.0f) + } + if (tmp_co[1] > 0.0f) { octant += 2; - if (tmp_co[2] > 0.0f) + } + if (tmp_co[2] > 0.0f) { octant += 4; + } /* apex is the bb's vertex at the chosen octant */ copy_v3_v3(apex, bb[octant]); @@ -400,20 +416,24 @@ static void cuboid_do(CastModifierData *cmd, /* ok, now we know which coordinate of the vertex to use */ - if (fabsf(tmp_co[coord]) < FLT_EPSILON) /* avoid division by zero */ + if (fabsf(tmp_co[coord]) < FLT_EPSILON) { /* avoid division by zero */ continue; + } /* finally, this is the factor we wanted, to project the vertex * to its bounding box (bb) */ fbb = apex[coord] / tmp_co[coord]; /* calculate the new vertex position */ - if (flag & MOD_CAST_X) + if (flag & MOD_CAST_X) { tmp_co[0] = facm * tmp_co[0] + fac * tmp_co[0] * fbb; - if (flag & MOD_CAST_Y) + } + if (flag & MOD_CAST_Y) { tmp_co[1] = facm * tmp_co[1] + fac * tmp_co[1] * fbb; - if (flag & MOD_CAST_Z) + } + if (flag & MOD_CAST_Z) { tmp_co[2] = facm * tmp_co[2] + fac * tmp_co[2] * fbb; + } if (ctrl_ob) { if (flag & MOD_CAST_USE_OB_TRANSFORM) { diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 9eeef583e44..3c4dd9f2c56 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -59,8 +59,9 @@ static void initData(ModifierData *md) clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches); /* check for alloc failing */ - if (!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache) + if (!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache) { return; + } cloth_init(clmd); } @@ -79,8 +80,9 @@ static void deformVerts(ModifierData *md, if (!clmd->sim_parms || !clmd->coll_parms) { initData(md); - if (!clmd->sim_parms || !clmd->coll_parms) + if (!clmd->sim_parms || !clmd->coll_parms) { return; + } } if (mesh == NULL) { @@ -156,13 +158,15 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla ClothModifierData *tclmd = (ClothModifierData *)target; if (tclmd->sim_parms) { - if (tclmd->sim_parms->effector_weights) + if (tclmd->sim_parms->effector_weights) { MEM_freeN(tclmd->sim_parms->effector_weights); + } MEM_freeN(tclmd->sim_parms); } - if (tclmd->coll_parms) + if (tclmd->coll_parms) { MEM_freeN(tclmd->coll_parms); + } BKE_ptcache_free_list(&tclmd->ptcaches); if (flag & LIB_ID_CREATE_NO_MAIN) { @@ -177,8 +181,9 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla } tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms); - if (clmd->sim_parms->effector_weights) + if (clmd->sim_parms->effector_weights) { tclmd->sim_parms->effector_weights = MEM_dupallocN(clmd->sim_parms->effector_weights); + } tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms); tclmd->clothObject = NULL; tclmd->hairdata = NULL; @@ -202,12 +207,14 @@ static void freeData(ModifierData *md) cloth_free_modifier_extern(clmd); if (clmd->sim_parms) { - if (clmd->sim_parms->effector_weights) + if (clmd->sim_parms->effector_weights) { MEM_freeN(clmd->sim_parms->effector_weights); + } MEM_freeN(clmd->sim_parms); } - if (clmd->coll_parms) + if (clmd->coll_parms) { MEM_freeN(clmd->coll_parms); + } if (md->flag & eModifierFlag_SharedCaches) { BLI_listbase_clear(&clmd->ptcaches); @@ -217,11 +224,13 @@ static void freeData(ModifierData *md) } clmd->point_cache = NULL; - if (clmd->hairdata) + if (clmd->hairdata) { MEM_freeN(clmd->hairdata); + } - if (clmd->solver_result) + if (clmd->solver_result) { MEM_freeN(clmd->solver_result); + } } } diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 59f4a1a93b6..1bbc25643a1 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -141,8 +141,9 @@ static void deformVerts(ModifierData *md, } /* check if mesh has changed */ - if (collmd->x && (mvert_num != collmd->mvert_num)) + if (collmd->x && (mvert_num != collmd->mvert_num)) { freeData((ModifierData *)collmd); + } if (collmd->time_xnew == -1000) { /* first time */ diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index b0c633b1cdd..50447ae0376 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -284,10 +284,12 @@ static void displaceModifier_do(DisplaceModifierData *dmd, float local_mat[4][4] = {{0}}; const bool use_global_direction = dmd->space == MOD_DISP_SPACE_GLOBAL; - if (dmd->texture == NULL && dmd->direction == MOD_DISP_DIR_RGB_XYZ) + if (dmd->texture == NULL && dmd->direction == MOD_DISP_DIR_RGB_XYZ) { return; - if (dmd->strength == 0.0f) + } + if (dmd->strength == 0.0f) { return; + } mvert = mesh->mvert; MOD_get_vgroup(ob, mesh, dmd->defgrp_name, &dvert, &defgrp_index); diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 9c2ad13db94..59d560b9a4a 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -118,8 +118,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *UNUSED(c Mesh *result; EdgeSplitModifierData *emd = (EdgeSplitModifierData *)md; - if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG))) + if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG))) { return mesh; + } result = doEdgeSplit(mesh, emd); diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 6109db3651c..7d87ba240d5 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -129,8 +129,9 @@ static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *p for (i = 0; i < totvert; i++, dvert++) { float val = BLI_rng_get_float(rng); val = (1.0f - emd->protect) * val + emd->protect * 0.5f; - if (val < defvert_find_weight(dvert, defgrp_index)) + if (val < defvert_find_weight(dvert, defgrp_index)) { vertpa[i] = -1; + } } } } @@ -716,8 +717,9 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh) BLI_edgehashIterator_free(ehi); /* count new faces due to splitting */ - for (i = 0, fs = facesplit; i < totface; i++, fs++) + for (i = 0, fs = facesplit; i < totface; i++, fs++) { totfsplit += add_faces[*fs]; + } split_m = BKE_mesh_new_nomain_from_template(mesh, totesplit, 0, totface + totfsplit, 0, 0); @@ -1031,12 +1033,15 @@ static Mesh *explodeMesh(ExplodeModifierData *emd, if (facepa[i] != totpart) { pa = pars + facepa[i]; - if (pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) + if (pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) { continue; - if (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) + } + if (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) { continue; - if (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0) + } + if (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0) { continue; + } } source = mesh->mface[i]; diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c index 02682b23490..71636463f70 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.c +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c @@ -730,8 +730,9 @@ static bool isDisabled(const struct Scene *UNUSED(scene), bool UNUSED(useRenderParams)) { LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md; - if (lmd->anchor_grp_name[0]) + if (lmd->anchor_grp_name[0]) { return 0; + } return 1; } diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c index 0dfe5f49393..4a86c26cdeb 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c @@ -501,8 +501,9 @@ static bool is_disabled(const struct Scene *UNUSED(scene), flag = smd->flag & (MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z); /* disable if modifier is off for X, Y and Z or if factor is 0 */ - if (flag == 0) + if (flag == 0) { return 1; + } return 0; } @@ -527,8 +528,9 @@ static void deformVerts(ModifierData *md, { Mesh *mesh_src; - if (numVerts == 0) + if (numVerts == 0) { return; + } mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); @@ -549,8 +551,9 @@ static void deformVertsEM(ModifierData *md, { Mesh *mesh_src; - if (numVerts == 0) + if (numVerts == 0) { return; + } mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false); diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c index cf1b2daa9cd..e01f07584ee 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.c +++ b/source/blender/modifiers/intern/MOD_meshcache.c @@ -226,12 +226,15 @@ static void meshcache_do(MeshCacheModifierData *mcmd, if (mcmd->flip_axis) { float tmat[3][3]; unit_m3(tmat); - if (mcmd->flip_axis & (1 << 0)) + if (mcmd->flip_axis & (1 << 0)) { tmat[0][0] = -1.0f; - if (mcmd->flip_axis & (1 << 1)) + } + if (mcmd->flip_axis & (1 << 1)) { tmat[1][1] = -1.0f; - if (mcmd->flip_axis & (1 << 2)) + } + if (mcmd->flip_axis & (1 << 2)) { tmat[2][2] = -1.0f; + } mul_m3_m3m3(mat, tmat, mat); use_matrix = true; diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 9238057f032..d89a47f4cf3 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -62,22 +62,30 @@ static void freeData(ModifierData *md) { MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; - if (mmd->bindinfluences) + if (mmd->bindinfluences) { MEM_freeN(mmd->bindinfluences); - if (mmd->bindoffsets) + } + if (mmd->bindoffsets) { MEM_freeN(mmd->bindoffsets); - if (mmd->bindcagecos) + } + if (mmd->bindcagecos) { MEM_freeN(mmd->bindcagecos); - if (mmd->dyngrid) + } + if (mmd->dyngrid) { MEM_freeN(mmd->dyngrid); - if (mmd->dyninfluences) + } + if (mmd->dyninfluences) { MEM_freeN(mmd->dyninfluences); - if (mmd->dynverts) + } + if (mmd->dynverts) { MEM_freeN(mmd->dynverts); - if (mmd->bindweights) + } + if (mmd->bindweights) { MEM_freeN(mmd->bindweights); /* deprecated */ - if (mmd->bindcos) + } + if (mmd->bindcos) { MEM_freeN(mmd->bindcos); /* deprecated */ + } } static void copyData(const ModifierData *md, ModifierData *target, const int flag) @@ -87,22 +95,30 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla modifier_copyData_generic(md, target, flag); - if (mmd->bindinfluences) + if (mmd->bindinfluences) { tmmd->bindinfluences = MEM_dupallocN(mmd->bindinfluences); - if (mmd->bindoffsets) + } + if (mmd->bindoffsets) { tmmd->bindoffsets = MEM_dupallocN(mmd->bindoffsets); - if (mmd->bindcagecos) + } + if (mmd->bindcagecos) { tmmd->bindcagecos = MEM_dupallocN(mmd->bindcagecos); - if (mmd->dyngrid) + } + if (mmd->dyngrid) { tmmd->dyngrid = MEM_dupallocN(mmd->dyngrid); - if (mmd->dyninfluences) + } + if (mmd->dyninfluences) { tmmd->dyninfluences = MEM_dupallocN(mmd->dyninfluences); - if (mmd->dynverts) + } + if (mmd->dynverts) { tmmd->dynverts = MEM_dupallocN(mmd->dynverts); - if (mmd->bindweights) + } + if (mmd->bindweights) { tmmd->bindweights = MEM_dupallocN(mmd->bindweights); /* deprecated */ - if (mmd->bindcos) + } + if (mmd->bindcos) { tmmd->bindcos = MEM_dupallocN(mmd->bindcos); /* deprecated */ + } } static void requiredDataMask(Object *UNUSED(ob), @@ -256,9 +272,11 @@ static void meshdeform_vert_task(void *__restrict userdata, float co[3]; float weight, totweight, fac = 1.0f; - if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) - if (!mmd->dynverts[iter]) + if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) { + if (!mmd->dynverts[iter]) { return; + } + } if (dvert) { fac = defvert_find_weight(&dvert[iter], defgrp_index); @@ -293,10 +311,12 @@ static void meshdeform_vert_task(void *__restrict userdata, if (totweight > 0.0f) { mul_v3_fl(co, fac / totweight); mul_m3_v3(data->icagemat, co); - if (G.debug_value != 527) + if (G.debug_value != 527) { add_v3_v3(vertexCos[iter], co); - else + } + else { copy_v3_v3(vertexCos[iter], co); + } } } @@ -319,8 +339,9 @@ static void meshdeformModifier_do(ModifierData *md, static int recursive_bind_sentinel = 0; - if (mmd->object == NULL || (mmd->bindcagecos == NULL && mmd->bindfunc == NULL)) + if (mmd->object == NULL || (mmd->bindcagecos == NULL && mmd->bindfunc == NULL)) { return; + } /* Get cage mesh. * @@ -467,8 +488,9 @@ void modifier_mdef_compact_influences(ModifierData *md) int totinfluence, totvert, totcagevert, a, b; weights = mmd->bindweights; - if (!weights) + if (!weights) { return; + } totvert = mmd->totvert; totcagevert = mmd->totcagevert; @@ -478,8 +500,9 @@ void modifier_mdef_compact_influences(ModifierData *md) for (a = 0; a < totcagevert; a++) { weight = weights[a + b * totcagevert]; - if (weight > MESHDEFORM_MIN_INFLUENCE) + if (weight > MESHDEFORM_MIN_INFLUENCE) { mmd->totinfluence++; + } } } @@ -499,8 +522,9 @@ void modifier_mdef_compact_influences(ModifierData *md) for (a = 0; a < totcagevert; a++) { weight = weights[a + b * totcagevert]; - if (weight > MESHDEFORM_MIN_INFLUENCE) + if (weight > MESHDEFORM_MIN_INFLUENCE) { totweight += weight; + } } /* assign weights normalized */ diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c index 39b86ca48fd..ba1681b3ac3 100644 --- a/source/blender/modifiers/intern/MOD_mirror.c +++ b/source/blender/modifiers/intern/MOD_mirror.c @@ -283,12 +283,13 @@ static Mesh *doMirrorOnAxis(MirrorModifierData *mmd, CustomData_copy_data( &result->ldata, &result->ldata, mp->loopstart, mp->loopstart + maxLoops, 1); - for (j = 1; j < mp->totloop; j++) + for (j = 1; j < mp->totloop; j++) { CustomData_copy_data(&result->ldata, &result->ldata, mp->loopstart + j, mp->loopstart + maxLoops + mp->totloop - j, 1); + } ml2 = ml + mp->loopstart + maxLoops; e = ml2[0].e; @@ -321,10 +322,12 @@ static Mesh *doMirrorOnAxis(MirrorModifierData *mmd, int j = maxLoops; dmloopuv += j; /* second set of loops only */ for (; j-- > 0; dmloopuv++) { - if (do_mirr_u) + if (do_mirr_u) { dmloopuv->uv[0] = 1.0f - dmloopuv->uv[0] + mmd->uv_offset[0]; - if (do_mirr_v) + } + if (do_mirr_v) { dmloopuv->uv[1] = 1.0f - dmloopuv->uv[1] + mmd->uv_offset[1]; + } dmloopuv->uv[0] += mmd->uv_offset_copy[0]; dmloopuv->uv[1] += mmd->uv_offset_copy[1]; } @@ -342,10 +345,12 @@ static Mesh *doMirrorOnAxis(MirrorModifierData *mmd, if (flip_map) { for (i = 0; i < maxVerts; dvert++, i++) { /* merged vertices get both groups, others get flipped */ - if (do_vtargetmap && (vtargetmap[i] != -1)) + if (do_vtargetmap && (vtargetmap[i] != -1)) { defvert_flip_merged(dvert, flip_map, flip_map_len); - else + } + else { defvert_flip(dvert, flip_map, flip_map_len); + } } MEM_freeN(flip_map); diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index ce1554b7e33..1ca25cbb068 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -481,8 +481,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes result = doOcean(md, ctx, mesh); - if (result != mesh) + if (result != mesh) { result->runtime.cd_dirty_vert |= CD_MASK_NORMAL; + } return result; } diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index 718c1e6a038..71913378277 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -80,12 +80,14 @@ static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRend ParticleSystem *psys; ModifierData *ob_md; - if (!pimd->ob) + if (!pimd->ob) { return true; + } psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1); - if (psys == NULL) + if (psys == NULL) { return true; + } /* If the psys modifier is disabled we cannot use its data. * First look up the psys modifier from the object, then check if it is enabled. @@ -96,13 +98,16 @@ static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRend if (psmd->psys == psys) { int required_mode; - if (useRenderParams) + if (useRenderParams) { required_mode = eModifierMode_Render; - else + } + else { required_mode = eModifierMode_Realtime; + } - if (!modifier_isEnabled(scene, ob_md, required_mode)) + if (!modifier_isEnabled(scene, ob_md, required_mode)) { return true; + } break; } @@ -145,12 +150,15 @@ static bool particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *ps } if (pa) { - if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) + if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) { return true; - if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) + } + if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) { return true; - if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) + } + if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) { return true; + } } if (pimd->particle_amount == 1.0f) { @@ -219,8 +227,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes if (pimd->ob) { psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1); - if (psys == NULL || psys->totpart == 0) + if (psys == NULL || psys->totpart == 0) { return mesh; + } } else { return mesh; @@ -229,13 +238,16 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes part_start = use_parents ? 0 : psys->totpart; part_end = 0; - if (use_parents) + if (use_parents) { part_end += psys->totpart; - if (use_children) + } + if (use_children) { part_end += psys->totchild; + } - if (part_end == 0) + if (part_end == 0) { return mesh; + } sim.depsgraph = ctx->depsgraph; sim.scene = scene; @@ -249,8 +261,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes si = size = MEM_calloc_arrayN(part_end, sizeof(float), "particle size array"); if (pimd->flag & eParticleInstanceFlag_Parents) { - for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++, si++) + for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++, si++) { *si = pa->size; + } } if (pimd->flag & eParticleInstanceFlag_Children) { @@ -289,8 +302,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes maxedge = 0; for (p = part_start; p < part_end; p++) { - if (particle_skip(pimd, psys, p)) + if (particle_skip(pimd, psys, p)) { continue; + } maxvert += totvert; maxpoly += totpoly; @@ -336,8 +350,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes float p_random = psys_frand(psys, 77091 + 283 * p); /* skip particle? */ - if (particle_skip(pimd, psys, p)) + if (particle_skip(pimd, psys, p)) { continue; + } /* set vertices coordinates */ for (k = 0; k < totvert; k++) { @@ -377,8 +392,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes else { state.time = (mv->co[axis] - min_co) / (max_co - min_co) * pimd->position * (1.0f - ran); - if (trackneg) + if (trackneg) { state.time = 1.0f - state.time; + } mv->co[axis] = 0.0; } @@ -392,8 +408,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes float hairmat[4][4]; float mat[3][3]; - if (p < psys->totpart) + if (p < psys->totpart) { pa = psys->particles + p; + } else { ChildParticle *cpa = psys->child + (p - psys->totpart); pa = psys->particles + (between ? cpa->pa[0] : cpa->parent); @@ -454,8 +471,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } mul_qt_v3(state.rot, mv->co); - if (pimd->flag & eParticleInstanceFlag_UseSize) + if (pimd->flag & eParticleInstanceFlag_UseSize) { mul_v3_fl(mv->co, size[p]); + } add_v3_v3(mv->co, state.co); mul_m4_v3(spacemat, mv->co); @@ -509,8 +527,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes psys->lattice_deform_data = NULL; } - if (size) + if (size) { MEM_freeN(size); + } MEM_SAFE_FREE(vert_part_index); MEM_SAFE_FREE(vert_part_value); diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index 8573ef14e09..5d7b380a751 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -62,8 +62,9 @@ static void freeData(ModifierData *md) /* ED_object_modifier_remove may have freed this first before calling * modifier_free (which calls this function) */ - if (psmd->psys) + if (psmd->psys) { psmd->psys->flag |= PSYS_DELETE; + } } static void copyData(const ModifierData *md, ModifierData *target, const int flag) @@ -101,13 +102,16 @@ static void deformVerts(ModifierData *md, ParticleSystem *psys = NULL; /* float cfra = BKE_scene_frame_get(md->scene); */ /* UNUSED */ - if (ctx->object->particlesystem.first) + if (ctx->object->particlesystem.first) { psys = psmd->psys; - else + } + else { return; + } - if (!psys_check_enabled(ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0)) + if (!psys_check_enabled(ctx->object, psys, (ctx->flag & MOD_APPLY_RENDER) != 0)) { return; + } if (mesh_src == NULL) { mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, vertexCos, numVerts, false, true); diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 8fadfbaff07..bfd1858df09 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -250,8 +250,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes const char mpoly_flag = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) ? ME_SMOOTH : 0; /* don't do anything? */ - if (!totvert) + if (!totvert) { return BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0, 0); + } switch (ltmd->axis) { case 0: @@ -350,8 +351,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON * 100.0f)) { close = 1; step_tot--; - if (step_tot < 3) + if (step_tot < 3) { step_tot = 3; + } maxVerts = totvert * step_tot; /* -1 because we're joining back up */ maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ @@ -362,8 +364,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } else { close = 0; - if (step_tot < 3) + if (step_tot < 3) { step_tot = 3; + } maxVerts = totvert * step_tot; /* -1 because we're joining back up */ maxEdges = (totvert * (step_tot - 1)) + /* these are the edges between new verts */ @@ -690,8 +693,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes ed_loop_flip = !ed_loop_flip; #endif - if (angle < 0.0f) + if (angle < 0.0f) { ed_loop_flip = !ed_loop_flip; + } /* if its closed, we only need 1 loop */ for (j = ed_loop_closed; j < 2; j++) { @@ -704,8 +708,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes /* If this is the vert off the best vert and * the best vert has 2 edges connected too it * then swap the flip direction */ - if (j == 1 && SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1])) + if (j == 1 && SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1])) { ed_loop_flip = !ed_loop_flip; + } while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) { /*printf("\tOrdering Vert V %i\n", lt_iter.v);*/ @@ -812,8 +817,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } /* we won't be looping on this data again so copy normals here */ - if ((angle < 0.0f) != do_flip) + if ((angle < 0.0f) != do_flip) { negate_v3(vc->no); + } normalize_v3(vc->no); normal_float_to_short_v3(mvert_new[i].no, vc->no); @@ -849,8 +855,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } copy_m4_m3(mat, mat3); - if (screw_ofs) + if (screw_ofs) { madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)step / (float)(step_tot - 1))); + } /* copy a slice */ CustomData_copy_data(&mesh->vdata, &result->vdata, 0, (int)varray_stride, (int)totvert); diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index 5667a74bce6..69db6f5565d 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -64,13 +64,16 @@ static void deformMatrices(ModifierData *md, if (kb && kb->totelem == numVerts && kb != key->refkey) { int a; - if (ctx->object->shapeflag & OB_SHAPE_LOCK) + if (ctx->object->shapeflag & OB_SHAPE_LOCK) { scale_m3_fl(scale, 1); - else + } + else { scale_m3_fl(scale, kb->curval); + } - for (a = 0; a < numVerts; a++) + for (a = 0; a < numVerts; a++) { copy_m3_m3(defMats[a], scale); + } } deformVerts(md, ctx, mesh, vertexCos, numVerts); @@ -85,8 +88,9 @@ static void deformVertsEM(ModifierData *md, { Key *key = BKE_key_from_object(ctx->object); - if (key && key->type == KEY_RELATIVE) + if (key && key->type == KEY_RELATIVE) { deformVerts(md, ctx, mesh, vertexCos, numVerts); + } } static void deformMatricesEM(ModifierData *UNUSED(md), @@ -107,8 +111,9 @@ static void deformMatricesEM(ModifierData *UNUSED(md), int a; scale_m3_fl(scale, kb->curval); - for (a = 0; a < numVerts; a++) + for (a = 0; a < numVerts; 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 3b4d6251c0a..07182d82fdc 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -172,8 +172,9 @@ static bool dependsOnNormals(ModifierData *md) { ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md; - if (smd->target && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) + if (smd->target && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) { return (smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL); + } return false; } diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 2434bd514f4..8d511207b9b 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -73,10 +73,12 @@ BLI_INLINE void copy_v3_v3_unmap(float a[3], const float b[3], const uint map[3] static void axis_limit(const int axis, const float limits[2], float co[3], float dcut[3]) { float val = co[axis]; - if (limits[0] > val) + if (limits[0] > val) { val = limits[0]; - if (limits[1] < val) + } + if (limits[1] < val) { val = limits[1]; + } dcut[axis] = co[axis] - val; co[axis] = val; @@ -228,13 +230,16 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, } /* Safe-check */ - if (smd->origin == ob) + if (smd->origin == ob) { smd->origin = NULL; /* No self references */ + } - if (smd->limit[0] < 0.0f) + if (smd->limit[0] < 0.0f) { smd->limit[0] = 0.0f; - if (smd->limit[0] > 1.0f) + } + if (smd->limit[0] > 1.0f) { smd->limit[0] = 1.0f; + } smd->limit[0] = min_ff(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */ diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 74381a491b5..7ddde7236c0 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -148,14 +148,16 @@ static bool is_quad_symmetric(BMVert *quad[4], const SkinModifierData *smd) if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) { copy_v3_v3(a, quad[2]->co); a[axis] = -a[axis]; - if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) + if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) { return 1; + } } else if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) { copy_v3_v3(a, quad[2]->co); a[axis] = -a[axis]; - if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) + if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) { return 1; + } } } } @@ -174,13 +176,16 @@ static bool quad_crosses_symmetry_plane(BMVert *quad[4], const SkinModifierData int i; for (i = 0; i < 4; i++) { - if (quad[i]->co[axis] < 0.0f) + if (quad[i]->co[axis] < 0.0f) { left = true; - else if (quad[i]->co[axis] > 0.0f) + } + else if (quad[i]->co[axis] > 0.0f) { right = true; + } - if (left && right) + if (left && right) { return true; + } } } } @@ -196,13 +201,16 @@ static bool skin_frame_find_contained_faces(const Frame *frame, BMFace *fill_fac /* See if the frame is bisected by a diagonal edge */ diag = BM_edge_exists(frame->verts[0], frame->verts[2]); - if (!diag) + if (!diag) { diag = BM_edge_exists(frame->verts[1], frame->verts[3]); + } - if (diag) + if (diag) { return BM_edge_face_pair(diag, &fill_faces[0], &fill_faces[1]); - else + } + else { return false; + } } /* Returns true if hull is successfully built, false otherwise */ @@ -242,8 +250,9 @@ static bool build_hull(SkinOutput *so, Frame **frames, int totframe) /* Apply face attributes to hull output */ BMO_ITER (f, &oiter, op.slots_out, "geom.out", BM_FACE) { BM_face_normal_update(f); - if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING) + if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING) { BM_elem_flag_enable(f, BM_ELEM_SMOOTH); + } f->mat_nr = so->mat_nr; } @@ -292,8 +301,9 @@ static bool build_hull(SkinOutput *so, Frame **frames, int totframe) BM_elem_flag_enable(fill_faces[0], BM_ELEM_TAG); BM_elem_flag_enable(fill_faces[1], BM_ELEM_TAG); } - else + else { frame->detached = true; + } } } @@ -307,8 +317,9 @@ static bool build_hull(SkinOutput *so, Frame **frames, int totframe) break; } } - if (is_wire) + if (is_wire) { BM_elem_flag_enable(e, BM_ELEM_TAG); + } } BMO_op_finish(bm, &op); @@ -341,8 +352,9 @@ static void merge_frame_corners(Frame **frames, int totframe) for (j = 0; j < 4; j++) { /* Ensure the merge target is not itself a merge target */ - if (frames[i]->merge[j].frame) + if (frames[i]->merge[j].frame) { continue; + } for (k = i + 1; k < totframe; k++) { BLI_assert(frames[i] != frames[k]); @@ -352,8 +364,9 @@ static void merge_frame_corners(Frame **frames, int totframe) /* Compare with each corner of all other frames... */ for (l = 0; l < 4; l++) { - if (frames[k]->merge[l].frame || frames[k]->merge[l].is_target) + if (frames[k]->merge[l].frame || frames[k]->merge[l].is_target) { continue; + } /* Some additional concerns that could be checked * further: @@ -406,10 +419,12 @@ static Frame **collect_hull_frames( const MEdge *e = &medge[emap[v].indices[nbr]]; f = &frames[BKE_mesh_edge_other_vert(e, v)]; /* Can't have adjacent branch nodes yet */ - if (f->totframe) + if (f->totframe) { hull_frames[i++] = &f->frames[0]; - else + } + else { (*tothullframe)--; + } } return hull_frames; @@ -425,8 +440,9 @@ static void node_frames_init(SkinNode *nf, int totframe) memset(nf->frames, 0, sizeof(nf->frames)); nf->flag = 0; - for (i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { nf->seam_edges[i] = -1; + } } static void create_frame( @@ -451,8 +467,9 @@ static void create_frame( sub_v3_v3v3(frame->co[0], frame->co[0], rz); mul_v3_v3fl(rx, mat[0], offset); - for (i = 0; i < 4; i++) + for (i = 0; i < 4; i++) { add_v3_v3v3(frame->co[i], frame->co[i], rx); + } } static float half_v2(const float v[2]) @@ -492,15 +509,17 @@ static void end_node_frames(int v, /* Use incoming edge for orientation */ copy_m3_m3(mat, emat[emap[v].indices[0]].mat); - if (emat[emap[v].indices[0]].origin != v) + if (emat[emap[v].indices[0]].origin != v) { negate_v3(mat[0]); + } /* End frame */ create_frame(&skin_nodes[v].frames[0], mvert[v].co, rad, mat, 0); } - if (nodes[v].flag & MVERT_SKIN_ROOT) + if (nodes[v].flag & MVERT_SKIN_ROOT) { skin_nodes[v].flag |= ROOT; + } } /* Returns 1 for seam, 0 otherwise */ @@ -520,8 +539,9 @@ static int connection_node_mat(float mat[3][3], int v, const MeshElemMap *emap, copy_m3_m3(ine, e2->mat); copy_m3_m3(oute, e1->mat); } - else + else { return 1; + } /* Get axis and angle to rotate frame by */ angle = angle_normalized_v3v3(ine[0], oute[0]) / 2.0f; @@ -560,14 +580,16 @@ static void connection_node_frames(int v, skin_nodes[v].flag |= SEAM_FRAME; copy_m3_m3(mat, e1->mat); - if (e1->origin != v) + if (e1->origin != v) { negate_v3(mat[0]); + } create_frame(&skin_nodes[v].frames[0], mvert[v].co, rad, mat, avg); skin_nodes[v].seam_edges[0] = emap[v].indices[0]; copy_m3_m3(mat, e2->mat); - if (e2->origin != v) + if (e2->origin != v) { negate_v3(mat[0]); + } create_frame(&skin_nodes[v].frames[1], mvert[v].co, rad, mat, avg); skin_nodes[v].seam_edges[1] = emap[v].indices[1]; @@ -588,10 +610,12 @@ static SkinNode *build_frames( skin_nodes = MEM_calloc_arrayN(totvert, sizeof(SkinNode), "build_frames.skin_nodes"); for (v = 0; v < totvert; v++) { - if (emap[v].count <= 1) + if (emap[v].count <= 1) { end_node_frames(v, skin_nodes, mvert, nodes, emap, emat); - else if (emap[v].count == 2) + } + else if (emap[v].count == 2) { connection_node_frames(v, skin_nodes, mvert, nodes, emap, emat); + } else { /* Branch node generates no frames */ } @@ -654,8 +678,9 @@ static void build_emats_stack(BLI_Stack *stack, e = stack_elem.e; /* Skip if edge already visited */ - if (BLI_BITMAP_TEST(visited_e, e)) + if (BLI_BITMAP_TEST(visited_e, e)) { return; + } /* Mark edge as visited */ BLI_BITMAP_ENABLE(visited_e, e); @@ -766,10 +791,12 @@ static int calc_edge_subdivisions(const MVert *mvert, * the edge (or subdivide just twice if both are branches) */ if ((v1_branch && (evs[0]->flag & MVERT_SKIN_LOOSE)) || (v2_branch && (evs[1]->flag & MVERT_SKIN_LOOSE))) { - if (v1_branch && v2_branch) + if (v1_branch && v2_branch) { return 2; - else + } + else { return 0; + } } avg_radius = half_v2(evs[0]->radius) + half_v2(evs[1]->radius); @@ -792,8 +819,9 @@ static int calc_edge_subdivisions(const MVert *mvert, /* If both ends are branch nodes, two intermediate nodes are * required */ - if (num_subdivisions < 2 && v1_branch && v2_branch) + if (num_subdivisions < 2 && v1_branch && v2_branch) { num_subdivisions = 2; + } return num_subdivisions; @@ -907,8 +935,9 @@ static Mesh *subdivide_base(Mesh *orig) vg = &vgroups[k]; weight = interpf(vg->w2, vg->w1, t); - if (weight > 0) + if (weight > 0) { defvert_add_index_notest(&outdvert[v], vg->def_nr, weight); + } } outedge->v1 = u; @@ -916,8 +945,9 @@ static Mesh *subdivide_base(Mesh *orig) u = v; } - if (vgroups) + if (vgroups) { MEM_freeN(vgroups); + } /* Link up to final vertex */ outedge->v1 = u; @@ -945,8 +975,9 @@ static void add_poly(SkinOutput *so, BMVert *v1, BMVert *v2, BMVert *v3, BMVert f = BM_face_create_verts(so->bm, verts, v4 ? 4 : 3, NULL, BM_CREATE_NO_DOUBLE, true); BM_face_normal_update(f); - if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING) + if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING) { BM_elem_flag_enable(f, BM_ELEM_SMOOTH); + } f->mat_nr = so->mat_nr; } @@ -994,10 +1025,12 @@ static void connect_frames(SkinOutput *so, BMVert *frame1[4], BMVert *frame2[4]) #endif for (i = 0; i < 4; i++) { - if (swap) + if (swap) { add_poly(so, q[i][3], q[i][2], q[i][1], q[i][0]); - else + } + else { add_poly(so, q[i][0], q[i][1], q[i][2], q[i][3]); + } } } @@ -1048,8 +1081,9 @@ static int isect_ray_poly(const float ray_start[3], bool hit = false; BM_ITER_ELEM (v, &iter, f, BM_VERTS_OF_FACE) { - if (!v_first) + if (!v_first) { v_first = v; + } else if (v_prev != v_first) { float dist; bool curhit; @@ -1079,8 +1113,9 @@ static BMFace *collapse_face_corners(BMesh *bm, BMFace *f, int n, BMVert **orig_ BLI_assert(n >= 3); BLI_assert(f->len > n); - if (f->len <= n) + if (f->len <= n) { return f; + } /* Collapse shortest edge for now */ while (f->len > n) { @@ -1176,10 +1211,11 @@ static BMFace *skin_hole_target_face(BMesh *bm, Frame *frame) } f = isect_target_face; - if (!f || best_center_dist < best_isect_dist / 2) + if (!f || best_center_dist < best_isect_dist / 2) { f = center_target_face; + } - /* This case is unlikely now, but could still happen. Should look + /* This case is unlikely now, but could still happen. Should look * into splitting edges to make new faces. */ #if PRINT_HOLE_INFO if (!f) { @@ -1210,8 +1246,9 @@ static void skin_choose_quad_bridge_order(BMVert *a[4], BMVert *b[4], int best_o float len = 0; /* Get total edge length for this configuration */ - for (j = 0; j < 4; j++) + for (j = 0; j < 4; j++) { len += len_squared_v3v3(a[j]->co, b[orders[i][j]]->co); + } if (len < shortest_len) { shortest_len = len; @@ -1288,8 +1325,9 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f /* Done with dynamic array, split_face must now be a quad */ BLI_array_free(vert_buf); BLI_assert(split_face->len == 4); - if (split_face->len != 4) + if (split_face->len != 4) { return; + } /* Get split face's verts */ // BM_iter_as_array(bm, BM_VERTS_OF_FACE, split_face, (void **)verts, 4); @@ -1316,8 +1354,9 @@ static void skin_hole_detach_partially_attached_frame(BMesh *bm, Frame *frame) /* Get/count attached frame corners */ for (i = 0; i < 4; i++) { - if (!frame->inside_hull[i]) + if (!frame->inside_hull[i]) { attached[totattached++] = i; + } } /* Detach everything */ @@ -1409,10 +1448,12 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd) if (quad_crosses_symmetry_plane(quad, smd)) { /* Increase score if the triangles form a * symmetric quad, otherwise don't use it */ - if (is_quad_symmetric(quad, smd)) + if (is_quad_symmetric(quad, smd)) { score *= 10; - else + } + else { continue; + } } /* Don't use the quad if it's concave */ @@ -1506,8 +1547,9 @@ static void skin_fix_hull_topology(BMesh *bm, SkinNode *skin_nodes, int totvert) skin_hole_detach_partially_attached_frame(bm, f); target_face = skin_hole_target_face(bm, f); - if (target_face) + if (target_face) { skin_fix_hole_no_good_verts(bm, f, target_face); + } } } } @@ -1525,8 +1567,9 @@ static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, int totv int i, order[4]; skin_choose_quad_bridge_order(sn->frames[0].verts, sn->frames[1].verts, order); - for (i = 0; i < 4; i++) + for (i = 0; i < 4; i++) { v_order[i] = sn->frames[1].verts[order[i]]; + } connect_frames(so, sn->frames[0].verts, v_order); } else if (sn->totframe == 2) { @@ -1577,14 +1620,17 @@ static void skin_output_connections(SkinOutput *so, BMVert *v_order[4]; int i, order[4]; - if ((a->flag & SEAM_FRAME) && (e != a->seam_edges[0])) + if ((a->flag & SEAM_FRAME) && (e != a->seam_edges[0])) { fr[0]++; - if ((b->flag & SEAM_FRAME) && (e != b->seam_edges[0])) + } + if ((b->flag & SEAM_FRAME) && (e != b->seam_edges[0])) { fr[1]++; + } skin_choose_quad_bridge_order(fr[0]->verts, fr[1]->verts, order); - for (i = 0; i < 4; i++) + for (i = 0; i < 4; i++) { v_order[i] = fr[1]->verts[order[i]]; + } connect_frames(so, fr[0]->verts, v_order); } else { @@ -1603,8 +1649,9 @@ static void skin_smooth_hulls(BMesh *bm, BMVert *v; int i, j, k, skey; - if (smd->branch_smoothing == 0) + if (smd->branch_smoothing == 0) { return; + } /* Mark all frame vertices */ BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false); @@ -1612,8 +1659,9 @@ static void skin_smooth_hulls(BMesh *bm, for (j = 0; j < skin_nodes[i].totframe; j++) { Frame *frame = &skin_nodes[i].frames[j]; - for (k = 0; k < 4; k++) + for (k = 0; k < 4; k++) { BM_elem_flag_enable(frame->verts[k], BM_ELEM_TAG); + } } } @@ -1633,8 +1681,9 @@ static void skin_smooth_hulls(BMesh *bm, float weight = smd->branch_smoothing; int totv = 1; - if (BM_elem_flag_test(v, BM_ELEM_TAG)) + if (BM_elem_flag_test(v, BM_ELEM_TAG)) { weight *= 0.5f; + } copy_v3_v3(avg, v->co); BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { @@ -1670,8 +1719,9 @@ static bool skin_output_branch_hulls( int tothullframe; hull_frames = collect_hull_frames(v, skin_nodes, emap, medge, &tothullframe); - if (!build_hull(so, hull_frames, tothullframe)) + if (!build_hull(so, hull_frames, tothullframe)) { result = false; + } MEM_freeN(hull_frames); } @@ -1703,8 +1753,9 @@ static BMesh *build_skin(SkinNode *skin_nodes, BMO_push(so.bm, NULL); bmesh_edit_begin(so.bm, 0); - if (input_dvert) + if (input_dvert) { BM_data_layer_add(so.bm, &so.bm->vdata, CD_MDEFORMVERT); + } /* Check for mergeable frame corners around hulls before * outputting vertices */ @@ -1712,15 +1763,17 @@ static BMesh *build_skin(SkinNode *skin_nodes, /* Write out all frame vertices to the mesh */ for (v = 0; v < totvert; ++v) { - if (skin_nodes[v].totframe) + 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); - if (!skin_output_branch_hulls(&so, skin_nodes, totvert, emap, medge)) + if (!skin_output_branch_hulls(&so, skin_nodes, totvert, emap, medge)) { modifier_setError(&smd->modifier, "Hull error"); + } /* Merge triangles here in the hope of providing better target * faces for skin_fix_hull_topology() to connect to */ @@ -1807,8 +1860,9 @@ static Mesh *base_skin(Mesh *origmesh, SkinModifierData *smd) "No valid root vertex found (you need one per mesh island you want to skin)"); } - if (!bm) + if (!bm) { return NULL; + } result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL); BM_mesh_free(bm); @@ -1825,8 +1879,9 @@ static Mesh *final_skin(SkinModifierData *smd, Mesh *mesh) Mesh *result; /* Skin node layer is required */ - if (!CustomData_get_layer(&mesh->vdata, CD_MVERT_SKIN)) + if (!CustomData_get_layer(&mesh->vdata, CD_MVERT_SKIN)) { return mesh; + } mesh = subdivide_base(mesh); result = base_skin(mesh, smd); @@ -1853,8 +1908,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *UNUSED(c { Mesh *result; - if (!(result = final_skin((SkinModifierData *)md, mesh))) + if (!(result = final_skin((SkinModifierData *)md, mesh))) { return mesh; + } return result; } diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index 60d4c1a01c3..34275d91ee6 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -83,11 +83,13 @@ static void requiredDataMask(Object *UNUSED(ob), if (smd && (smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) { if (smd->flow->source == MOD_SMOKE_FLOW_SOURCE_MESH) { /* vertex groups */ - if (smd->flow->vgroup_density) + if (smd->flow->vgroup_density) { r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT; + } /* uv layer */ - if (smd->flow->texture_type == MOD_SMOKE_FLOW_TEXTURE_MAP_UV) + if (smd->flow->texture_type == MOD_SMOKE_FLOW_TEXTURE_MAP_UV) { r_cddata_masks->fmask |= CD_MASK_MTFACE; + } } } } diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index 08430d0e8f1..59d5b2ccbd2 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -59,8 +59,9 @@ static bool isDisabled(const struct Scene *UNUSED(scene), flag = smd->flag & (MOD_SMOOTH_X | MOD_SMOOTH_Y | MOD_SMOOTH_Z); /* disable if modifier is off for X, Y and Z or if factor is 0 */ - if ((smd->fac == 0.0f) || flag == 0) + if ((smd->fac == 0.0f) || flag == 0) { return 1; + } return 0; } @@ -88,12 +89,14 @@ static void smoothModifier_do( float *ftmp, fac, facm; ftmp = (float *)MEM_calloc_arrayN(numVerts, 3 * sizeof(float), "smoothmodifier_f"); - if (!ftmp) + if (!ftmp) { return; + } uctmp = (unsigned char *)MEM_calloc_arrayN(numVerts, sizeof(unsigned char), "smoothmodifier_uc"); if (!uctmp) { - if (ftmp) + if (ftmp) { MEM_freeN(ftmp); + } return; } @@ -150,23 +153,28 @@ static void smoothModifier_do( fp = &ftmp[i * 3]; f = defvert_find_weight(dv, defgrp_index); - if (f <= 0.0f) + if (f <= 0.0f) { continue; + } f *= fac; fm = 1.0f - f; /* fp is the sum of uctmp[i] verts, so must be averaged */ facw = 0.0f; - if (uctmp[i]) + if (uctmp[i]) { facw = f / (float)uctmp[i]; + } - if (flag & MOD_SMOOTH_X) + if (flag & MOD_SMOOTH_X) { v[0] = fm * v[0] + facw * fp[0]; - if (flag & MOD_SMOOTH_Y) + } + if (flag & MOD_SMOOTH_Y) { v[1] = fm * v[1] + facw * fp[1]; - if (flag & MOD_SMOOTH_Z) + } + if (flag & MOD_SMOOTH_Z) { v[2] = fm * v[2] + facw * fp[2]; + } } } else { /* no vertex group */ @@ -179,15 +187,19 @@ static void smoothModifier_do( /* fp is the sum of uctmp[i] verts, so must be averaged */ facw = 0.0f; - if (uctmp[i]) + if (uctmp[i]) { facw = fac / (float)uctmp[i]; + } - if (flag & MOD_SMOOTH_X) + if (flag & MOD_SMOOTH_X) { v[0] = facm * v[0] + facw * fp[0]; - if (flag & MOD_SMOOTH_Y) + } + if (flag & MOD_SMOOTH_Y) { v[1] = facm * v[1] + facw * fp[1]; - if (flag & MOD_SMOOTH_Z) + } + if (flag & MOD_SMOOTH_Z) { v[2] = facm * v[2] + facw * fp[2]; + } } } diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 0cf864fbf89..78006147ab5 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -534,10 +534,12 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes const unsigned int i = do_shell_align ? i_orig : new_vert_arr[i_orig]; if (dvert) { MDeformVert *dv = &dvert[i]; - if (defgrp_invert) + if (defgrp_invert) { scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); - else + } + else { scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); + } scalar_short_vgroup = (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; } @@ -568,10 +570,12 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes const unsigned int i = do_shell_align ? i_orig : new_vert_arr[i_orig]; if (dvert) { MDeformVert *dv = &dvert[i]; - if (defgrp_invert) + if (defgrp_invert) { scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); - else + } + else { scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); + } scalar_short_vgroup = (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; } @@ -735,8 +739,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes MEM_freeN(vert_angles); } - if (vert_nors) + if (vert_nors) { MEM_freeN(vert_nors); + } /* must recalculate normals with vgroups since they can displace unevenly [#26888] */ if ((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) || (smd->flag & MOD_SOLIDIFY_RIM) || dvert) { @@ -948,11 +953,13 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes MEM_freeN(edge_order); } - if (old_vert_arr) + if (old_vert_arr) { MEM_freeN(old_vert_arr); + } - if (poly_nors) + if (poly_nors) { MEM_freeN(poly_nors); + } if (numPolys == 0 && numEdges != 0) { modifier_setError(md, "Faces needed for useful output"); diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c index 02678879e89..dcc6371e024 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.c @@ -159,10 +159,12 @@ static void deformVerts(ModifierData *md, vec = surmd->mesh->mvert[i].co; mul_m4_v3(ctx->object->obmat, vec); - if (init) + if (init) { v->co[0] = v->co[1] = v->co[2] = 0.0f; - else + } + else { sub_v3_v3v3(v->co, vec, x->co); + } copy_v3_v3(x->co, vec); } @@ -171,10 +173,12 @@ static void deformVerts(ModifierData *md, surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh"); - if (surmd->mesh->totpoly) + if (surmd->mesh->totpoly) { BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_LOOPTRI, 2); - else + } + else { BKE_bvhtree_from_mesh_get(surmd->bvhtree, surmd->mesh, BVHTREE_FROM_EDGES, 2); + } } } diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index b23dff753f8..69cf8a651eb 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -158,10 +158,12 @@ void MOD_previous_vcos_store(ModifierData *md, float (*vertexCos)[3]) { while ((md = md->next) && md->type == eModifierType_Armature) { ArmatureModifierData *amd = (ArmatureModifierData *)md; - if (amd->multi && amd->prevCos == NULL) + if (amd->multi && amd->prevCos == NULL) { amd->prevCos = MEM_dupallocN(vertexCos); - else + } + else { break; + } } /* lattice/mesh modifier too */ } @@ -235,10 +237,12 @@ void MOD_get_vgroup( *dvert = NULL; if (*defgrp_index != -1) { - if (ob->type == OB_LATTICE) + if (ob->type == OB_LATTICE) { *dvert = BKE_lattice_deform_verts_get(ob); - else if (mesh) + } + else if (mesh) { *dvert = mesh->dvert; + } } } diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 2ee0b36edc9..f9eb92cd132 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -68,8 +68,9 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, UVProjectModifierData *umd = (UVProjectModifierData *)md; int i; - for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) + for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) { walk(userData, ob, &umd->projectors[i], IDWALK_CB_NOP); + } } static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) @@ -129,13 +130,15 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, } } - if (num_projectors == 0) + if (num_projectors == 0) { return mesh; + } /* make sure there are UV Maps available */ - if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) + if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) { return mesh; + } /* make sure we're using an existing layer */ CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, umd->uvlayer_name, uvname); @@ -204,13 +207,16 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, coords = BKE_mesh_vertexCos_get(mesh, &numVerts); /* convert coords to world space */ - for (i = 0, co = coords; i < numVerts; ++i, ++co) + for (i = 0, co = coords; i < numVerts; ++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 (num_projectors == 1 && projectors[0].uci == NULL) { + for (i = 0, co = coords; i < numVerts; ++i, ++co) { mul_project_m4_v3(projectors[0].projmat, *co); + } + } mpoly = mesh->mpoly; mloop = mesh->mloop; diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c index 83b9a8e1804..995f3d06fcb 100644 --- a/source/blender/modifiers/intern/MOD_uvwarp.c +++ b/source/blender/modifiers/intern/MOD_uvwarp.c @@ -226,10 +226,12 @@ static void uv_warp_deps_object_bone_new(struct DepsNodeHandle *node, const char *bonename) { if (object != NULL) { - if (bonename[0]) + if (bonename[0]) { DEG_add_object_relation(node, object, DEG_OB_COMP_EVAL_POSE, "UVWarp Modifier"); - else + } + else { DEG_add_object_relation(node, object, DEG_OB_COMP_TRANSFORM, "UVWarp Modifier"); + } } } diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 67b91cfd963..6441ab69391 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -178,16 +178,18 @@ static void warpModifier_do(WarpModifierData *wmd, float(*tex_co)[3] = NULL; - if (!(wmd->object_from && wmd->object_to)) + if (!(wmd->object_from && wmd->object_to)) { return; + } MOD_get_vgroup(ob, mesh, wmd->defgrp_name, &dvert, &defgrp_index); if (dvert == NULL) { defgrp_index = -1; } - if (wmd->curfalloff == NULL) /* should never happen, but bad lib linking could cause it */ + if (wmd->curfalloff == NULL) { /* should never happen, but bad lib linking could cause it */ wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + } if (wmd->curfalloff) { curvemapping_initialize(wmd->curfalloff); diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index c0b686dd098..d480f3416b1 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -182,10 +182,12 @@ static void waveModifier_do(WaveModifierData *md, if (x > wmd->lifetime) { lifefac = x - wmd->lifetime; - if (lifefac > wmd->damp) + if (lifefac > wmd->damp) { lifefac = 0.0; - else + } + else { lifefac = (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp))); + } } } diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 3e1c2f9bc02..871da8dfba9 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -135,8 +135,9 @@ void weightvg_do_mask(const ModifierEvalContext *ctx, int i; /* If influence factor is null, nothing to do! */ - if (fact == 0.0f) + if (fact == 0.0f) { return; + } /* If we want to mask vgroup weights from a texture. */ if (texture != NULL) { diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 5f4983af6cc..7e49af4f3bf 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -105,8 +105,9 @@ static bool dependsOnTime(ModifierData *md) { WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md; - if (wmd->mask_texture) + if (wmd->mask_texture) { return BKE_texture_dependsOnTime(wmd->mask_texture); + } return false; } diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index f41689b741c..e509d1464f2 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -78,28 +78,37 @@ static float mix_weight(float weight, float weight2, char mix_mode) return weight2; } #endif - if (mix_mode == MOD_WVG_MIX_SET) + if (mix_mode == MOD_WVG_MIX_SET) { return weight2; - else if (mix_mode == MOD_WVG_MIX_ADD) + } + else if (mix_mode == MOD_WVG_MIX_ADD) { return (weight + weight2); - else if (mix_mode == MOD_WVG_MIX_SUB) + } + else if (mix_mode == MOD_WVG_MIX_SUB) { return (weight - weight2); - else if (mix_mode == MOD_WVG_MIX_MUL) + } + else if (mix_mode == MOD_WVG_MIX_MUL) { return (weight * weight2); + } else if (mix_mode == MOD_WVG_MIX_DIV) { /* Avoid dividing by zero (or really small values). */ - if (weight2 < 0.0f && weight2 > -MOD_WVG_ZEROFLOOR) + if (weight2 < 0.0f && weight2 > -MOD_WVG_ZEROFLOOR) { weight2 = -MOD_WVG_ZEROFLOOR; - else if (weight2 >= 0.0f && weight2 < MOD_WVG_ZEROFLOOR) + } + else if (weight2 >= 0.0f && weight2 < MOD_WVG_ZEROFLOOR) { weight2 = MOD_WVG_ZEROFLOOR; + } return (weight / weight2); } - else if (mix_mode == MOD_WVG_MIX_DIF) + else if (mix_mode == MOD_WVG_MIX_DIF) { return (weight < weight2 ? weight2 - weight : weight - weight2); - else if (mix_mode == MOD_WVG_MIX_AVG) + } + else if (mix_mode == MOD_WVG_MIX_AVG) { return (weight + weight2) * 0.5f; - else + } + else { return weight2; + } } /************************************** @@ -140,8 +149,9 @@ static bool dependsOnTime(ModifierData *md) { WeightVGMixModifierData *wmd = (WeightVGMixModifierData *)md; - if (wmd->mask_texture) + if (wmd->mask_texture) { return BKE_texture_dependsOnTime(wmd->mask_texture); + } return false; } diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 66b7ddb54d6..9699b5f15dd 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -194,12 +194,15 @@ static void get_vert2geom_distance(int numVerts, settings.userdata_chunk_size = sizeof(data_chunk); BLI_task_parallel_range(0, numVerts, &data, vert2geom_task_cb_ex, &settings); - if (dist_v) + if (dist_v) { free_bvhtree_from_mesh(&treeData_v); - if (dist_e) + } + if (dist_e) { free_bvhtree_from_mesh(&treeData_e); - if (dist_f) + } + if (dist_f) { free_bvhtree_from_mesh(&treeData_f); + } } /** @@ -245,22 +248,28 @@ static void do_map( } else if (max_d > min_d) { while (i-- > 0) { - if (weights[i] >= max_d) + if (weights[i] >= max_d) { weights[i] = 1.0f; /* most likely case first */ - else if (weights[i] <= min_d) + } + else if (weights[i] <= min_d) { weights[i] = 0.0f; - else + } + else { weights[i] = (weights[i] - min_d) * range_inv; + } } } else { while (i-- > 0) { - if (weights[i] <= max_d) + if (weights[i] <= max_d) { weights[i] = 1.0f; /* most likely case first */ - else if (weights[i] >= min_d) + } + else if (weights[i] >= min_d) { weights[i] = 0.0f; - else + } + else { weights[i] = (weights[i] - min_d) * range_inv; + } } } @@ -318,8 +327,9 @@ static bool dependsOnTime(ModifierData *md) { WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md; - if (wmd->mask_texture) + if (wmd->mask_texture) { return BKE_texture_dependsOnTime(wmd->mask_texture); + } return 0; } @@ -374,8 +384,9 @@ static bool isDisabled(const struct Scene *UNUSED(scene), { WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md; /* If no vertex group, bypass. */ - if (wmd->defgrp_name[0] == '\0') + if (wmd->defgrp_name[0] == '\0') { return 1; + } /* If no target object, bypass. */ return (wmd->proximity_ob_target == NULL); } @@ -520,10 +531,12 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes get_vert2geom_distance(numIdx, v_cos, dists_v, dists_e, dists_f, target_mesh, &loc2trgt); for (i = 0; i < numIdx; i++) { new_w[i] = dists_v ? dists_v[i] : FLT_MAX; - if (dists_e) + if (dists_e) { new_w[i] = min_ff(dists_e[i], new_w[i]); - if (dists_f) + } + if (dists_f) { new_w[i] = min_ff(dists_f[i], new_w[i]); + } } MEM_SAFE_FREE(dists_v); -- cgit v1.2.3