Fix T65585: Knife fails when cursor away from the object

Zeroed mouse coordinates were being used making projection fail.
This commit is contained in:
Campbell Barton 2020-11-10 16:22:35 +11:00 committed by Jeroen Bakker
parent 22c0555cc5
commit 19b85c5f4b
Notes: blender-bot 2023-02-14 02:16:33 +01:00
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
Referenced by issue #65585, Knife Tool fail if camera is too close to the object and mouse away from object
1 changed files with 9 additions and 2 deletions

View File

@ -1895,8 +1895,15 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd,
if (!f) {
if (kcd->is_interactive) {
/* try to use backbuffer selection method if ray casting failed */
f = EDBM_face_find_nearest(&kcd->vc, &dist);
/* Try to use back-buffer selection method if ray casting failed.
*
* Apply the mouse coordinates to a copy of the view-context
* since we don't want to rely on this being set elsewhere. */
ViewContext vc = kcd->vc;
vc.mval[0] = (int)kcd->curr.mval[0];
vc.mval[1] = (int)kcd->curr.mval[1];
f = EDBM_face_find_nearest(&vc, &dist);
/* cheat for now; just put in the origin instead
* of a true coordinate on the face.