diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_path.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_path.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c index bf5a7e3a053..2ae48bee095 100644 --- a/source/blender/editors/mesh/editmesh_path.c +++ b/source/blender/editors/mesh/editmesh_path.c @@ -59,6 +59,8 @@ #include "bmesh.h" #include "bmesh_tools.h" +#include "DEG_depsgraph.h" + #include "mesh_intern.h" /* own include */ /* -------------------------------------------------------------------- */ @@ -126,10 +128,9 @@ static void verttag_set_cb(BMVert *v, bool val, void *user_data_v) } static void mouse_mesh_shortest_path_vert( - Scene *scene, const struct PathSelectParams *op_params, + Scene *UNUSED(scene), Object *obedit, const struct PathSelectParams *op_params, BMVert *v_act, BMVert *v_dst) { - Object *obedit = scene->obedit; BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; @@ -286,11 +287,11 @@ static void edgetag_set_cb(BMEdge *e, bool val, void *user_data_v) } } -static void edgetag_ensure_cd_flag(Scene *scene, Mesh *me) +static void edgetag_ensure_cd_flag(Mesh *me, const char edge_mode) { BMesh *bm = me->edit_btmesh->bm; - switch (scene->toolsettings->edge_mode) { + switch (edge_mode) { case EDGE_MODE_TAG_CREASE: BM_mesh_cd_flag_ensure(bm, me, ME_CDFLAG_EDGE_CREASE); break; @@ -313,10 +314,9 @@ static void edgetag_ensure_cd_flag(Scene *scene, Mesh *me) /* since you want to create paths with multiple selects, it doesn't have extend option */ static void mouse_mesh_shortest_path_edge( - Scene *scene, const struct PathSelectParams *op_params, + Scene *scene, Object *obedit, const struct PathSelectParams *op_params, BMEdge *e_act, BMEdge *e_dst) { - Object *obedit = scene->obedit; BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; @@ -325,7 +325,7 @@ static void mouse_mesh_shortest_path_edge( Mesh *me = obedit->data; bool is_path_ordered = false; - edgetag_ensure_cd_flag(scene, obedit->data); + edgetag_ensure_cd_flag(obedit->data, op_params->edge_mode); if (e_act && (e_act != e_dst)) { if (op_params->use_fill) { @@ -383,7 +383,7 @@ static void mouse_mesh_shortest_path_edge( } else { const bool is_act = !edgetag_test_cb(e_dst, &user_data); - edgetag_ensure_cd_flag(scene, obedit->data); + edgetag_ensure_cd_flag(obedit->data, op_params->edge_mode); edgetag_set_cb(e_dst, is_act, &user_data); /* switch the edge option */ } @@ -459,10 +459,9 @@ static void facetag_set_cb(BMFace *f, bool val, void *user_data_v) } static void mouse_mesh_shortest_path_face( - Scene *scene, const struct PathSelectParams *op_params, + Scene *UNUSED(scene), Object *obedit, const struct PathSelectParams *op_params, BMFace *f_act, BMFace *f_dst) { - Object *obedit = scene->obedit; BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; @@ -554,7 +553,7 @@ static void mouse_mesh_shortest_path_face( * \{ */ static bool edbm_shortest_path_pick_ex( - Scene *scene, const struct PathSelectParams *op_params, + Scene *scene, Object *obedit, const struct PathSelectParams *op_params, BMElem *ele_src, BMElem *ele_dst) { @@ -562,15 +561,15 @@ static bool edbm_shortest_path_pick_ex( /* pass */ } else if (ele_src->head.htype == BM_VERT) { - mouse_mesh_shortest_path_vert(scene, op_params, (BMVert *)ele_src, (BMVert *)ele_dst); + mouse_mesh_shortest_path_vert(scene, obedit, op_params, (BMVert *)ele_src, (BMVert *)ele_dst); return true; } else if (ele_src->head.htype == BM_EDGE) { - mouse_mesh_shortest_path_edge(scene, op_params, (BMEdge *)ele_src, (BMEdge *)ele_dst); + mouse_mesh_shortest_path_edge(scene, obedit, op_params, (BMEdge *)ele_src, (BMEdge *)ele_dst); return true; } else if (ele_src->head.htype == BM_FACE) { - mouse_mesh_shortest_path_face(scene, op_params, (BMFace *)ele_src, (BMFace *)ele_dst); + mouse_mesh_shortest_path_face(scene, obedit, op_params, (BMFace *)ele_src, (BMFace *)ele_dst); return true; } @@ -579,19 +578,19 @@ static bool edbm_shortest_path_pick_ex( static int edbm_shortest_path_pick_exec(bContext *C, wmOperator *op); -static BMElem *edbm_elem_find_nearest(ViewContext *vc, const char htype) +static BMElem *edbm_elem_find_nearest(const struct EvaluationContext *eval_ctx, ViewContext *vc, const char htype) { BMEditMesh *em = vc->em; float dist = ED_view3d_select_dist_px(); if ((em->selectmode & SCE_SELECT_VERTEX) && (htype == BM_VERT)) { - return (BMElem *)EDBM_vert_find_nearest(vc, &dist); + return (BMElem *)EDBM_vert_find_nearest(eval_ctx, vc, &dist); } else if ((em->selectmode & SCE_SELECT_EDGE) && (htype == BM_EDGE)) { - return (BMElem *)EDBM_edge_find_nearest(vc, &dist); + return (BMElem *)EDBM_edge_find_nearest(eval_ctx, vc, &dist); } else if ((em->selectmode & SCE_SELECT_FACE) && (htype == BM_FACE)) { - return (BMElem *)EDBM_face_find_nearest(vc, &dist); + return (BMElem *)EDBM_face_find_nearest(eval_ctx, vc, &dist); } return NULL; @@ -614,10 +613,12 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE return edbm_shortest_path_pick_exec(C, op); } + EvaluationContext eval_ctx; ViewContext vc; BMEditMesh *em; bool track_active = true; + CTX_data_eval_ctx(C, &eval_ctx); em_setup_viewcontext(C, &vc); copy_v2_v2_int(vc.mval, event->mval); em = vc.em; @@ -626,14 +627,14 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE BMElem *ele_src, *ele_dst; if (!(ele_src = edbm_elem_active_elem_or_face_get(em->bm)) || - !(ele_dst = edbm_elem_find_nearest(&vc, ele_src->head.htype))) + !(ele_dst = edbm_elem_find_nearest(&eval_ctx, &vc, ele_src->head.htype))) { /* special case, toggle edge tags even when we don't have a path */ if (((em->selectmode & SCE_SELECT_EDGE) && (vc.scene->toolsettings->edge_mode != EDGE_MODE_SELECT)) && /* check if we only have a destination edge */ ((ele_src == NULL) && - (ele_dst = edbm_elem_find_nearest(&vc, BM_EDGE)))) + (ele_dst = edbm_elem_find_nearest(&eval_ctx, &vc, BM_EDGE)))) { ele_src = ele_dst; track_active = false; @@ -649,7 +650,7 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE op_params.track_active = track_active; op_params.edge_mode = vc.scene->toolsettings->edge_mode; - if (!edbm_shortest_path_pick_ex(vc.scene, &op_params, ele_src, ele_dst)) { + if (!edbm_shortest_path_pick_ex(vc.scene, vc.obedit, &op_params, ele_src, ele_dst)) { return OPERATOR_PASS_THROUGH; } @@ -686,7 +687,7 @@ static int edbm_shortest_path_pick_exec(bContext *C, wmOperator *op) op_params.track_active = true; op_params.edge_mode = scene->toolsettings->edge_mode; - if (!edbm_shortest_path_pick_ex(scene, &op_params, ele_src, ele_dst)) { + if (!edbm_shortest_path_pick_ex(scene, obedit, &op_params, ele_src, ele_dst)) { return OPERATOR_CANCELLED; } @@ -727,8 +728,8 @@ void MESH_OT_shortest_path_pick(wmOperatorType *ot) static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_edit_object(C); - BMEditMesh *em = BKE_editmesh_from_object(ob); + Object *obedit = CTX_data_edit_object(C); + BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; BMIter iter; BMEditSelection *ese_src, *ese_dst; @@ -780,7 +781,7 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op) struct PathSelectParams op_params; path_select_params_from_op(op, &op_params); - edbm_shortest_path_pick_ex(scene, &op_params, ele_src, ele_dst); + edbm_shortest_path_pick_ex(scene, obedit, &op_params, ele_src, ele_dst); return OPERATOR_FINISHED; } |