From 97576cd51b2fd5cca4de8003be0665f8d79fe2d3 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 7 Oct 2010 10:57:21 +0000 Subject: [PATCH] Fix for [#22250] Retopo projects to the wrong object when multiple objects are behind. * Scaling of objects wasn't properly taken into account when projecting the verts. --- source/blender/editors/transform/transform_snap.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 5b7bcac65f2..09c04168a71 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1301,15 +1301,18 @@ int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, E BVHTreeRayHit hit; BVHTreeFromMesh treeData; + /* local scale in normal direction */ + float local_scale = len_v3(ray_normal_local); + bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6); hit.index = -1; - hit.dist = *depth; + hit.dist = *depth * (*depth == FLT_MAX ? 1.0f : local_scale); if(treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) { - if(hit.dist<=*depth) { - *depth= hit.dist; + if(hit.dist/local_scale <= *depth) { + *depth= hit.dist/local_scale; copy_v3_v3(loc, hit.co); copy_v3_v3(no, hit.no);