Multi-Objects: MESH_OT_shortest_path_pick

This fully works as "expected", however it seems strange when
there is no selected vertex in the non-active object.

In 2.7x if you join two monkeys, select a vertex in one of them and
try to use this operator in the other it will select the lonely newly
selected vertex.

If you split both monkeys and do this in 2.8 while multi-editing them
you won't get nothing when trying to ctrl+RMB any vertex in the monkey
object that has nothing selected yet.

I propose to have this addressed in an upcoming patch where we always
select a vertex if no vertex was previously selected.
This commit is contained in:
Dalai Felinto 2018-08-21 13:19:02 -03:00
parent 4abb060edf
commit c32cc3e43e
Notes: blender-bot 2023-02-14 06:49:57 +01:00
Referenced by issue #54643, Multi-Object-Mode: EditMesh Tools
3 changed files with 31 additions and 0 deletions

View File

@ -35,6 +35,7 @@
extern "C" {
#endif
struct Base;
struct ID;
struct View3D;
struct ARegion;
@ -169,6 +170,13 @@ struct BMFace *EDBM_face_find_nearest_ex(
struct BMFace *EDBM_face_find_nearest(
struct ViewContext *vc, float *r_dist);
bool EDBM_unified_findnearest(
struct ViewContext *vc,
struct Base **r_base,
struct BMVert **r_eve,
struct BMEdge **r_eed,
struct BMFace **r_efa);
bool EDBM_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
void EDBM_selectmode_set(struct BMEditMesh *em);

View File

@ -619,6 +619,11 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
return edbm_shortest_path_pick_exec(C, op);
}
Base *basact = NULL;
BMVert *eve = NULL;
BMEdge *eed = NULL;
BMFace *efa = NULL;
ViewContext vc;
BMEditMesh *em;
bool track_active = true;
@ -629,6 +634,11 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
view3d_operator_needs_opengl(C);
if (EDBM_unified_findnearest(&vc, &basact, &eve, &eed, &efa)) {
ED_view3d_viewcontext_init_object(&vc, basact->object);
em = vc.em;
}
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)))
@ -658,6 +668,12 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE
return OPERATOR_PASS_THROUGH;
}
if (vc.view_layer->basact != basact) {
vc.view_layer->basact = basact;
DEG_id_tag_update(&vc.scene->id, DEG_TAG_SELECT_UPDATE);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, vc.scene);
}
/* to support redo */
BM_mesh_elem_index_ensure(em->bm, ele_dst->head.htype);
int index = EDBM_elem_to_index_any(em, ele_dst);

View File

@ -1086,6 +1086,13 @@ static bool unified_findnearest(
#undef FAKE_SELECT_MODE_BEGIN
#undef FAKE_SELECT_MODE_END
bool EDBM_unified_findnearest(
ViewContext *vc,
Base **r_base, BMVert **r_eve, BMEdge **r_eed, BMFace **r_efa)
{
return unified_findnearest(vc, r_base, r_eve, r_eed, r_efa);
}
/** \} */
/* -------------------------------------------------------------------- */