diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-07-10 04:31:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-07-10 04:49:46 +0300 |
commit | 0b77e2f4c4370b1f54c3562c39081c4189355ceb (patch) | |
tree | e86f83bb9c65372968cd0f3e55e2cec3cc653128 /source/blender | |
parent | 92bc2779503bf3f41ede76ce690f520ea9c09e5d (diff) |
Cleanup: variable names, use define for maximum path cost
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/bmesh/tools/bmesh_path.c | 16 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_path_uv.c | 13 |
2 files changed, 16 insertions, 13 deletions
diff --git a/source/blender/bmesh/tools/bmesh_path.c b/source/blender/bmesh/tools/bmesh_path.c index 815f4a1c5bb..673bf5b42e1 100644 --- a/source/blender/bmesh/tools/bmesh_path.c +++ b/source/blender/bmesh/tools/bmesh_path.c @@ -31,6 +31,8 @@ #include "bmesh.h" #include "bmesh_path.h" /* own include */ +#define COST_INIT_MAX 1e20f + /* -------------------------------------------------------------------- */ /** \name Generic Helpers * \{ */ @@ -154,7 +156,7 @@ LinkNode *BM_mesh_calc_path_vert(BMesh *bm, verts_prev = MEM_callocN(sizeof(*verts_prev) * totvert, __func__); cost = MEM_mallocN(sizeof(*cost) * totvert, __func__); - copy_vn_fl(cost, totvert, 1e20f); + copy_vn_fl(cost, totvert, COST_INIT_MAX); /* * Arrays are now filled as follows: @@ -334,7 +336,7 @@ LinkNode *BM_mesh_calc_path_edge(BMesh *bm, edges_prev = MEM_callocN(sizeof(*edges_prev) * totedge, __func__); cost = MEM_mallocN(sizeof(*cost) * totedge, __func__); - copy_vn_fl(cost, totedge, 1e20f); + copy_vn_fl(cost, totedge, COST_INIT_MAX); /* * Arrays are now filled as follows: @@ -400,13 +402,13 @@ static float facetag_cut_cost_edge(BMFace *f_a, #else /* For triangle fans it gives better results to pick a point on the edge. */ { - float ix_e[3], ix_f[3], f; + float ix_e[3], ix_f[3]; isect_line_line_v3(e->v1->co, e->v2->co, f_a_cent, f_b_cent, ix_e, ix_f); - f = line_point_factor_v3(ix_e, e->v1->co, e->v2->co); - if (f < 0.0f) { + const float factor = line_point_factor_v3(ix_e, e->v1->co, e->v2->co); + if (factor < 0.0f) { copy_v3_v3(e_cent, e->v1->co); } - else if (f > 1.0f) { + else if (factor > 1.0f) { copy_v3_v3(e_cent, e->v2->co); } else { @@ -535,7 +537,7 @@ LinkNode *BM_mesh_calc_path_face(BMesh *bm, faces_prev = MEM_callocN(sizeof(*faces_prev) * totface, __func__); cost = MEM_mallocN(sizeof(*cost) * totface, __func__); - copy_vn_fl(cost, totface, 1e20f); + copy_vn_fl(cost, totface, COST_INIT_MAX); /* * Arrays are now filled as follows: diff --git a/source/blender/bmesh/tools/bmesh_path_uv.c b/source/blender/bmesh/tools/bmesh_path_uv.c index b2999b305e0..23bee37be7b 100644 --- a/source/blender/bmesh/tools/bmesh_path_uv.c +++ b/source/blender/bmesh/tools/bmesh_path_uv.c @@ -33,6 +33,8 @@ #include "intern/bmesh_query.h" #include "intern/bmesh_query_uv.h" +#define COST_INIT_MAX 1e20f + /* -------------------------------------------------------------------- */ /** \name Generic Helpers * \{ */ @@ -156,7 +158,7 @@ struct LinkNode *BM_mesh_calc_path_uv_vert(BMesh *bm, loops_prev = MEM_callocN(sizeof(*loops_prev) * totloop, __func__); cost = MEM_mallocN(sizeof(*cost) * totloop, __func__); - copy_vn_fl(cost, totloop, 1e20f); + copy_vn_fl(cost, totloop, COST_INIT_MAX); /* Regular dijkstra shortest path, but over UV loops instead of vertices. */ heap = BLI_heapsimple_new(); @@ -196,8 +198,7 @@ struct LinkNode *BM_mesh_calc_path_uv_vert(BMesh *bm, /* -------------------------------------------------------------------- */ /** \name BM_mesh_calc_path_uv_edge * \{ */ - -/* TODO(campbell): not very urgent. */ +/* TODO(campbell): not very urgent, since the operator fakes this using vertex path. */ /** \} */ @@ -228,9 +229,9 @@ static float facetag_cut_cost_edge_uv(BMFace *f_a, #else /* For triangle fans it gives better results to pick a point on the edge. */ { - float ix_e[2], factor; + float ix_e[2]; isect_line_line_v2_point(co_v1, co_v2, f_a_cent, f_b_cent, ix_e); - factor = line_point_factor_v2(ix_e, co_v1, co_v2); + const float factor = line_point_factor_v2(ix_e, co_v1, co_v2); if (factor < 0.0f) { copy_v2_v2(e_cent, co_v1); } @@ -394,7 +395,7 @@ struct LinkNode *BM_mesh_calc_path_uv_face(BMesh *bm, faces_prev = MEM_callocN(sizeof(*faces_prev) * totface, __func__); cost = MEM_mallocN(sizeof(*cost) * totface, __func__); - copy_vn_fl(cost, totface, 1e20f); + copy_vn_fl(cost, totface, COST_INIT_MAX); /* Regular dijkstra shortest path, but over UV faces instead of vertices. */ heap = BLI_heapsimple_new(); |