From 7d4d44bb1f660e4094b7d7bb35f6cda1bb2fc1b4 Mon Sep 17 00:00:00 2001 From: Andrew Wiggin Date: Thu, 20 Oct 2011 13:41:52 +0000 Subject: [PATCH] Trial fix for knife cut intermediate point snapping: snap intermediate points (for edge intersections between clicks in knife tool) to midpoints or endpoints, depending on which is closest --- source/blender/editors/mesh/knifetool.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/mesh/knifetool.c b/source/blender/editors/mesh/knifetool.c index 38a90628c8b..b954c44c74c 100755 --- a/source/blender/editors/mesh/knifetool.c +++ b/source/blender/editors/mesh/knifetool.c @@ -858,8 +858,21 @@ static BMEdgeHit *knife_edge_tri_isect(knifetool_opdata *kcd, BMBVHTree *bmtree, copy_v3_v3(hit.realhit, p); if (kcd->snap_midpoints) { - interp_v3_v3v3(hit.hit, kfe->v1->co, kfe->v2->co, 0.5f); - interp_v3_v3v3(hit.cagehit, kfe->v1->cageco, kfe->v2->cageco, 0.5f); + float perc = hit.perc; + + /* select the closest from the edge endpoints or the midpoint */ + if (perc < 0.25f) { + perc = 0.0f; + } + else if (perc < 0.75f) { + perc = 0.5f; + } + else { + perc = 1.0f; + } + + interp_v3_v3v3(hit.hit, kfe->v1->co, kfe->v2->co, perc); + interp_v3_v3v3(hit.cagehit, kfe->v1->cageco, kfe->v2->cageco, perc); } else { copy_v3_v3(hit.hit, p); }