diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_slide.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_slide.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c index eaf0c14a0a8..bd1d13f3528 100644 --- a/source/blender/editors/mesh/editmesh_slide.c +++ b/source/blender/editors/mesh/editmesh_slide.c @@ -381,23 +381,22 @@ static BMEdge *vtx_slide_nrst_in_frame(VertexSlideOp *vso, const float mval[2]) BMEdge *edge = NULL; float v1_proj[3], v2_proj[3]; + float dist = 0; float min_dist = FLT_MAX; for (i = 0; i < vso->disk_edges; i++) { edge = vso->edge_frame[i]; mul_v3_m4v3(v1_proj, vso->obj->obmat, edge->v1->co); + ED_view3d_project_float_noclip(vso->active_region, v1_proj, v1_proj); + mul_v3_m4v3(v2_proj, vso->obj->obmat, edge->v2->co); + ED_view3d_project_float_noclip(vso->active_region, v2_proj, v2_proj); - /* we could use ED_view3d_project_float_object here, but for now dont since we dont have the context */ - if ((ED_view3d_project_float_global(vso->active_region, v1_proj, v1_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && - (ED_view3d_project_float_global(vso->active_region, v2_proj, v2_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) - { - const float dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj); - if (dist < min_dist) { - min_dist = dist; - cl_edge = edge; - } + dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj); + if (dist < min_dist) { + min_dist = dist; + cl_edge = edge; } } } @@ -449,21 +448,17 @@ static void vtx_slide_update(VertexSlideOp *vso, wmEvent *event) /* Calculate interpolation value for preview */ float t_val; - float mval_float[2] = { (float)event->mval[0], (float)event->mval[1]}; + float mval_float[] = { (float)event->mval[0], (float)event->mval[1]}; float closest_2d[2]; other = BM_edge_other_vert(edge, vso->start_vtx); /* Project points onto screen and do interpolation in 2D */ mul_v3_m4v3(start_vtx_proj, vso->obj->obmat, vso->start_vtx->co); - mul_v3_m4v3(edge_other_proj, vso->obj->obmat, other->co); + ED_view3d_project_float_noclip(vso->active_region, start_vtx_proj, start_vtx_proj); - if ((ED_view3d_project_float_global(vso->active_region, edge_other_proj, edge_other_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) || - (ED_view3d_project_float_global(vso->active_region, start_vtx_proj, start_vtx_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK)) - { - /* not much we can do here */ - return; - } + mul_v3_m4v3(edge_other_proj, vso->obj->obmat, other->co); + ED_view3d_project_float_noclip(vso->active_region, edge_other_proj, edge_other_proj); closest_to_line_v2(closest_2d, mval_float, start_vtx_proj, edge_other_proj); @@ -475,7 +470,7 @@ static void vtx_slide_update(VertexSlideOp *vso, wmEvent *event) if (edge_len <= 0.0f) edge_len = VTX_SLIDE_SNAP_THRSH; - edge_len = (BM_edge_calc_length(edge) * VTX_SLIDE_SNAP_THRSH) / edge_len; + edge_len = (len_v3v3(edge->v1->co, edge->v2->co) * VTX_SLIDE_SNAP_THRSH) / edge_len; vso->snap_threshold = edge_len; |