From f9b7617104a74d9b1a267a775627cdad60e0e333 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 17 Jun 2014 03:53:02 +1000 Subject: Fix T40646: Knife project fails with clipping --- source/blender/editors/mesh/editmesh_knife.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 8be8c415be2..96a608a432b 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1161,6 +1161,13 @@ static bool point_is_visible(KnifeTool_OpData *kcd, const float p[3], const floa { BMFace *f_hit; + /* If box clipping on, make sure p is not clipped */ + if (kcd->vc.rv3d->rflag & RV3D_CLIPPING && + ED_view3d_clipping_test(kcd->vc.rv3d, p, true)) + { + return false; + } + /* If not cutting through, make sure no face is in front of p */ if (!kcd->cut_through) { float dist; @@ -1181,19 +1188,23 @@ static bool point_is_visible(KnifeTool_OpData *kcd, const float p[3], const floa dist = kcd->vc.v3d->far * 2.0f; } + if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { + float view_clip[2][3]; + /* note: view_clip[0] should never get clipped */ + copy_v3_v3(view_clip[0], p_ofs); + madd_v3_v3v3fl(view_clip[1], p_ofs, view, dist); + + if (clip_segment_v3_plane_n(view_clip[0], view_clip[1], kcd->vc.rv3d->clip_local, 6)) { + dist = len_v3v3(p_ofs, view_clip[1]); + } + } + /* see if there's a face hit between p1 and the view */ f_hit = BKE_bmbvh_ray_cast(kcd->bmbvh, p_ofs, view, KNIFE_FLT_EPS, &dist, NULL, NULL); if (f_hit) return false; } - /* If box clipping on, make sure p is not clipped */ - if (kcd->vc.rv3d->rflag & RV3D_CLIPPING && - ED_view3d_clipping_test(kcd->vc.rv3d, p, true)) - { - return false; - } - return true; } -- cgit v1.2.3