From 80cbbd2843c2358879b1a710d81a3b41e1468327 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 29 Mar 2021 17:43:06 +1100 Subject: Knife: support vert/edge snapping when not directly over a face Respect the distance argument to EDBM_face_find_nearest, when zero, sample a single pixel, otherwise sample a region. Knife uses the selection-buffer to pick a face when the ray-cast failed. This was meant to allow snapping to nearby faces however as the margin was ignored, it was only used in edge cases where the ray-cast missed but the pixel didn't. Now the face-picking threshold is working as expected. Note that other callers to EDBM_face_find_nearest have been updated so set their distance argument to zero so this only impacts the knife. Regular selection and path select could be modified separately if users prefer this behavior. --- source/blender/editors/mesh/editmesh_path.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/editors/mesh/editmesh_path.c') diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c index b7f671a4157..13c156fddec 100644 --- a/source/blender/editors/mesh/editmesh_path.c +++ b/source/blender/editors/mesh/editmesh_path.c @@ -646,6 +646,9 @@ static BMElem *edbm_elem_find_nearest(ViewContext *vc, const char htype) return (BMElem *)EDBM_edge_find_nearest(vc, &dist); } if ((em->selectmode & SCE_SELECT_FACE) && (htype == BM_FACE)) { + /* Only pick faces directly under the cursor. + * We could look into changing this, for now it matches regular face selection. */ + dist = 0.0f; return (BMElem *)EDBM_face_find_nearest(vc, &dist); } -- cgit v1.2.3