Fix T40646: Knife project fails with clipping

This commit is contained in:
Campbell Barton 2014-06-17 03:53:02 +10:00
parent e848cb9e48
commit f9b7617104
Notes: blender-bot 2023-02-14 10:29:30 +01:00
Referenced by issue #40646, Knife project does not work when the "Clipping Border" cuts out a portion of the mesh that would other wise obscure the surface to be cut.
1 changed files with 18 additions and 7 deletions

View File

@ -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;
}