diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-06-20 00:11:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-06-20 00:11:28 +0400 |
commit | 93af050824170913d716e42e918ab58c224ed7f1 (patch) | |
tree | 1899aa595d18c35b90ded63b18df774e5840f938 | |
parent | 998101763aae5b0d25f6fa0f1a3227e45bb03b1e (diff) |
correct editmesh BKE_bmbvh_find_vert_closest(), distances are expected to be squared.
-rw-r--r-- | source/blender/blenkernel/intern/editmesh_bvh.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/editmesh_bvh.c b/source/blender/blenkernel/intern/editmesh_bvh.c index 979a38f0346..160972889fd 100644 --- a/source/blender/blenkernel/intern/editmesh_bvh.c +++ b/source/blender/blenkernel/intern/editmesh_bvh.c @@ -382,7 +382,7 @@ static void bmbvh_find_vert_closest_cb(void *userdata, int index, const float *U bmbvh_tri_from_face(tri_cos, ltri, bmcb_data->cos_cage); for (i = 0; i < 3; i++) { - dist = len_v3v3(hit->co, tri_cos[i]); + dist = len_squared_v3v3(hit->co, tri_cos[i]); if (dist < hit->dist && dist < maxdist) { copy_v3_v3(hit->co, tri_cos[i]); /* XXX, normal ignores cage */ @@ -398,17 +398,17 @@ BMVert *BKE_bmbvh_find_vert_closest(BMBVHTree *bmtree, const float co[3], const { BVHTreeNearest hit; struct VertSearchUserData bmcb_data; + const float maxdist_sq = maxdist * maxdist; if (bmtree->cos_cage) BLI_assert(!(bmtree->em->bm->elem_index_dirty & BM_VERT)); copy_v3_v3(hit.co, co); - /* XXX, why x5, scampbell */ - hit.dist = maxdist * 5; + hit.dist = maxdist_sq; hit.index = -1; bmcb_data.looptris = (const BMLoop *(*)[3])bmtree->em->looptris; bmcb_data.cos_cage = (const float (*)[3])bmtree->cos_cage; - bmcb_data.maxdist = maxdist; + bmcb_data.maxdist = maxdist_sq; BLI_bvhtree_find_nearest(bmtree->tree, co, &hit, bmbvh_find_vert_closest_cb, &bmcb_data); if (hit.dist != FLT_MAX && hit.index != -1) { |