[Bf-blender-cvs] [c32cc3e43e4] blender2.8: Multi-Objects: MESH_OT_shortest_path_pick

Dalai Felinto noreply at git.blender.org
Wed Aug 22 15:02:43 CEST 2018


Commit: c32cc3e43e49009892e3ecfe0f9e91c98592f98a
Author: Dalai Felinto
Date:   Tue Aug 21 13:19:02 2018 -0300
Branches: blender2.8
https://developer.blender.org/rBc32cc3e43e49009892e3ecfe0f9e91c98592f98a

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.

===================================================================

M	source/blender/editors/include/ED_mesh.h
M	source/blender/editors/mesh/editmesh_path.c
M	source/blender/editors/mesh/editmesh_select.c

===================================================================

diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 0a884e7909b..c084033bbb6 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -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);
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c
index 7bc12aa9ebf..1f6a48b41b3 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -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);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 8c3c9df54dd..a035ba5ab33 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -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);
+}
+
 /** \} */
 
 /* -------------------------------------------------------------------- */



More information about the Bf-blender-cvs mailing list