[Bf-extensions-cvs] [67c555a8] master: mesh_snap_utilities_line: fixes bug with shift constrain due to recent changes

Germano noreply at git.blender.org
Fri Sep 22 20:33:55 CEST 2017


Commit: 67c555a8b193749b6440d2cdcad9961a9949f0b2
Author: Germano
Date:   Fri Sep 22 15:33:46 2017 -0300
Branches: master
https://developer.blender.org/rBA67c555a8b193749b6440d2cdcad9961a9949f0b2

mesh_snap_utilities_line: fixes bug with shift constrain due to recent changes

===================================================================

M	mesh_snap_utilities_line.py

===================================================================

diff --git a/mesh_snap_utilities_line.py b/mesh_snap_utilities_line.py
index f582c701..a74c7479 100644
--- a/mesh_snap_utilities_line.py
+++ b/mesh_snap_utilities_line.py
@@ -127,7 +127,7 @@ def out_Location(rv3d, region, orig, vector):
     return hit
 
 
-def get_closest_edge(bm, point, dist_sq):
+def get_closest_edge(bm, point, dist):
     r_edge = None
     for edge in bm.edges:
         v1 = edge.verts[0].co
@@ -151,9 +151,9 @@ def get_closest_edge(bm, point, dist_sq):
             else:
                 tmp = ret[0]
 
-            new_dist_sq = (point - tmp).length_squared
-            if new_dist_sq <= dist_sq:
-                dist_sq = new_dist_sq
+            new_dist = (point - tmp).length
+            if new_dist <= dist:
+                dist = new_dist
                 r_edge = edge
 
     return r_edge
@@ -206,6 +206,10 @@ def snap_utilities(
         is_increment = True
         r_type = 'OUT'
         r_loc = out_Location(rv3d, region, orig, view_vector)
+        if constrain:
+            t_loc = intersect_point_line(r_loc, constrain[0], constrain[1])[0]
+            if t_loc:
+                r_loc = t_loc
 
     elif snp_obj.data[0] != obj: #OUT
         r_loc = loc
@@ -759,7 +763,7 @@ class SnapUtilitiesLine(Operator):
                 point = self.obj_matinv * self.location
                 # with constraint the intersection can be in a different element of the selected one
                 if self.vector_constrain and self.geom:
-                    geom2 = get_closest_edge(self.bm, point, 1e-06)
+                    geom2 = get_closest_edge(self.bm, point, 0.001)
                 else:
                     geom2 = self.geom



More information about the Bf-extensions-cvs mailing list