diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-22 02:19:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-22 12:48:16 +0300 |
commit | 620b960d3d8cfd90b9f0df6ba3671c33eccb8309 (patch) | |
tree | 64f69db4bf9d44f0a32d1c92b0714bf2dc98ff2d /source/blender/editors/mesh | |
parent | bba60bb564cf5a16cfcac744d4ba82cf8eba3da9 (diff) |
Cleanup: style, use braces for editors
Diffstat (limited to 'source/blender/editors/mesh')
19 files changed, 533 insertions, 266 deletions
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index f342cc3a809..28b697531ab 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -65,8 +65,9 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag) BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0); - if (me == NULL) + if (me == NULL) { return; + } /* note, call #BKE_mesh_flush_hidden_from_verts_ex first when changing hidden flags */ @@ -139,8 +140,9 @@ void paintface_hide(bContext *C, Object *ob, const bool unselected) int a; me = BKE_mesh_from_object(ob); - if (me == NULL || me->totpoly == 0) + if (me == NULL || me->totpoly == 0) { return; + } mpoly = me->mpoly; a = me->totpoly; @@ -170,8 +172,9 @@ void paintface_reveal(bContext *C, Object *ob, const bool select) int a; me = BKE_mesh_from_object(ob); - if (me == NULL || me->totpoly == 0) + if (me == NULL || me->totpoly == 0) { return; + } mpoly = me->mpoly; a = me->totpoly; @@ -227,8 +230,9 @@ static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index, /* expand selection */ mp = me->mpoly; for (a = 0; a < me->totpoly; a++, mp++) { - if (mp->flag & ME_HIDE) + if (mp->flag & ME_HIDE) { continue; + } if (!BLI_BITMAP_TEST(poly_tag, a)) { mark = false; @@ -269,8 +273,9 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b unsigned int index = (unsigned int)-1; me = BKE_mesh_from_object(ob); - if (me == NULL || me->totpoly == 0) + if (me == NULL || me->totpoly == 0) { return; + } if (mval) { if (!ED_mesh_pick_face(C, ob, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) { @@ -364,8 +369,9 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3]) mvert = me->mvert; mp = me->mpoly; for (a = me->totpoly; a > 0; a--, mp++) { - if (mp->flag & ME_HIDE || !(mp->flag & ME_FACE_SEL)) + if (mp->flag & ME_HIDE || !(mp->flag & ME_FACE_SEL)) { continue; + } ml = me->mloop + mp->totloop; for (b = 0; b < mp->totloop; b++, ml++) { @@ -399,8 +405,9 @@ bool paintface_mouse_select( } mpoly_sel = me->mpoly + index; - if (mpoly_sel->flag & ME_HIDE) + if (mpoly_sel->flag & ME_HIDE) { return false; + } /* clear flags */ if (!extend && !deselect && !toggle) { @@ -416,10 +423,12 @@ bool paintface_mouse_select( mpoly_sel->flag &= ~ME_FACE_SEL; } else if (toggle) { - if (mpoly_sel->flag & ME_FACE_SEL) + if (mpoly_sel->flag & ME_FACE_SEL) { mpoly_sel->flag &= ~ME_FACE_SEL; - else + } + else { mpoly_sel->flag |= ME_FACE_SEL; + } } else { mpoly_sel->flag |= ME_FACE_SEL; @@ -512,15 +521,17 @@ void paintvert_flush_flags(Object *ob) int totvert; int i; - if (me == NULL) + if (me == NULL) { return; + } /* we could call this directly in all areas that change selection, * since this could become slow for realtime updates (circle-select for eg) */ BKE_mesh_flush_select_from_verts(me); - if (me_eval == NULL) + if (me_eval == NULL) { return; + } index_array = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX); diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 1a05e182c3a..f6940cae953 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -120,10 +120,12 @@ static float get_bevel_offset(wmOperator *op) { float val; - if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) + if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) { val = RNA_float_get(op->ptr, "offset_pct"); - else + } + else { val = RNA_float_get(op->ptr, "offset"); + } return val; } @@ -579,10 +581,12 @@ static bool edbm_bevel_poll_property(const bContext *UNUSED(C), if (STRPREFIX(prop_id, "offset")) { int offset_type = RNA_enum_get(op->ptr, "offset_type"); - if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT) + if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT) { return false; - else if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT) + } + else if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT) { return false; + } } return true; @@ -648,8 +652,9 @@ wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Bevel Modal Map"); /* this function is called for each spacetype, only needs to add map once */ - if (keymap && keymap->modal_items) + if (keymap && keymap->modal_items) { return NULL; + } keymap = WM_modalkeymap_add(keyconf, "Bevel Modal Map", modal_items); @@ -689,10 +694,12 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) } else if (etype == MOUSEPAN) { float delta = 0.02f * (event->y - event->prevy); - if (opdata->segments >= 1 && opdata->segments + delta < 1) + if (opdata->segments >= 1 && opdata->segments + delta < 1) { opdata->segments = 1; - else + } + else { opdata->segments += delta; + } RNA_int_set(op->ptr, "segments", (int)opdata->segments); edbm_bevel_calc(op); edbm_bevel_update_header(C, op); @@ -733,13 +740,16 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) if (type > BEVEL_AMT_PERCENT) { type = BEVEL_AMT_OFFSET; } - if (opdata->value_mode == OFFSET_VALUE && type == BEVEL_AMT_PERCENT) + if (opdata->value_mode == OFFSET_VALUE && type == BEVEL_AMT_PERCENT) { opdata->value_mode = OFFSET_VALUE_PERCENT; - else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT) + } + else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT) { opdata->value_mode = OFFSET_VALUE; + } RNA_enum_set(op->ptr, "offset_type", type); - if (opdata->initial_length[opdata->value_mode] == -1.0f) + if (opdata->initial_length[opdata->value_mode] == -1.0f) { edbm_bevel_calc_initial_length(op, event, true); + } } /* Update offset accordingly to new offset_type. */ if (!has_numinput && @@ -805,10 +815,12 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) case BEV_MODAL_INNER_MITER_CHANGE: { int miter_inner = RNA_enum_get(op->ptr, "miter_inner"); miter_inner++; - if (miter_inner == BEVEL_MITER_PATCH) + if (miter_inner == BEVEL_MITER_PATCH) { miter_inner++; /* no patch option for inner miter */ - if (miter_inner > BEVEL_MITER_ARC) + } + if (miter_inner > BEVEL_MITER_ARC) { miter_inner = BEVEL_MITER_SHARP; + } RNA_enum_set(op->ptr, "miter_inner", miter_inner); edbm_bevel_calc(op); edbm_bevel_update_header(C, op); @@ -819,8 +831,9 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) case BEV_MODAL_OUTER_MITER_CHANGE: { int miter_outer = RNA_enum_get(op->ptr, "miter_outer"); miter_outer++; - if (miter_outer > BEVEL_MITER_ARC) + if (miter_outer > BEVEL_MITER_ARC) { miter_outer = BEVEL_MITER_SHARP; + } RNA_enum_set(op->ptr, "miter_outer", miter_outer); edbm_bevel_calc(op); edbm_bevel_update_header(C, op); diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index eeda7ec5f2d..9314b96afee 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -347,28 +347,37 @@ static bool edbm_extrude_mesh(Object *obedit, BMEditMesh *em, wmOperator *op) bool changed = false; if (em->selectmode & SCE_SELECT_VERTEX) { - if (em->bm->totvertsel == 0) + if (em->bm->totvertsel == 0) { nr = NONE; - else if (em->bm->totvertsel == 1) + } + else if (em->bm->totvertsel == 1) { nr = VERT_ONLY; - else if (em->bm->totedgesel == 0) + } + else if (em->bm->totedgesel == 0) { nr = VERT_ONLY; - else + } + else { nr = ELEM_FLAG; + } } else if (em->selectmode & SCE_SELECT_EDGE) { - if (em->bm->totedgesel == 0) + if (em->bm->totedgesel == 0) { nr = NONE; - else if (em->bm->totfacesel == 0) + } + else if (em->bm->totfacesel == 0) { nr = EDGE_ONLY; - else + } + else { nr = ELEM_FLAG; + } } else { - if (em->bm->totfacesel == 0) + if (em->bm->totfacesel == 0) { nr = NONE; - else + } + else { nr = ELEM_FLAG; + } } switch (nr) { diff --git a/source/blender/editors/mesh/editmesh_extrude_screw.c b/source/blender/editors/mesh/editmesh_extrude_screw.c index c9422545c7b..252f95a10ac 100644 --- a/source/blender/editors/mesh/editmesh_extrude_screw.c +++ b/source/blender/editors/mesh/editmesh_extrude_screw.c @@ -125,8 +125,9 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) sub_v3_v3v3(dvec, v1_co_global, v2_co_global); mul_v3_fl(dvec, 1.0f / steps); - if (dot_v3v3(nor, dvec) > 0.0f) + if (dot_v3v3(nor, dvec) > 0.0f) { negate_v3(dvec); + } BMOperator spinop; if (!EDBM_op_init( diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index 7bee030bb46..2955488a597 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -91,8 +91,9 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C) if (sa) { char flts_str[NUM_STR_REP_LEN * 2]; - if (hasNumInput(&opdata->num_input)) + if (hasNumInput(&opdata->num_input)) { outputNumInput(&opdata->num_input, flts_str, &sce->unit); + } else { BLI_snprintf(flts_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "thickness")); BLI_snprintf( @@ -413,18 +414,21 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) } /* Fake shift-transform... */ - if (opdata->shift) + if (opdata->shift) { amount = (amount - opdata->shift_amount) * 0.1f + opdata->shift_amount; + } - if (opdata->modify_depth) + if (opdata->modify_depth) { RNA_float_set(op->ptr, "depth", amount); + } else { amount = max_ff(amount, 0.0f); RNA_float_set(op->ptr, "thickness", amount); } - if (edbm_inset_calc(op)) + if (edbm_inset_calc(op)) { edbm_inset_update_header(op, C); + } else { edbm_inset_cancel(C, op); return OPERATOR_CANCELLED; @@ -446,10 +450,12 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) case LEFTSHIFTKEY: case RIGHTSHIFTKEY: if (event->val == KM_PRESS) { - if (opdata->modify_depth) + if (opdata->modify_depth) { opdata->shift_amount = RNA_float_get(op->ptr, "depth"); - else + } + else { opdata->shift_amount = RNA_float_get(op->ptr, "thickness"); + } opdata->shift = true; handled = true; } @@ -469,14 +475,16 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_PRESS) { opdata->old_thickness = RNA_float_get(op->ptr, "thickness"); - if (opdata->shift) + if (opdata->shift) { opdata->shift_amount = opdata->old_thickness; + } opdata->modify_depth = true; } else { opdata->old_depth = RNA_float_get(op->ptr, "depth"); - if (opdata->shift) + if (opdata->shift) { opdata->shift_amount = opdata->old_depth; + } opdata->modify_depth = false; } opdata->initial_length = len_v2(mlen); diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c index 06e2ef6e304..370cc6a2a6d 100644 --- a/source/blender/editors/mesh/editmesh_intersect.c +++ b/source/blender/editors/mesh/editmesh_intersect.c @@ -512,12 +512,15 @@ static int bm_edge_sort_length_cb(const void *e_a_v, const void *e_b_v) const float val_a = -BM_edge_calc_length_squared(*((BMEdge **)e_a_v)); const float val_b = -BM_edge_calc_length_squared(*((BMEdge **)e_b_v)); - if (val_a > val_b) + if (val_a > val_b) { return 1; - else if (val_a < val_b) + } + else if (val_a < val_b) { return -1; - else + } + else { return 0; + } } static void bm_face_split_by_edges_island_connect( diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 10a767c2b86..cd5281e1273 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -366,8 +366,9 @@ static Ref *find_ref(ListBase *lb, void *ref) Ref *ref1; for (ref1 = lb->first; ref1; ref1 = ref1->next) { - if (ref1->ref == ref) + if (ref1->ref == ref) { return ref1; + } } return NULL; @@ -375,8 +376,9 @@ static Ref *find_ref(ListBase *lb, void *ref) static void knife_append_list_no_dup(KnifeTool_OpData *kcd, ListBase *lst, void *elem) { - if (!find_ref(lst, elem)) + if (!find_ref(lst, elem)) { knife_append_list(kcd, lst, elem); + } } static KnifeEdge *new_knife_edge(KnifeTool_OpData *kcd) @@ -410,8 +412,9 @@ static BMFace *knife_find_common_face(ListBase *faces1, ListBase *faces2) for (ref1 = faces1->first; ref1; ref1 = ref1->next) { for (ref2 = faces2->first; ref2; ref2 = ref2->next) { - if (ref1->ref == ref2->ref) + if (ref1->ref == ref2->ref) { return (BMFace *)(ref1->ref); + } } } return NULL; @@ -441,10 +444,12 @@ static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v) BMIter bmiter; BMFace *f; - if (BM_elem_index_get(v) >= 0) + if (BM_elem_index_get(v) >= 0) { cageco = kcd->cagecos[BM_elem_index_get(v)]; - else + } + else { cageco = v->co; + } kfv = new_knife_vert(kcd, v->co, cageco); kfv->v = v; BLI_ghash_insert(kcd->origvertmap, v, kfv); @@ -493,8 +498,9 @@ static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index) { int i; - if (BLI_ghash_lookup(kcd->facetrimap, f)) + if (BLI_ghash_lookup(kcd->facetrimap, f)) { return; + } BLI_assert(index >= 0 && index < kcd->em->tottri); BLI_assert(kcd->em->looptris[index][0]->f == f); @@ -504,8 +510,9 @@ static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index) break; } } - if (i == -1) + if (i == -1) { i++; + } BLI_ghash_insert(kcd->facetrimap, f, POINTER_FROM_INT(i + 1)); } @@ -594,8 +601,9 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd, * If v1 and v2 are in multiple faces together (e.g., if they * are in doubled polys) then this arbitrarily chooses one of them */ f = knife_find_common_face(&kfe->v1->faces, &kfe->v2->faces); - if (f) + if (f) { knife_append_list(kcd, &newkfe->v2->faces, f); + } } newkfe->basef = kfe->basef; @@ -605,8 +613,9 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd, kfe->v1 = newkfe->v2; BLI_addtail(&kfe->v1->edges, ref); - for (ref = kfe->faces.first; ref; ref = ref->next) + for (ref = kfe->faces.first; ref; ref = ref->next) { knife_edge_append_face(kcd, newkfe, ref->ref); + } knife_add_to_vert_edges(kcd, newkfe); @@ -637,22 +646,29 @@ static int linehit_compare(const void *vlh1, const void *vlh2) const KnifeLineHit *lh1 = vlh1; const KnifeLineHit *lh2 = vlh2; - if (lh1->l < lh2->l) + if (lh1->l < lh2->l) { return -1; - else if (lh1->l > lh2->l) + } + else if (lh1->l > lh2->l) { return 1; + } else { - if (lh1->m < lh2->m) + if (lh1->m < lh2->m) { return -1; - else if (lh1->m > lh2->m) + } + else if (lh1->m > lh2->m) { return 1; + } else { - if (lh1->v < lh2->v) + if (lh1->v < lh2->v) { return -1; - else if (lh1->v > lh2->v) + } + else if (lh1->v > lh2->v) { return 1; - else + } + else { return 0; + } } } } @@ -670,8 +686,9 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) n = kcd->totlinehit; linehits = kcd->linehits; - if (n == 0) + if (n == 0) { return; + } qsort(linehits, n, sizeof(KnifeLineHit), linehit_compare); @@ -725,8 +742,9 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) memcpy(&linehits[i], &linehits[j], sizeof(KnifeLineHit)); } else { - if (i + 1 != j) + if (i + 1 != j) { memcpy(&linehits[i + 1], &linehits[j], sizeof(KnifeLineHit)); + } i++; } j++; @@ -851,8 +869,9 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd, knife_add_to_vert_edges(kcd, kfe); /* TODO: check if this is ever needed */ - if (kfe->basef && !find_ref(&kfe->faces, kfe->basef)) + if (kfe->basef && !find_ref(&kfe->faces, kfe->basef)) { knife_edge_append_face(kcd, kfe, kfe->basef); + } } /* Given a list of KnifeLineHits for one face, sorted by l @@ -863,8 +882,9 @@ static void knife_cut_face(KnifeTool_OpData *kcd, BMFace *f, ListBase *hits) { Ref *r; - if (BLI_listbase_count_at_most(hits, 2) != 2) + if (BLI_listbase_count_at_most(hits, 2) != 2) { return; + } for (r = hits->first; r->next; r = r->next) { knife_add_single_cut(kcd, r->ref, r->next->ref, f); @@ -1167,8 +1187,9 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void BLI_mempool_iternew(kcd->kedges, &iter); for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) { - if (!kfe->is_cut) + if (!kfe->is_cut) { continue; + } immVertex3fv(pos, kfe->v1->cageco); immVertex3fv(pos, kfe->v2->cageco); @@ -1191,8 +1212,9 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void BLI_mempool_iternew(kcd->kverts, &iter); for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) { - if (!kfv->is_cut) + if (!kfv->is_cut) { continue; + } immVertex3fv(pos, kfv->cageco); } @@ -1249,8 +1271,9 @@ static bool knife_ray_intersect_face(KnifeTool_OpData *kcd, float ray_tri_uv[2]; tri = kcd->em->looptris[tri_i]; - if (tri[0]->f != f) + if (tri[0]->f != f) { break; + } lv1 = kcd->cagecos[BM_elem_index_get(tri[0]->v)]; lv2 = kcd->cagecos[BM_elem_index_get(tri[1]->v)]; lv3 = kcd->cagecos[BM_elem_index_get(tri[2]->v)]; @@ -1594,8 +1617,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) * (which may involve using doubles everywhere!), * limit the distance between these points */ if (kcd->is_ortho && (kcd->vc.rv3d->persp != RV3D_CAMOB)) { - if (kcd->ortho_extent == 0.0f) + if (kcd->ortho_extent == 0.0f) { calc_ortho_extent(kcd); + } clip_to_ortho_planes(v1, v3, kcd->ortho_extent_center, kcd->ortho_extent + 10.0f); clip_to_ortho_planes(v2, v4, kcd->ortho_extent_center, kcd->ortho_extent + 10.0f); } @@ -1642,8 +1666,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) lst = knife_get_face_kedges(kcd, f); for (ref = lst->first; ref; ref = ref->next) { kfe = ref->ref; - if (BLI_smallhash_haskey(&kfes, (uintptr_t)kfe)) + if (BLI_smallhash_haskey(&kfes, (uintptr_t)kfe)) { continue; + } BLI_smallhash_insert(&kfes, (uintptr_t)kfe, kfe); v = kfe->v1; BLI_smallhash_reinsert(&kfvs, (uintptr_t)v, v); @@ -1725,12 +1750,14 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) if (isect_kind == -1) { /* isect_seg_seg_v2_simple doesn't do tolerance test around ends of s1-s2 */ closest_to_line_segment_v2(sint, s1, se1, se2); - if (len_squared_v2v2(sint, s1) <= line_tol_sq) + if (len_squared_v2v2(sint, s1) <= line_tol_sq) { isect_kind = 1; + } else { closest_to_line_segment_v2(sint, s2, se1, se2); - if (len_squared_v2v2(sint, s2) <= line_tol_sq) + if (len_squared_v2v2(sint, s2) <= line_tol_sq) { isect_kind = 1; + } } } if (isect_kind == 1) { @@ -1809,8 +1836,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) BLI_smallhash_release(&kfes); BLI_smallhash_release(&kfvs); BLI_bvhtree_free(planetree); - if (results) + if (results) { MEM_freeN(results); + } } static void knife_input_ray_segment(KnifeTool_OpData *kcd, @@ -1852,8 +1880,9 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd, f = NULL; } - if (is_space) + if (is_space) { *is_space = !f; + } if (!f) { if (kcd->is_interactive) { @@ -2025,8 +2054,9 @@ static KnifeEdge *knife_find_closest_edge( copy_v3_v3(cur_cagep, test_cagep); } - if (fptr) + if (fptr) { *fptr = f; + } if (cure) { if (!kcd->ignore_edge_snapping || !(cure->e)) { @@ -2056,8 +2086,9 @@ static KnifeEdge *knife_find_closest_edge( return cure; } - if (fptr) + if (fptr) { *fptr = NULL; + } return NULL; } @@ -2133,8 +2164,9 @@ static KnifeVert *knife_find_closest_vert( } if (!kcd->ignore_vert_snapping || !(curv && curv->v)) { - if (fptr) + if (fptr) { *fptr = f; + } if (curv) { copy_v3_v3(p, curv->co); @@ -2149,15 +2181,17 @@ static KnifeVert *knife_find_closest_vert( return curv; } else { - if (fptr) + if (fptr) { *fptr = f; + } return NULL; } } - if (fptr) + if (fptr) { *fptr = NULL; + } return NULL; } @@ -2262,12 +2296,15 @@ static int sort_verts_by_dist_cb(void *co_p, const void *cur_a_p, const void *cu const float a_sq = len_squared_v3v3(co, cur_a->co); const float b_sq = len_squared_v3v3(co, cur_b->co); - if (a_sq < b_sq) + if (a_sq < b_sq) { return -1; - else if (a_sq > b_sq) + } + else if (a_sq > b_sq) { return 1; - else + } + else { return 0; + } } static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f) @@ -2276,8 +2313,9 @@ static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f) bool v1_inface, v2_inface; BMLoop *l1, *l2; - if (!f || !v1 || !v2) + if (!f || !v1 || !v2) { return false; + } l1 = v1->v ? BM_face_vert_share_loop(f, v1->v) : NULL; l2 = v2->v ? BM_face_vert_share_loop(f, v2->v) : NULL; @@ -2454,8 +2492,9 @@ static void knife_make_cuts(KnifeTool_OpData *kcd) } f = kfe->basef; - if (!f || kfe->e) + if (!f || kfe->e) { continue; + } lst = BLI_smallhash_lookup(fhash, (uintptr_t)f); if (!lst) { lst = knife_empty_list(kcd); @@ -2467,21 +2506,24 @@ static void knife_make_cuts(KnifeTool_OpData *kcd) /* put list of splitting vertices for an edge into ehash, keyed by edge */ BLI_mempool_iternew(kcd->kverts, &iter); for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) { - if (kfv->v) + if (kfv->v) { continue; /* already have a BMVert */ + } for (ref = kfv->edges.first; ref; ref = ref->next) { kfe = ref->ref; e = kfe->e; - if (!e) + if (!e) { continue; + } lst = BLI_smallhash_lookup(ehash, (uintptr_t)e); if (!lst) { lst = knife_empty_list(kcd); BLI_smallhash_insert(ehash, (uintptr_t)e, lst); } /* there can be more than one kfe in kfv's list with same e */ - if (!find_ref(lst, kfv)) + if (!find_ref(lst, kfv)) { knife_append_list(kcd, lst, kfv); + } } } @@ -2545,8 +2587,9 @@ static void knife_recalc_projmat(KnifeTool_OpData *kcd) /* called when modal loop selection is done... */ static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd) { - if (!kcd) + if (!kcd) { return; + } if (kcd->is_interactive) { WM_cursor_modal_restore(CTX_wm_window(C)); @@ -2576,8 +2619,9 @@ static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd) knifetool_free_bmbvh(kcd); - if (kcd->linehits) + if (kcd->linehits) { MEM_freeN(kcd->linehits); + } /* destroy kcd itself */ MEM_freeN(kcd); @@ -2774,8 +2818,9 @@ wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Knife Tool Modal Map"); /* this function is called for each spacetype, only needs to add map once */ - if (keymap && keymap->modal_items) + if (keymap && keymap->modal_items) { return NULL; + } keymap = WM_modalkeymap_add(keyconf, "Knife Tool Modal Map", modal_items); @@ -2802,8 +2847,9 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) view3d_operator_needs_opengl(C); ED_view3d_init_mats_rv3d(obedit, kcd->vc.rv3d); /* needed to initialize clipping */ - if (kcd->mode == MODE_PANNING) + if (kcd->mode == MODE_PANNING) { kcd->mode = kcd->prevmode; + } /* handle modal keymap */ if (event->type == EVT_MODAL_MAP) { diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index d0988811d15..528235e693a 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -545,8 +545,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) case RETKEY: case PADENTER: case LEFTMOUSE: /* confirm */ // XXX hardcoded - if (event->val == KM_PRESS) + if (event->val == KM_PRESS) { return loopcut_finish(lcd, C, op); + } ED_region_tag_redraw(lcd->ar); handled = true; @@ -573,8 +574,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) case MOUSEPAN: if (event->alt == 0) { cuts += 0.02f * (event->y - event->prevy); - if (cuts < 1 && lcd->cuts >= 1) + if (cuts < 1 && lcd->cuts >= 1) { cuts = 1; + } } else { smoothness += 0.002f * (event->y - event->prevy); @@ -584,8 +586,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) case PADPLUSKEY: case PAGEUPKEY: case WHEELUPMOUSE: /* change number of cuts */ - if (event->val == KM_RELEASE) + if (event->val == KM_RELEASE) { break; + } if (event->alt == 0) { cuts += 1; } @@ -597,8 +600,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) case PADMINUS: case PAGEDOWNKEY: case WHEELDOWNMOUSE: /* change number of cuts */ - if (event->val == KM_RELEASE) + if (event->val == KM_RELEASE) { break; + } if (event->alt == 0) { cuts = max_ff(cuts - 1, 1); } diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c index c6b1ab9f1f2..062008cd656 100644 --- a/source/blender/editors/mesh/editmesh_path.c +++ b/source/blender/editors/mesh/editmesh_path.c @@ -281,10 +281,12 @@ static void edgetag_set_cb(BMEdge *e, bool val, void *user_data_v) case EDGE_MODE_TAG_FREESTYLE: { FreestyleEdge *fed; fed = CustomData_bmesh_get(&bm->edata, e->head.data, CD_FREESTYLE_EDGE); - if (!val) + if (!val) { fed->flag &= ~FREESTYLE_EDGE_MARK; - else + } + else { fed->flag |= FREESTYLE_EDGE_MARK; + } break; } #endif @@ -396,8 +398,9 @@ static void mouse_mesh_shortest_path_edge(Scene *UNUSED(scene), if (op_params->edge_mode != EDGE_MODE_SELECT) { if (op_params->track_active) { /* simple rules - last edge is _always_ active and selected */ - if (e_act) + if (e_act) { BM_edge_select_set(bm, e_act, false); + } BM_edge_select_set(bm, e_dst_last, true); BM_select_history_store(bm, e_dst_last); } @@ -408,10 +411,12 @@ static void mouse_mesh_shortest_path_edge(Scene *UNUSED(scene), if (op_params->track_active) { /* even if this is selected it may not be in the selection list */ if (op_params->edge_mode == EDGE_MODE_SELECT) { - if (edgetag_test_cb(e_dst_last, &user_data) == 0) + if (edgetag_test_cb(e_dst_last, &user_data) == 0) { BM_select_history_remove(bm, e_dst_last); - else + } + else { BM_select_history_store(bm, e_dst_last); + } } } @@ -777,12 +782,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op) if ((em->selectmode & SCE_SELECT_VERTEX) && (bm->totvertsel >= 2)) { BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) { - if (ele_src == NULL) + if (ele_src == NULL) { ele_src = ele; - else if (ele_dst == NULL) + } + else if (ele_dst == NULL) { ele_dst = ele; - else + } + else { break; + } } } } @@ -791,12 +799,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op) ele_src = NULL; BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) { - if (ele_src == NULL) + if (ele_src == NULL) { ele_src = ele; - else if (ele_dst == NULL) + } + else if (ele_dst == NULL) { ele_dst = ele; - else + } + else { break; + } } } } @@ -805,12 +816,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op) ele_src = NULL; BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) { - if (ele_src == NULL) + if (ele_src == NULL) { ele_src = ele; - else if (ele_dst == NULL) + } + else if (ele_dst == NULL) { ele_dst = ele; - else + } + else { break; + } } } } diff --git a/source/blender/editors/mesh/editmesh_preselect_edgering.c b/source/blender/editors/mesh/editmesh_preselect_edgering.c index b007343e14e..92a8c7da71d 100644 --- a/source/blender/editors/mesh/editmesh_preselect_edgering.c +++ b/source/blender/editors/mesh/editmesh_preselect_edgering.c @@ -93,8 +93,9 @@ static void edgering_find_order(BMEdge *eed_last, BMEdge *eed, BMVert *eve_last, if (!(BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f))) { BMIter liter; BM_ITER_ELEM (l, &liter, l, BM_LOOPS_OF_LOOP) { - if (BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f)) + if (BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f)) { break; + } } } diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 8d995d542dc..a39944fc145 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -542,8 +542,9 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed ese.ele = NULL; BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(v, BM_ELEM_SELECT)) + if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { break; + } } } @@ -812,8 +813,9 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed BM_vert_select_set(bm, v_rip, true); } else { - if (fill_uloop_pairs) + if (fill_uloop_pairs) { MEM_freeN(fill_uloop_pairs); + } return OPERATOR_CANCELLED; } } @@ -942,8 +944,9 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed if (BM_edge_is_manifold(l->e)) { l = l->radial_next; - if (totedge_manifold != 3) + if (totedge_manifold != 3) { l = BM_loop_other_edge_loop(l, v); + } if (l) { BLI_assert(!BM_elem_flag_test(l->e, BM_ELEM_TAG)); diff --git a/source/blender/editors/mesh/editmesh_rip_edge.c b/source/blender/editors/mesh/editmesh_rip_edge.c index e2b77d8c83b..61253f06f9f 100644 --- a/source/blender/editors/mesh/editmesh_rip_edge.c +++ b/source/blender/editors/mesh/editmesh_rip_edge.c @@ -71,8 +71,9 @@ static int edbm_rip_edge_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve float projectMat[4][4]; - if (bm->totvertsel == 0) + if (bm->totvertsel == 0) { continue; + } ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 69066adba41..d81de37add3 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -110,8 +110,9 @@ void EDBM_select_mirrored( EDBM_verts_mirror_cache_begin(em, axis, true, true, use_topology); - if (!extend) + if (!extend) { EDBM_flag_disable_all(em, BM_ELEM_SELECT); + } if (bm->selectmode & SCE_SELECT_VERTEX) { BMVert *v; @@ -241,19 +242,22 @@ bool EDBM_backbuf_check(unsigned int index) /* odd logic, if selbuf is NULL we assume no zbuf-selection is enabled * and just ignore the depth buffer, this is error prone since its possible * code doesn't set the depth buffer by accident, but leave for now. - Campbell */ - if (selbuf == NULL) + if (selbuf == NULL) { return true; + } - if (index > 0 && index <= bm_vertoffs) + if (index > 0 && index <= bm_vertoffs) { return BLI_BITMAP_TEST_BOOL(selbuf, index); + } return false; } void EDBM_backbuf_free(void) { - if (selbuf) + if (selbuf) { MEM_freeN(selbuf); + } selbuf = NULL; } @@ -1423,10 +1427,12 @@ static int edbm_select_mode_invoke(bContext *C, wmOperator *op, const wmEvent *e /* detecting these options based on shift/ctrl here is weak, but it's done * to make this work when clicking buttons or menus */ - if (!RNA_struct_property_is_set(op->ptr, "use_extend")) + if (!RNA_struct_property_is_set(op->ptr, "use_extend")) { RNA_boolean_set(op->ptr, "use_extend", event->shift); - if (!RNA_struct_property_is_set(op->ptr, "use_expand")) + } + if (!RNA_struct_property_is_set(op->ptr, "use_expand")) { RNA_boolean_set(op->ptr, "use_expand", event->ctrl); + } return edbm_select_mode_exec(C, op); } @@ -2204,8 +2210,9 @@ static void edbm_strip_selections(BMEditMesh *em) ese = em->bm->selected.first; while (ese) { nextese = ese->next; - if (ese->htype == BM_VERT) + if (ese->htype == BM_VERT) { BLI_freelinkN(&(em->bm->selected), ese); + } ese = nextese; } } @@ -2213,8 +2220,9 @@ static void edbm_strip_selections(BMEditMesh *em) ese = em->bm->selected.first; while (ese) { nextese = ese->next; - if (ese->htype == BM_EDGE) + if (ese->htype == BM_EDGE) { BLI_freelinkN(&(em->bm->selected), ese); + } ese = nextese; } } @@ -2222,8 +2230,9 @@ static void edbm_strip_selections(BMEditMesh *em) ese = em->bm->selected.first; while (ese) { nextese = ese->next; - if (ese->htype == BM_FACE) + if (ese->htype == BM_FACE) { BLI_freelinkN(&(em->bm->selected), ese); + } ese = nextese; } } @@ -2575,8 +2584,9 @@ bool EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool sel bool changed = false; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) + if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { continue; + } if (efa->mat_nr == index) { changed = true; BM_face_select_set(em->bm, efa, select); @@ -2587,10 +2597,12 @@ bool EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool sel void EDBM_select_toggle_all(BMEditMesh *em) /* exported for UV */ { - if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel) + if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel) { EDBM_flag_disable_all(em, BM_ELEM_SELECT); - else + } + else { EDBM_flag_enable_all(em, BM_ELEM_SELECT); + } } void EDBM_select_swap(BMEditMesh *em) /* exported for UV */ @@ -2602,22 +2614,25 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */ if (em->bm->selectmode & SCE_SELECT_VERTEX) { BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) + if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { continue; + } BM_vert_select_set(em->bm, eve, !BM_elem_flag_test(eve, BM_ELEM_SELECT)); } } else if (em->selectmode & SCE_SELECT_EDGE) { BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) + if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { continue; + } BM_edge_select_set(em->bm, eed, !BM_elem_flag_test(eed, BM_ELEM_SELECT)); } } else { BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) + if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { continue; + } BM_face_select_set(em->bm, efa, !BM_elem_flag_test(efa, BM_ELEM_SELECT)); } } @@ -2674,8 +2689,9 @@ bool EDBM_select_interior_faces(BMEditMesh *em) bool changed = false; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) + if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { continue; + } ok = true; BM_ITER_ELEM (eed, &eiter, efa, BM_EDGES_OF_FACE) { @@ -4601,8 +4617,9 @@ static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op)) totsel += BM_elem_flag_test(l2->f, BM_ELEM_SELECT) != 0; } - if ((tot != totsel && totsel > 0) || (totsel == 1 && tot == 1)) + if ((tot != totsel && totsel > 0) || (totsel == 1 && tot == 1)) { BM_elem_flag_enable(l1->e, BM_ELEM_TAG); + } } } @@ -4670,8 +4687,9 @@ static int loop_find_region(BMLoop *l, int flag, GSet *visit_face_set, BMFace ** BLI_array_append(region, f); BM_ITER_ELEM (l1, &liter1, f, BM_LOOPS_OF_FACE) { - if (BM_elem_flag_test(l1->e, flag)) + if (BM_elem_flag_test(l1->e, flag)) { continue; + } BM_ITER_ELEM (l2, &liter2, l1->e, BM_LOOPS_OF_EDGE) { /* avoids finding same region twice @@ -4701,10 +4719,12 @@ static int verg_radial(const void *va, const void *vb) const int a = BM_edge_face_count(e_a); const int b = BM_edge_face_count(e_b); - if (a > b) + if (a > b) { return -1; - if (a < b) + } + if (a < b) { return 1; + } return 0; } @@ -4747,12 +4767,14 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger) e = edges[i]; - if (!BM_elem_flag_test(e, BM_ELEM_TAG)) + if (!BM_elem_flag_test(e, BM_ELEM_TAG)) { continue; + } BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) { - if (BLI_gset_haskey(visit_face_set, l->f)) + if (BLI_gset_haskey(visit_face_set, l->f)) { continue; + } c = loop_find_region(l, BM_ELEM_SELECT, visit_face_set, ®ion_out); diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c index 3006e2ed73d..2782cc92aca 100644 --- a/source/blender/editors/mesh/editmesh_select_similar.c +++ b/source/blender/editors/mesh/editmesh_select_similar.c @@ -1218,12 +1218,15 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op) ts->select_thresh = RNA_property_float_get(op->ptr, prop); } - if (type < 100) + if (type < 100) { return similar_vert_select_exec(C, op); - else if (type < 200) + } + else if (type < 200) { return similar_edge_select_exec(C, op); - else + } + else { return similar_face_select_exec(C, op); + } } static const EnumPropertyItem *select_similar_type_itemf(bContext *C, @@ -1233,8 +1236,9 @@ static const EnumPropertyItem *select_similar_type_itemf(bContext *C, { Object *obedit; - if (!C) /* needed for docs and i18n tools */ + if (!C) { /* needed for docs and i18n tools */ return prop_similar_types; + } obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 05466ce04bc..0a07b8cf6f6 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2273,12 +2273,15 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) MirrorModifierData *mmd = (MirrorModifierData *)md; if (mmd->flag & MOD_MIR_CLIPPING) { - if (mmd->flag & MOD_MIR_AXIS_X) + if (mmd->flag & MOD_MIR_AXIS_X) { mirrx = true; - if (mmd->flag & MOD_MIR_AXIS_Y) + } + if (mmd->flag & MOD_MIR_AXIS_Y) { mirry = true; - if (mmd->flag & MOD_MIR_AXIS_Z) + } + if (mmd->flag & MOD_MIR_AXIS_Z) { mirrz = true; + } clip_dist = mmd->tolerance; } @@ -2498,8 +2501,9 @@ static void mesh_set_smooth_faces(BMEditMesh *em, short smooth) BMIter iter; BMFace *efa; - if (em == NULL) + if (em == NULL) { return; + } BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) { @@ -2837,31 +2841,37 @@ static bool merge_firstlast(BMEditMesh *em, /* do sanity check in mergemenu in edit.c ?*/ if (use_first == false) { - if (!em->bm->selected.last || ((BMEditSelection *)em->bm->selected.last)->htype != BM_VERT) + if (!em->bm->selected.last || ((BMEditSelection *)em->bm->selected.last)->htype != BM_VERT) { return false; + } ese = em->bm->selected.last; mergevert = (BMVert *)ese->ele; } else { - if (!em->bm->selected.first || ((BMEditSelection *)em->bm->selected.first)->htype != BM_VERT) + if (!em->bm->selected.first || ((BMEditSelection *)em->bm->selected.first)->htype != BM_VERT) { return false; + } ese = em->bm->selected.first; mergevert = (BMVert *)ese->ele; } - if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT)) + if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT)) { return false; + } if (use_uvmerge) { if (!EDBM_op_callf( - em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert)) + em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert)) { return false; + } } - if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co)) + if (!EDBM_op_callf( + em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co)) { return false; + } return true; } @@ -2888,14 +2898,16 @@ static bool merge_target(BMEditMesh *em, float fac; int i = 0; BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { - if (!BM_elem_flag_test(v, BM_ELEM_SELECT)) + if (!BM_elem_flag_test(v, BM_ELEM_SELECT)) { continue; + } add_v3_v3(cent, v->co); i++; } - if (!i) + if (!i) { return false; + } fac = 1.0f / (float)i; mul_v3_fl(cent, fac); @@ -2903,16 +2915,19 @@ static bool merge_target(BMEditMesh *em, vco = co; } - if (!vco) + if (!vco) { return false; + } if (use_uvmerge) { - if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT)) + if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT)) { return false; + } } - if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co)) + if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co)) { return false; + } return true; } @@ -2996,8 +3011,9 @@ static const EnumPropertyItem *merge_type_itemf(bContext *C, EnumPropertyItem *item = NULL; int totitem = 0; - if (!C) /* needed for docs */ + if (!C) { /* needed for docs */ return merge_type_items; + } obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_MESH) { @@ -3094,12 +3110,15 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) /* avoid losing selection state (select -> tags) */ char htype_select; - if (em->selectmode & SCE_SELECT_VERTEX) + if (em->selectmode & SCE_SELECT_VERTEX) { htype_select = BM_VERT; - else if (em->selectmode & SCE_SELECT_EDGE) + } + else if (em->selectmode & SCE_SELECT_EDGE) { htype_select = BM_EDGE; - else + } + else { htype_select = BM_FACE; + } /* store selection as tags */ BM_mesh_elem_hflag_enable_test(em->bm, htype_select, BM_ELEM_TAG, true, true, BM_ELEM_SELECT); @@ -3332,8 +3351,9 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) if (kb) { /* Perform blending on selected vertices. */ BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) + if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { continue; + } /* Get coordinates of shapekey we're blending from. */ sco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, shape); @@ -3383,8 +3403,9 @@ static const EnumPropertyItem *shape_itemf(bContext *C, int a; for (a = 0; a < em->bm->vdata.totlayer; a++) { - if (em->bm->vdata.layers[a].type != CD_SHAPEKEY) + if (em->bm->vdata.layers[a].type != CD_SHAPEKEY) { continue; + } tmp.value = totitem; tmp.identifier = em->bm->vdata.layers[a].name; @@ -3619,11 +3640,13 @@ static float bm_edge_seg_isect(const float sco_a[2], /* sqrt(m2 * m2 + 1); Only looking for change in sign. Skip extra math .*/ dist = (y12 - m2 * x12 - b2); } - else + else { dist = x22 - x12; + } - if (i == 0) + if (i == 0) { lastdist = dist; + } /* if dist changes sign, and intersect point in edge's Bound Box */ if ((lastdist * dist) <= 0) { @@ -3684,10 +3707,12 @@ static float bm_edge_seg_isect(const float sco_a[2], } } } - if ((m2 <= 1.0f) && (m2 >= -1.0f)) + if ((m2 <= 1.0f) && (m2 >= -1.0f)) { perc = (xi - x21) / (x22 - x21); - else + } + else { perc = (yi - y21) / (y22 - y21); /* lower slope more accurate */ + } //isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */ break; @@ -3720,8 +3745,9 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) float(*screen_vert_coords)[2], (*sco)[2], (*mouse_path)[2]; /* edit-object needed for matrix, and ar->regiondata for projections to work */ - if (ELEM(NULL, obedit, ar, ar->regiondata)) + if (ELEM(NULL, obedit, ar, ar->regiondata)) { return OPERATOR_CANCELLED; + } if (bm->totvertsel < 2) { BKE_report(op->reports, RPT_ERROR, "No edges are selected to operate on"); @@ -3797,8 +3823,9 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) BMO_slot_buffer_from_enabled_flag(bm, &bmop, bmop.slots_in, "edges", BM_EDGE, ELE_EDGE_CUT); - if (mode == KNIFE_MIDPOINT) + if (mode == KNIFE_MIDPOINT) { numcuts = 1; + } BMO_slot_int_set(bmop.slots_in, "cuts", numcuts); BMO_slot_int_set(bmop.slots_in, "quad_corner_type", SUBD_CORNER_STRAIGHT_CUT); @@ -5965,15 +5992,19 @@ static void sort_bmelem_flag(bContext *C, int affected[3] = {0, 0, 0}; int i, j; - if (!(types && flag && action)) + if (!(types && flag && action)) { return; + } - if (types & BM_VERT) + if (types & BM_VERT) { totelem[0] = em->bm->totvert; - if (types & BM_EDGE) + } + if (types & BM_EDGE) { totelem[1] = em->bm->totedge; - if (types & BM_FACE) + } + if (types & BM_FACE) { totelem[2] = em->bm->totface; + } if (ELEM(action, SRT_VIEW_ZAXIS, SRT_VIEW_XAXIS)) { float mat[4][4]; @@ -6185,8 +6216,9 @@ static void sort_bmelem_flag(bContext *C, int aff = affected[j]; tb = tbuf[j]; mp = map[j]; - if (!(tb && mp)) + if (!(tb && mp)) { continue; + } if (ELEM(aff, 0, tot)) { MEM_freeN(tb); MEM_freeN(mp); @@ -6327,12 +6359,15 @@ static void sort_bmelem_flag(bContext *C, /* printf("%d faces: %d to be affected...\n", totelem[2], affected[2]);*/ if (affected[0] == 0 && affected[1] == 0 && affected[2] == 0) { for (j = 3; j--;) { - if (pblock[j]) + if (pblock[j]) { MEM_freeN(pblock[j]); - if (sblock[j]) + } + if (sblock[j]) { MEM_freeN(sblock[j]); - if (map[j]) + } + if (map[j]) { MEM_freeN(map[j]); + } } return; } @@ -6362,10 +6397,12 @@ static void sort_bmelem_flag(bContext *C, } } } - if (pb) + if (pb) { MEM_freeN(pb); - if (sb) + } + if (sb) { MEM_freeN(sb); + } } BM_mesh_remap(em->bm, map[0], map[1], map[2]); @@ -6373,8 +6410,9 @@ static void sort_bmelem_flag(bContext *C, WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); for (j = 3; j--;) { - if (map[j]) + if (map[j]) { MEM_freeN(map[j]); + } } } @@ -6406,12 +6444,15 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op) } else { BMEditMesh *em = BKE_editmesh_from_object(ob_active); - if (em->selectmode & SCE_SELECT_VERTEX) + if (em->selectmode & SCE_SELECT_VERTEX) { elem_types |= BM_VERT; - if (em->selectmode & SCE_SELECT_EDGE) + } + if (em->selectmode & SCE_SELECT_EDGE) { elem_types |= BM_EDGE; - if (em->selectmode & SCE_SELECT_FACE) + } + if (em->selectmode & SCE_SELECT_FACE) { elem_types |= BM_FACE; + } RNA_enum_set(op->ptr, "elements", elem_types); } @@ -6453,18 +6494,22 @@ static bool edbm_sort_elements_poll_property(const bContext *UNUSED(C), /* Only show seed for randomize action! */ if (STREQ(prop_id, "seed")) { - if (action == SRT_RANDOMIZE) + if (action == SRT_RANDOMIZE) { return true; - else + } + else { return false; + } } /* Hide seed for reverse and randomize actions! */ if (STREQ(prop_id, "reverse")) { - if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) + if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) { return false; - else + } + else { return true; + } } return true; @@ -7601,8 +7646,9 @@ wmKeyMap *point_normals_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_modalkeymap_get(keyconf, keymap_name); /* We only need to add map once */ - if (keymap && keymap->modal_items) + if (keymap && keymap->modal_items) { return NULL; + } keymap = WM_modalkeymap_add(keyconf, keymap_name, modal_items); diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index f3055b5c75e..d7ed14184fa 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -626,10 +626,12 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm, if (fabsf(uvdiff[0]) < limit[0] && fabsf(uvdiff[1]) < limit[1] && (!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) { - if (lastv) + if (lastv) { lastv->next = next; - else + } + else { vlist = next; + } iterv->next = newvlist; newvlist = iterv; } @@ -776,10 +778,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, if (fabsf(uvdiff[0]) < STD_UV_CONNECT_LIMIT && fabsf(uvdiff[1]) < STD_UV_CONNECT_LIMIT && (!use_winding || winding[BM_elem_index_get(iterv->l->f)] == winding[BM_elem_index_get(v->l->f)])) { - if (lastv) + if (lastv) { lastv->next = next; - else + } + else { vlist = next; + } iterv->next = newvlist; newvlist = iterv; } @@ -833,8 +837,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, UvElement *element, *initelement = element_map->vert[BM_elem_index_get(l->v)]; for (element = initelement; element; element = element->next) { - if (element->separate) + if (element->separate) { initelement = element; + } if (element->l->f == efa) { /* found the uv corresponding to our face and vertex. @@ -848,8 +853,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, islandbufsize++; for (element = initelement; element; element = element->next) { - if (element->separate && element != initelement) + if (element->separate && element != initelement) { break; + } if (island_number[BM_elem_index_get(element->l->f)] == INVALID_ISLAND) { stack[stacksize++] = element->l->f; @@ -871,8 +877,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, /* remap */ for (i = 0; i < bm->totvert; i++) { /* important since we may do selection only. Some of these may be NULL */ - if (element_map->vert[i]) + if (element_map->vert[i]) { element_map->vert[i] = &islandbuf[map[element_map->vert[i] - element_map->buf]]; + } } element_map->islandIndices = MEM_callocN(sizeof(*element_map->islandIndices) * nislands, @@ -880,10 +887,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, j = 0; for (i = 0; i < totuv; i++) { UvElement *element = element_map->buf[i].next; - if (element == NULL) + if (element == NULL) { islandbuf[map[i]].next = NULL; - else + } + else { islandbuf[map[i]].next = &islandbuf[map[element - element_map->buf]]; + } if (islandbuf[i].island != j) { j++; @@ -907,10 +916,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm, void BM_uv_vert_map_free(UvVertMap *vmap) { if (vmap) { - if (vmap->vert) + if (vmap->vert) { MEM_freeN(vmap->vert); - if (vmap->buf) + } + if (vmap->buf) { MEM_freeN(vmap->buf); + } MEM_freeN(vmap); } } @@ -918,12 +929,15 @@ void BM_uv_vert_map_free(UvVertMap *vmap) void BM_uv_element_map_free(UvElementMap *element_map) { if (element_map) { - if (element_map->vert) + if (element_map->vert) { MEM_freeN(element_map->vert); - if (element_map->buf) + } + if (element_map->buf) { MEM_freeN(element_map->buf); - if (element_map->islandIndices) + } + if (element_map->islandIndices) { MEM_freeN(element_map->islandIndices); + } MEM_freeN(element_map); } } @@ -1243,12 +1257,15 @@ bool EDBM_mesh_hide(BMEditMesh *em, bool swap) char hflag_swap = swap ? BM_ELEM_SELECT : 0; bool changed = true; - if (em->selectmode & SCE_SELECT_VERTEX) + if (em->selectmode & SCE_SELECT_VERTEX) { itermode = BM_VERTS_OF_MESH; - else if (em->selectmode & SCE_SELECT_EDGE) + } + else if (em->selectmode & SCE_SELECT_EDGE) { itermode = BM_EDGES_OF_MESH; - else + } + else { itermode = BM_FACES_OF_MESH; + } BM_ITER_MESH (ele, &iter, em->bm, itermode) { if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) { diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index fccecf993e8..385b3c69422 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -217,8 +217,9 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) BLI_assert(cd_loop_uv_offset != -1); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) + if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) { continue; + } mesh_uv_reset_bmface(efa, cd_loop_uv_offset); } @@ -261,8 +262,9 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, co em = me->edit_mesh; layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV); - if (layernum_dst >= MAX_MTFACE) + if (layernum_dst >= MAX_MTFACE) { return -1; + } /* CD_MLOOPUV */ BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPUV, name); @@ -279,8 +281,9 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, co } else { layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); - if (layernum_dst >= MAX_MTFACE) + if (layernum_dst >= MAX_MTFACE) { return -1; + } if (me->mloopuv && do_init) { CustomData_add_layer_named( @@ -322,13 +325,15 @@ void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name) em = me->edit_mesh; layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV); - if (layernum_dst == 0) + if (layernum_dst == 0) { ED_mesh_uv_texture_add(me, name, true, true); + } } else { layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); - if (layernum_dst == 0) + if (layernum_dst == 0) { ED_mesh_uv_texture_add(me, name, true, true); + } } } @@ -341,8 +346,9 @@ bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n) index = CustomData_get_layer_index_n(ldata, CD_MLOOPUV, n); cdlu = (index == -1) ? NULL : &ldata->layers[index]; - if (!cdlu) + if (!cdlu) { return false; + } delete_customdata_layer(me, cdlu); @@ -455,8 +461,9 @@ bool ED_mesh_color_remove_index(Mesh *me, const int n) index = CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, n); cdl = (index == -1) ? NULL : &ldata->layers[index]; - if (!cdl) + if (!cdl) { return false; + } delete_customdata_layer(me, cdl); DEG_id_tag_update(&me->id, 0); @@ -501,8 +508,9 @@ static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); Mesh *me = ob->data; - if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1) + if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1) { return OPERATOR_CANCELLED; + } if (ob->mode & OB_MODE_TEXTURE_PAINT) { Scene *scene = CTX_data_scene(C); @@ -533,8 +541,9 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); Mesh *me = ob->data; - if (!ED_mesh_uv_texture_remove_active(me)) + if (!ED_mesh_uv_texture_remove_active(me)) { return OPERATOR_CANCELLED; + } if (ob->mode & OB_MODE_TEXTURE_PAINT) { Scene *scene = CTX_data_scene(C); @@ -567,8 +576,9 @@ static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); Mesh *me = ob->data; - if (ED_mesh_color_add(me, NULL, true, true) == -1) + if (ED_mesh_color_add(me, NULL, true, true) == -1) { return OPERATOR_CANCELLED; + } return OPERATOR_FINISHED; } @@ -593,8 +603,9 @@ static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); Mesh *me = ob->data; - if (!ED_mesh_color_remove_active(me)) + if (!ED_mesh_color_remove_active(me)) { return OPERATOR_CANCELLED; + } return OPERATOR_FINISHED; } @@ -892,8 +903,9 @@ void ED_mesh_update( BKE_mesh_calc_edges_loose(mesh); } - if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0)) + if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0)) { BKE_mesh_calc_edges(mesh, calc_edges, true); + } if (calc_tessface) { if (tessface_input == false) { @@ -917,15 +929,17 @@ static void mesh_add_verts(Mesh *mesh, int len) MVert *mvert; int i, totvert; - if (len == 0) + if (len == 0) { return; + } totvert = mesh->totvert + len; CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert); CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert); - if (!CustomData_has_layer(&vdata, CD_MVERT)) + if (!CustomData_has_layer(&vdata, CD_MVERT)) { CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert); + } CustomData_free(&mesh->vdata, mesh->totvert); mesh->vdata = vdata; @@ -935,8 +949,9 @@ static void mesh_add_verts(Mesh *mesh, int len) /* set default flags */ mvert = &mesh->mvert[mesh->totvert]; - for (i = 0; i < len; i++, mvert++) + for (i = 0; i < len; i++, mvert++) { mvert->flag |= SELECT; + } /* set final vertex list size */ mesh->totvert = totvert; @@ -948,8 +963,9 @@ static void mesh_add_edges(Mesh *mesh, int len) MEdge *medge; int i, totedge; - if (len == 0) + if (len == 0) { return; + } totedge = mesh->totedge + len; @@ -957,8 +973,9 @@ static void mesh_add_edges(Mesh *mesh, int len) CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge); CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge); - if (!CustomData_has_layer(&edata, CD_MEDGE)) + if (!CustomData_has_layer(&edata, CD_MEDGE)) { CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge); + } CustomData_free(&mesh->edata, mesh->totedge); mesh->edata = edata; @@ -966,8 +983,9 @@ static void mesh_add_edges(Mesh *mesh, int len) /* set default flags */ medge = &mesh->medge[mesh->totedge]; - for (i = 0; i < len; i++, medge++) + for (i = 0; i < len; i++, medge++) { medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT; + } mesh->totedge = totedge; } @@ -978,8 +996,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len) MFace *mface; int i, totface; - if (len == 0) + if (len == 0) { return; + } totface = mesh->totface + len; /* new face count */ @@ -987,8 +1006,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len) CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH.fmask, CD_DEFAULT, totface); CustomData_copy_data(&mesh->fdata, &fdata, 0, 0, mesh->totface); - if (!CustomData_has_layer(&fdata, CD_MFACE)) + if (!CustomData_has_layer(&fdata, CD_MFACE)) { CustomData_add_layer(&fdata, CD_MFACE, CD_CALLOC, NULL, totface); + } CustomData_free(&mesh->fdata, mesh->totface); mesh->fdata = fdata; @@ -996,8 +1016,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len) /* set default flags */ mface = &mesh->mface[mesh->totface]; - for (i = 0; i < len; i++, mface++) + for (i = 0; i < len; i++, mface++) { mface->flag = ME_FACE_SEL; + } mesh->totface = totface; } @@ -1007,8 +1028,9 @@ static void mesh_add_loops(Mesh *mesh, int len) CustomData ldata; int totloop; - if (len == 0) + if (len == 0) { return; + } totloop = mesh->totloop + len; /* new face count */ @@ -1016,8 +1038,9 @@ static void mesh_add_loops(Mesh *mesh, int len) CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH.lmask, CD_DEFAULT, totloop); CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop); - if (!CustomData_has_layer(&ldata, CD_MLOOP)) + if (!CustomData_has_layer(&ldata, CD_MLOOP)) { CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop); + } CustomData_free(&mesh->ldata, mesh->totloop); mesh->ldata = ldata; @@ -1032,8 +1055,9 @@ static void mesh_add_polys(Mesh *mesh, int len) MPoly *mpoly; int i, totpoly; - if (len == 0) + if (len == 0) { return; + } totpoly = mesh->totpoly + len; /* new face count */ @@ -1041,8 +1065,9 @@ static void mesh_add_polys(Mesh *mesh, int len) CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH.pmask, CD_DEFAULT, totpoly); CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly); - if (!CustomData_has_layer(&pdata, CD_MPOLY)) + if (!CustomData_has_layer(&pdata, CD_MPOLY)) { CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly); + } CustomData_free(&mesh->pdata, mesh->totpoly); mesh->pdata = pdata; @@ -1050,8 +1075,9 @@ static void mesh_add_polys(Mesh *mesh, int len) /* set default flags */ mpoly = &mesh->mpoly[mesh->totpoly]; - for (i = 0; i < len; i++, mpoly++) + for (i = 0; i < len; i++, mpoly++) { mpoly->flag = ME_FACE_SEL; + } mesh->totpoly = totpoly; } @@ -1060,8 +1086,9 @@ static void mesh_remove_verts(Mesh *mesh, int len) { int totvert; - if (len == 0) + if (len == 0) { return; + } totvert = mesh->totvert - len; CustomData_free_elem(&mesh->vdata, totvert, len); @@ -1074,8 +1101,9 @@ static void mesh_remove_edges(Mesh *mesh, int len) { int totedge; - if (len == 0) + if (len == 0) { return; + } totedge = mesh->totedge - len; CustomData_free_elem(&mesh->edata, totedge, len); @@ -1087,8 +1115,9 @@ static void mesh_remove_faces(Mesh *mesh, int len) { int totface; - if (len == 0) + if (len == 0) { return; + } totface = mesh->totface - len; /* new face count */ CustomData_free_elem(&mesh->fdata, totface, len); diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index 7d0ee19b5ea..eec0c4a57fa 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -50,8 +50,9 @@ int ED_mesh_mirror_spatial_table( Object *ob, BMEditMesh *em, Mesh *me_eval, const float co[3], char mode) { if (mode == 'u') { /* use table */ - if (MirrKdStore.tree == NULL) + if (MirrKdStore.tree == NULL) { ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's'); + } if (MirrKdStore.tree) { KDTreeNearest_3d nearest; @@ -70,8 +71,9 @@ int ED_mesh_mirror_spatial_table( const bool use_em = (!me_eval && em && me->edit_mesh == em); const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : me->totvert; - if (MirrKdStore.tree) /* happens when entering this call without ending it */ + if (MirrKdStore.tree) { /* happens when entering this call without ending it */ ED_mesh_mirror_spatial_table(ob, em, me_eval, co, 'e'); + } MirrKdStore.tree = BLI_kdtree_3d_new(totvert); @@ -126,19 +128,23 @@ typedef struct MirrTopoVert_t { static int mirrtopo_hash_sort(const void *l1, const void *l2) { - if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2) + if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2) { return 1; - else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2) + } + else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2) { return -1; + } return 0; } static int mirrtopo_vert_sort(const void *v1, const void *v2) { - if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash) + if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash) { return 1; - else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash) + } + else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash) { return -1; + } return 0; } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 9c799550608..c32fef42d27 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -323,12 +323,14 @@ int join_mesh_exec(bContext *C, wmOperator *op) totpoly += me->totpoly; totmat += ob_iter->totcol; - if (ob_iter == ob) + if (ob_iter == ob) { ok = true; + } /* check for shapekeys */ - if (me->key) + if (me->key) { haskey++; + } } } CTX_DATA_END; @@ -386,8 +388,9 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* for all keys in old block, clear data-arrays */ for (kb = key->block.first; kb; kb = kb->next) { - if (kb->data) + if (kb->data) { MEM_freeN(kb->data); + } kb->data = MEM_callocN(sizeof(float) * 3 * totvert, "join_shapekey"); kb->totelem = totvert; } @@ -413,8 +416,9 @@ int join_mesh_exec(bContext *C, wmOperator *op) BLI_addtail(&ob->defbase, odg); } } - if (ob->defbase.first && ob->actdef == 0) + if (ob->defbase.first && ob->actdef == 0) { ob->actdef = 1; + } if (me->totvert) { /* Add this object's materials to the base one's if they don't exist already @@ -609,13 +613,15 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* old material array */ for (a = 1; a <= ob->totcol; a++) { ma = ob->mat[a - 1]; - if (ma) + if (ma) { id_us_min(&ma->id); + } } for (a = 1; a <= me->totcol; a++) { ma = me->mat[a - 1]; - if (ma) + if (ma) { id_us_min(&ma->id); + } } MEM_SAFE_FREE(ob->mat); MEM_SAFE_FREE(ob->matbits); @@ -683,21 +689,25 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) if (ob_iter->type == OB_MESH) { selme = (Mesh *)ob_iter->data; - if (selme->totvert == me->totvert) + if (selme->totvert == me->totvert) { ok = true; - else + } + else { nonequal_verts = 1; + } } } CTX_DATA_END; if (!ok) { - if (nonequal_verts) + if (nonequal_verts) { BKE_report(op->reports, RPT_WARNING, "Selected meshes must have equal numbers of vertices"); - else + } + else { BKE_report(op->reports, RPT_WARNING, "No additional selected meshes with equal vertex count to join"); + } return OPERATOR_CANCELLED; } @@ -793,8 +803,9 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index) static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index) { - if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1) + if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1) { return -1; + } return mesh_topo_store.index_lookup[index]; } @@ -836,8 +847,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, int index) { intptr_t poinval; - if (ED_mesh_mirror_topo_table(ob, NULL, 'u') == -1) + if (ED_mesh_mirror_topo_table(ob, NULL, 'u') == -1) { return NULL; + } if (index == -1) { BMIter iter; @@ -845,8 +857,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, index = 0; BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { - if (v == eve) + if (v == eve) { break; + } index++; } @@ -857,8 +870,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, poinval = mesh_topo_store.index_lookup[index]; - if (poinval != -1) + if (poinval != -1) { return (BMVert *)(poinval); + } return NULL; } @@ -978,22 +992,29 @@ static unsigned int mirror_facehash(const void *ptr) static int mirror_facerotation(MFace *a, MFace *b) { if (b->v4) { - if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4) + if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4) { return 0; - else if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4) + } + else if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4) { return 1; - else if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4) + } + else if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4) { return 2; - else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4) + } + else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4) { return 3; + } } else { - if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3) + if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3) { return 0; - else if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3) + } + else if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3) { return 1; - else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3) + } + else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3) { return 2; + } } return -1; @@ -1028,14 +1049,16 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's'); - for (a = 0, mv = mvert; a < totvert; a++, mv++) + for (a = 0, mv = mvert; a < totvert; a++, mv++) { mirrorverts[a] = mesh_get_x_mirror_vert(ob, me_eval, a, use_topology); + } ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 'e'); fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface); - for (a = 0, mf = mface; a < totface; a++, mf++) + for (a = 0, mf = mface; a < totface; a++, mf++) { BLI_ghash_insert(fhash, mf, mf); + } for (a = 0, mf = mface; a < totface; a++, mf++) { mirrormf.v1 = mirrorverts[mf->v3]; @@ -1054,8 +1077,9 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval) mirrorfaces[a * 2] = hashmf - mface; mirrorfaces[a * 2 + 1] = mirror_facerotation(&mirrormf, hashmf); } - else + else { mirrorfaces[a * 2] = -1; + } } BLI_ghash_free(fhash, NULL, NULL); @@ -1080,8 +1104,9 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, BLI_assert(me && GS(me->id.name) == ID_ME); - if (!me || me->totpoly == 0) + if (!me || me->totpoly == 0) { return false; + } ED_view3d_viewcontext_init(C, &vc); @@ -1261,8 +1286,9 @@ bool ED_mesh_pick_vert( BLI_assert(me && GS(me->id.name) == ID_ME); - if (!me || me->totvert == 0) + if (!me || me->totvert == 0) { return false; + } ED_view3d_viewcontext_init(C, &vc); @@ -1336,15 +1362,17 @@ MDeformVert *ED_mesh_active_dvert_get_em(Object *ob, BMVert **r_eve) BMVert *eve = BM_mesh_active_vert_get(bm); if (eve) { - if (r_eve) + if (r_eve) { *r_eve = eve; + } return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset); } } } - if (r_eve) + if (r_eve) { *r_eve = NULL; + } return NULL; } @@ -1352,8 +1380,9 @@ MDeformVert *ED_mesh_active_dvert_get_ob(Object *ob, int *r_index) { Mesh *me = ob->data; int index = BKE_mesh_mselect_active_get(me, ME_VSEL); - if (r_index) + if (r_index) { *r_index = index; + } if (index == -1 || me->dvert == NULL) { return NULL; } |