From 67c555a8b193749b6440d2cdcad9961a9949f0b2 Mon Sep 17 00:00:00 2001 From: Germano <germano.costa@ig.com.br> Date: Fri, 22 Sep 2017 15:33:46 -0300 Subject: [PATCH] mesh_snap_utilities_line: fixes bug with shift constrain due to recent changes --- mesh_snap_utilities_line.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mesh_snap_utilities_line.py b/mesh_snap_utilities_line.py index f582c7011..a74c74794 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 -- GitLab