From a1eb5ec81c8116e09f62b123cf6facbff5967e25 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Apr 2020 14:44:13 +1000 Subject: Cleanup: doxy sections, move utility function to editmesh_utils.c --- source/blender/editors/mesh/editmesh_utils.c | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'source/blender/editors/mesh/editmesh_utils.c') diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 998e0d736e6..a26003d78ed 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -52,6 +52,7 @@ #include "ED_mesh.h" #include "ED_screen.h" +#include "ED_transform_snap_object_context.h" #include "ED_uvedit.h" #include "ED_view3d.h" @@ -1638,3 +1639,48 @@ bool BMBVH_EdgeVisible(struct BMBVHTree *tree, } /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name BMesh Vertex Projection API + * \{ */ + +void EDBM_project_snap_verts( + bContext *C, Depsgraph *depsgraph, ARegion *region, Object *obedit, BMEditMesh *em) +{ + Main *bmain = CTX_data_main(C); + BMIter iter; + BMVert *eve; + + ED_view3d_init_mats_rv3d(obedit, region->regiondata); + + struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( + bmain, CTX_data_scene(C), 0, region, CTX_wm_view3d(C)); + + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { + if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { + float mval[2], co_proj[3]; + if (ED_view3d_project_float_object(region, eve->co, mval, V3D_PROJ_TEST_NOP) == + V3D_PROJ_RET_OK) { + if (ED_transform_snap_object_project_view3d(snap_context, + depsgraph, + SCE_SNAP_MODE_FACE, + &(const struct SnapObjectParams){ + .snap_select = SNAP_NOT_ACTIVE, + .use_object_edit_cage = false, + .use_occlusion_test = true, + }, + mval, + NULL, + NULL, + co_proj, + NULL)) { + mul_v3_m4v3(eve->co, obedit->imat, co_proj); + } + } + } + } + + ED_transform_snap_object_context_destroy(snap_context); +} + +/** \} */ -- cgit v1.2.3