From 963a991a20de2a57c14c58f56391f0818e30c043 Mon Sep 17 00:00:00 2001 From: mano-wii Date: Tue, 27 Aug 2019 01:06:30 -0300 Subject: Fix specific case where a vertex is ignored in snapping Sometimes the index of the edge and the vertex may coincide. --- source/blender/editors/transform/transform_snap_object.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 7a8a123cf79..e809b3d1acd 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -2335,7 +2335,6 @@ static short snapEditMesh(SnapObjectContext *sctx, .index = -1, .dist_sq = dist_px_sq, }; - int last_index = nearest.index; short elem = SCE_SNAP_MODE_VERTEX; float tobmat[4][4], clip_planes_local[MAX_CLIPPLANE_LEN][4]; @@ -2356,12 +2355,12 @@ static short snapEditMesh(SnapObjectContext *sctx, &nearest, cb_snap_vert, &nearest2d); - - last_index = nearest.index; } if (treedata_edge && snapdata->snap_to_flag & (SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR)) { + int last_index = nearest.index; + nearest.index = -1; BM_mesh_elem_table_ensure(em->bm, BM_EDGE | BM_VERT); BLI_bvhtree_find_nearest_projected(treedata_edge->tree, lpmat, @@ -2373,9 +2372,12 @@ static short snapEditMesh(SnapObjectContext *sctx, cb_snap_edge, &nearest2d); - if (last_index != nearest.index) { + if (nearest.index != -1) { elem = SCE_SNAP_MODE_EDGE; } + else { + nearest.index = last_index; + } } if (nearest.index != -1) { -- cgit v1.2.3