diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-14 12:44:35 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-14 12:44:35 +0400 |
commit | f2074949e7a3dbf3a1dc5b51a0a3eee0eee9aada (patch) | |
tree | 1912a8eb416499bdba69f0955515b3d905c52024 /source/blender/editors/uvedit/uvedit_ops.c | |
parent | 8d496b3bf2c58a0a161c20c987f414953a6d1e87 (diff) |
code cleanup: reduce calling sqrt() when distances are only calculated for comparison use dist_squared_to_line_segment_v2().
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_ops.c')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 38fd3fe5c68..54c5cbfce93 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -680,10 +680,10 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, const float BMLoop *l; BMIter iter, liter; MLoopUV *luv, *nextluv; - float mindist, dist; + float mindist_squared, dist_squared; int i; - mindist = 1e10f; + mindist_squared = 1e10f; memset(hit, 0, sizeof(*hit)); BM_mesh_elem_index_ensure(em->bm, BM_VERT); @@ -698,9 +698,9 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, const float luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); nextluv = CustomData_bmesh_get(&em->bm->ldata, l->next->head.data, CD_MLOOPUV); - dist = dist_to_line_segment_v2(co, luv->uv, nextluv->uv); + dist_squared = dist_squared_to_line_segment_v2(co, luv->uv, nextluv->uv); - if (dist < mindist) { + if (dist_squared < mindist_squared) { hit->tf = tf; hit->efa = efa; @@ -712,7 +712,7 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, const float hit->vert1 = BM_elem_index_get(hit->l->v); hit->vert2 = BM_elem_index_get(hit->l->next->v); - mindist = dist; + mindist_squared = dist_squared; } i++; |