diff options
Diffstat (limited to 'source/blender/bmesh/tools')
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.c | 48 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bisect_plane.c | 12 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_decimate_collapse.c | 23 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_decimate_dissolve.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_edgenet.c | 81 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_intersect.c | 8 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_intersect_edges.c | 14 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_path_region.c | 6 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_region_match.c | 24 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_wireframe.c | 14 |
10 files changed, 94 insertions, 140 deletions
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 1d48634203f..b29d471d262 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -534,7 +534,7 @@ static EdgeHalf *find_other_end_edge_half(BevelParams *bp, EdgeHalf *e, BevVert BLI_assert(eother != NULL); return eother; } - else if (r_bvother) { + if (r_bvother) { *r_bvother = NULL; } return NULL; @@ -1095,13 +1095,11 @@ static bool is_outside_edge(EdgeHalf *e, const float co[3], BMVert **ret_closer_ *ret_closer_v = e->e->v1; return true; } - else if (lambda >= (1.0f + BEVEL_EPSILON_BIG) * lenu) { + if (lambda >= (1.0f + BEVEL_EPSILON_BIG) * lenu) { *ret_closer_v = e->e->v2; return true; } - else { - return false; - } + return false; } /* Return whether the angle is less than, equal to, or larger than 180 degrees. */ @@ -1132,12 +1130,10 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v) if (fabsf(dot) < BEVEL_EPSILON_BIG) { return ANGLE_STRAIGHT; } - else if (dot < 0.0f) { + if (dot < 0.0f) { return ANGLE_LARGER; } - else { - return ANGLE_SMALLER; - } + return ANGLE_SMALLER; } /* co should be approximately on the plane between e1 and e2, which share common vert v and common @@ -1845,9 +1841,7 @@ static double superellipse_co(double x, float r, bool rbig) if (rbig) { return pow((1.0 - pow(x, r)), (1.0 / r)); } - else { - return 1.0 - pow((1.0 - pow(1.0 - x, r)), (1.0 / r)); - } + return 1.0 - pow((1.0 - pow(1.0 - x, r)), (1.0 / r)); } /** @@ -3291,16 +3285,13 @@ static EdgeHalf *next_edgehalf_bev(BevelParams *bp, if ((next_edge != NULL) && compare_ff(best_dot, second_best_dot, BEVEL_SMALL_ANG_DOT)) { return NULL; } - else { - return next_edge; - } - } - else { - /* Case 2: The next EdgeHalf is the other side of the BMEdge. - * It's part of the same BMEdge, so we know the other EdgeHalf is also beveled. */ - next_edge = find_other_end_edge_half(bp, start_edge, r_bv); return next_edge; } + + /* Case 2: The next EdgeHalf is the other side of the BMEdge. + * It's part of the same BMEdge, so we know the other EdgeHalf is also beveled. */ + next_edge = find_other_end_edge_half(bp, start_edge, r_bv); + return next_edge; } /** @@ -3740,9 +3731,8 @@ static bool is_canon(VMesh *vm, int i, int j, int k) if (vm->seg % 2 == 1) { /* Odd. */ return (j <= ns2 && k <= ns2); } - else { /* Even. */ - return ((j < ns2 && k <= ns2) || (j == ns2 && k == ns2 && i == 0)); - } + /* Even. */ + return ((j < ns2 && k <= ns2) || (j == ns2 && k == ns2 && i == 0)); } /* Copy the vertex data to all of vm verts from canonical ones. */ @@ -3806,7 +3796,7 @@ static float sabin_gamma(int n) if (n < 3) { return 0.0f; } - else if (n == 3) { + if (n == 3) { ans = 0.065247584f; } else if (n == 4) { @@ -4260,7 +4250,7 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp) if (r == PRO_SQUARE_R) { return make_cube_corner_square(mem_arena, nseg); } - else if (r == PRO_SQUARE_IN_R) { + if (r == PRO_SQUARE_IN_R) { return make_cube_corner_square_in(mem_arena, nseg); } } @@ -4628,9 +4618,7 @@ static BMEdge *find_closer_edge(float *co, BMEdge *e1, BMEdge *e2) if (dsq1 < dsq2) { return e1; } - else { - return e2; - } + return e2; } /* Snap co to the closest edge of face f. Return the edge in *r_snap_e, @@ -5769,9 +5757,7 @@ static float edge_face_angle(EdgeHalf *e) /* Angle between faces is supplement of angle between face normals. */ return (float)M_PI - angle_normalized_v3v3(e->fprev->no, e->fnext->no); } - else { - return 0.0f; - } + return 0.0f; } /* Take care, this flag isn't cleared before use, it just so happens that its not set. */ diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.c b/source/blender/bmesh/tools/bmesh_bisect_plane.c index 7b6a820ea33..85de065daff 100644 --- a/source/blender/bmesh/tools/bmesh_bisect_plane.c +++ b/source/blender/bmesh/tools/bmesh_bisect_plane.c @@ -57,12 +57,10 @@ static short plane_point_test_v3(const float plane[4], if (f <= -eps) { return -1; } - else if (f >= eps) { + if (f >= eps) { return 1; } - else { - return 0; - } + return 0; } /* -------------------------------------------------------------------- */ @@ -135,12 +133,10 @@ static int bm_vert_sortval_cb(const void *v_a_v, const void *v_b_v) if (val_a > val_b) { return 1; } - else if (val_a < val_b) { + if (val_a < val_b) { return -1; } - else { - return 0; - } + return 0; } static void bm_face_bisect_verts( diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c index 0fc0fb130fc..a2a949b5567 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c @@ -148,11 +148,10 @@ static void bm_decim_calc_target_co_db(BMEdge *e, double optimize_co[3], const Q /* all is good */ return; } - else { - optimize_co[0] = 0.5 * ((double)e->v1->co[0] + (double)e->v2->co[0]); - optimize_co[1] = 0.5 * ((double)e->v1->co[1] + (double)e->v2->co[1]); - optimize_co[2] = 0.5 * ((double)e->v1->co[2] + (double)e->v2->co[2]); - } + + optimize_co[0] = 0.5 * ((double)e->v1->co[0] + (double)e->v2->co[0]); + optimize_co[1] = 0.5 * ((double)e->v1->co[1] + (double)e->v2->co[1]); + optimize_co[2] = 0.5 * ((double)e->v1->co[2] + (double)e->v2->co[2]); } static void bm_decim_calc_target_co_fl(BMEdge *e, float optimize_co[3], const Quadric *vquadrics) @@ -1059,7 +1058,7 @@ static bool bm_edge_collapse(BMesh *bm, return true; } - else if (BM_edge_is_boundary(e_clear)) { + if (BM_edge_is_boundary(e_clear)) { /* same as above but only one triangle */ BMLoop *l_a; BMEdge *e_a_other[2]; @@ -1115,9 +1114,7 @@ static bool bm_edge_collapse(BMesh *bm, return true; } - else { - return false; - } + return false; } /** @@ -1273,11 +1270,9 @@ static bool bm_decim_edge_collapse(BMesh *bm, return true; #endif } - else { - /* add back with a high cost */ - bm_decim_invalid_edge_cost_single(e, eheap, eheap_table); - return false; - } + /* add back with a high cost */ + bm_decim_invalid_edge_cost_single(e, eheap, eheap_table); + return false; } /* Main Decimate Function diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c index 0f23165f9af..3ed27ea580e 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c +++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c @@ -278,9 +278,7 @@ static bool bm_vert_collapse_is_degenerate(BMVert *v) } return false; } - else { - return true; - } + return true; } #endif /* USE_DEGENERATE_CHECK */ diff --git a/source/blender/bmesh/tools/bmesh_edgenet.c b/source/blender/bmesh/tools/bmesh_edgenet.c index 70b39393a4f..9f4327fd1e3 100644 --- a/source/blender/bmesh/tools/bmesh_edgenet.c +++ b/source/blender/bmesh/tools/bmesh_edgenet.c @@ -143,9 +143,7 @@ static bool bm_edgenet_path_check_overlap(BMVert *v1, BMVert *v2, VertNetInfo *v return BM_face_exists_overlap_subset(vert_arr, (int)v_ls_tot); } - else { - return false; - } + return false; } /** @@ -331,11 +329,10 @@ static LinkNode *bm_edgenet_path_calc(BMEdge *e, *r_path_cost = path_cost_accum; return path; } - else { - /* check if a change was made */ - if (v_ls_next_old != v_ls_next) { - found = true; - } + + /* check if a change was made */ + if (v_ls_next_old != v_ls_next) { + found = true; } } BLI_assert(v_ls_prev == NULL); @@ -379,49 +376,49 @@ static LinkNode *bm_edgenet_path_calc_best(BMEdge *e, if (path == NULL) { return NULL; } - else if (path_cost < 1) { + if (path_cost < 1) { /* any face that takes 1 iteration to find we consider valid */ return path; } - else { - /* Check every edge to see if any can give a better path. - * This avoids very strange/long paths from being created. */ - const uint path_len = *r_path_len; - uint i, i_prev; - BMVert **vert_arr = BLI_array_alloca(vert_arr, path_len); - LinkNode *v_lnk; + /* Check every edge to see if any can give a better path. + * This avoids very strange/long paths from being created. */ - for (v_lnk = path, i = 0; v_lnk; v_lnk = v_lnk->next, i++) { - vert_arr[i] = v_lnk->link; - } + const uint path_len = *r_path_len; + uint i, i_prev; + BMVert **vert_arr = BLI_array_alloca(vert_arr, path_len); + LinkNode *v_lnk; - i_prev = path_len - 1; - for (i = 0; i < path_len; i++) { - BMEdge *e_other = BM_edge_exists(vert_arr[i], vert_arr[i_prev]); - if (e_other != e) { - LinkNode *path_test; - uint path_len_test; - uint path_cost_test; - - path_test = bm_edgenet_path_calc( - e_other, *pass_nr, path_cost, &path_len_test, &path_cost_test, vnet_info, path_pool); - (*pass_nr)++; - - if (path_test) { - BLI_assert(path_cost_test < path_cost); - - BLI_linklist_free_pool(path, NULL, path_pool); - path = path_test; - *r_path_len = path_len_test; - *r_path_cost = path_cost_test; - path_cost = path_cost_test; - } - } + for (v_lnk = path, i = 0; v_lnk; v_lnk = v_lnk->next, i++) { + vert_arr[i] = v_lnk->link; + } - i_prev = i; + i_prev = path_len - 1; + for (i = 0; i < path_len; i++) { + BMEdge *e_other = BM_edge_exists(vert_arr[i], vert_arr[i_prev]); + if (e_other != e) { + LinkNode *path_test; + uint path_len_test; + uint path_cost_test; + + path_test = bm_edgenet_path_calc( + e_other, *pass_nr, path_cost, &path_len_test, &path_cost_test, vnet_info, path_pool); + (*pass_nr)++; + + if (path_test) { + BLI_assert(path_cost_test < path_cost); + + BLI_linklist_free_pool(path, NULL, path_pool); + path = path_test; + *r_path_len = path_len_test; + *r_path_cost = path_cost_test; + path_cost = path_cost_test; + } } + + i_prev = i; } + return path; } diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c index c73b80d57f7..6426fe9c687 100644 --- a/source/blender/bmesh/tools/bmesh_intersect.c +++ b/source/blender/bmesh/tools/bmesh_intersect.c @@ -99,9 +99,7 @@ static BMEdge *bm_vert_other_edge(BMVert *v, BMEdge *e) if (v->e != e) { return v->e; } - else { - return BM_DISK_EDGE_NEXT(v->e, v); - } + return BM_DISK_EDGE_NEXT(v->e, v); } #endif @@ -1341,10 +1339,8 @@ bool BM_mesh_intersect(BMesh *bm, splice_pair[1] = v_next; break; } - else { - e_next = bm_vert_other_edge(v_next, e_step); - } + e_next = bm_vert_other_edge(v_next, e_step); e_step = e_next; v_step = v_next; BM_elem_flag_enable(e_step, BM_ELEM_TAG); diff --git a/source/blender/bmesh/tools/bmesh_intersect_edges.c b/source/blender/bmesh/tools/bmesh_intersect_edges.c index 3f0492aebb6..99a5a9edb57 100644 --- a/source/blender/bmesh/tools/bmesh_intersect_edges.c +++ b/source/blender/bmesh/tools/bmesh_intersect_edges.c @@ -127,12 +127,10 @@ static bool bm_vert_pair_share_splittable_face_cb(BMFace *UNUSED(f), if (IN_RANGE(lambda_b, range_min, range_max)) { return true; } - else { - copy_v3_v3(co, l_b->prev->v->co); - sub_v3_v3v3(dir, l_b->next->v->co, co); - if (isect_ray_ray_v3(v_a_co, v_a_b_dir, co, dir, NULL, &lambda_b)) { - return IN_RANGE(lambda_b, range_min, range_max); - } + copy_v3_v3(co, l_b->prev->v->co); + sub_v3_v3v3(dir, l_b->next->v->co, co); + if (isect_ray_ray_v3(v_a_co, v_a_b_dir, co, dir, NULL, &lambda_b)) { + return IN_RANGE(lambda_b, range_min, range_max); } } return false; @@ -476,9 +474,7 @@ static int sort_cmp_by_lambda_cb(const void *index1_v, const void *index2_v, voi if (pair_flat[index1].lambda > pair_flat[index2].lambda) { return 1; } - else { - return -1; - } + return -1; } /* -------------------------------------------------------------------- */ diff --git a/source/blender/bmesh/tools/bmesh_path_region.c b/source/blender/bmesh/tools/bmesh_path_region.c index f3061704884..f8e981bbd58 100644 --- a/source/blender/bmesh/tools/bmesh_path_region.c +++ b/source/blender/bmesh/tools/bmesh_path_region.c @@ -91,9 +91,9 @@ static bool bm_vert_region_test_chain(BMVert *v, int *const depths[2], const int if (bm_vert_region_test(v, depths, pass)) { return true; } - else if (BM_vert_is_edge_pair_manifold(v) && bm_vert_pair_ends(v, v_end_pair) && - bm_vert_region_test(v_end_pair[0], depths, pass) && - bm_vert_region_test(v_end_pair[1], depths, pass)) { + if (BM_vert_is_edge_pair_manifold(v) && bm_vert_pair_ends(v, v_end_pair) && + bm_vert_region_test(v_end_pair[0], depths, pass) && + bm_vert_region_test(v_end_pair[1], depths, pass)) { return true; } diff --git a/source/blender/bmesh/tools/bmesh_region_match.c b/source/blender/bmesh/tools/bmesh_region_match.c index 44761b9f37e..8de23b696bf 100644 --- a/source/blender/bmesh/tools/bmesh_region_match.c +++ b/source/blender/bmesh/tools/bmesh_region_match.c @@ -139,9 +139,7 @@ BLI_INLINE bool bm_uuidwalk_face_test(UUIDWalk *uuidwalk, BMFace *f) if (uuidwalk->use_face_isolate) { return BM_elem_flag_test_bool(f, BM_ELEM_TAG); } - else { - return true; - } + return true; } BLI_INLINE bool bm_uuidwalk_vert_lookup(UUIDWalk *uuidwalk, BMVert *v, UUID_Int *r_uuid) @@ -152,9 +150,7 @@ BLI_INLINE bool bm_uuidwalk_vert_lookup(UUIDWalk *uuidwalk, BMVert *v, UUID_Int *r_uuid = (UUID_Int)(*ret); return true; } - else { - return false; - } + return false; } BLI_INLINE bool bm_uuidwalk_face_lookup(UUIDWalk *uuidwalk, BMFace *f, UUID_Int *r_uuid) @@ -165,9 +161,7 @@ BLI_INLINE bool bm_uuidwalk_face_lookup(UUIDWalk *uuidwalk, BMFace *f, UUID_Int *r_uuid = (UUID_Int)(*ret); return true; } - else { - return false; - } + return false; } static uint ghashutil_bmelem_indexhash(const void *key) @@ -566,12 +560,10 @@ static int bm_face_len_cmp(const void *v1, const void *v2) if (f1->len > f2->len) { return 1; } - else if (f1->len < f2->len) { + if (f1->len < f2->len) { return -1; } - else { - return 0; - } + return 0; } static uint bm_uuidwalk_init_from_edge(UUIDWalk *uuidwalk, BMEdge *e) @@ -937,10 +929,8 @@ static bool bm_edge_is_region_boundary(BMEdge *e) } while ((l_iter = l_iter->radial_next) != e->l); return false; } - else { - /* boundary */ - return true; - } + /* boundary */ + return true; } static void bm_face_region_pivot_edge_use_best(GHash *gh, diff --git a/source/blender/bmesh/tools/bmesh_wireframe.c b/source/blender/bmesh/tools/bmesh_wireframe.c index 2240c64807c..1c820db74f4 100644 --- a/source/blender/bmesh/tools/bmesh_wireframe.c +++ b/source/blender/bmesh/tools/bmesh_wireframe.c @@ -142,13 +142,13 @@ static bool bm_loop_is_radial_boundary(BMLoop *l_first) if (l == l_first) { return true; /* a real boundary */ } - else { - do { - if (BM_elem_flag_test(l->f, BM_ELEM_TAG)) { - return false; - } - } while ((l = l->radial_next) != l_first); - } + + do { + if (BM_elem_flag_test(l->f, BM_ELEM_TAG)) { + return false; + } + } while ((l = l->radial_next) != l_first); + return true; } |