Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editmesh_knife.c
| Show First 20 Lines • Show All 1,454 Lines • ▼ Show 20 Lines | |||||
| static bool point_is_visible(KnifeTool_OpData *kcd, | static bool point_is_visible(KnifeTool_OpData *kcd, | ||||
| const float p[3], | const float p[3], | ||||
| const float s[2], | const float s[2], | ||||
| BMElem *ele_test) | BMElem *ele_test) | ||||
| { | { | ||||
| BMFace *f_hit; | BMFace *f_hit; | ||||
| /* If box clipping on, make sure p is not clipped */ | /* 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)) { | if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d) && | ||||
| ED_view3d_clipping_test(kcd->vc.rv3d, p, true)) { | |||||
| return false; | return false; | ||||
| } | } | ||||
| /* If not cutting through, make sure no face is in front of p */ | /* If not cutting through, make sure no face is in front of p */ | ||||
| if (!kcd->cut_through) { | if (!kcd->cut_through) { | ||||
| float dist; | float dist; | ||||
| float view[3], p_ofs[3]; | float view[3], p_ofs[3]; | ||||
| /* TODO: I think there's a simpler way to get the required raycast ray */ | /* TODO: I think there's a simpler way to get the required raycast ray */ | ||||
| ED_view3d_unproject(kcd->vc.ar, s[0], s[1], 0.0f, view); | ED_view3d_unproject(kcd->vc.ar, s[0], s[1], 0.0f, view); | ||||
| mul_m4_v3(kcd->ob->imat, view); | mul_m4_v3(kcd->ob->imat, view); | ||||
| /* make p_ofs a little towards view, so ray doesn't hit p's face. */ | /* make p_ofs a little towards view, so ray doesn't hit p's face. */ | ||||
| sub_v3_v3(view, p); | sub_v3_v3(view, p); | ||||
| dist = normalize_v3(view); | dist = normalize_v3(view); | ||||
| copy_v3_v3(p_ofs, p); | copy_v3_v3(p_ofs, p); | ||||
| /* avoid projecting behind the viewpoint */ | /* avoid projecting behind the viewpoint */ | ||||
| if (kcd->is_ortho && (kcd->vc.rv3d->persp != RV3D_CAMOB)) { | if (kcd->is_ortho && (kcd->vc.rv3d->persp != RV3D_CAMOB)) { | ||||
| dist = kcd->vc.v3d->clip_end * 2.0f; | dist = kcd->vc.v3d->clip_end * 2.0f; | ||||
| } | } | ||||
| if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { | if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d)) { | ||||
| float view_clip[2][3]; | float view_clip[2][3]; | ||||
| /* note: view_clip[0] should never get clipped */ | /* note: view_clip[0] should never get clipped */ | ||||
| copy_v3_v3(view_clip[0], p_ofs); | copy_v3_v3(view_clip[0], p_ofs); | ||||
| madd_v3_v3v3fl(view_clip[1], p_ofs, view, dist); | madd_v3_v3v3fl(view_clip[1], p_ofs, view, dist); | ||||
| if (clip_segment_v3_plane_n(view_clip[0], | if (clip_segment_v3_plane_n(view_clip[0], | ||||
| view_clip[1], | view_clip[1], | ||||
| kcd->vc.rv3d->clip_local, | kcd->vc.rv3d->clip_local, | ||||
| ▲ Show 20 Lines • Show All 434 Lines • ▼ Show 20 Lines | for (ref = lst->first; ref; ref = ref->next) { | ||||
| for (i = 0; i < 2; i++) { | for (i = 0; i < 2; i++) { | ||||
| KnifeVert *kfv = i ? kfe->v2 : kfe->v1; | KnifeVert *kfv = i ? kfe->v2 : kfe->v1; | ||||
| knife_project_v2(kcd, kfv->cageco, kfv->sco); | knife_project_v2(kcd, kfv->cageco, kfv->sco); | ||||
| dis_sq = len_squared_v2v2(kfv->sco, sco); | dis_sq = len_squared_v2v2(kfv->sco, sco); | ||||
| if (dis_sq < radius_sq) { | if (dis_sq < radius_sq) { | ||||
| if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { | if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d)) { | ||||
| if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true) == 0) { | if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true) == 0) { | ||||
| c++; | c++; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| c++; | c++; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | for (ref = lst->first; ref; ref = ref->next) { | ||||
| else { | else { | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| /* now we have 'lambda' calculated (in screen-space) */ | /* now we have 'lambda' calculated (in screen-space) */ | ||||
| knife_interp_v3_v3v3(kcd, test_cagep, kfe->v1->cageco, kfe->v2->cageco, lambda); | knife_interp_v3_v3v3(kcd, test_cagep, kfe->v1->cageco, kfe->v2->cageco, lambda); | ||||
| if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { | if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d)) { | ||||
| /* check we're in the view */ | /* check we're in the view */ | ||||
| if (ED_view3d_clipping_test(kcd->vc.rv3d, test_cagep, true)) { | if (ED_view3d_clipping_test(kcd->vc.rv3d, test_cagep, true)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| cure = kfe; | cure = kfe; | ||||
| curdis_sq = dis_sq; | curdis_sq = dis_sq; | ||||
| ▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | for (ref = lst->first; ref; ref = ref->next) { | ||||
| if (dist_squared_to_line_segment_v2(kfv->sco, kcd->prev.mval, kcd->curr.mval) > | if (dist_squared_to_line_segment_v2(kfv->sco, kcd->prev.mval, kcd->curr.mval) > | ||||
| KNIFE_FLT_EPSBIG) { | KNIFE_FLT_EPSBIG) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| dis_sq = len_squared_v2v2(kfv->sco, sco); | dis_sq = len_squared_v2v2(kfv->sco, sco); | ||||
| if (dis_sq < curdis_sq && dis_sq < maxdist_sq) { | if (dis_sq < curdis_sq && dis_sq < maxdist_sq) { | ||||
| if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { | if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d)) { | ||||
| if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true) == 0) { | if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true) == 0) { | ||||
| curv = kfv; | curv = kfv; | ||||
| curdis_sq = dis_sq; | curdis_sq = dis_sq; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| curv = kfv; | curv = kfv; | ||||
| curdis_sq = dis_sq; | curdis_sq = dis_sq; | ||||
| ▲ Show 20 Lines • Show All 1,072 Lines • Show Last 20 Lines | |||||