diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-06-16 21:53:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-06-16 22:07:03 +0400 |
commit | f9b7617104a74d9b1a267a775627cdad60e0e333 (patch) | |
tree | 7d96ed1022e992a6fa1aadbb9cd88dd97184846f /source/blender/editors/mesh | |
parent | e848cb9e48541cebe6bf47674e6db71d152d759f (diff) |
Fix T40646: Knife project fails with clipping
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 25 |
1 files 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; } |