Transform: Use `isect_ray_seg_v3` instead `dist_squared_ray_to_seg_v3` in the functio...
authorGermano <germano.costa@ig.com.br>
Thu, 17 May 2018 01:04:41 +0000 (22:04 -0300)
committerGermano <germano.costa@ig.com.br>
Thu, 17 May 2018 01:04:41 +0000 (22:04 -0300)
source/blender/editors/transform/transform_snap_object.c

index 5f6fafaeff3129104014d8b7d9994dafe3c17592..84a4c7dbf14bd1481e37d2331019da4f28b942cb 100644 (file)
@@ -916,11 +916,25 @@ static bool test_projected_edge_dist(
         const bool is_persp, const float va[3], const float vb[3],
         float *dist_px_sq, float r_co[3])
 {
-       float near_co[3], dummy_depth;
-       dist_squared_ray_to_seg_v3(
+       float near_co[3], lambda;
+       if (!isect_ray_seg_v3(
                precalc->ray_origin,
                precalc->ray_direction,
-               va, vb, near_co, &dummy_depth);
+               va, vb, &lambda))
+       {
+               copy_v3_v3(near_co, va);
+       }
+       else {
+               if (lambda <= 0.0f) {
+                       copy_v3_v3(near_co, va);
+               }
+               else if (lambda >= 1.0f) {
+                       copy_v3_v3(near_co, vb);
+               }
+               else {
+                       interp_v3_v3v3(near_co, va, vb, lambda);
+               }
+       }
 
        return test_projected_vert_dist(
                precalc, clip_plane, clip_plane_len,