diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-27 09:14:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-27 09:14:36 +0300 |
commit | 8d7005d7152459eb66fa33ae14eba94a0169adbb (patch) | |
tree | 78a117f4c1256dda7ce1af72f3e5b04ecbb0c4cd /source/blender/bmesh | |
parent | e26b67fa1e13b45c395878dfc667af0b4cc458cf (diff) |
Cleanup: style, use braces for bmesh
Diffstat (limited to 'source/blender/bmesh')
43 files changed, 1082 insertions, 531 deletions
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index fba71b20e7c..c24a5b21b6c 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -737,7 +737,9 @@ BMesh *BM_mesh_copy(BMesh *bm_old) ftable[i] = f_new; - if (f == bm_old->act_face) bm_new->act_face = f_new; + if (f == bm_old->act_face) { + bm_new->act_face = f_new; + } } bm_old->elem_index_dirty &= ~BM_FACE; bm_new->elem_index_dirty &= ~BM_FACE; diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index eead30bcd24..58b83cd0586 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -152,8 +152,9 @@ BMEdge *BM_edge_create( BLI_assert((e_example == NULL) || (e_example->head.htype == BM_EDGE)); BLI_assert(!(create_flag & 1)); - if ((create_flag & BM_CREATE_NO_DOUBLE) && (e = BM_edge_exists(v1, v2))) + if ((create_flag & BM_CREATE_NO_DOUBLE) && (e = BM_edge_exists(v1, v2))) { return e; + } e = BLI_mempool_alloc(bm->epool); @@ -554,11 +555,13 @@ int bmesh_elem_check(void *element, const char htype) IS_FACE_WRONG_LENGTH = (1 << 26), } err = 0; - if (!element) + if (!element) { return IS_NULL; + } - if (head->htype != htype) + if (head->htype != htype) { return IS_WRONG_TYPE; + } switch (htype) { case BM_VERT: @@ -748,8 +751,9 @@ static void bm_kill_only_vert(BMesh *bm, BMVert *v) BM_select_history_remove(bm, v); - if (v->head.data) + if (v->head.data) { CustomData_bmesh_free_block(&bm->vdata, &v->head.data); + } if (bm->vtoolflagpool) { BLI_mempool_free(bm->vtoolflagpool, ((BMVert_OFlag *)v)->oflags); @@ -769,8 +773,9 @@ static void bm_kill_only_edge(BMesh *bm, BMEdge *e) BM_select_history_remove(bm, (BMElem *)e); - if (e->head.data) + if (e->head.data) { CustomData_bmesh_free_block(&bm->edata, &e->head.data); + } if (bm->etoolflagpool) { BLI_mempool_free(bm->etoolflagpool, ((BMEdge_OFlag *)e)->oflags); @@ -784,8 +789,9 @@ static void bm_kill_only_edge(BMesh *bm, BMEdge *e) */ static void bm_kill_only_face(BMesh *bm, BMFace *f) { - if (bm->act_face == f) + if (bm->act_face == f) { bm->act_face = NULL; + } bm->totface--; bm->elem_index_dirty |= BM_FACE; @@ -793,8 +799,9 @@ static void bm_kill_only_face(BMesh *bm, BMFace *f) BM_select_history_remove(bm, (BMElem *)f); - if (f->head.data) + if (f->head.data) { CustomData_bmesh_free_block(&bm->pdata, &f->head.data); + } if (bm->ftoolflagpool) { BLI_mempool_free(bm->ftoolflagpool, ((BMFace_OFlag *)f)->oflags); @@ -810,8 +817,9 @@ static void bm_kill_only_loop(BMesh *bm, BMLoop *l) { bm->totloop--; bm->elem_index_dirty |= BM_LOOP; - if (l->head.data) + if (l->head.data) { CustomData_bmesh_free_block(&bm->ldata, &l->head.data); + } BLI_mempool_free(bm->lpool, l); } @@ -1128,8 +1136,9 @@ static int UNUSED_FUNCTION(bm_vert_systag_count_disk)(BMVert *v, const char api_ BMEdge *e = v->e; int i = 0; - if (!e) + if (!e) { return 0; + } do { i += BM_ELEM_API_FLAG_TEST(e, api_flag) ? 1 : 0; @@ -1146,8 +1155,9 @@ static bool bm_vert_is_manifold_flagged(BMVert *v, const char api_flag) { BMEdge *e = v->e; - if (!e) + if (!e) { return false; + } do { BMLoop *l = e->l; @@ -1161,8 +1171,9 @@ static bool bm_vert_is_manifold_flagged(BMVert *v, const char api_flag) } do { - if (!BM_ELEM_API_FLAG_TEST(l->f, api_flag)) + if (!BM_ELEM_API_FLAG_TEST(l->f, api_flag)) { return false; + } } while ((l = l->radial_next) != e->l); } while ((e = bmesh_disk_edge_next(e, v)) != v->e); @@ -1209,8 +1220,9 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const bool do_del) return NULL; } - if (totface == 1) + if (totface == 1) { return faces[0]; + } bm_elements_systag_enable(faces, totface, _FLAG_JF); @@ -1291,8 +1303,9 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const bool do_del) BMLoop *l2 = l_iter->radial_next; do { - if (BM_ELEM_API_FLAG_TEST(l2->f, _FLAG_JF)) + if (BM_ELEM_API_FLAG_TEST(l2->f, _FLAG_JF)) { break; + } l2 = l2->radial_next; } while (l2 != l_iter); @@ -1486,31 +1499,38 @@ BMFace *bmesh_kernel_split_face_make_edge( l_iter = l_first = l_f1; first_loop_f1 = 0; do { - if (l_iter == f->l_first) + if (l_iter == f->l_first) { first_loop_f1 = 1; + } } while ((l_iter = l_iter->next) != l_first); if (first_loop_f1) { /* original first loop was in f1, find a suitable first loop for f2 * which is as similar as possible to f1. the order matters for tools * such as duplifaces. */ - if (f->l_first->prev == l_f1) + if (f->l_first->prev == l_f1) { f2->l_first = l_f2->prev; - else if (f->l_first->next == l_f1) + } + else if (f->l_first->next == l_f1) { f2->l_first = l_f2->next; - else + } + else { f2->l_first = l_f2; + } } else { /* original first loop was in f2, further do same as above */ f2->l_first = f->l_first; - if (f->l_first->prev == l_f2) + if (f->l_first->prev == l_f2) { f->l_first = l_f1->prev; - else if (f->l_first->next == l_f2) + } + else if (f->l_first->next == l_f2) { f->l_first = l_f1->next; - else + } + else { f->l_first = l_f1; + } } #endif @@ -1539,7 +1559,9 @@ BMFace *bmesh_kernel_split_face_make_edge( f->len = f1len; - if (r_l) *r_l = l_f2; + if (r_l) { + *r_l = l_f2; + } #ifdef USE_BMESH_HOLES if (holes) { @@ -1728,7 +1750,9 @@ BMVert *bmesh_kernel_split_edge_make_vert(BMesh *bm, BMVert *tv, BMEdge *e, BMEd BM_CHECK_ELEMENT(e); BM_CHECK_ELEMENT(tv); - if (r_e) *r_e = e_new; + if (r_e) { + *r_e = e_new; + } return v_new; } @@ -2123,16 +2147,18 @@ BMFace *bmesh_kernel_join_face_kill_edge(BMesh *bm, BMFace *f1, BMFace *f2, BMEd l_f2->prev->next = l_f1->next; /* if l_f1 was baseloop, make l_f1->next the base. */ - if (BM_FACE_FIRST_LOOP(f1) == l_f1) + if (BM_FACE_FIRST_LOOP(f1) == l_f1) { BM_FACE_FIRST_LOOP(f1) = l_f1->next; + } /* increase length of f1 */ f1->len += (f2->len - 2); /* make sure each loop points to the proper face */ newlen = f1->len; - for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f1); i < newlen; i++, l_iter = l_iter->next) + for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f1); i < newlen; i++, l_iter = l_iter->next) { l_iter->f = f1; + } /* remove edge from the disk cycle of its two vertices */ bmesh_disk_edge_remove(l_f1->e, l_f1->e->v1); diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c index 7bd86922df2..1f8661c3e04 100644 --- a/source/blender/bmesh/intern/bmesh_edgeloop.c +++ b/source/blender/bmesh/intern/bmesh_edgeloop.c @@ -471,8 +471,9 @@ void BM_mesh_edgeloops_calc_order(BMesh *UNUSED(bm), ListBase *eloops, const boo const float *no = ((BMEdgeLoopStore *)eloops_ordered.last)->no; float len_best_sq = FLT_MAX; - if (use_normals) + if (use_normals) { BLI_ASSERT_UNIT_V3(no); + } for (el_store = eloops->first; el_store; el_store = el_store->next) { float len_sq; @@ -619,8 +620,9 @@ void BM_edgeloop_calc_center(BMesh *UNUSED(bm), BMEdgeLoopStore *el_store) v_next = NODE_AS_CO(node_next); } while (1); - if (totw != 0.0f) + if (totw != 0.0f) { mul_v3_fl(el_store->co, 1.0f / (float) totw); + } } diff --git a/source/blender/bmesh/intern/bmesh_inline.h b/source/blender/bmesh/intern/bmesh_inline.h index 39657f1c32e..549fc90fe40 100644 --- a/source/blender/bmesh/intern/bmesh_inline.h +++ b/source/blender/bmesh/intern/bmesh_inline.h @@ -58,8 +58,8 @@ BLI_INLINE void _bm_elem_flag_disable(BMHeader *head, const char hflag) BLI_INLINE void _bm_elem_flag_set(BMHeader *head, const char hflag, const int val) { - if (val) _bm_elem_flag_enable(head, hflag); - else _bm_elem_flag_disable(head, hflag); + if (val) { _bm_elem_flag_enable(head, hflag); } + else { _bm_elem_flag_disable(head, hflag); } } BLI_INLINE void _bm_elem_flag_toggle(BMHeader *head, const char hflag) diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 655772b49ac..11d6df430c3 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -177,8 +177,9 @@ void BM_face_interp_from_face_ex( float co[2]; int i; - if (f_src != f_dst) + if (f_src != f_dst) { BM_elem_attrs_copy(bm, bm, f_src, f_dst); + } /* interpolate */ i = 0; @@ -213,7 +214,9 @@ void BM_face_interp_from_face(BMesh *bm, BMFace *f_dst, const BMFace *f_src, con do { mul_v2_m3v3(cos_2d[i], axis_mat, l_iter->v->co); blocks_l[i] = l_iter->head.data; - if (do_vertex) blocks_v[i] = l_iter->v->head.data; + if (do_vertex) { + blocks_v[i] = l_iter->v->head.data; + } } while ((void)i++, (l_iter = l_iter->next) != l_first); BM_face_interp_from_face_ex(bm, f_dst, f_src, do_vertex, @@ -324,10 +327,12 @@ static bool mdisp_in_mdispquad( float v1[3], v2[3], c[3], v3[3], v4[3], e1[3], e2[3]; float eps = FLT_EPSILON * 4000; - if (is_zero_v3(l_src->v->no)) + if (is_zero_v3(l_src->v->no)) { BM_vert_normal_update_all(l_src->v); - if (is_zero_v3(l_dst->v->no)) + } + if (is_zero_v3(l_dst->v->no)) { BM_vert_normal_update_all(l_dst->v); + } compute_mdisp_quad(l_dst, l_dst_f_center, v1, v2, v3, v4, e1, e2); @@ -341,8 +346,9 @@ static bool mdisp_in_mdispquad( add_v3_v3(v1, c); add_v3_v3(v2, c); add_v3_v3(v3, c); add_v3_v3(v4, c); - if (!quad_co(v1, v2, v3, v4, p, l_src->v->no, r_uv)) + if (!quad_co(v1, v2, v3, v4, p, l_src->v->no, r_uv)) { return 0; + } mul_v2_fl(r_uv, (float)(res - 1)); @@ -386,8 +392,9 @@ static void bm_loop_flip_disp( if (fabsf(d) < 1e-4f) { d = bm_loop_flip_equotion(mat, b, target_axis_x, target_axis_y, coord, 0, 2); - if (fabsf(d) < 1e-4f) + if (fabsf(d) < 1e-4f) { d = bm_loop_flip_equotion(mat, b, target_axis_x, target_axis_y, coord, 1, 2); + } } disp[0] = (b[0] * mat[1][1] - mat[0][1] * b[1]) / d; @@ -472,8 +479,9 @@ void BM_loop_interp_multires_ex( float axis_x[3], axis_y[3]; /* ignore 2-edged faces */ - if (UNLIKELY(l_dst->f->len < 3)) + if (UNLIKELY(l_dst->f->len < 3)) { return; + } md_dst = BM_ELEM_CD_GET_VOID_P(l_dst, cd_loop_mdisp_offset); compute_mdisp_quad(l_dst, f_dst_center, v1, v2, v3, v4, e1, e2); @@ -564,8 +572,9 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f) BMLoop *l; BMIter liter; - if (cd_loop_mdisp_offset == -1) + if (cd_loop_mdisp_offset == -1) { return; + } BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { MDisps *mdp = BM_ELEM_CD_GET_VOID_P(l->prev, cd_loop_mdisp_offset); @@ -621,13 +630,16 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f) * </pre> */ - if (l->radial_next == l) + if (l->radial_next == l) { continue; + } - if (l->radial_next->v == l->v) + if (l->radial_next->v == l->v) { mdl2 = BM_ELEM_CD_GET_VOID_P(l->radial_next, cd_loop_mdisp_offset); - else + } + else { mdl2 = BM_ELEM_CD_GET_VOID_P(l->radial_next->next, cd_loop_mdisp_offset); + } sides = (int)sqrt(mdl1->totdisp); for (y = 0; y < sides; y++) { @@ -826,7 +838,9 @@ void BM_data_layer_add(BMesh *bm, CustomData *data, int type) CustomData_add_layer(data, type, CD_DEFAULT, NULL, 0); update_data_blocks(bm, &olddata, data); - if (olddata.layers) MEM_freeN(olddata.layers); + if (olddata.layers) { + MEM_freeN(olddata.layers); + } } void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name) @@ -842,7 +856,9 @@ void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char * CustomData_add_layer_named(data, type, CD_DEFAULT, NULL, 0, name); update_data_blocks(bm, &olddata, data); - if (olddata.layers) MEM_freeN(olddata.layers); + if (olddata.layers) { + MEM_freeN(olddata.layers); + } } void BM_data_layer_free(BMesh *bm, CustomData *data, int type) @@ -862,7 +878,9 @@ void BM_data_layer_free(BMesh *bm, CustomData *data, int type) UNUSED_VARS_NDEBUG(has_layer); update_data_blocks(bm, &olddata, data); - if (olddata.layers) MEM_freeN(olddata.layers); + if (olddata.layers) { + MEM_freeN(olddata.layers); + } } void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n) @@ -882,7 +900,9 @@ void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n) UNUSED_VARS_NDEBUG(has_layer); update_data_blocks(bm, &olddata, data); - if (olddata.layers) MEM_freeN(olddata.layers); + if (olddata.layers) { + MEM_freeN(olddata.layers); + } } void BM_data_layer_copy(BMesh *bm, CustomData *data, int type, int src_n, int dst_n) @@ -940,7 +960,9 @@ float BM_elem_float_data_get(CustomData *cd, void *element, int type) void BM_elem_float_data_set(CustomData *cd, void *element, int type, const float val) { float *f = CustomData_bmesh_get(cd, ((BMHeader *)element)->data, type); - if (f) *f = val; + if (f) { + *f = val; + } } /** \name Loop interpolation functions: BM_vert_loop_groups_data_layer_*** diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index ce275342557..2f9eeac83e9 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -584,8 +584,9 @@ void bmiter__loop_of_loop_begin(struct BMIter__loop_of_loop *iter) iter->l_first = iter->ldata; iter->l_next = iter->l_first->radial_next; - if (iter->l_next == iter->l_first) + if (iter->l_next == iter->l_first) { iter->l_next = NULL; + } } void *bmiter__loop_of_loop_step(struct BMIter__loop_of_loop *iter) diff --git a/source/blender/bmesh/intern/bmesh_log.c b/source/blender/bmesh/intern/bmesh_log.c index 77dd6aa76ec..3b2e43b89ad 100644 --- a/source/blender/bmesh/intern/bmesh_log.c +++ b/source/blender/bmesh/intern/bmesh_log.c @@ -523,10 +523,12 @@ BMLog *BM_log_from_existing_entries_create(BMesh *bm, BMLogEntry *entry) { BMLog *log = BM_log_create(bm); - if (entry->prev) + if (entry->prev) { log->current_entry = entry; - else + } + else { log->current_entry = NULL; + } /* Let BMLog manage the entry list again */ log->entries.first = log->entries.last = entry; @@ -563,19 +565,23 @@ void BM_log_free(BMLog *log) { BMLogEntry *entry; - if (log->unused_ids) + if (log->unused_ids) { range_tree_uint_free(log->unused_ids); + } - if (log->id_to_elem) + if (log->id_to_elem) { BLI_ghash_free(log->id_to_elem, NULL, NULL); + } - if (log->elem_to_id) + if (log->elem_to_id) { BLI_ghash_free(log->elem_to_id, NULL, NULL); + } /* Clear the BMLog references within each entry, but do not free * the entries themselves */ - for (entry = log->entries.first; entry; entry = entry->next) + for (entry = log->entries.first; entry; entry = entry->next) { entry->log = NULL; + } MEM_freeN(log); } @@ -691,10 +697,12 @@ void BM_log_entry_drop(BMLogEntry *entry) if (!log) { /* Unlink */ BLI_assert(!(entry->prev && entry->next)); - if (entry->prev) + if (entry->prev) { entry->prev->next = NULL; - else if (entry->next) + } + else if (entry->next) { entry->next->prev = NULL; + } bm_log_entry_free(entry); MEM_freeN(entry); @@ -740,8 +748,9 @@ void BM_log_entry_drop(BMLogEntry *entry) BLI_assert(!"Cannot drop BMLogEntry from middle"); } - if (log->current_entry == entry) + if (log->current_entry == entry) { log->current_entry = entry->prev; + } bm_log_entry_free(entry); BLI_freelinkN(&log->entries, entry); diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 0c18625924d..53d9b4b1b56 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -60,7 +60,9 @@ static void recount_totsels(BMesh *bm) int count = 0; BM_ITER_MESH (ele, &iter, bm, iter_types[i]) { - if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) count += 1; + if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) { + count += 1; + } } *tots[i] = count; } @@ -667,20 +669,32 @@ static int bm_mesh_flag_count( if (htype & BM_VERT) { BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { - if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue; - if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++; + if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) { + continue; + } + if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { + tot++; + } } } if (htype & BM_EDGE) { BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { - if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue; - if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++; + if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) { + continue; + } + if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { + tot++; + } } } if (htype & BM_FACE) { BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { - if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) continue; - if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) tot++; + if (respecthide && BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) { + continue; + } + if (BM_elem_flag_test_bool(ele, hflag) == test_for_enabled) { + tot++; + } } } @@ -876,9 +890,9 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3]) * we cant make a crossvec from a vec thats the same as the vec * unlikely but possible, so make sure if the normal is (0, 0, 1) * that vec isn't the same or in the same direction even. */ - if (eve->no[0] < 0.5f) vec[0] = 1.0f; - else if (eve->no[1] < 0.5f) vec[1] = 1.0f; - else vec[2] = 1.0f; + if (eve->no[0] < 0.5f) { vec[0] = 1.0f; } + else if (eve->no[1] < 0.5f) { vec[1] = 1.0f; } + else { vec[2] = 1.0f; } cross_v3_v3v3(r_plane, eve->no, vec); } normalize_v3(r_plane); @@ -1371,15 +1385,21 @@ void _bm_elem_hide_set(BMesh *bm, BMHeader *head, const bool hide) * hiding an element */ switch (head->htype) { case BM_VERT: - if (hide) BM_vert_select_set(bm, (BMVert *)head, false); + if (hide) { + BM_vert_select_set(bm, (BMVert *)head, false); + } BM_vert_hide_set((BMVert *)head, hide); break; case BM_EDGE: - if (hide) BM_edge_select_set(bm, (BMEdge *)head, false); + if (hide) { + BM_edge_select_set(bm, (BMEdge *)head, false); + } BM_edge_hide_set((BMEdge *)head, hide); break; case BM_FACE: - if (hide) BM_face_select_set(bm, (BMFace *)head, false); + if (hide) { + BM_face_select_set(bm, (BMFace *)head, false); + } BM_face_hide_set((BMFace *)head, hide); break; default: diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index c0c46a65479..460b7ce8dae 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -213,8 +213,9 @@ void BM_mesh_data_free(BMesh *bm) if (is_ldata_free || is_pdata_free) { BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - if (is_pdata_free) + if (is_pdata_free) { CustomData_bmesh_free_block(&(bm->pdata), &(f->head.data)); + } if (is_ldata_free) { BM_ITER_ELEM (l, &itersub, f, BM_LOOPS_OF_FACE) { CustomData_bmesh_free_block(&(bm->ldata), &(l->head.data)); @@ -224,10 +225,10 @@ void BM_mesh_data_free(BMesh *bm) } /* Free custom data pools, This should probably go in CustomData_free? */ - if (bm->vdata.totlayer) BLI_mempool_destroy(bm->vdata.pool); - if (bm->edata.totlayer) BLI_mempool_destroy(bm->edata.pool); - if (bm->ldata.totlayer) BLI_mempool_destroy(bm->ldata.pool); - if (bm->pdata.totlayer) BLI_mempool_destroy(bm->pdata.pool); + if (bm->vdata.totlayer) { BLI_mempool_destroy(bm->vdata.pool); } + if (bm->edata.totlayer) { BLI_mempool_destroy(bm->edata.pool); } + if (bm->ldata.totlayer) { BLI_mempool_destroy(bm->ldata.pool); } + if (bm->pdata.totlayer) { BLI_mempool_destroy(bm->pdata.pool); } /* free custom data */ CustomData_free(&bm->vdata, 0); @@ -241,9 +242,9 @@ void BM_mesh_data_free(BMesh *bm) BLI_mempool_destroy(bm->lpool); BLI_mempool_destroy(bm->fpool); - if (bm->vtable) MEM_freeN(bm->vtable); - if (bm->etable) MEM_freeN(bm->etable); - if (bm->ftable) MEM_freeN(bm->ftable); + if (bm->vtable) { MEM_freeN(bm->vtable); } + if (bm->etable) { MEM_freeN(bm->etable); } + if (bm->ftable) { MEM_freeN(bm->ftable); } /* destroy flag pool */ BM_mesh_elem_toolflags_clear(bm); @@ -924,7 +925,9 @@ static void bm_mesh_loops_calc_normals( } else { /* We still have to consume the stack! */ - while (BLI_SMALLSTACK_POP(clnors)); + while (BLI_SMALLSTACK_POP(clnors)) { + /* pass */ + } } BKE_lnor_space_custom_data_to_normal(lnor_space, *clnor_ref, lnor); } @@ -941,7 +944,9 @@ static void bm_mesh_loops_calc_normals( } else { /* We still have to consume the stack! */ - while (BLI_SMALLSTACK_POP(normal)); + while (BLI_SMALLSTACK_POP(normal)) { + /* pass */ + } } } @@ -1849,8 +1854,9 @@ void BM_mesh_elem_table_ensure(BMesh *bm, const char htype) /* pass (re-use the array) */ } else { - if (bm->vtable) + if (bm->vtable) { MEM_freeN(bm->vtable); + } bm->vtable = MEM_mallocN(sizeof(void **) * bm->totvert, "bm->vtable"); bm->vtable_tot = bm->totvert; } @@ -1860,8 +1866,9 @@ void BM_mesh_elem_table_ensure(BMesh *bm, const char htype) /* pass (re-use the array) */ } else { - if (bm->etable) + if (bm->etable) { MEM_freeN(bm->etable); + } bm->etable = MEM_mallocN(sizeof(void **) * bm->totedge, "bm->etable"); bm->etable_tot = bm->totedge; } @@ -1871,8 +1878,9 @@ void BM_mesh_elem_table_ensure(BMesh *bm, const char htype) /* pass (re-use the array) */ } else { - if (bm->ftable) + if (bm->ftable) { MEM_freeN(bm->ftable); + } bm->ftable = MEM_mallocN(sizeof(void **) * bm->totface, "bm->ftable"); bm->ftable_tot = bm->totface; } @@ -2020,8 +2028,9 @@ void BM_mesh_remap( BMFace *fa; BMLoop *lo; - if (!(vert_idx || edge_idx || face_idx)) + if (!(vert_idx || edge_idx || face_idx)) { return; + } BM_mesh_elem_table_ensure( bm, @@ -2271,12 +2280,15 @@ void BM_mesh_remap( } } - if (vptr_map) + if (vptr_map) { BLI_ghash_free(vptr_map, NULL, NULL); - if (eptr_map) + } + if (eptr_map) { BLI_ghash_free(eptr_map, NULL, NULL); - if (fptr_map) + } + if (fptr_map) { BLI_ghash_free(fptr_map, NULL, NULL); + } } /** diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 4dc6cc8b965..66cd3a0b30c 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -318,10 +318,14 @@ void BM_mesh_bm_from_me( /* Copy Custom Data */ CustomData_to_bmesh_block(&me->vdata, &bm->vdata, i, &v->head.data, true); - if (cd_vert_bweight_offset != -1) BM_ELEM_CD_SET_FLOAT(v, cd_vert_bweight_offset, (float)mvert->bweight / 255.0f); + if (cd_vert_bweight_offset != -1) { + BM_ELEM_CD_SET_FLOAT(v, cd_vert_bweight_offset, (float)mvert->bweight / 255.0f); + } /* set shape key original index */ - if (cd_shape_keyindex_offset != -1) BM_ELEM_CD_SET_INT(v, cd_shape_keyindex_offset, i); + if (cd_shape_keyindex_offset != -1) { + BM_ELEM_CD_SET_INT(v, cd_shape_keyindex_offset, i); + } /* set shapekey data */ if (tot_shape_keys) { @@ -353,8 +357,12 @@ void BM_mesh_bm_from_me( /* Copy Custom Data */ CustomData_to_bmesh_block(&me->edata, &bm->edata, i, &e->head.data, true); - if (cd_edge_bweight_offset != -1) BM_ELEM_CD_SET_FLOAT(e, cd_edge_bweight_offset, (float)medge->bweight / 255.0f); - if (cd_edge_crease_offset != -1) BM_ELEM_CD_SET_FLOAT(e, cd_edge_crease_offset, (float)medge->crease / 255.0f); + if (cd_edge_bweight_offset != -1) { + BM_ELEM_CD_SET_FLOAT(e, cd_edge_bweight_offset, (float)medge->bweight / 255.0f); + } + if (cd_edge_crease_offset != -1) { + BM_ELEM_CD_SET_FLOAT(e, cd_edge_crease_offset, (float)medge->crease / 255.0f); + } } if (is_new) { @@ -397,7 +405,9 @@ void BM_mesh_bm_from_me( } f->mat_nr = mp->mat_nr; - if (i == me->act_face) bm->act_face = f; + if (i == me->act_face) { + bm->act_face = f; + } int j = mp->loopstart; l_iter = l_first = BM_FACE_FIRST_LOOP(f); @@ -567,20 +577,36 @@ void BM_mesh_bm_to_me( ototvert = me->totvert; /* new vertex block */ - if (bm->totvert == 0) mvert = NULL; - else mvert = MEM_callocN(bm->totvert * sizeof(MVert), "loadeditbMesh vert"); + if (bm->totvert == 0) { + mvert = NULL; + } + else { + mvert = MEM_callocN(bm->totvert * sizeof(MVert), "loadeditbMesh vert"); + } /* new edge block */ - if (bm->totedge == 0) medge = NULL; - else medge = MEM_callocN(bm->totedge * sizeof(MEdge), "loadeditbMesh edge"); + if (bm->totedge == 0) { + medge = NULL; + } + else { + medge = MEM_callocN(bm->totedge * sizeof(MEdge), "loadeditbMesh edge"); + } /* new ngon face block */ - if (bm->totface == 0) mpoly = NULL; - else mpoly = MEM_callocN(bm->totface * sizeof(MPoly), "loadeditbMesh poly"); + if (bm->totface == 0) { + mpoly = NULL; + } + else { + mpoly = MEM_callocN(bm->totface * sizeof(MPoly), "loadeditbMesh poly"); + } /* new loop block */ - if (bm->totloop == 0) mloop = NULL; - else mloop = MEM_callocN(bm->totloop * sizeof(MLoop), "loadeditbMesh loop"); + if (bm->totloop == 0) { + mloop = NULL; + } + else { + mloop = MEM_callocN(bm->totloop * sizeof(MLoop), "loadeditbMesh loop"); + } /* lets save the old verts just in case we are actually working on * a key ... we now do processing of the keys at the end */ @@ -640,7 +666,9 @@ void BM_mesh_bm_to_me( /* copy over customdat */ CustomData_from_bmesh_block(&bm->vdata, &me->vdata, v->head.data, i); - if (cd_vert_bweight_offset != -1) mvert->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(v, cd_vert_bweight_offset); + if (cd_vert_bweight_offset != -1) { + mvert->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(v, cd_vert_bweight_offset); + } i++; mvert++; @@ -664,8 +692,12 @@ void BM_mesh_bm_to_me( bmesh_quick_edgedraw_flag(med, e); - if (cd_edge_crease_offset != -1) med->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_crease_offset); - if (cd_edge_bweight_offset != -1) med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_bweight_offset); + if (cd_edge_crease_offset != -1) { + med->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_crease_offset); + } + if (cd_edge_bweight_offset != -1) { + med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(e, cd_edge_bweight_offset); + } i++; med++; @@ -697,7 +729,9 @@ void BM_mesh_bm_to_me( BM_CHECK_ELEMENT(l_iter->v); } while ((l_iter = l_iter->next) != l_first); - if (f == bm->act_face) me->act_face = i; + if (f == bm->act_face) { + me->act_face = i; + } /* copy over customdata */ CustomData_from_bmesh_block(&bm->pdata, &me->pdata, f->head.data, i); @@ -723,15 +757,21 @@ void BM_mesh_bm_to_me( if (ob->par1 < ototvert) { eve = vertMap[ob->par1]; - if (eve) ob->par1 = BM_elem_index_get(eve); + if (eve) { + ob->par1 = BM_elem_index_get(eve); + } } if (ob->par2 < ototvert) { eve = vertMap[ob->par2]; - if (eve) ob->par2 = BM_elem_index_get(eve); + if (eve) { + ob->par2 = BM_elem_index_get(eve); + } } if (ob->par3 < ototvert) { eve = vertMap[ob->par3]; - if (eve) ob->par3 = BM_elem_index_get(eve); + if (eve) { + ob->par3 = BM_elem_index_get(eve); + } } } @@ -763,7 +803,9 @@ void BM_mesh_bm_to_me( } } - if (vertMap) MEM_freeN(vertMap); + if (vertMap) { + MEM_freeN(vertMap); + } } BKE_mesh_update_customdata_pointers(me, false); @@ -809,12 +851,14 @@ void BM_mesh_bm_to_me( * necessary */ j = 0; for (i = 0; i < bm->vdata.totlayer; i++) { - if (bm->vdata.layers[i].type != CD_SHAPEKEY) + if (bm->vdata.layers[i].type != CD_SHAPEKEY) { continue; + } for (currkey = me->key->block.first; currkey; currkey = currkey->next) { - if (currkey->uid == bm->vdata.layers[i].uid) + if (currkey->uid == bm->vdata.layers[i].uid) { break; + } } if (!currkey) { @@ -930,10 +974,14 @@ void BM_mesh_bm_to_me( currkey->data = newkey; } - if (ofs) MEM_freeN(ofs); + if (ofs) { + MEM_freeN(ofs); + } } - if (oldverts) MEM_freeN(oldverts); + if (oldverts) { + MEM_freeN(oldverts); + } /* topology could be changed, ensure mdisps are ok */ multires_topology_changed(me); @@ -1025,9 +1073,13 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks * mv->flag = BM_vert_flag_to_mflag(eve); - if (cd_vert_bweight_offset != -1) mv->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eve, cd_vert_bweight_offset); + if (cd_vert_bweight_offset != -1) { + mv->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eve, cd_vert_bweight_offset); + } - if (add_orig) *index++ = i; + if (add_orig) { + *index++ = i; + } CustomData_from_bmesh_block(&bm->vdata, &me->vdata, eve->head.data, i); } @@ -1052,11 +1104,17 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks * } } - if (cd_edge_crease_offset != -1) med->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_crease_offset); - if (cd_edge_bweight_offset != -1) med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_bweight_offset); + if (cd_edge_crease_offset != -1) { + med->crease = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_crease_offset); + } + if (cd_edge_bweight_offset != -1) { + med->bweight = BM_ELEM_CD_GET_FLOAT_AS_UCHAR(eed, cd_edge_bweight_offset); + } CustomData_from_bmesh_block(&bm->edata, &me->edata, eed->head.data, i); - if (add_orig) *index++ = i; + if (add_orig) { + *index++ = i; + } } bm->elem_index_dirty &= ~BM_EDGE; @@ -1088,7 +1146,9 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks * CustomData_from_bmesh_block(&bm->pdata, &me->pdata, efa->head.data, i); - if (add_orig) *index++ = i; + if (add_orig) { + *index++ = i; + } } bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP); diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h index 030b9480e4f..78e75cf3d30 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h +++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h @@ -64,8 +64,8 @@ ATTR_NONNULL(1, 2) BLI_INLINE void _bmo_elem_flag_set(BMesh *bm, BMFlagLayer *oflags, const short oflag, int val) { BLI_assert(bm->use_toolflags); - if (val) oflags[bm->toolflag_index].f |= oflag; - else oflags[bm->toolflag_index].f &= (short)~oflag; + if (val) { oflags[bm->toolflag_index].f |= oflag; } + else { oflags[bm->toolflag_index].f &= (short)~oflag; } } ATTR_NONNULL(1, 2) @@ -204,7 +204,9 @@ BLI_INLINE void *BMO_slot_map_ptr_get(BMOpSlot *slot, const void *element) { void **val = BMO_slot_map_data_get(slot, element); BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL); - if (val) return *val; + if (val) { + return *val; + } return NULL; } @@ -214,7 +216,9 @@ BLI_INLINE void *BMO_slot_map_elem_get(BMOpSlot *slot, const void *element) { void **val = (void **) BMO_slot_map_data_get(slot, element); BLI_assert(slot->slot_subtype.map == BMO_OP_SLOT_SUBTYPE_MAP_ELEM); - if (val) return *val; + if (val) { + return *val; + } return NULL; } diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 2ce03cf5a7d..5586db26664 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -96,10 +96,12 @@ void BMO_push(BMesh *bm, BMOperator *UNUSED(op)) BLI_assert(bm->totflags > 0); /* add flag layer, if appropriate */ - if (bm->toolflag_index > 0) + if (bm->toolflag_index > 0) { bmo_flag_layer_alloc(bm); - else + } + else { bmo_flag_layer_clear(bm); + } } /** @@ -111,8 +113,9 @@ void BMO_push(BMesh *bm, BMOperator *UNUSED(op)) */ void BMO_pop(BMesh *bm) { - if (bm->toolflag_index > 0) + if (bm->toolflag_index > 0) { bmo_flag_layer_free(bm); + } bm->toolflag_index--; } @@ -212,12 +215,14 @@ void BMO_op_exec(BMesh *bm, BMOperator *op) BMO_push(bm, op); - if (bm->toolflag_index == 1) + if (bm->toolflag_index == 1) { bmesh_edit_begin(bm, op->type_flag); + } op->exec(bm, op); - if (bm->toolflag_index == 1) + if (bm->toolflag_index == 1) { bmesh_edit_end(bm, op->type_flag); + } BMO_pop(bm); } @@ -287,8 +292,9 @@ void _bmo_slot_copy( BMOpSlot *slot_src = BMO_slot_get(slot_args_src, slot_name_src); BMOpSlot *slot_dst = BMO_slot_get(slot_args_dst, slot_name_dst); - if (slot_src == slot_dst) + if (slot_src == slot_dst) { return; + } BLI_assert(slot_src->slot_type == slot_dst->slot_type); if (slot_src->slot_type != slot_dst->slot_type) { @@ -368,8 +374,9 @@ void BMO_slot_float_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_n { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); - if (!(slot->slot_type == BMO_OP_SLOT_FLT)) + if (!(slot->slot_type == BMO_OP_SLOT_FLT)) { return; + } slot->data.f = f; } @@ -378,8 +385,9 @@ void BMO_slot_int_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_nam { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); - if (!(slot->slot_type == BMO_OP_SLOT_INT)) + if (!(slot->slot_type == BMO_OP_SLOT_INT)) { return; + } slot->data.i = i; } @@ -388,8 +396,9 @@ void BMO_slot_bool_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); - if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) + if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) { return; + } slot->data.i = i; } @@ -399,8 +408,9 @@ void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], cons { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); - if (!(slot->slot_type == BMO_OP_SLOT_MAT)) + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) { return; + } slot->len = 4; slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float) * 4 * 4); @@ -422,8 +432,9 @@ void BMO_slot_mat4_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); - if (!(slot->slot_type == BMO_OP_SLOT_MAT)) + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) { return; + } if (slot->data.p) { copy_m4_m4(r_mat, BMO_SLOT_AS_MATRIX(slot)); @@ -437,8 +448,9 @@ void BMO_slot_mat3_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); - if (!(slot->slot_type == BMO_OP_SLOT_MAT)) + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) { return; + } if (slot->data.p) { copy_m3_m4(r_mat, BMO_SLOT_AS_MATRIX(slot)); @@ -452,8 +464,9 @@ void BMO_slot_ptr_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_nam { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); - if (!(slot->slot_type == BMO_OP_SLOT_PTR)) + if (!(slot->slot_type == BMO_OP_SLOT_PTR)) { return; + } slot->data.p = p; } @@ -462,8 +475,9 @@ void BMO_slot_vec_set(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_nam { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); - if (!(slot->slot_type == BMO_OP_SLOT_VEC)) + if (!(slot->slot_type == BMO_OP_SLOT_VEC)) { return; + } copy_v3_v3(slot->data.vec, vec); } @@ -473,8 +487,9 @@ float BMO_slot_float_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_ { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); - if (!(slot->slot_type == BMO_OP_SLOT_FLT)) + if (!(slot->slot_type == BMO_OP_SLOT_FLT)) { return 0.0f; + } return slot->data.f; } @@ -483,8 +498,9 @@ int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); - if (!(slot->slot_type == BMO_OP_SLOT_INT)) + if (!(slot->slot_type == BMO_OP_SLOT_INT)) { return 0; + } return slot->data.i; } @@ -493,8 +509,9 @@ bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); - if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) + if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) { return 0; + } return slot->data.i; } @@ -518,8 +535,9 @@ void *BMO_slot_ptr_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); - if (!(slot->slot_type == BMO_OP_SLOT_PTR)) + if (!(slot->slot_type == BMO_OP_SLOT_PTR)) { return NULL; + } return slot->data.p; } @@ -528,8 +546,9 @@ void BMO_slot_vec_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_nam { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); - if (!(slot->slot_type == BMO_OP_SLOT_VEC)) + if (!(slot->slot_type == BMO_OP_SLOT_VEC)) { return; + } copy_v3_v3(r_vec, slot->data.vec); } @@ -660,8 +679,9 @@ int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); /* check if its actually a buffer */ - if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) { return 0; + } return slot->len; } @@ -755,8 +775,9 @@ void *BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS] BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); /* check if its actually a buffer */ - if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) { return NULL; + } slot->len = len; if (len) { @@ -784,9 +805,9 @@ void BMO_slot_buffer_from_all( BLI_assert(output->slot_type == BMO_OP_SLOT_ELEMENT_BUF); BLI_assert(((output->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype); - if (htype & BM_VERT) totelement += bm->totvert; - if (htype & BM_EDGE) totelement += bm->totedge; - if (htype & BM_FACE) totelement += bm->totface; + if (htype & BM_VERT) { totelement += bm->totvert; } + if (htype & BM_EDGE) { totelement += bm->totedge; } + if (htype & BM_FACE) { totelement += bm->totface; } if (totelement) { BMIter iter; @@ -838,10 +859,12 @@ static void bmo_slot_buffer_from_hflag( BLI_assert(((output->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype); BLI_assert((output->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) == 0); - if (test_for_enabled) + if (test_for_enabled) { totelement = BM_mesh_elem_hflag_count_enabled(bm, htype, hflag, respecthide); - else + } + else { totelement = BM_mesh_elem_hflag_count_disabled(bm, htype, hflag, respecthide); + } if (totelement) { BMIter iter; @@ -999,10 +1022,12 @@ static void bmo_slot_buffer_from_flag( BLI_assert(((slot->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype); BLI_assert((slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) == 0); - if (test_for_enabled) + if (test_for_enabled) { totelement = BMO_mesh_enabled_flag_count(bm, htype, oflag); - else + } + else { totelement = BMO_mesh_disabled_flag_count(bm, htype, oflag); + } if (totelement) { BMIter iter; @@ -1085,8 +1110,9 @@ void BMO_slot_buffer_hflag_enable( BLI_assert((slot->slot_subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) == 0); for (i = 0; i < slot->len; i++, data++) { - if (!(htype & (*data)->head.htype)) + if (!(htype & (*data)->head.htype)) { continue; + } if (do_flush_select) { BM_elem_select_set(bm, *data, true); @@ -1121,8 +1147,9 @@ void BMO_slot_buffer_hflag_disable( BLI_assert(((slot->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype); for (i = 0; i < slot->len; i++, data++) { - if (!(htype & (*data)->head.htype)) + if (!(htype & (*data)->head.htype)) { continue; + } if (do_flush_select) { BM_elem_select_set(bm, *data, false); @@ -1154,8 +1181,9 @@ void BMO_slot_buffer_flag_enable( BLI_assert(((slot->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype); for (i = 0; i < slot->len; i++) { - if (!(htype & data[i]->htype)) + if (!(htype & data[i]->htype)) { continue; + } BMO_elem_flag_enable(bm, (BMElemF *)data[i], oflag); } @@ -1179,8 +1207,9 @@ void BMO_slot_buffer_flag_disable( BLI_assert(((slot->slot_subtype.elem & BM_ALL_NOLOOP) & htype) == htype); for (i = 0; i < slot->len; i++) { - if (!(htype & data[i]->htype)) + if (!(htype & data[i]->htype)) { continue; + } BMO_elem_flag_disable(bm, (BMElemF *)data[i], oflag); } @@ -1363,8 +1392,9 @@ void *BMO_slot_buffer_get_first(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char { BMOpSlot *slot = BMO_slot_get(slot_args, slot_name); - if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) { return NULL; + } return slot->data.buf ? *slot->data.buf : NULL; } @@ -1496,7 +1526,9 @@ typedef struct BMOpError { void BMO_error_clear(BMesh *bm) { - while (BMO_error_pop(bm, NULL, NULL)); + while (BMO_error_pop(bm, NULL, NULL)) { + /* pass */ + } } void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg) @@ -1526,8 +1558,12 @@ int BMO_error_get(BMesh *bm, const char **msg, BMOperator **op) return 0; } - if (msg) *msg = err->msg; - if (op) *op = err->op; + if (msg) { + *msg = err->msg; + } + if (op) { + *op = err->op; + } return err->errorcode; } @@ -1590,8 +1626,9 @@ int BMO_opcode_from_opname(const char *opname) static int BMO_opcode_from_opname_check(const char *opname) { int i = BMO_opcode_from_opname(opname); - if (i == -1) + if (i == -1) { fprintf(stderr, "%s: could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname); + } return i; } @@ -1702,8 +1739,9 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, fmt += i; /* ignore trailing whitespace */ - if (!fmt[i]) + if (!fmt[i]) { break; + } /* find end of slot name, only "slot=%f", can be used */ i = strcspn(fmt, "="); @@ -1734,9 +1772,9 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, const char c = NEXT_CHAR(fmt); fmt++; - if (c == '3') size = 3; - else if (c == '4') size = 4; - else GOTO_ERROR("matrix size was not 3 or 4"); + if (c == '3') { size = 3; } + else if (c == '4') { size = 4; } + else { GOTO_ERROR("matrix size was not 3 or 4"); } BMO_slot_mat_set(op, op->slots_in, slot_name, va_arg(vlist, void *), size); state = true; @@ -1816,9 +1854,9 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, while (1) { char htype_set; const char c = NEXT_CHAR(fmt); - if (c == 'f') htype_set = BM_FACE; - else if (c == 'e') htype_set = BM_EDGE; - else if (c == 'v') htype_set = BM_VERT; + if (c == 'f') { htype_set = BM_FACE; } + else if (c == 'e') { htype_set = BM_EDGE; } + else if (c == 'v') { htype_set = BM_VERT; } else { break; } diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 03dc9997587..4cc3cf3e4c1 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -635,8 +635,9 @@ void BM_face_calc_center_median_weighted(const BMFace *f, float r_cent[3]) w_prev = w_curr; } while ((l_iter = l_iter->next) != l_first); - if (totw != 0.0f) + if (totw != 0.0f) { mul_v3_fl(r_cent, 1.0f / (float) totw); + } } /** diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c index 7a0d1c7ec5a..4b34e1fe07d 100644 --- a/source/blender/bmesh/intern/bmesh_query.c +++ b/source/blender/bmesh/intern/bmesh_query.c @@ -1179,8 +1179,9 @@ int BM_face_share_face_count(BMFace *f1, BMFace *f2) BM_ITER_ELEM (e, &iter1, f1, BM_EDGES_OF_FACE) { BM_ITER_ELEM (f, &iter2, e, BM_FACES_OF_EDGE) { - if (f != f1 && f != f2 && BM_face_share_edge_check(f, f2)) + if (f != f1 && f != f2 && BM_face_share_edge_check(f, f2)) { count++; + } } } @@ -1198,8 +1199,9 @@ bool BM_face_share_face_check(BMFace *f1, BMFace *f2) BM_ITER_ELEM (e, &iter1, f1, BM_EDGES_OF_FACE) { BM_ITER_ELEM (f, &iter2, e, BM_FACES_OF_EDGE) { - if (f != f1 && f != f2 && BM_face_share_edge_check(f, f2)) + if (f != f1 && f != f2 && BM_face_share_edge_check(f, f2)) { return true; + } } } diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c index e4bad715b29..a90d0d245d0 100644 --- a/source/blender/bmesh/intern/bmesh_structure.c +++ b/source/blender/bmesh/intern/bmesh_structure.c @@ -172,8 +172,9 @@ void bmesh_disk_edge_append(BMEdge *e, BMVert *v) dl1->prev = dl2->prev; dl2->prev = e; - if (dl3) + if (dl3) { dl3->next = e; + } } } @@ -192,8 +193,9 @@ void bmesh_disk_edge_remove(BMEdge *e, BMVert *v) dl2->prev = dl1->prev; } - if (v->e == e) + if (v->e == e) { v->e = (e != dl1->next) ? dl1->next : NULL; + } dl1->next = dl1->prev = NULL; } @@ -387,8 +389,9 @@ bool bmesh_radial_validate(int radlen, BMLoop *l) BMLoop *l_iter = l; int i = 0; - if (bmesh_radial_length(l) != radlen) + if (bmesh_radial_length(l) != radlen) { return false; + } do { if (UNLIKELY(!l_iter)) { @@ -396,10 +399,12 @@ bool bmesh_radial_validate(int radlen, BMLoop *l) return false; } - if (l_iter->e != l->e) + if (l_iter->e != l->e) { return false; - if (l_iter->v != l->e->v1 && l_iter->v != l->e->v2) + } + if (l_iter->v != l->e->v1 && l_iter->v != l->e->v2) { return false; + } if (UNLIKELY(i > BM_LOOP_RADIAL_MAX)) { BMESH_ASSERT(0); @@ -526,8 +531,9 @@ int bmesh_radial_length(const BMLoop *l) const BMLoop *l_iter = l; int i = 0; - if (!l) + if (!l) { return 0; + } do { if (UNLIKELY(!l_iter)) { diff --git a/source/blender/bmesh/intern/bmesh_structure_inline.h b/source/blender/bmesh/intern/bmesh_structure_inline.h index 31c1e6500c9..0998d9bd907 100644 --- a/source/blender/bmesh/intern/bmesh_structure_inline.h +++ b/source/blender/bmesh/intern/bmesh_structure_inline.h @@ -40,20 +40,24 @@ BLI_INLINE BMDiskLink *bmesh_disk_edge_link_from_vert(const BMEdge *e, const BMV ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) BLI_INLINE BMEdge *bmesh_disk_edge_next_safe(const BMEdge *e, const BMVert *v) { - if (v == e->v1) + if (v == e->v1) { return e->v1_disk_link.next; - if (v == e->v2) + } + if (v == e->v2) { return e->v2_disk_link.next; + } return NULL; } ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) BLI_INLINE BMEdge *bmesh_disk_edge_prev_safe(const BMEdge *e, const BMVert *v) { - if (v == e->v1) + if (v == e->v1) { return e->v1_disk_link.prev; - if (v == e->v2) + } + if (v == e->v2) { return e->v2_disk_link.prev; + } return NULL; } diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 67e3a86fbe3..0ac9b958c11 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -1170,8 +1170,9 @@ static void bmw_FaceLoopWalker_begin(BMWalker *walker, void *data) /* BMesh *bm = walker->bm; */ /* UNUSED */ /* int fcount = BM_edge_face_count(e); */ /* UNUSED */ - if (!bmw_FaceLoopWalker_edge_begins_loop(walker, e)) + if (!bmw_FaceLoopWalker_edge_begins_loop(walker, e)) { return; + } lwalk = BMW_state_add(walker); lwalk->l = e->l; @@ -1334,8 +1335,9 @@ static void *bmw_EdgeringWalker_step(BMWalker *walker) lwalk = &owalk; l = lwalk->l; - if (!l) + if (!l) { return lwalk->wireedge; + } e = l->e; if (!EDGE_CHECK(e)) { @@ -1368,7 +1370,6 @@ static void *bmw_EdgeringWalker_step(BMWalker *walker) /* only walk to manifold edge */ if ((l->f->len % 2 == 0) && EDGE_CHECK(l->e) && !BLI_gset_haskey(walker->visit_set, l->e)) - #else l = l->radial_next; @@ -1407,8 +1408,9 @@ static void bmw_EdgeboundaryWalker_begin(BMWalker *walker, void *data) BLI_assert(BM_edge_is_boundary(e)); - if (BLI_gset_haskey(walker->visit_set, e)) + if (BLI_gset_haskey(walker->visit_set, e)) { return; + } lwalk = BMW_state_add(walker); lwalk->e = e; @@ -1483,8 +1485,9 @@ static void bmw_UVEdgeWalker_begin(BMWalker *walker, void *data) BMwUVEdgeWalker *lwalk; BMLoop *l = data; - if (BLI_gset_haskey(walker->visit_set, l)) + if (BLI_gset_haskey(walker->visit_set, l)) { return; + } lwalk = BMW_state_add(walker); lwalk->l = l; @@ -1548,8 +1551,9 @@ static void *bmw_UVEdgeWalker_step(BMWalker *walker) l_other = (l_radial->v != l_pivot->v) ? l_radial->next : l_radial; data_other = BM_ELEM_CD_GET_VOID_P(l_other, offset); - if (!CustomData_data_equals(type, data_pivot, data_other)) + if (!CustomData_data_equals(type, data_pivot, data_other)) { continue; + } lwalk = BMW_state_add(walker); BLI_gset_insert(walker->visit_set, l_radial); diff --git a/source/blender/bmesh/operators/bmo_bridge.c b/source/blender/bmesh/operators/bmo_bridge.c index 896c28dd743..84b5f44a43f 100644 --- a/source/blender/bmesh/operators/bmo_bridge.c +++ b/source/blender/bmesh/operators/bmo_bridge.c @@ -384,10 +384,10 @@ static void bridge_loop_pair( l_b = l_b_next = BM_iter_at_index(bm, BM_LOOPS_OF_VERT, v_b, 0); } - if (l_a && l_a_next == NULL) l_a_next = l_a; - if (l_a_next && l_a == NULL) l_a = l_a_next; - if (l_b && l_b_next == NULL) l_b_next = l_b; - if (l_b_next && l_b == NULL) l_b = l_b_next; + if (l_a && l_a_next == NULL) { l_a_next = l_a; } + if (l_a_next && l_a == NULL) { l_a = l_a_next; } + if (l_b && l_b_next == NULL) { l_b_next = l_b; } + if (l_b_next && l_b == NULL) { l_b = l_b_next; } f_example = l_a ? l_a->f : (l_b ? l_b->f : NULL); if (v_b != v_b_next) { diff --git a/source/blender/bmesh/operators/bmo_connect_concave.c b/source/blender/bmesh/operators/bmo_connect_concave.c index 7e3278853ce..98527482f52 100644 --- a/source/blender/bmesh/operators/bmo_connect_concave.c +++ b/source/blender/bmesh/operators/bmo_connect_concave.c @@ -56,15 +56,15 @@ static int bm_edge_length_cmp(const void *a_, const void *b_) /* merge edges between concave edges last since these * are most likely to remain and be the main dividers */ - if (e_a_concave < e_b_concave) return -1; - else if (e_a_concave > e_b_concave) return 1; + if (e_a_concave < e_b_concave) { return -1; } + else if (e_a_concave > e_b_concave) { return 1; } else { /* otherwise shortest edges last */ const float e_a_len = BM_edge_calc_length_squared(e_a); const float e_b_len = BM_edge_calc_length_squared(e_b); - if (e_a_len < e_b_len) return 1; - else if (e_a_len > e_b_len) return -1; - else return 0; + if (e_a_len < e_b_len) { return 1; } + else if (e_a_len > e_b_len) { return -1; } + else { return 0; } } } diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c index ff4b671784d..001c3004ec9 100644 --- a/source/blender/bmesh/operators/bmo_create.c +++ b/source/blender/bmesh/operators/bmo_create.c @@ -108,13 +108,13 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) const int tot_edges = BMO_iter_elem_count_flag(bm, BM_EDGES_OF_VERT, v, ELE_NEW, true); if (tot_edges == 0) { /* only accept 1 free vert */ - if (v_free == NULL) v_free = v; - else ok = false; /* only ever want one of these */ + if (v_free == NULL) { v_free = v; } + else { ok = false; } /* only ever want one of these */ } else if (tot_edges == 1) { - if (v_a == NULL) v_a = v; - else if (v_b == NULL) v_b = v; - else ok = false; /* only ever want 2 of these */ + if (v_a == NULL) { v_a = v; } + else if (v_b == NULL) { v_b = v; } + else { ok = false; } /* only ever want 2 of these */ } else if (tot_edges == 2) { /* do nothing, regular case */ diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 0c249f84cb2..d04fe2b7146 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -203,8 +203,9 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) goto cleanup; } - while (faces[tot]) + while (faces[tot]) { tot++; + } f_new = BM_faces_join(bm, faces, tot, true); @@ -254,7 +255,9 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) cleanup: /* free/cleanup */ for (i = 0; i < BLI_array_len(regions); i++) { - if (regions[i]) MEM_freeN(regions[i]); + if (regions[i]) { + MEM_freeN(regions[i]); + } } BLI_array_free(regions); diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index b2961c5cb6b..5c7c78eb654 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -333,8 +333,9 @@ void bmo_duplicate_exec(BMesh *bm, BMOperator *op) BMOperator *dupeop = op; BMesh *bm_dst = BMO_slot_ptr_get(op->slots_in, "dest"); - if (!bm_dst) + if (!bm_dst) { bm_dst = bm; + } /* flag input */ BMO_slot_buffer_flag_enable(bm, dupeop->slots_in, "geom", BM_ALL_NOLOOP, DUPE_INPUT); diff --git a/source/blender/bmesh/operators/bmo_edgenet.c b/source/blender/bmesh/operators/bmo_edgenet.c index b974c2aeb79..4334c7bcdcc 100644 --- a/source/blender/bmesh/operators/bmo_edgenet.c +++ b/source/blender/bmesh/operators/bmo_edgenet.c @@ -44,8 +44,9 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op) const bool use_smooth = BMO_slot_bool_get(op->slots_in, "use_smooth"); // const int sides = BMO_slot_int_get(op->slots_in, "sides"); - if (!bm->totvert || !bm->totedge) + if (!bm->totvert || !bm->totedge) { return; + } BM_mesh_elem_hflag_disable_all(bm, BM_EDGE, BM_ELEM_TAG, false); BMO_slot_buffer_hflag_enable(bm, op->slots_in, "edges", BM_EDGE, BM_ELEM_TAG, false); diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index d4c49ae2347..eaf059c7e03 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -258,8 +258,9 @@ void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op) dupev = BM_vert_create(bm, v->co, v, BM_CREATE_NOP); BMO_vert_flag_enable(bm, dupev, EXT_KEEP); - if (has_vskin) + if (has_vskin) { bm_extrude_disable_skin_root(bm, v); + } if (select_history_map) { BMEditSelection *ese; @@ -464,10 +465,12 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) BM_edge_kill(bm, e); /* kill standalone vertices from this edge - see [#32341] */ - if (!v1->e) + if (!v1->e) { BM_vert_kill(bm, v1); - if (!v2->e) + } + if (!v2->e) { BM_vert_kill(bm, v2); + } continue; } @@ -563,7 +566,9 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) } /* cleanup */ - if (delorig) BMO_op_finish(bm, &delop); + if (delorig) { + BMO_op_finish(bm, &delop); + } BMO_op_finish(bm, &dupeop); } diff --git a/source/blender/bmesh/operators/bmo_fill_grid.c b/source/blender/bmesh/operators/bmo_fill_grid.c index ff9ad5135dd..09c174586f8 100644 --- a/source/blender/bmesh/operators/bmo_fill_grid.c +++ b/source/blender/bmesh/operators/bmo_fill_grid.c @@ -89,7 +89,9 @@ static void quad_verts_to_barycentric_tri( normalize_v3(no); } - if (is_flip) negate_v3(no); + if (is_flip) { + negate_v3(no); + } mul_v3_fl(no, len_v3v3(tri[0], tri[1])); mid_v3_v3v3(tri[2], tri[0], tri[1]); diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index 1979cddfa17..664c4b3f615 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -74,8 +74,9 @@ static void hull_add_triangle( t->v[2] = v3; /* Mark triangles vertices as not interior */ - for (i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { BMO_vert_flag_disable(bm, t->v[i], HULL_FLAG_INTERIOR_ELE); + } BLI_gset_insert(hull_triangles, t); normal_tri_v3(t->no, v1->co, v2->co, v3->co); @@ -126,8 +127,9 @@ static void hull_output_triangles(BMesh *bm, GSet *hull_triangles) else { /* Look for an adjacent face that existed before the hull */ for (i = 0; i < 3; i++) { - if (!example) + if (!example) { example = hull_find_example_face(bm, edges[i]); + } } /* Create new hull face */ @@ -178,8 +180,9 @@ static LinkData *final_edges_find_link(ListBase *adj, BMVert *v) LinkData *link; for (link = adj->first; link; link = link->next) { - if (link->data == v) + if (link->data == v) { return link; + } } return NULL; @@ -192,12 +195,14 @@ static int hull_final_edges_lookup( ListBase *adj; /* Use lower vertex pointer for hash key */ - if (v1 > v2) + if (v1 > v2) { SWAP(BMVert *, v1, v2); + } adj = BLI_ghash_lookup(final_edges->edges, v1); - if (!adj) + if (!adj) { return false; + } return !!final_edges_find_link(adj, v2); } @@ -224,8 +229,9 @@ static HullFinalEdges *hull_final_edges(GSet *hull_triangles) ListBase *adj; /* Use lower vertex pointer for hash key */ - if (v1 > v2) + if (v1 > v2) { SWAP(BMVert *, v1, v2); + } adj = BLI_ghash_lookup(final_edges->edges, v1); if (!adj) { @@ -304,8 +310,9 @@ static void hull_mark_interior_elements( /* Check for interior edges too */ BMO_ITER (e, &oiter, op->slots_in, "input", BM_EDGE) { - if (!hull_final_edges_lookup(final_edges, e->v1, e->v2)) + if (!hull_final_edges_lookup(final_edges, e->v1, e->v2)) { BMO_edge_flag_enable(bm, e, HULL_FLAG_INTERIOR_ELE); + } } /* Mark all input faces as interior, some may be unmarked in @@ -409,8 +416,9 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op) } } - if (hole && any_faces) + if (hole && any_faces) { BMO_edge_flag_enable(bm, e, HULL_FLAG_HOLE); + } } } @@ -476,8 +484,9 @@ static BMVert **hull_verts_from_bullet( if (original_index >= 0 && original_index < num_input_verts) { hull_verts[i] = input_verts[original_index]; } - else + else { BLI_assert(!"Unexpected new vertex in hull output"); + } } return hull_verts; @@ -552,8 +561,9 @@ static bool hull_num_input_verts_is_ok(BMOperator *op) BMO_ITER (v, &oiter, op->slots_in, "input", BM_VERT) { partial_num_verts++; - if (partial_num_verts >= 3) + if (partial_num_verts >= 3) { break; + } } return (partial_num_verts >= 3); diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index 72fce49f41f..3534d798b02 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -174,8 +174,9 @@ static void bm_loop_customdata_merge( for (layer_n = 0; layer_n < bm->ldata.totlayer; layer_n++) { const int type = bm->ldata.layers[layer_n].type; const int offset = bm->ldata.layers[layer_n].offset; - if (!CustomData_layer_has_math(&bm->ldata, layer_n)) + if (!CustomData_layer_has_math(&bm->ldata, layer_n)) { continue; + } /* check we begin with merged data */ if ((CustomData_data_equals( diff --git a/source/blender/bmesh/operators/bmo_join_triangles.c b/source/blender/bmesh/operators/bmo_join_triangles.c index 7ff7cbbe1ac..19d01cb2e08 100644 --- a/source/blender/bmesh/operators/bmo_join_triangles.c +++ b/source/blender/bmesh/operators/bmo_join_triangles.c @@ -339,8 +339,9 @@ void bmo_join_triangles_exec(BMesh *bm, BMOperator *op) const BMVert *verts[4]; float error; - if (!BMO_edge_flag_test(bm, e, EDGE_MARK)) + if (!BMO_edge_flag_test(bm, e, EDGE_MARK)) { continue; + } bm_edge_to_quad_verts(e, verts); diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c index e3bf4b00968..2ef96d1df03 100644 --- a/source/blender/bmesh/operators/bmo_mirror.c +++ b/source/blender/bmesh/operators/bmo_mirror.c @@ -93,10 +93,12 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { for (i = 0; i < totlayer; i++) { luv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i); - if (mirror_u) + if (mirror_u) { luv->uv[0] = 1.0f - luv->uv[0]; - if (mirror_v) + } + if (mirror_v) { luv->uv[1] = 1.0f - luv->uv[1]; + } } } } @@ -109,6 +111,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_ALL_NOLOOP, ELE_NEW); - if (vmap) + if (vmap) { MEM_freeN(vmap); + } } diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index 12962dd281c..ae9adfbcbba 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -840,8 +840,9 @@ void BM_mesh_calc_uvs_grid( BLI_assert(cd_loop_uv_offset != -1); BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - if (!BMO_face_flag_test(bm, f, oflag)) + if (!BMO_face_flag_test(bm, f, oflag)) { continue; + } BM_ITER_ELEM_INDEX (l, &liter, f, BM_LOOPS_OF_FACE, loop_index) { MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -938,8 +939,9 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op) prevop = bmop; } - if (a) + if (a) { BMO_op_finish(bm, &bmop); + } { float len, len2, vec2[3]; @@ -1166,8 +1168,9 @@ void BM_mesh_calc_uvs_sphere( BLI_assert(cd_loop_uv_offset != -1); /* caller is responsible for giving us UVs */ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - if (!BMO_face_flag_test(bm, f, oflag)) + if (!BMO_face_flag_test(bm, f, oflag)) { continue; + } bm_mesh_calc_uvs_sphere_face(f, cd_loop_uv_offset); } @@ -1178,8 +1181,9 @@ void BM_mesh_calc_uvs_sphere( float minx = 1.0f; BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - if (!BMO_face_flag_test(bm, f, oflag)) + if (!BMO_face_flag_test(bm, f, oflag)) { continue; + } BM_ITER_ELEM_INDEX (l, &iter2, f, BM_LOOPS_OF_FACE, loop_index) { MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); if (luv->uv[0] < minx) { @@ -1189,8 +1193,9 @@ void BM_mesh_calc_uvs_sphere( } BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - if (!BMO_face_flag_test(bm, f, oflag)) + if (!BMO_face_flag_test(bm, f, oflag)) { continue; + } BM_ITER_ELEM_INDEX (l, &iter2, f, BM_LOOPS_OF_FACE, loop_index) { MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); luv->uv[0] -= minx; @@ -1291,8 +1296,9 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op) float vec[3], mat[4][4], phi, phid; int a; - if (!segs) + if (!segs) { return; + } BMO_slot_mat4_get(op->slots_in, "matrix", mat); @@ -1317,8 +1323,9 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op) BMO_vert_flag_enable(bm, v1, VERT_MARK); - if (lastv1) + if (lastv1) { BM_edge_create(bm, v1, lastv1, NULL, BM_CREATE_NOP); + } if (a && cap_ends) { BMFace *f; @@ -1327,14 +1334,16 @@ void bmo_create_circle_exec(BMesh *bm, BMOperator *op) BMO_face_flag_enable(bm, f, FACE_NEW); } - if (!firstv1) + if (!firstv1) { firstv1 = v1; + } lastv1 = v1; } - if (!a) + if (!a) { return; + } BM_edge_create(bm, firstv1, lastv1, NULL, 0); @@ -1382,8 +1391,9 @@ void BM_mesh_calc_uvs_circle( invert_m4_m4(inv_mat, mat); BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - if (!BMO_face_flag_test(bm, f, oflag)) + if (!BMO_face_flag_test(bm, f, oflag)) { continue; + } BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -1416,8 +1426,9 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op) const bool calc_uvs = (cd_loop_uv_offset != -1) && BMO_slot_bool_get(op->slots_in, "calc_uvs"); int a; - if (!segs) + if (!segs) { return; + } BMO_slot_mat4_get(op->slots_in, "matrix", mat); @@ -1487,8 +1498,9 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op) lastv2 = v2; } - if (!a) + if (!a) { return; + } if (cap_ends) { f = BM_face_create_quad_tri(bm, cent1, v1, firstv1, NULL, NULL, BM_CREATE_NOP); @@ -1574,8 +1586,9 @@ void BM_mesh_calc_uvs_cone( y = 1.0f - uv_height; BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - if (!BMO_face_flag_test(bm, f, oflag)) + if (!BMO_face_flag_test(bm, f, oflag)) { continue; + } if (f->len == 4 && radius_top && radius_bottom) { /* side face - so unwrap it in a rectangle */ @@ -1647,7 +1660,9 @@ void bmo_create_cube_exec(BMesh *bm, BMOperator *op) BMO_slot_mat4_get(op->slots_in, "matrix", mat); - if (!off) off = 0.5f; + if (!off) { + off = 0.5f; + } int i = 0; for (int x = -1; x < 2; x += 2) { diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index eba8c37f1e0..e59bad0d682 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -230,10 +230,12 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op) const bool is_del_v2 = BMO_vert_flag_test_bool(bm, (v2 = e->v2), ELE_DEL); if (is_del_v1 || is_del_v2) { - if (is_del_v1) + if (is_del_v1) { v1 = BMO_slot_map_elem_get(slot_targetmap, v1); - if (is_del_v2) + } + if (is_del_v2) { v2 = BMO_slot_map_elem_get(slot_targetmap, v2); + } if (v1 == v2) { BMO_edge_flag_enable(bm, e, EDGE_COL); @@ -337,8 +339,9 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op) vert_snap = BMO_slot_buffer_get_single(BMO_slot_get(op->slots_in, "vert_snap")); tot = BM_vert_face_count(vert_snap); - if (!tot) + if (!tot) { return; + } fac = 1.0f / tot; BM_ITER_ELEM (l, &iter, vert_snap, BM_LOOPS_OF_VERT) { @@ -388,8 +391,9 @@ void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op) const int type = bm->ldata.layers[i].type; const int offset = bm->ldata.layers[i].offset; - if (!CustomData_layer_has_math(&bm->ldata, i)) + if (!CustomData_layer_has_math(&bm->ldata, i)) { continue; + } CustomData_data_initminmax(type, &min, &max); @@ -474,8 +478,9 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op) zero_v3(center); - if (!BMO_edge_flag_test(bm, e, EDGE_MARK)) + if (!BMO_edge_flag_test(bm, e, EDGE_MARK)) { continue; + } BLI_assert(BLI_stack_is_empty(edge_stack)); @@ -598,8 +603,9 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op) #endif for (i = 0; i < bm->ldata.totlayer; i++) { - if (CustomData_layer_has_math(&bm->ldata, i)) + if (CustomData_layer_has_math(&bm->ldata, i)) { bmo_collapsecon_do_layer(bm, i, oflag); + } } #ifndef NDEBUG diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c index acdb49e94e1..bf376a757ef 100644 --- a/source/blender/bmesh/operators/bmo_smooth_laplacian.c +++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c @@ -229,13 +229,17 @@ static void init_laplacian_matrix(LaplacianSystem *sys) sys->zerola[idv1] = 1; sys->zerola[idv2] = 1; sys->zerola[idv3] = 1; - if (has_4_vert) sys->zerola[idv4] = 1; + if (has_4_vert) { + sys->zerola[idv4] = 1; + } } sys->ring_areas[idv1] += areaf; sys->ring_areas[idv2] += areaf; sys->ring_areas[idv3] += areaf; - if (has_4_vert) sys->ring_areas[idv4] += areaf; + if (has_4_vert) { + sys->ring_areas[idv4] += areaf; + } if (has_4_vert) { @@ -478,9 +482,13 @@ void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op) BMVert *v; LaplacianSystem *sys; - if (bm->totface == 0) return; + if (bm->totface == 0) { + return; + } sys = init_laplacian_system(bm->totedge, bm->totface, bm->totvert); - if (!sys) return; + if (!sys) { + return; + } sys->bm = bm; sys->op = op; diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 360b1fea4d2..6b7f81aabb6 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -151,7 +151,9 @@ static BMEdge *connect_smallest_face(BMesh *bm, BMVert *v_a, BMVert *v_b, BMFace f_new = BM_face_split(bm, f, l_a, l_b, &l_new, NULL, false); - if (r_f_new) *r_f_new = f_new; + if (r_f_new) { + *r_f_new = f_new; + } return l_new ? l_new->e : NULL; } @@ -448,8 +450,12 @@ static void bm_subdivide_multicut( BMO_edge_flag_enable(bm, e_new, SUBD_SPLIT | ELE_SPLIT); BM_CHECK_ELEMENT(v); - if (v->e) BM_CHECK_ELEMENT(v->e); - if (v->e && v->e->l) BM_CHECK_ELEMENT(v->e->l->f); + if (v->e) { + BM_CHECK_ELEMENT(v->e); + } + if (v->e && v->e->l) { + BM_CHECK_ELEMENT(v->e->l->f); + } } alter_co(v1, &e_tmp, params, 0, &v1_tmp, &v2_tmp); @@ -689,8 +695,9 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts b = numcuts + 1 + numcuts + 1 + (numcuts - i - 1); e = connect_smallest_face(bm, verts[a], verts[b], &f_new); - if (!e) + if (!e) { continue; + } BMO_edge_flag_enable(bm, e, ELE_INNER); BMO_face_flag_enable(bm, f_new, ELE_INNER); @@ -715,8 +722,9 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts a = i * s + j; b = (i - 1) * s + j; e = connect_smallest_face(bm, lines[a], lines[b], &f_new); - if (!e) + if (!e) { continue; + } BMO_edge_flag_enable(bm, e, ELE_INNER); BMO_face_flag_enable(bm, f_new, ELE_INNER); @@ -794,7 +802,9 @@ static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, a = numcuts * 2 + 2 + i; b = numcuts + numcuts - i; e = connect_smallest_face(bm, verts[a], verts[b], &f_new); - if (!e) goto cleanup; + if (!e) { + goto cleanup; + } BMO_edge_flag_enable(bm, e, ELE_INNER); BMO_face_flag_enable(bm, f_new, ELE_INNER); @@ -843,7 +853,9 @@ static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, cleanup: for (i = 1; i < numcuts + 2; i++) { - if (lines[i]) MEM_freeN(lines[i]); + if (lines[i]) { + MEM_freeN(lines[i]); + } } MEM_freeN(lines); @@ -1001,8 +1013,9 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) bool matched = false; /* skip non-quads if requested */ - if (use_only_quads && face->len != 4) + if (use_only_quads && face->len != 4) { continue; + } /* figure out which pattern to use */ @@ -1018,8 +1031,8 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) verts[i] = l_new->v; if (BMO_edge_flag_test(bm, edges[i], SUBD_SPLIT)) { - if (!e1) e1 = edges[i]; - else e2 = edges[i]; + if (!e1) { e1 = edges[i]; } + else { e2 = edges[i]; } totesel++; } @@ -1278,8 +1291,12 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) BM_data_layer_free_n(bm, &bm->vdata, CD_SHAPEKEY, params.shape_info.tmpkey); BLI_stack_free(facedata); - if (edges) BLI_array_free(edges); - if (verts) BLI_array_free(verts); + if (edges) { + BLI_array_free(edges); + } + if (verts) { + BLI_array_free(verts); + } BLI_array_free(loops_split); BLI_array_free(loops); diff --git a/source/blender/bmesh/operators/bmo_subdivide_edgering.c b/source/blender/bmesh/operators/bmo_subdivide_edgering.c index 04a5cf316be..8c5ee4ede3d 100644 --- a/source/blender/bmesh/operators/bmo_subdivide_edgering.c +++ b/source/blender/bmesh/operators/bmo_subdivide_edgering.c @@ -249,8 +249,9 @@ static GSet *bm_edgering_pair_calc(BMesh *bm, ListBase *eloops_rim) pair_test.first = el_store; pair_test.second = el_store_other; - if (pair_test.first > pair_test.second) + if (pair_test.first > pair_test.second) { SWAP(const void *, pair_test.first, pair_test.second); + } void **pair_key_p; if (!BLI_gset_ensure_p_ex(eloop_pair_gs, &pair_test, &pair_key_p)) { @@ -693,8 +694,8 @@ static void bm_edgering_pair_interpolate( /* create the triangle and transform */ for (j = 0; j < 3; j++) { zero_v3(tri_tmp[j]); - if (j == 1) tri_tmp[j][0] = shape_size; - else if (j == 2) tri_tmp[j][1] = shape_size; + if (j == 1) { tri_tmp[j][0] = shape_size; } + else if (j == 2) { tri_tmp[j][1] = shape_size; } mul_qt_v3(quat_array[i], tri_tmp[j]); add_v3_v3(tri_tmp[j], coord_array_main[i]); } diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index 3e99d5fb814..2439b5fe2b2 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -399,24 +399,30 @@ void bmo_smooth_vert_exec(BMesh *UNUSED(bm), BMOperator *op) mul_v3_fl(co, 1.0f / (float)j); interp_v3_v3v3(co, v->co, co, fac); - if (clipx && fabsf(v->co[0]) <= clip_dist) + if (clipx && fabsf(v->co[0]) <= clip_dist) { co[0] = 0.0f; - if (clipy && fabsf(v->co[1]) <= clip_dist) + } + if (clipy && fabsf(v->co[1]) <= clip_dist) { co[1] = 0.0f; - if (clipz && fabsf(v->co[2]) <= clip_dist) + } + if (clipz && fabsf(v->co[2]) <= clip_dist) { co[2] = 0.0f; + } i++; } i = 0; BMO_ITER (v, &siter, op->slots_in, "verts", BM_VERT) { - if (xaxis) + if (xaxis) { v->co[0] = cos[i][0]; - if (yaxis) + } + if (yaxis) { v->co[1] = cos[i][1]; - if (zaxis) + } + if (zaxis) { v->co[2] = cos[i][2]; + } i++; } diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index f629c054f8c..284df9f9bc9 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -240,26 +240,30 @@ static int bev_debug_flags = 0; /* If we're called from the modifier, tool flags aren't available, but don't need output geometry */ static void flag_out_edge(BMesh *bm, BMEdge *bme) { - if (bm->use_toolflags) + if (bm->use_toolflags) { BMO_edge_flag_enable(bm, bme, EDGE_OUT); + } } static void flag_out_vert(BMesh *bm, BMVert *bmv) { - if (bm->use_toolflags) + if (bm->use_toolflags) { BMO_vert_flag_enable(bm, bmv, VERT_OUT); + } } static void disable_flag_out_edge(BMesh *bm, BMEdge *bme) { - if (bm->use_toolflags) + if (bm->use_toolflags) { BMO_edge_flag_disable(bm, bme, EDGE_OUT); + } } static void record_face_kind(BevelParams *bp, BMFace *f, FKind fkind) { - if (bp->face_hash) + if (bp->face_hash) { BLI_ghash_insert(bp->face_hash, f, POINTER_FROM_INT(fkind)); + } } static FKind get_face_kind(BevelParams *bp, BMFace *f) @@ -352,8 +356,9 @@ static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme) int i; for (i = 0; i < bv->edgecount; i++) { - if (bv->edges[i].e == bme) + if (bv->edges[i].e == bme) { return &bv->edges[i]; + } } return NULL; } @@ -374,8 +379,9 @@ static EdgeHalf *find_other_end_edge_half(BevelParams *bp, EdgeHalf *e, BevVert bvo = find_bevvert(bp, e->is_rev ? e->e->v1 : e->e->v2); if (bvo) { - if (r_bvother) + if (r_bvother) { *r_bvother = bvo; + } eother = find_edge_half(bvo, e->e); BLI_assert(eother != NULL); return eother; @@ -392,8 +398,9 @@ static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e) { EdgeHalf *e; - if (from_e == NULL) + if (from_e == NULL) { from_e = &bv->edges[bv->edgecount - 1]; + } e = from_e; do { if (e->is_bev) { @@ -410,8 +417,9 @@ static int count_ccw_edges_between(EdgeHalf *e1, EdgeHalf *e2) EdgeHalf *e = e1; do { - if (e == e2) + if (e == e2) { break; + } e = e->next; cnt++; } while (e != e1); @@ -427,8 +435,9 @@ static bool edges_face_connected_at_vert(BMEdge *bme1, BMEdge *bme2) BMIter iter; BM_ITER_ELEM(l, &iter, bme1, BM_LOOPS_OF_EDGE) { - if (l->prev->e == bme2 || l->next->e == bme2) + if (l->prev->e == bme2 || l->next->e == bme2) { return true; + } } return false; } @@ -445,23 +454,28 @@ static BMFace *boundvert_rep_face(BoundVert *v, BMFace **r_fother) frep2 = NULL; if (v->ebev) { frep = v->ebev->fprev; - if (v->efirst->fprev != frep) + if (v->efirst->fprev != frep) { frep2 = v->efirst->fprev; + } } else if (v->efirst) { frep = v->efirst->fprev; if (frep) { - if (v->elast->fnext != frep) + if (v->elast->fnext != frep) { frep2 = v->elast->fnext; - else if (v->efirst->fnext != frep) + } + else if (v->efirst->fnext != frep) { frep2 = v->efirst->fnext; - else if (v->elast->fprev != frep) + } + else if (v->elast->fprev != frep) { frep2 = v->efirst->fprev; + } } else if (v->efirst->fnext) { frep = v->efirst->fnext; - if (v->elast->fnext != frep) + if (v->elast->fnext != frep) { frep2 = v->elast->fnext; + } } else if (v->elast->fprev) { frep = v->elast->fprev; @@ -470,17 +484,20 @@ static BMFace *boundvert_rep_face(BoundVert *v, BMFace **r_fother) else if (v->prev->elast) { frep = v->prev->elast->fnext; if (v->next->efirst) { - if (frep) + if (frep) { frep2 = v->next->efirst->fprev; - else + } + else { frep = v->next->efirst->fprev; + } } } else { frep = NULL; } - if (r_fother) + if (r_fother) { *r_fother = frep2; + } return frep; } @@ -523,8 +540,9 @@ static BMFace *bev_create_ngon( } if (interp_f) { bme = NULL; - if (edge_arr) + if (edge_arr) { bme = edge_arr[i]; + } if (bme) { copy_v3_v3(save_co, l->v->co); closest_to_line_segment_v3(l->v->co, save_co, bme->v1->co, bme->v2->co); @@ -548,8 +566,9 @@ static BMFace *bev_create_ngon( } } - if (mat_nr >= 0) + if (mat_nr >= 0) { f->mat_nr = mat_nr; + } return f; } @@ -596,13 +615,15 @@ static bool contig_ldata_across_edge(BMesh *bm, BMEdge *e, BMFace *f1, BMFace *f BMVert *v1, *v2; int i; - if (bm->ldata.totlayer == 0) + if (bm->ldata.totlayer == 0) { return true; + } v1 = e->v1; v2 = e->v2; - if (!BM_edge_loop_pair(e, &lef1, &lef2)) + if (!BM_edge_loop_pair(e, &lef1, &lef2)) { return false; + } if (lef1->f == f2) { SWAP(BMLoop *, lef1, lef2); } @@ -651,8 +672,9 @@ static void bev_merge_uvs(BMesh *bm, BMVert *v) for (i = 0; i < num_of_uv_layers; i++) { int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i); - if (cd_loop_uv_offset == -1) + if (cd_loop_uv_offset == -1) { return; + } n = 0; zero_v2(uv); @@ -685,19 +707,23 @@ static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v) l1 = NULL; l2 = NULL; BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { - if (l->e == bme) + if (l->e == bme) { l1 = l; - else if (l->prev->e == bme) + } + else if (l->prev->e == bme) { l2 = l; + } } - if (l1 == NULL || l2 == NULL) + if (l1 == NULL || l2 == NULL) { return; + } for (i = 0; i < num_of_uv_layers; i++) { int cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, i); - if (cd_loop_uv_offset == -1) + if (cd_loop_uv_offset == -1) { return; + } zero_v2(uv); luv = BM_ELEM_CD_GET_VOID_P(l1, cd_loop_uv_offset); @@ -719,8 +745,9 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float slideco[3]) sub_v3_v3v3(dir, v->co, BM_edge_other_vert(e->e, v)->co); len = normalize_v3(dir); - if (d > len) + if (d > len) { d = len - (float)(50.0 * BEVEL_EPSILON_D); + } copy_v3_v3(slideco, v->co); madd_v3_v3fl(slideco, dir, -d); } @@ -762,19 +789,25 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v) /* angles are in [0,pi]. need to compare cross product with normal to see if they are reflex */ cross_v3_v3v3(cross, dir1, dir2); normalize_v3(cross); - if (e1->fnext) + if (e1->fnext) { no = e1->fnext->no; - else if (e2->fprev) + } + else if (e2->fprev) { no = e2->fprev->no; - else + } + else { no = v->no; + } dot = dot_v3v3(cross, no); - if (fabsf(dot) < BEVEL_EPSILON_BIG) + if (fabsf(dot) < BEVEL_EPSILON_BIG) { return 0; - else if (dot < 0.0f) + } + else if (dot < 0.0f) { return 1; - else + } + else { return -1; + } } /* co should be approximately on the plane between e1 and e2, which share common vert v @@ -798,11 +831,13 @@ static bool point_between_edges(float co[3], BMVert *v, BMFace *f, EdgeHalf *e1, ang1co = angle_normalized_v3v3(dir1, dirco); /* angles are in [0,pi]. need to compare cross product with normal to see if they are reflex */ cross_v3_v3v3(no, dir1, dir2); - if (dot_v3v3(no, f->no) < 0.0f) + if (dot_v3v3(no, f->no) < 0.0f) { ang11 = (float)(M_PI * 2.0) - ang11; + } cross_v3_v3v3(no, dir1, dirco); - if (dot_v3v3(no, f->no) < 0.0f) + if (dot_v3v3(no, f->no) < 0.0f) { ang1co = (float)(M_PI * 2.0) - ang1co; + } return (ang11 - ang1co > -BEVEL_EPSILON_ANG); } @@ -858,10 +893,12 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool e * if offsets are different, we're out of luck: * use the max of the two (so get consistent looking results if the same situation * arises elsewhere in the object but with opposite roles for e1 and e2 */ - if (f) + if (f) { copy_v3_v3(norm_v, f->no); - else + } + else { copy_v3_v3(norm_v, v->no); + } add_v3_v3(dir1, dir2); cross_v3_v3v3(norm_perp1, dir1, norm_v); normalize_v3(norm_perp1); @@ -896,8 +933,9 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool e else if (!edges_between) { cross_v3_v3v3(norm_v1, dir2, dir1); normalize_v3(norm_v1); - if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f) + if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f) { negate_v3(norm_v1); + } copy_v3_v3(norm_v2, norm_v1); } else { @@ -905,13 +943,15 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool e cross_v3_v3v3(norm_v1, dir1n, dir1); normalize_v3(norm_v1); f = e1->fnext; - if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f) + if (dot_v3v3(norm_v1, f ? f->no : v->no) < 0.0f) { negate_v3(norm_v1); + } cross_v3_v3v3(norm_v2, dir2, dir2p); normalize_v3(norm_v2); f = e2->fprev; - if (dot_v3v3(norm_v2, f ? f->no : v->no) < 0.0f) + if (dot_v3v3(norm_v2, f ? f->no : v->no) < 0.0f) { negate_v3(norm_v2); + } } /* get vectors perp to each edge, perp to norm_v, and pointing into face */ @@ -954,8 +994,9 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, BMFace *f, bool e } for (e = e1; e != e2; e = e->next) { ff = e->fnext; - if (!ff) + if (!ff) { continue; + } plane_from_point_normal_v3(plane, v->co, ff->no); closest_to_plane_normalized_v3(dropco, plane, meetco); if (point_between_edges(dropco, v, ff, e, e->next)) { @@ -988,30 +1029,36 @@ static bool offset_meet_edge(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetc /* find angle from dir1 to dir2 as viewed from vertex normal side */ ang = angle_normalized_v3v3(dir1, dir2); if (fabsf(ang) < BEVEL_GOOD_ANGLE) { - if (r_angle) + if (r_angle) { *r_angle = 0.0f; + } return false; } cross_v3_v3v3(fno, dir1, dir2); if (dot_v3v3(fno, v->no) < 0.0f) { ang = 2.0f * (float)M_PI - ang; /* angle is reflex */ - if (r_angle) + if (r_angle) { *r_angle = ang; + } return false; } - if (r_angle) + if (r_angle) { *r_angle = ang; + } - if (fabsf(ang - (float)M_PI) < BEVEL_GOOD_ANGLE) + if (fabsf(ang - (float)M_PI) < BEVEL_GOOD_ANGLE) { return false; + } sinang = sinf(ang); copy_v3_v3(meetco, v->co); - if (e1->offset_r == 0.0f) + if (e1->offset_r == 0.0f) { madd_v3_v3fl(meetco, dir1, e2->offset_l / sinang); - else + } + else { madd_v3_v3fl(meetco, dir2, e1->offset_r / sinang); + } return true; } @@ -1046,9 +1093,10 @@ static bool offset_on_edge_between( ok2 = offset_meet_edge(emid, e2, v, meet2, &ang2); if (ok1 && ok2) { mid_v3_v3v3(meetco, meet1, meet2); - if (r_sinratio) + if (r_sinratio) { /* ang1 should not be 0, but be paranoid */ *r_sinratio = (ang1 == 0.0f) ? 1.0f : sinf(ang2) / sinf(ang1); + } retval = true; } else if (ok1 && !ok2) { @@ -1083,15 +1131,19 @@ static void offset_in_plane(EdgeHalf *e, const float plane_no[3], bool left, flo } else { zero_v3(no); - if (fabsf(dir[0]) < fabsf(dir[1])) + if (fabsf(dir[0]) < fabsf(dir[1])) { no[0] = 1.0f; - else + } + else { no[1] = 1.0f; + } } - if (left) + if (left) { cross_v3_v3v3(fdir, dir, no); - else + } + else { cross_v3_v3v3(fdir, no, dir); + } normalize_v3(fdir); copy_v3_v3(r, v->co); madd_v3_v3fl(r, fdir, left ? e->offset_l : e->offset_r); @@ -1255,16 +1307,18 @@ static void move_profile_plane(BoundVert *bndv, EdgeHalf *e1, EdgeHalf *e2) float d1[3], d2[3], no[3], no2[3], dot; /* only do this if projecting, and e1, e2, and proj_dir are not coplanar */ - if (is_zero_v3(bndv->profile.proj_dir)) + if (is_zero_v3(bndv->profile.proj_dir)) { return; + } sub_v3_v3v3(d1, e1->e->v1->co, e1->e->v2->co); sub_v3_v3v3(d2, e2->e->v1->co, e2->e->v2->co); cross_v3_v3v3(no, d1, d2); cross_v3_v3v3(no2, d1, bndv->profile.proj_dir); if (normalize_v3(no) > BEVEL_EPSILON_BIG && normalize_v3(no2) > BEVEL_EPSILON_BIG) { dot = fabsf(dot_v3v3(no, no2)); - if (fabsf(dot - 1.0f) > BEVEL_EPSILON_BIG) + if (fabsf(dot - 1.0f) > BEVEL_EPSILON_BIG) { copy_v3_v3(bndv->profile.plane_no, no); + } } } @@ -1278,8 +1332,9 @@ static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *b float d1[3], d2[3], no[3], no2[3], no3[3], dot1, dot2, l1, l2, l3; /* only do this if projecting, and d1, d2, and proj_dir are not coplanar */ - if (is_zero_v3(bndv1->profile.proj_dir) || is_zero_v3(bndv2->profile.proj_dir)) + if (is_zero_v3(bndv1->profile.proj_dir) || is_zero_v3(bndv2->profile.proj_dir)) { return; + } sub_v3_v3v3(d1, bv->v->co, bndv1->nv.co); sub_v3_v3v3(d2, bv->v->co, bndv2->nv.co); cross_v3_v3v3(no, d1, d2); @@ -1293,10 +1348,12 @@ static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *b if (l1 > BEVEL_EPSILON && (l2 > BEVEL_EPSILON || l3 > BEVEL_EPSILON)) { dot1 = fabsf(dot_v3v3(no, no2)); dot2 = fabsf(dot_v3v3(no, no3)); - if (fabsf(dot1 - 1.0f) > BEVEL_EPSILON) + if (fabsf(dot1 - 1.0f) > BEVEL_EPSILON) { copy_v3_v3(bndv1->profile.plane_no, no); - if (fabsf(dot2 - 1.0f) > BEVEL_EPSILON) + } + if (fabsf(dot2 - 1.0f) > BEVEL_EPSILON) { copy_v3_v3(bndv2->profile.plane_no, no); + } } } @@ -1306,12 +1363,14 @@ static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f) { BMLoop *la, *lb; - if (!f) + if (!f) { return 0; + } la = BM_face_edge_share_loop(f, a); lb = BM_face_edge_share_loop(f, b); - if (!la || !lb) + if (!la || !lb) { return 0; + } return lb->next == la ? 1 : -1; } @@ -1450,10 +1509,12 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int n, int d; if (bp->seg == 1) { - if (i == 0) + if (i == 0) { copy_v3_v3(r_co, pro->coa); - else + } + else { copy_v3_v3(r_co, pro->cob); + } } else { @@ -1487,22 +1548,27 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv) bool need_2, map_ok; Profile *pro = &bndv->profile; - if (bp->seg == 1) + if (bp->seg == 1) { return; + } need_2 = bp->seg != bp->pro_spacing.seg_2; if (!pro->prof_co) { pro->prof_co = (float *)BLI_memarena_alloc(bp->mem_arena, (bp->seg + 1) * 3 * sizeof(float)); - if (need_2) + if (need_2) { pro->prof_co_2 = (float *)BLI_memarena_alloc(bp->mem_arena, (bp->pro_spacing.seg_2 + 1) * 3 *sizeof(float)); - else + } + else { pro->prof_co_2 = pro->prof_co; + } } r = pro->super_r; - if (r == PRO_LINE_R) + if (r == PRO_LINE_R) { map_ok = false; - else + } + else { map_ok = make_unit_square_map(pro->coa, pro->midco, pro->cob, m); + } for (i = 0; i < 2; i++) { if (i == 0) { ns = bp->seg; @@ -1511,8 +1577,9 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv) prof_co = pro->prof_co; } else { - if (!need_2) + if (!need_2) { break; /* shares coords with pro->prof_co */ + } ns = bp->pro_spacing.seg_2; xvals = bp->pro_spacing.xvals_2; yvals = bp->pro_spacing.yvals_2; @@ -1520,10 +1587,12 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv) } BLI_assert((r == PRO_LINE_R || (xvals != NULL && yvals != NULL)) && prof_co != NULL); for (k = 0; k <= ns; k++) { - if (k == 0) + if (k == 0) { copy_v3_v3(co, pro->coa); - else if (k == ns) + } + else if (k == ns) { copy_v3_v3(co, pro->cob); + } else { if (map_ok) { p[0] = xvals[k]; @@ -1631,13 +1700,15 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg) /* First first edge with seam or sharp edge data */ while ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(e, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag))) { e = e->next; - if (e == efirst) + if (e == efirst) { break; + } } /* If no such edge found, return */ - if ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(e, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag))) + if ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(e, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag))) { return; + } /* Set efirst to this first encountered edge. */ efirst = e; @@ -1649,8 +1720,9 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg) while (((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(ne, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(ne, flag))) && ne != efirst) { - if (ne->is_bev) + if (ne->is_bev) { flag_count++; + } ne = ne->next; } if (ne == e || (ne == efirst && ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(efirst, flag)) || @@ -1678,8 +1750,9 @@ static void bevel_extend_edge_data(BevVert *bv) do { /* If current boundvert has a seam length > 0 then it has a seam running along its edges */ if (bcur->seam_len) { - if (!bv->vmesh->boundstart->seam_len && start == bv->vmesh->boundstart) + if (!bv->vmesh->boundstart->seam_len && start == bv->vmesh->boundstart) { start = bcur; /* set start to first boundvert with seam_len > 0 */ + } /* Now for all the mesh_verts starting at current index and ending at idxlen * We go through outermost ring and through all its segments and add seams @@ -1694,10 +1767,12 @@ static void bevel_extend_edge_data(BevVert *bv) /* Here v1 & v2 are current and next BMverts, we find common edge and set its edge data */ e = v1->e; while (e->v1 != v2 && e->v2 != v2) { - if (e->v1 == v1) + if (e->v1 == v1) { e = e->v1_disk_link.next; - else + } + else { e = e->v2_disk_link.next; + } } BM_elem_flag_set(e, BM_ELEM_SEAM, true); v1 = v2; @@ -1705,17 +1780,20 @@ static void bevel_extend_edge_data(BevVert *bv) BMVert *v3 = mesh_vert(vm, (i + 1) % vm->count, 0, 0)->v; e = v1->e; //Do same as above for first and last vert while (e->v1 != v3 && e->v2 != v3) { - if (e->v1 == v1) + if (e->v1 == v1) { e = e->v1_disk_link.next; - else + } + else { e = e->v2_disk_link.next; + } } BM_elem_flag_set(e, BM_ELEM_SEAM, true); bcur = bcur->next; } } - else + else { bcur = bcur->next; + } } while (bcur != start); @@ -1723,8 +1801,9 @@ static void bevel_extend_edge_data(BevVert *bv) start = bcur; do { if (bcur->sharp_len) { - if (!bv->vmesh->boundstart->sharp_len && start == bv->vmesh->boundstart) + if (!bv->vmesh->boundstart->sharp_len && start == bv->vmesh->boundstart) { start = bcur; + } int idxlen = bcur->index + bcur->sharp_len; for (int i = bcur->index; i < idxlen; i++) { @@ -1735,10 +1814,12 @@ static void bevel_extend_edge_data(BevVert *bv) e = v1->e; while (e->v1 != v2 && e->v2 != v2) { - if (e->v1 == v1) + if (e->v1 == v1) { e = e->v1_disk_link.next; - else + } + else { e = e->v2_disk_link.next; + } } BM_elem_flag_set(e, BM_ELEM_SMOOTH, false); v1 = v2; @@ -1746,17 +1827,20 @@ static void bevel_extend_edge_data(BevVert *bv) BMVert *v3 = mesh_vert(vm, (i + 1) % vm->count, 0, 0)->v; e = v1->e; while (e->v1 != v3 && e->v2 != v3) { - if (e->v1 == v1) + if (e->v1 == v1) { e = e->v1_disk_link.next; - else + } + else { e = e->v2_disk_link.next; + } } BM_elem_flag_set(e, BM_ELEM_SMOOTH, false); bcur = bcur->next; } } - else + else { bcur = bcur->next; + } } while (bcur != start); } @@ -1769,10 +1853,12 @@ static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp) FKind fkind; BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) { - if (!BM_elem_flag_test(f, BM_ELEM_SMOOTH)) + if (!BM_elem_flag_test(f, BM_ELEM_SMOOTH)) { continue; - if (get_face_kind(bp, f) != F_RECON) + } + if (get_face_kind(bp, f) != F_RECON) { continue; + } BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) { /* cases we care about will have exactly one adjacent face */ lother = l->radial_next; @@ -1805,8 +1891,9 @@ static void bevel_harden_normals(BMesh *bm, BevelParams *bp) short *clnors; float *pnorm, norm[3]; - if (bp->offset == 0.0 || !bp->harden_normals) + if (bp->offset == 0.0 || !bp->harden_normals) { return; + } /* recalculate all face and vertex normals; side effect: ensures vertex, edge, face indices */ /* I suspect this is not necessary: TODO: test that guess */ @@ -1826,13 +1913,15 @@ static void bevel_harden_normals(BMesh *bm, BevelParams *bp) /* ensure that bm->lnor_spacearr has properly stored loop normals; side effect: ensures loop indices */ BM_lnorspace_update(bm); - if (cd_clnors_offset == -1) + if (cd_clnors_offset == -1) { cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL); + } BM_ITER_MESH(f, &fiter, bm, BM_FACES_OF_MESH) { fkind = get_face_kind(bp, f); - if (fkind == F_ORIG || fkind == F_RECON) + if (fkind == F_ORIG || fkind == F_RECON) { continue; + } BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) { estep = l->prev->e; /* causes CW walk around l->v fan */ lprev = BM_vert_step_fan_loop(l, &estep); @@ -1976,8 +2065,9 @@ static void set_bound_vert_seams(BevVert *bv, bool mark_seam, bool mark_sharp) v->any_seam = false; for (e = v->efirst; e; e = e->next) { v->any_seam |= e->is_seam; - if (e == v->elast) + if (e == v->elast) { break; + } } bv->any_seam |= v->any_seam; } while ((v = v->next) != bv->vmesh->boundstart); @@ -1994,13 +2084,15 @@ static int count_bound_vert_seams(BevVert *bv) { int ans, i; - if (!bv->any_seam) + if (!bv->any_seam) { return 0; + } ans = 0; for (i = 0; i < bv->edgecount; i++) - if (bv->edges[i].is_seam) + if (bv->edges[i].is_seam) { ans++; + } return ans; } @@ -2059,12 +2151,15 @@ static void build_boundary_vertex_only(BevelParams *bp, BevVert *bv, bool constr if (construct) { set_bound_vert_seams(bv, bp->mark_seam, bp->mark_sharp); - if (vm->count == 2) + if (vm->count == 2) { vm->mesh_kind = M_NONE; - else if (bp->seg == 1) + } + else if (bp->seg == 1) { vm->mesh_kind = M_POLY; - else + } + else { vm->mesh_kind = M_ADJ; + } } } @@ -2208,8 +2303,9 @@ static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter) v1prev = v1->prev; v3next = v3->next; copy_v3_v3(co2, v1->nv.co); - if (v1->is_arc_start) + if (v1->is_arc_start) { copy_v3_v3(v1->profile.midco, co2); + } /* co1 is intersection of line through co2 in dir of emiter->e * and plane with normal the dir of emiter->e and through v1prev */ @@ -2290,8 +2386,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) int ang_kind; /* Current bevel does nothing if only one edge into a vertex */ - if (bv->edgecount <= 1) + if (bv->edgecount <= 1) { return; + } if (bp->vertex_only) { build_boundary_vertex_only(bp, bv, construct); @@ -2347,8 +2444,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) } else if (nnip > 0) { if (bp->loop_slide && nnip == 1 && good_offset_on_edge_between(e, e2, enip, bv->v)) { - if (offset_on_edge_between(e, e2, enip, bv->v, co, &r)) + if (offset_on_edge_between(e, e2, enip, bv->v, co, &r)) { eon = enip; + } } else { offset_meet(e, e2, bv->v, NULL, true, co); @@ -2357,8 +2455,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) else { /* nip > 0 and nnip == 0 */ if (bp->loop_slide && nip == 1 && good_offset_on_edge_between(e, e2, eip, bv->v)) { - if (offset_on_edge_between(e, e2, eip, bv->v, co, &r)) + if (offset_on_edge_between(e, e2, eip, bv->v, co, &r)) { eon = eip; + } } else { offset_meet(e, e2, bv->v, e->fnext, true, co); @@ -2370,8 +2469,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) v->elast = e2; v->ebev = e2; v->eon = eon; - if (eon) + if (eon) { v->sinratio = r; + } e->rightv = v; e2->leftv = v; for (e3 = e->next; e3 != e2; e3 = e3->next) { @@ -2388,15 +2488,18 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) if ((miter_outer != BEVEL_MITER_SHARP && !emiter && ang_kind == 1) || (miter_inner != BEVEL_MITER_SHARP && ang_kind == -1)) { - if (ang_kind == 1) + if (ang_kind == 1) { emiter = e; + } /* make one or two more boundverts; for now all will have same co */ v1 = v; v1->ebev = NULL; - if (ang_kind == 1 && miter_outer == BEVEL_MITER_PATCH) + if (ang_kind == 1 && miter_outer == BEVEL_MITER_PATCH) { v2 = add_new_bound_vert(mem_arena, vm, co); - else + } + else { v2 = NULL; + } v3 = add_new_bound_vert(mem_arena, vm, co); v3->ebev = e2; v3->efirst = e2; @@ -2439,12 +2542,15 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) * If between is odd, put middle one at midindex */ for (e3 = e->next; e3 != e2; e3 = e3->next) { v1->elast = e3; - if (i < bet2) + if (i < bet2) { e3->profile_index = 0; - else if (betodd && i == bet2) + } + else if (betodd && i == bet2) { e3->profile_index = bp->seg / 2; - else + } + else { e3->profile_index = bp->seg; + } i++; } } @@ -2456,8 +2562,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) if ((miter_outer != BEVEL_MITER_SHARP && !emiter && ang_kind == 1) || (miter_inner != BEVEL_MITER_SHARP && ang_kind == -1)) { - if (ang_kind == 1) + if (ang_kind == 1) { emiter = e; + } v1 = e->rightv; if (ang_kind == 1 && miter_outer == BEVEL_MITER_PATCH) { v2 = v1->next; @@ -2468,8 +2575,9 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) v3 = v1->next; } adjust_bound_vert(v1, co); - if (v2) + if (v2) { adjust_bound_vert(v2, co); + } adjust_bound_vert(v3, co); } else { @@ -2531,10 +2639,12 @@ static void print_adjust_stats(BoundVert *vstart) printf("e%d r(%f) vs l(%f): abs(delta)=%f, delta_pct=%f\n", BM_elem_index_get(eright->e), eright->offset_r, eleft->offset_l, delta, delta_pct); even_residual2 += delta * delta; - if (delta > max_even_r) + if (delta > max_even_r) { max_even_r = delta; - if (delta_pct > max_even_r_pct) + } + if (delta_pct > max_even_r_pct) { max_even_r_pct = delta_pct; + } } v = v->adjchain; } while (v && v != vstart); @@ -2552,10 +2662,12 @@ static void print_adjust_stats(BoundVert *vstart) spec_residual2 += delta * delta; delta = fabs(delta); delta_pct = fabs(delta_pct); - if (delta > max_spec_r) + if (delta > max_spec_r) { max_spec_r = delta; - if (delta_pct > max_spec_r_pct) + } + if (delta_pct > max_spec_r_pct) { max_spec_r_pct = delta_pct; + } delta = eleft->offset_l - eleft->offset_l_spec; delta_pct = 100.0 * delta / eright->offset_l_spec; @@ -2564,10 +2676,12 @@ static void print_adjust_stats(BoundVert *vstart) spec_residual2 += delta * delta; delta = fabs(delta); delta_pct = fabs(delta_pct); - if (delta > max_spec_r) + if (delta > max_spec_r) { max_spec_r = delta; - if (delta_pct > max_spec_r_pct) + } + if (delta_pct > max_spec_r_pct) { max_spec_r_pct = delta_pct; + } } v = v->adjchain; } while (v && v != vstart); @@ -2696,12 +2810,13 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) v = v->adjchain; } while (v && v != vstart); #ifdef DEBUG_ADJUST - printf(" -> %d parms\n", np); + printf(" -> %d parms\n", np); #endif #ifdef FAST_ADJUST_CODE - if (adjust_the_cycle_or_chain_fast(vstart, np, iscycle)) + if (adjust_the_cycle_or_chain_fast(vstart, np, iscycle)) { return; + } #endif nrows = iscycle ? 3 * np : 3 * np - 3; @@ -2719,8 +2834,9 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) enextleft = v->adjchain->elast; #ifdef DEBUG_ADJUST printf("p%d: e%d->offset_r = %f\n", i, BM_elem_index_get(eright->e), eright->offset_r); - if (iscycle || v != vstart) + if (iscycle || v != vstart) { printf(" dependent: e%d->offset_l = %f * p%d\n", BM_elem_index_get(eleft->e), v->sinratio, i); + } #endif /* residue i: width difference between eright and eleft of next */ @@ -2771,8 +2887,9 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) /* Note: this print only works after solve, but by that time b has been cleared */ EIG_linear_solver_print_matrix(solver); printf("\nSolution:\n"); - for (i = 0; i < np; i++) + for (i = 0; i < np; i++) { printf("p%d = %f\n", i, EIG_linear_solver_variable_get(solver, 0, i)); + } #endif /* Use the solution to set new widths */ @@ -2838,8 +2955,9 @@ static void adjust_offsets(BevelParams *bp) bv = bvcur = BLI_ghashIterator_getValue(&giter); vanchor = bv->vmesh->boundstart; do { - if (vanchor->visited || !vanchor->eon) + if (vanchor->visited || !vanchor->eon) { continue; + } /* Find one of (1) a cycle that starts and ends at v * where each v has v->eon set and had not been visited before; @@ -2857,11 +2975,13 @@ static void adjust_offsets(BevelParams *bp) chainlen = 1; while (v->eon && !v->visited && !iscycle) { v->visited = true; - if (!v->efirst) + if (!v->efirst) { break; + } enext = find_other_end_edge_half(bp, v->efirst, &bvcur); - if (!enext) + if (!enext) { break; + } BLI_assert(enext != NULL); vnext = enext->leftv; v->adjchain = vnext; @@ -2882,19 +3002,22 @@ static void adjust_offsets(BevelParams *bp) bvcur = bv; do { v->visited = true; - if (!v->elast) + if (!v->elast) { break; + } enext = find_other_end_edge_half(bp, v->elast, &bvcur); - if (!enext) + if (!enext) { break; + } vnext = enext->rightv; vnext->adjchain = v; chainlen++; vchainstart = vnext; v = vnext; } while (!v->visited && v->eon); - if (chainlen >= 3 && !vchainstart->eon && !vchainend->eon) + if (chainlen >= 3 && !vchainstart->eon && !vchainend->eon) { adjust_the_cycle_or_chain(vchainstart, false); + } } } while ((vanchor = vanchor->next) != bv->vmesh->boundstart); } @@ -2921,8 +3044,9 @@ static BoundVert *pipe_test(BevVert *bv) float dir1[3], dir3[3]; vm = bv->vmesh; - if (vm->count < 3 || vm->count > 4 || bv->selcount < 3 || bv->selcount > 4) + if (vm->count < 3 || vm->count > 4 || bv->selcount < 3 || bv->selcount > 4) { return NULL; + } /* find v1, v2, v3 all with beveled edges, where v1 and v3 have collinear edges */ epipe = NULL; @@ -2942,14 +3066,16 @@ static BoundVert *pipe_test(BevVert *bv) } } while ((v1 = v1->next) != vm->boundstart); - if (!epipe) + if (!epipe) { return NULL; + } /* check face planes: all should have normals perpendicular to epipe */ for (e = &bv->edges[0]; e != &bv->edges[bv->edgecount]; e++) { if (e->fnext) { - if (dot_v3v3(dir1, e->fnext->no) > BEVEL_EPSILON_BIG) + if (dot_v3v3(dir1, e->fnext->no) > BEVEL_EPSILON_BIG) { return NULL; + } } } return v1; @@ -2986,24 +3112,30 @@ static NewVert *mesh_vert_canon(VMesh *vm, int i, int j, int k) odd = ns % 2; BLI_assert(0 <= i && i <= n && 0 <= j && j <= ns && 0 <= k && k <= ns); - if (!odd && j == ns2 && k == ns2) + if (!odd && j == ns2 && k == ns2) { ans = mesh_vert(vm, 0, j, k); - else if (j <= ns2 - 1 + odd && k <= ns2) + } + else if (j <= ns2 - 1 + odd && k <= ns2) { ans = mesh_vert(vm, i, j, k); - else if (k <= ns2) + } + else if (k <= ns2) { ans = mesh_vert(vm, (i + n - 1) % n, k, ns - j); - else + } + else { ans = mesh_vert(vm, (i + 1) % n, ns - k, j); + } return ans; } static bool is_canon(VMesh *vm, int i, int j, int k) { int ns2 = vm->seg / 2; - if (vm->seg % 2 == 1) + if (vm->seg % 2 == 1) { return (j <= ns2 && k <= ns2); - else + } + else { return ((j < ns2 && k <= ns2) || (j == ns2 && k == ns2 && i == 0)); + } } /* Copy the vertex data to all of vm verts from canonical ones */ @@ -3018,8 +3150,9 @@ static void vmesh_copy_equiv_verts(VMesh *vm) for (i = 0; i < n; i++) { for (j = 0; j <= ns2; j++) { for (k = 0; k <= ns; k++) { - if (is_canon(vm, i, j, k)) + if (is_canon(vm, i, j, k)) { continue; + } v1 = mesh_vert(vm, i, j, k); v0 = mesh_vert_canon(vm, i, j, k); copy_v3_v3(v1->co, v0->co); @@ -3065,16 +3198,21 @@ static float sabin_gamma(int n) double ans, k, k2, k4, k6, x, y; /* precalculated for common cases of n */ - if (n < 3) + if (n < 3) { return 0.0f; - else if (n == 3) + } + else if (n == 3) { ans = 0.065247584f; - else if (n == 4) + } + else if (n == 4) { ans = 0.25f; - else if (n == 5) + } + else if (n == 5) { ans = 0.401983447f; - else if (n == 6) + } + else if (n == 6) { ans = 0.523423277f; + } else { k = cos(M_PI / (double)n); /* need x, real root of x^3 + (4k^2 - 3)x - 2k = 0. @@ -3103,8 +3241,9 @@ static void fill_vmesh_fracs(VMesh *vm, float *frac, int i) frac[k + 1] = total; } if (total > 0.0f) { - for (k = 1; k <= ns; k++) + for (k = 1; k <= ns; k++) { frac[k] /= total; + } } else { frac[ns] = 1.0f; @@ -3147,10 +3286,12 @@ static int interp_range(const float *frac, int n, const float f, float *r_rest) for (i = 0; i < n; i++) { if (f <= frac[i + 1]) { rest = f - frac[i]; - if (rest == 0) + if (rest == 0) { *r_rest = 0.0f; - else + } + else { *r_rest = rest / (frac[i + 1] - frac[i]); + } if (i == n - 1 && *r_rest == 1.0f) { i = n; *r_rest = 0.0f; @@ -3384,8 +3525,9 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm0) mul_v3_fl(co, 1.0f / (float)n); madd_v3_v3fl(co, co2, beta / (2.0f * (float)n)); madd_v3_v3fl(co, mesh_vert(vm0, 0, ns20, ns20)->co, gamma); - for (i = 0; i < n; i++) + for (i = 0; i < n; i++) { copy_v3_v3(mesh_vert(vm1, i, ns0, ns0)->co, co); + } /* Final step: sample the boundary vertices at even parameter spacing */ bndv = vm1->boundstart; @@ -3422,8 +3564,9 @@ static VMesh *make_cube_corner_square(MemArena *mem_arena, int nseg) for (i = 0; i < 3; i++) { for (j = 0; j <= ns2; j++) { for (k = 0; k <= ns2; k++) { - if (!is_canon(vm, i, j, k)) + if (!is_canon(vm, i, j, k)) { continue; + } co[i] = 1.0f; co[(i + 1) % 3] = (float)k * 2.0f / (float)nseg; co[(i + 2) % 3] = (float)j * 2.0f / (float)nseg; @@ -3455,10 +3598,12 @@ static VMesh *make_cube_corner_square_in(MemArena *mem_arena, int nseg) co[i] = 1.0f; add_new_bound_vert(mem_arena, vm, co); } - if (odd) + if (odd) { b = 2.0f / (2.0f * (float)ns2 + (float)M_SQRT2); - else + } + else { b = 2.0f / (float)nseg; + } for (i = 0; i < 3; i++) { for (k = 0; k <= ns2; k++) { co[i] = 1.0f - (float)k * b; @@ -3490,10 +3635,12 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp) int i, j, k, ns2; float co[3], coc[3]; - if (r == PRO_SQUARE_R) + if (r == PRO_SQUARE_R) { return make_cube_corner_square(mem_arena, nseg); - else if (r == PRO_SQUARE_IN_R) + } + else if (r == PRO_SQUARE_IN_R) { return make_cube_corner_square_in(mem_arena, nseg); + } /* initial mesh has 3 sides, 2 segments */ vm0 = new_adj_vmesh(mem_arena, 3, 2, NULL); @@ -3526,10 +3673,12 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp) copy_v3_fl(co, M_SQRT1_3); if (nseg > 2) { - if (r > 1.5f) + if (r > 1.5f) { mul_v3_fl(co, 1.4f); - else if (r < 0.75f) + } + else if (r < 0.75f) { mul_v3_fl(co, 0.6f); + } } copy_v3_v3(mesh_vert(vm0, 0, 1, 1)->co, co); @@ -3539,8 +3688,9 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp) while (vm1->seg < nseg) { vm1 = cubic_subdiv(bp, vm1); } - if (vm1->seg != nseg) + if (vm1->seg != nseg) { vm1 = interp_vmesh(bp, vm1, nseg); + } /* Now snap each vertex to the superellipsoid */ ns2 = nseg / 2; @@ -3563,30 +3713,36 @@ static int tri_corner_test(BevelParams *bp, BevVert *bv) int i; int in_plane_e = 0; - if (bp->vertex_only) + if (bp->vertex_only) { return -1; - if (bv->vmesh->count != 3) + } + if (bv->vmesh->count != 3) { return 0; + } totang = 0.0f; for (i = 0; i < bv->edgecount; i++) { e = &bv->edges[i]; ang = BM_edge_calc_face_angle_signed_ex(e->e, 0.0f); - if (ang <= M_PI_4) + if (ang <= M_PI_4) { in_plane_e++; - else if (ang >= 3.0f * (float) M_PI_4) + } + else if (ang >= 3.0f * (float) M_PI_4) { return -1; + } totang += ang; } - if (in_plane_e != bv->edgecount - 3) + if (in_plane_e != bv->edgecount - 3) { return -1; + } angdiff = fabsf(totang - 3.0f * (float)M_PI_2); if ((bp->pro_super_r == PRO_SQUARE_R && angdiff > (float)M_PI / 16.0f) || (angdiff > (float)M_PI_4)) { return -1; } - if (bv->edgecount != 3 || bv->selcount != 3) + if (bv->edgecount != 3 || bv->selcount != 3) { return 0; + } return 1; } @@ -3699,8 +3855,9 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv) } } sub_v3_v3v3(dir, coa, co); - if (len_squared_v3(dir) > BEVEL_EPSILON_SQ) + if (len_squared_v3(dir) > BEVEL_EPSILON_SQ) { madd_v3_v3fl(co, dir, fullness); + } copy_v3_v3(mesh_vert(vm0, 0, 1, 1)->co, co); vmesh_copy_equiv_verts(vm0); @@ -3708,8 +3865,9 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv) do { vm1 = cubic_subdiv(bp, vm1); } while (vm1->seg < ns); - if (vm1->seg != ns) + if (vm1->seg != ns) { vm1 = interp_vmesh(bp, vm1, ns); + } return vm1; } @@ -3775,8 +3933,9 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe) for (i = 0; i < n; i++) { for (j = 1; j <= ns2; j++) { for (k = 0; k <= ns2; k++) { - if (!is_canon(vm, i, j, k)) + if (!is_canon(vm, i, j, k)) { continue; + } midline = even && k == ns2 && ((i == 0 && j == ns2) || (i == ipipe1 || i == ipipe2)); snap_to_pipe_profile(vpipe, midline, mesh_vert(vm, i, j, k)->co); @@ -3794,14 +3953,17 @@ static void get_incident_edges(BMFace *f, BMVert *v, BMEdge **r_e1, BMEdge **r_e *r_e1 = NULL; *r_e2 = NULL; - if (!f) + if (!f) { return; + } BM_ITER_ELEM (e, &iter, f, BM_EDGES_OF_FACE) { if (e->v1 == v || e->v2 == v) { - if (*r_e1 == NULL) + if (*r_e1 == NULL) { *r_e1 = e; - else if (*r_e2 == NULL) + } + else if (*r_e2 == NULL) { *r_e2 = e; + } } } } @@ -3813,10 +3975,12 @@ static BMEdge *find_closer_edge(float *co, BMEdge *e1, BMEdge *e2) BLI_assert(e1 != NULL && e2 != NULL); dsq1 = dist_squared_to_line_segment_v3(co, e1->v1->co, e1->v2->co); dsq2 = dist_squared_to_line_segment_v3(co, e2->v1->co, e2->v2->co); - if (dsq1 < dsq2) + if (dsq1 < dsq2) { return e1; - else + } + else { return e2; + } } /* Snap co to the closest edge of face f. Return the edge in *r_snap_e, @@ -3929,10 +4093,12 @@ static void build_square_in_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv, VMesh /* copy whichever of a and b is closer to v into r */ static void closer_v3_v3v3v3(float r[3], float a[3], float b[3], float v[3]) { - if (len_squared_v3v3(a, v) <= len_squared_v3v3(b, v)) + if (len_squared_v3v3(a, v) <= len_squared_v3v3(b, v)) { copy_v3_v3(r, a); - else + } + else { copy_v3_v3(r, b); + } } /* Special case of VMesh when profile == 1 and there are 3 or more beveled edges. @@ -3974,8 +4140,9 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) e1 = bndv->efirst; e2 = bndv->elast; akind = 0; - if (e1 && e2) + if (e1 && e2) { akind = edges_angle_kind(e1, e2, bv->v); + } if (bndv->is_patch_start) { mid_v3_v3v3(centerline + clstride * i, bndv->nv.co, bndv->next->nv.co); cset[i] = true; @@ -4092,8 +4259,9 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) * This is used in interpolation along centerline in odd case. * To avoid too big a drop from bv, cap finalfrac a 0.8 arbitrarily */ finalfrac = 0.5f / sin(ang); - if (finalfrac > 0.8f) + if (finalfrac > 0.8f) { finalfrac = 0.8f; + } } else { finalfrac = 0.8f; @@ -4125,8 +4293,9 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) } bndv = bndv->next; } - if (!odd) + if (!odd) { copy_v3_v3(mesh_vert(vm, 0, ns2, ns2)->co, bv->v->co); + } vmesh_copy_equiv_verts(vm); /* fill in interior points by interpolation from edges to centerlines */ @@ -4223,10 +4392,12 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv) for (i = 0; i < n; i++) { for (j = 0; j <= ns2; j++) { for (k = 0; k <= ns; k++) { - if (j == 0 && (k == 0 || k == ns)) + if (j == 0 && (k == 0 || k == ns)) { continue; /* boundary corners already made */ - if (!is_canon(vm, i, j, k)) + } + if (!is_canon(vm, i, j, k)) { continue; + } copy_v3_v3(mesh_vert(vm, i, j, k)->co, mesh_vert(vm1, i, j, k)->co); create_mesh_bmvert(bm, vm, i, j, k, bv->v); } @@ -4239,10 +4410,12 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv) i = v->index; f = boundvert_rep_face(v, NULL); f2 = boundvert_rep_face(v->next, NULL); - if (bp->vertex_only) + if (bp->vertex_only) { e = v->efirst; - else + } + else { e = v->ebev; + } bme = e ? e->e : NULL; /* For odd ns, make polys with lower left corner at (i,j,k) for * j in [0, ns2-1], k in [0, ns2]. And then the center ngon. @@ -4298,8 +4471,9 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv) else { bme1 = k == ns2 - 1 ? bme : NULL; bme3 = NULL; - if (j == ns2 - 1 && v->prev->ebev) + if (j == ns2 - 1 && v->prev->ebev) { bme3 = v->prev->ebev->e; + } bme2 = bme1 != NULL ? bme1 : bme3; r_f = bev_create_quad_ex(bm, bmv1, bmv2, bmv3, bmv4, f, f, f, f, NULL, bme1, bme2, bme3, mat_nr); @@ -4325,8 +4499,9 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv) } } while ((v = v->next) != vm->boundstart); bmv1 = mesh_vert(vm, 0, ns2, ns2)->v; - if (bp->vertex_only || count_bound_vert_seams(bv) <= 1) + if (bp->vertex_only || count_bound_vert_seams(bv) <= 1) { bev_merge_uvs(bm, bmv1); + } } /* center ngon */ @@ -4350,15 +4525,17 @@ static bool is_bad_uv_poly(BevVert *bv, BMFace *frep) v = vm->boundstart; d2 = snap_face_dist_squared(v->nv.v->co, frep, &firste, co); - if (d2 > BEVEL_EPSILON_BIG_SQ || firste == NULL) + if (d2 > BEVEL_EPSILON_BIG_SQ || firste == NULL) { return false; + } for (v = v->next; v != vm->boundstart; v = v->next) { snap_face_dist_squared(v->nv.v->co, frep, &snape, co); if (snape != firste) { d2 = dist_to_line_v3(co, firste->v1->co, firste->v2->co); - if (d2 > BEVEL_EPSILON_BIG_SQ) + if (d2 > BEVEL_EPSILON_BIG_SQ) { return false; + } } } return true; @@ -4511,8 +4688,9 @@ static void bevel_vert_two_edges(BevelParams *bp, BMesh *bm, BevVert *bv) create_mesh_bmvert(bm, vm, 0, 0, k, bv->v); } copy_v3_v3(mesh_vert(vm, 0, 0, ns)->co, v2->co); - for (k = 1; k < ns; k++) + for (k = 1; k < ns; k++) { copy_mesh_vert(vm, 1, 0, ns - k, 0, 0, k); + } } if (BM_vert_face_check(bv->v) == false) { @@ -4523,8 +4701,9 @@ static void bevel_vert_two_edges(BevelParams *bp, BMesh *bm, BevVert *bv) v2 = mesh_vert(vm, 0, 0, k + 1)->v; BLI_assert(v1 != NULL && v2 != NULL); bme = BM_edge_create(bm, v1, v2, e_eg, BM_CREATE_NO_DOUBLE); - if (bme) + if (bme) { flag_out_edge(bm, bme); + } } } } @@ -4557,8 +4736,9 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) create_mesh_bmvert(bm, vm, i, 0, 0, bv->v); v->nv.v = mesh_vert(vm, i, 0, 0)->v; if (weld && v->ebev) { - if (!weld1) + if (!weld1) { weld1 = v; + } else { weld2 = v; move_weld_profile_planes(bv, weld1, weld2); @@ -4577,8 +4757,9 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) if (v->ebev && vm->mesh_kind != M_ADJ) { get_profile_point(bp, &v->profile, k, ns, co); copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co); - if (!weld) + if (!weld) { create_mesh_bmvert(bm, vm, i, 0, k, bv->v); + } } else if (n == 2 && !v->ebev && vm->mesh_kind != M_ADJ) { /* case of one edge beveled and this is the v without ebev */ @@ -4611,14 +4792,16 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) copy_v3_v3(mesh_vert(vm, weld1->index, 0, k)->co, co); create_mesh_bmvert(bm, vm, weld1->index, 0, k, bv->v); } - for (k = 1; k < ns; k++) + for (k = 1; k < ns; k++) { copy_mesh_vert(vm, weld2->index, 0, ns - k, weld1->index, 0, k); + } } switch (vm->mesh_kind) { case M_NONE: - if (n == 2 && bp->vertex_only) + if (n == 2 && bp->vertex_only) { bevel_vert_two_edges(bp, bm, bv); + } break; case M_POLY: bevel_build_poly(bp, bm, bv); @@ -4741,8 +4924,9 @@ static bool fast_bevel_edge_order(BevVert *bv) bme2 = (l->v == bv->v) ? l->prev->e : l->next->e; if (!BM_BEVEL_EDGE_TAG_TEST(bme2)) { nsucs++; - if (bmenext == NULL) + if (bmenext == NULL) { bmenext = bme2; + } } } if (nsucs == 0 || (nsucs == 2 && j != 1) || nsucs > 2 || @@ -4774,24 +4958,28 @@ static bool fast_bevel_edge_order(BevVert *bv) * a unique face, if possible */ e = &bv->edges[0]; bme = e->e; - if (!bme->l) + if (!bme->l) { return false; + } for (i = 1; i < ntot; i++) { /* find an unflagged edge bme2 that shares a face f with previous bme */ num_shared_face = 0; first_suc = NULL; /* keep track of first successor to match legacy behavior */ BM_ITER_ELEM (bme2, &iter, bv->v, BM_EDGES_OF_VERT) { - if (BM_BEVEL_EDGE_TAG_TEST(bme2)) + if (BM_BEVEL_EDGE_TAG_TEST(bme2)) { continue; + } BM_ITER_ELEM (f, &iter2, bme2, BM_FACES_OF_EDGE) { if (BM_face_edge_share_loop(f, bme)) { num_shared_face++; - if (first_suc == NULL) + if (first_suc == NULL) { first_suc = bme2; + } } } - if (num_shared_face >= 3) + if (num_shared_face >= 3) { break; + } } if (num_shared_face == 1 || (i == 1 && num_shared_face == 2)) { e = &bv->edges[i]; @@ -4830,19 +5018,23 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme) BLI_assert(first_bme != NULL); bv->edges[i].e = first_bme; BM_BEVEL_EDGE_TAG_ENABLE(first_bme); - if (i == 0 && fast_bevel_edge_order(bv)) + if (i == 0 && fast_bevel_edge_order(bv)) { break; + } i = bevel_edge_order_extend(bm, bv, i); i++; - if (i >= bv->edgecount) + if (i >= bv->edgecount) { break; + } /* Not done yet: find a new first_bme */ first_bme = NULL; BM_ITER_ELEM(bme, &iter, bv->v, BM_EDGES_OF_VERT) { - if (BM_BEVEL_EDGE_TAG_TEST(bme)) + if (BM_BEVEL_EDGE_TAG_TEST(bme)) { continue; - if (!first_bme) + } + if (!first_bme) { first_bme = bme; + } if (BM_edge_face_count(bme) == 1) { first_bme = bme; break; @@ -4856,8 +5048,9 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme) bme = e->e; bme2 = e2->e; BLI_assert(bme != NULL); - if (e->fnext != NULL || e2->fprev != NULL) + if (e->fnext != NULL || e2->fprev != NULL) { continue; + } /* Which faces have successive loops that are for bme and bme2? * There could be more than one. E.g., in manifold ntot==2 case. * Prefer one that has loop in same direction as e. */ @@ -4865,8 +5058,9 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme) BM_ITER_ELEM(l, &iter, bme, BM_LOOPS_OF_EDGE) { f = l->f; if ((l->prev->e == bme2 || l->next->e == bme2)) { - if (!bestf || l->v == bv->v) + if (!bestf || l->v == bv->v) { bestf = f; + } } if (bestf) { e->fnext = e2->fprev = bestf; @@ -4909,15 +5103,17 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) if (BM_elem_flag_test(bme, BM_ELEM_TAG) && !bp->vertex_only) { BLI_assert(fcnt == 2); nsel++; - if (!first_bme) + if (!first_bme) { first_bme = bme; + } } if (fcnt == 1) { /* good to start face chain from this edge */ first_bme = bme; } - if (fcnt > 0 || bp->vertex_only) + if (fcnt > 0 || bp->vertex_only) { ntot++; + } if (BM_edge_is_wire(bme)) { nwire++; /* If edge beveling, exclude wire edges from edges array. @@ -4927,8 +5123,9 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } } } - if (!first_bme) + if (!first_bme) { first_bme = v->e; + } if ((nsel == 0 && !bp->vertex_only) || (ntot < 2 && bp->vertex_only)) { /* signal this vert isn't being beveled */ @@ -4943,10 +5140,12 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) bv->wirecount = nwire; bv->offset = bp->offset; bv->edges = (EdgeHalf *)BLI_memarena_alloc(bp->mem_arena, ntot * sizeof(EdgeHalf)); - if (nwire) + if (nwire) { bv->wire_edges = (BMEdge **)BLI_memarena_alloc(bp->mem_arena, nwire * sizeof(BMEdge *)); - else + } + else { bv->wire_edges = NULL; + } bv->vmesh = (VMesh *)BLI_memarena_alloc(bp->mem_arena, sizeof(VMesh)); bv->vmesh->seg = bp->seg; @@ -4995,9 +5194,10 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) * reverse the array, being careful to reverse face pointers too */ if (ntot > 1) { ccw_test_sum = 0; - for (i = 0; i < ntot; i++) + for (i = 0; i < ntot; i++) { ccw_test_sum += bev_ccw_test(bv->edges[i].e, bv->edges[(i + 1) % ntot].e, bv->edges[i].fnext); + } if (ccw_test_sum < 0) { for (i = 0; i <= (ntot / 2) - 1; i++) { SWAP(EdgeHalf, bv->edges[i], bv->edges[ntot - i - 1]); @@ -5027,17 +5227,21 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) break; case BEVEL_AMT_WIDTH: z = fabsf(2.0f * sinf(edge_face_angle(e) / 2.0f)); - if (z < BEVEL_EPSILON) + if (z < BEVEL_EPSILON) { e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ - else + } + else { e->offset_l_spec = bp->offset / z; + } break; case BEVEL_AMT_DEPTH: z = fabsf(cosf(edge_face_angle(e) / 2.0f)); - if (z < BEVEL_EPSILON) + if (z < BEVEL_EPSILON) { e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ - else + } + else { e->offset_l_spec = bp->offset / z; + } break; case BEVEL_AMT_PERCENT: /* offset needs to be such that it meets adjacent edges at percentage of their lengths */ @@ -5055,8 +5259,9 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) e->offset_l_spec = bp->offset; break; } - if (bp->offset_type != BEVEL_AMT_PERCENT) + if (bp->offset_type != BEVEL_AMT_PERCENT) { e->offset_r_spec = e->offset_l_spec; + } if (bp->use_weights) { weight = BM_elem_float_data_get(&bm->edata, e->e, CD_BWEIGHT); e->offset_l_spec *= weight; @@ -5081,10 +5286,12 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) e->offset_l = e->offset_l_spec; e->offset_r = e->offset_r_spec; - if (e->fprev && e->fnext) + if (e->fprev && e->fnext) { e->is_seam = !contig_ldata_across_edge(bm, e->e, e->fprev, e->fnext); - else + } + else { e->is_seam = true; + } } if (nwire) { @@ -5205,8 +5412,9 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) if (bmv) { BLI_array_append(vv, bmv); BLI_array_append(ee, bme); /* TODO: maybe better edge here */ - if (corner3special && v->ebev && !v->ebev->is_seam && k != vm->seg) + if (corner3special && v->ebev && !v->ebev->is_seam && k != vm->seg) { BLI_array_append(vv_fix, bmv); + } } } v = v->next; @@ -5232,8 +5440,9 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) if (bmv) { BLI_array_append(vv, bmv); BLI_array_append(ee, bme); - if (corner3special && v->ebev && !v->ebev->is_seam && k != 0) + if (corner3special && v->ebev && !v->ebev->is_seam && k != 0) { BLI_array_append(vv_fix, bmv); + } } } v = v->prev; @@ -5277,8 +5486,9 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) BM_elem_flag_enable(bme_new, BM_ELEM_SMOOTH); } } - else + else { bme_prev = ee[k]; + } } } @@ -5295,8 +5505,9 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) break; } } - if (!keep) + if (!keep) { disable_flag_out_edge(bm, bme); + } } } } @@ -5340,8 +5551,9 @@ static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v) int i; bv = find_bevvert(bp, v); - if (!bv || bv->wirecount == 0 || !bv->vmesh) + if (!bv || bv->wirecount == 0 || !bv->vmesh) { return; + } for (i = 0; i < bv->wirecount; i++) { e = bv->wire_edges[i]; @@ -5353,8 +5565,9 @@ static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v) bvother = NULL; if (BM_elem_flag_test(vother, BM_ELEM_TAG)) { bvother = find_bevvert(bp, vother); - if (!bvother || !bvother->vmesh) + if (!bvother || !bvother->vmesh) { return; /* shouldn't happen */ + } } bndv = bv->vmesh->boundstart; do { @@ -5453,10 +5666,12 @@ static void weld_cross_attrs_copy(BMesh *bm, BevVert *bv, VMesh *vm, int vmindex mesh_vert(vm, vmindex, 0, i + 1)->v); BLI_assert(bme); BM_elem_attrs_copy(bm, bm, bme_prev, bme); - if (disable_seam) + if (disable_seam) { BM_elem_flag_disable(bme, BM_ELEM_SEAM); - if (enable_smooth) + } + if (enable_smooth) { BM_elem_flag_enable(bme, BM_ELEM_SMOOTH); + } } } @@ -5479,8 +5694,9 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) int k, nseg, i1, i2, odd, mid; int mat_nr = bp->mat_nr; - if (!BM_edge_is_manifold(bme)) + if (!BM_edge_is_manifold(bme)) { return; + } bv1 = find_bevvert(bp, bme->v1); bv2 = find_bevvert(bp, bme->v2); @@ -5563,25 +5779,30 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) record_face_kind(bp, r_f, F_EDGE); /* tag the long edges: those out of verts[0] and verts[2] */ BM_ITER_ELEM(l, &iter, r_f, BM_LOOPS_OF_FACE) { - if (l->v == verts[0] || l->v == verts[2]) + if (l->v == verts[0] || l->v == verts[2]) { BM_elem_flag_enable(l, BM_ELEM_LONG_TAG); + } } verts[0] = verts[3]; verts[1] = verts[2]; } if (!odd) { - if (!e1->is_seam) + if (!e1->is_seam) { bev_merge_edge_uvs(bm, center_bme, mesh_vert(vm1, i1, 0, mid)->v); - if (!e2->is_seam) + } + if (!e2->is_seam) { bev_merge_edge_uvs(bm, center_bme, mesh_vert(vm2, i2, 0, mid)->v); + } } /* Fix UVs along end edge joints. A nop unless other side built already. */ /* TODO: if some seam, may want to do selective merge */ - if (!bv1->any_seam && bv1->vmesh->mesh_kind == M_NONE) + if (!bv1->any_seam && bv1->vmesh->mesh_kind == M_NONE) { bev_merge_end_uvs(bm, bv1, e1); - if (!bv2->any_seam && bv2->vmesh->mesh_kind == M_NONE) + } + if (!bv2->any_seam && bv2->vmesh->mesh_kind == M_NONE) { bev_merge_end_uvs(bm, bv2, e2); + } /* Copy edge data to first and last edge */ bme1 = BM_edge_exists(bmv1, bmv2); @@ -5615,11 +5836,13 @@ static double find_superellipse_chord_endpoint(double x0, double dtarget, float /* For gradient between -1 and 1, xnew can only be in * [x0 + sqrt(2)/2*dtarget, x0 + dtarget]. */ xmin = x0 + M_SQRT2 / 2.0 * dtarget; - if (xmin > 1.0) + if (xmin > 1.0) { xmin = 1.0; + } xmax = x0 + dtarget; - if (xmax > 1.0) + if (xmax > 1.0) { xmax = 1.0; + } ymin = superellipse_co(xmin, r, rbig); ymax = superellipse_co(xmax, r, rbig); @@ -5872,8 +6095,9 @@ static void set_profile_spacing(BevelParams *bp) bp->pro_spacing.yvals = (double *)BLI_memarena_alloc(bp->mem_arena, (seg + 1) * sizeof(double)); find_even_superellipse_chords(seg, bp->pro_super_r, bp->pro_spacing.xvals, bp->pro_spacing.yvals); seg_2 = power_of_2_max_i(bp->seg); - if (seg_2 == 2) + if (seg_2 == 2) { seg_2 = 4; + } bp->pro_spacing.seg_2 = seg_2; if (seg_2 == seg) { bp->pro_spacing.xvals_2 = bp->pro_spacing.xvals; @@ -5926,8 +6150,9 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb) float ka, kb, kc, g, h, t, den, no_collide_offset, th1, th2, sin1, sin2, tan1, tan2, limit; limit = no_collide_offset = bp->offset + 1e6; - if (bp->offset == 0.0f) + if (bp->offset == 0.0f) { return no_collide_offset; + } kb = eb->offset_l_spec; ea = eb->next; /* note: this is in direction b --> a */ ka = ea->offset_r_spec; @@ -5957,16 +6182,19 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb) if (!lb) { return no_collide_offset; } - if (lb->next->v == vc) + if (lb->next->v == vc) { vd = lb->next->next->v; - else if (lb->v == vc) + } + else if (lb->v == vc) { vd = lb->prev->v; + } else { return no_collide_offset; } } - if (ea->e == eb->e || (ec && ec->e == eb->e)) + if (ea->e == eb->e || (ec && ec->e == eb->e)) { return no_collide_offset; + } ka = ka / bp->offset; kb = kb / bp->offset; kc = kc / bp->offset; @@ -5987,8 +6215,9 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb) if (den != 0.0f) { t = BM_edge_calc_length(eb->e); t *= g * h / den; - if (t >= 0.0f) + if (t >= 0.0f) { limit = t; + } } } @@ -5996,14 +6225,16 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb) if (kb > 0.0f && ka == 0.0f /*&& bvb->selcount == 1 && bvb->edgecount > 2*/) { t = BM_edge_calc_length(ea->e); t *= sin1 / kb; - if (t >= 0.0f && t < limit) + if (t >= 0.0f && t < limit) { limit = t; + } } if (kb > 0.0f && kc == 0.0f /* && bvc && ec && bvc->selcount == 1 && bvc->edgecount > 2 */) { t = BM_edge_calc_length(ec->e); t *= sin2 / kb; - if (t >= 0.0f && t < limit) + if (t >= 0.0f && t < limit) { limit = t; + } } return limit; } @@ -6021,15 +6252,17 @@ static float vertex_collide_offset(BevelParams *bp, EdgeHalf *ea) EdgeHalf *eb; limit = no_collide_offset = bp->offset + 1e6; - if (bp->offset == 0.0f) + if (bp->offset == 0.0f) { return no_collide_offset; + } ka = ea->offset_l_spec / bp->offset; eb = find_other_end_edge_half(bp, ea, NULL); kb = eb ? eb->offset_l_spec / bp->offset : 0.0f; kab = ka + kb; la = BM_edge_calc_length(ea->e); - if (kab <= 0.0f) + if (kab <= 0.0f) { return no_collide_offset; + } limit = la / kab; return limit; } @@ -6057,13 +6290,15 @@ static void bevel_limit_offset(BevelParams *bp) eh = &bv->edges[i]; if (bp->vertex_only) { collision_offset = vertex_collide_offset(bp, eh); - if (collision_offset < limited_offset) + if (collision_offset < limited_offset) { limited_offset = collision_offset; + } } else { collision_offset = geometry_collide_offset(bp, eh); - if (collision_offset < limited_offset) + if (collision_offset < limited_offset) { limited_offset = collision_offset; + } } } } @@ -6161,8 +6396,9 @@ void BM_mesh_bevel( BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { bv = bevel_vert_construct(bm, &bp, v); - if (!limit_offset && bv) + if (!limit_offset && bv) { build_boundary(&bp, bv, true); + } } } @@ -6187,8 +6423,9 @@ void BM_mesh_bevel( BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { bv = find_bevvert(&bp, v); - if (bv) + if (bv) { build_vmesh(&bp, bm, bv); + } } } @@ -6233,8 +6470,9 @@ void BM_mesh_bevel( * will be set, and we to transfer the oflags to BM_ELEM_TAGs */ if (bm->use_toolflags) { BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - if (BMO_vert_flag_test(bm, v, VERT_OUT)) + if (BMO_vert_flag_test(bm, v, VERT_OUT)) { BM_elem_flag_enable(v, BM_ELEM_TAG); + } } BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { if (BMO_edge_flag_test(bm, e, EDGE_OUT)) { @@ -6245,8 +6483,9 @@ void BM_mesh_bevel( /* clear the BM_ELEM_LONG_TAG tags, which were only set on some edges in F_EDGE faces */ BM_ITER_MESH(f, &iter, bm, BM_FACES_OF_MESH) { - if (get_face_kind(&bp, f) != F_EDGE) + if (get_face_kind(&bp, f) != F_EDGE) { continue; + } BM_ITER_ELEM(l, &liter, f, BM_LOOPS_OF_FACE) { BM_elem_flag_disable(l, BM_ELEM_LONG_TAG); } diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c index 83f5edb01ea..da7feff70e6 100644 --- a/source/blender/bmesh/tools/bmesh_bisect_plane.c +++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c @@ -52,9 +52,9 @@ static short plane_point_test_v3(const float plane[4], const float co[3], const const float f = plane_point_side_v3(plane, co); *r_depth = f; - if (f <= -eps) return -1; - else if (f >= eps) return 1; - else return 0; + if (f <= -eps) { return -1; } + else if (f >= eps) { return 1; } + else { return 0; } } @@ -98,9 +98,9 @@ static int bm_vert_sortval_cb(const void *v_a_v, const void *v_b_v) const float val_a = BM_VERT_SORTVAL(*((BMVert **)v_a_v)); const float val_b = BM_VERT_SORTVAL(*((BMVert **)v_b_v)); - if (val_a > val_b) return 1; - else if (val_a < val_b) return -1; - else return 0; + if (val_a > val_b) { return 1; } + else if (val_a < val_b) { return -1; } + else { return 0; } } diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c index e5dd6491076..c60dd04fbb5 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c @@ -1257,10 +1257,12 @@ static bool bm_decim_edge_collapse( BM_ITER_ELEM (l, &liter, v_other, BM_LOOPS_OF_VERT) { if (l->f->len == 3) { BMEdge *e_outer; - if (BM_vert_in_edge(l->prev->e, l->v)) + if (BM_vert_in_edge(l->prev->e, l->v)) { e_outer = l->next->e; - else + } + else { e_outer = l->prev->e; + } BLI_assert(BM_vert_in_edge(e_outer, l->v) == false); @@ -1348,9 +1350,9 @@ void BM_mesh_decimate_collapse( #ifdef USE_CUSTOMDATA /* initialize customdata flag, we only need math for loops */ - if (CustomData_has_interp(&bm->vdata)) customdata_flag |= CD_DO_VERT; - if (CustomData_has_interp(&bm->edata)) customdata_flag |= CD_DO_EDGE; - if (CustomData_has_math(&bm->ldata)) customdata_flag |= CD_DO_LOOP; + if (CustomData_has_interp(&bm->vdata)) { customdata_flag |= CD_DO_VERT; } + if (CustomData_has_interp(&bm->edata)) { customdata_flag |= CD_DO_EDGE; } + if (CustomData_has_math(&bm->ldata)) { customdata_flag |= CD_DO_LOOP; } #endif /* iterative edge collapse and maintain the eheap */ diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c index b61a499cffc..6069175348c 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c +++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c @@ -376,12 +376,16 @@ void BM_mesh_decimate_dissolve_ex( BM_edge_kill(bm, e_iter); if (v1->e == NULL) { vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v1)]; - if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL; + if (vidx_reverse != -1) { + vinput_arr[vidx_reverse] = NULL; + } BM_vert_kill(bm, v1); } if (v2->e == NULL) { vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v2)]; - if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL; + if (vidx_reverse != -1) { + vinput_arr[vidx_reverse] = NULL; + } BM_vert_kill(bm, v2); } } diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c index 4068562d077..2445978e294 100644 --- a/source/blender/bmesh/tools/bmesh_intersect.c +++ b/source/blender/bmesh/tools/bmesh_intersect.c @@ -797,14 +797,16 @@ static void bm_isect_tri_tri( BMEdge *ie; if (i == 0) { - if (STACK_SIZE(iv_ls_a) != 2) + if (STACK_SIZE(iv_ls_a) != 2) { continue; + } ie_vs = iv_ls_a; f = f_a; } else { - if (STACK_SIZE(iv_ls_b) != 2) + if (STACK_SIZE(iv_ls_b) != 2) { continue; + } ie_vs = iv_ls_b; f = f_b; } diff --git a/source/blender/bmesh/tools/bmesh_path.c b/source/blender/bmesh/tools/bmesh_path.c index 0ae1f4a57f1..4710c3929c4 100644 --- a/source/blender/bmesh/tools/bmesh_path.c +++ b/source/blender/bmesh/tools/bmesh_path.c @@ -171,8 +171,9 @@ LinkNode *BM_mesh_calc_path_vert( while (!BLI_heapsimple_is_empty(heap)) { v = BLI_heapsimple_pop_min(heap); - if (v == v_dst) + if (v == v_dst) { break; + } if (!BM_elem_flag_test(v, BM_ELEM_TAG)) { BM_elem_flag_enable(v, BM_ELEM_TAG); @@ -343,8 +344,9 @@ LinkNode *BM_mesh_calc_path_edge( while (!BLI_heapsimple_is_empty(heap)) { e = BLI_heapsimple_pop_min(heap); - if (e == e_dst) + if (e == e_dst) { break; + } if (!BM_elem_flag_test(e, BM_ELEM_TAG)) { BM_elem_flag_enable(e, BM_ELEM_TAG); @@ -529,8 +531,9 @@ LinkNode *BM_mesh_calc_path_face( while (!BLI_heapsimple_is_empty(heap)) { f = BLI_heapsimple_pop_min(heap); - if (f == f_dst) + if (f == f_dst) { break; + } if (!BM_elem_flag_test(f, BM_ELEM_TAG)) { BM_elem_flag_enable(f, BM_ELEM_TAG); diff --git a/source/blender/bmesh/tools/bmesh_region_match.c b/source/blender/bmesh/tools/bmesh_region_match.c index 8a69dd05a06..a89c41eecc0 100644 --- a/source/blender/bmesh/tools/bmesh_region_match.c +++ b/source/blender/bmesh/tools/bmesh_region_match.c @@ -579,9 +579,9 @@ static int bm_face_len_cmp(const void *v1, const void *v2) { const BMFace *f1 = v1, *f2 = v2; - if (f1->len > f2->len) return 1; - else if (f1->len < f2->len) return -1; - else return 0; + if (f1->len > f2->len) { return 1; } + else if (f1->len < f2->len) { return -1; } + else { return 0; } } static uint bm_uuidwalk_init_from_edge( diff --git a/source/blender/bmesh/tools/bmesh_wireframe.c b/source/blender/bmesh/tools/bmesh_wireframe.c index e7fbed76e4c..10db05fad98 100644 --- a/source/blender/bmesh/tools/bmesh_wireframe.c +++ b/source/blender/bmesh/tools/bmesh_wireframe.c @@ -437,7 +437,9 @@ void BM_mesh_wireframe( BMVert *v_pos2 = verts_pos[i_2]; f_new = BM_face_create_quad_tri(bm, v_l1, v_l2, v_neg2, v_neg1, f_src, BM_CREATE_NOP); - if (mat_offset) f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max); + if (mat_offset) { + f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max); + } BM_elem_flag_enable(f_new, BM_ELEM_TAG); l_new = BM_FACE_FIRST_LOOP(f_new); @@ -448,7 +450,9 @@ void BM_mesh_wireframe( f_new = BM_face_create_quad_tri(bm, v_l2, v_l1, v_pos1, v_pos2, f_src, BM_CREATE_NOP); - if (mat_offset) f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max); + if (mat_offset) { + f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max); + } BM_elem_flag_enable(f_new, BM_ELEM_TAG); l_new = BM_FACE_FIRST_LOOP(f_new); @@ -465,7 +469,9 @@ void BM_mesh_wireframe( BMVert *v_b2 = verts_boundary[i_2]; f_new = BM_face_create_quad_tri(bm, v_b2, v_b1, v_neg1, v_neg2, f_src, BM_CREATE_NOP); - if (mat_offset) f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max); + if (mat_offset) { + f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max); + } BM_elem_flag_enable(f_new, BM_ELEM_TAG); l_new = BM_FACE_FIRST_LOOP(f_new); @@ -475,7 +481,9 @@ void BM_mesh_wireframe( BM_elem_attrs_copy(bm, bm, l, l_new->next->next); f_new = BM_face_create_quad_tri(bm, v_b1, v_b2, v_pos2, v_pos1, f_src, BM_CREATE_NOP); - if (mat_offset) f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max); + if (mat_offset) { + f_new->mat_nr = CLAMPIS(f_new->mat_nr + mat_offset, 0, mat_max); + } BM_elem_flag_enable(f_new, BM_ELEM_TAG); l_new = BM_FACE_FIRST_LOOP(f_new); |