diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_object.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_select.c | 25 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 29 |
3 files changed, 41 insertions, 16 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index a5125ce7470..38cf754dda2 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -277,4 +277,7 @@ void ED_object_facemap_face_remove(struct Object *ob, struct bFaceMap *fmap, int } #endif +/* Don't allow switching object-modes when selecting objects. */ +#define USE_OBJECT_MODE_STRICT + #endif /* __ED_OBJECT_H__ */ diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 65cf08d87df..dfeea12a2f1 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -249,6 +249,23 @@ static eOLDrawState tree_element_set_active_object( /* find associated base in current scene */ base = BKE_view_layer_base_find(view_layer, ob); +#ifdef USE_OBJECT_MODE_STRICT + if (base != NULL) { + Object *obact = OBACT(view_layer); + const eObjectMode object_mode = obact ? obact->mode : OB_MODE_OBJECT; + if (base && !BKE_object_is_mode_compat(base->object, object_mode)) { + if (object_mode == OB_MODE_OBJECT) { + struct Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + ED_object_mode_generic_exit(bmain, depsgraph, scene, base->object); + } + if (!BKE_object_is_mode_compat(base->object, object_mode)) { + base = NULL; + } + } + } +#endif + if (base) { if (set == OL_SETSEL_EXTEND) { /* swap select */ @@ -272,10 +289,10 @@ static eOLDrawState tree_element_set_active_object( ED_object_base_activate(C, base); /* adds notifier */ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - } - - if (ob != OBEDIT_FROM_VIEW_LAYER(view_layer)) { - ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); + + if (ob != OBEDIT_FROM_VIEW_LAYER(view_layer)) { + ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); + } } return OL_DRAWSEL_NORMAL; } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 16b3cb7b28f..6e415d1c8e4 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -106,9 +106,6 @@ // #include "PIL_time_utildefines.h" -/* Don't allow switching object-modes when selecting objects. */ -#define USE_OBJECT_MODE_STRICT - float ED_view3d_select_dist_px(void) { return 75.0f * U.pixelsize; @@ -1414,13 +1411,13 @@ static bool ed_object_select_pick( Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Base *base, *startbase = NULL, *basact = NULL, *oldbasact = BASACT(view_layer); + const eObjectMode object_mode = oldbasact ? oldbasact->object->mode : OB_MODE_OBJECT; bool is_obedit; float dist = ED_view3d_select_dist_px() * 1.3333f; bool retval = false; int hits; const float mval_fl[2] = {(float)mval[0], (float)mval[1]}; - /* setup view context for argument to callbacks */ ED_view3d_viewcontext_init(C, &vc); @@ -1470,10 +1467,14 @@ static bool ed_object_select_pick( } #ifdef USE_OBJECT_MODE_STRICT if (is_obedit == false) { - if (basact && !BKE_object_is_mode_compat( - basact->object, oldbasact ? oldbasact->object->mode : OB_MODE_OBJECT)) - { - basact = NULL; + if (basact && !BKE_object_is_mode_compat(basact->object, object_mode)) { + if (object_mode == OB_MODE_OBJECT) { + struct Main *bmain = CTX_data_main(C); + ED_object_mode_generic_exit(bmain, vc.depsgraph, scene, basact->object); + } + if (!BKE_object_is_mode_compat(basact->object, object_mode)) { + basact = NULL; + } } } #endif @@ -1503,10 +1504,14 @@ static bool ed_object_select_pick( #ifdef USE_OBJECT_MODE_STRICT if (is_obedit == false) { - if (basact && !BKE_object_is_mode_compat( - basact->object, oldbasact ? oldbasact->object->mode : OB_MODE_OBJECT)) - { - basact = NULL; + if (basact && !BKE_object_is_mode_compat(basact->object, object_mode)) { + if (object_mode == OB_MODE_OBJECT) { + struct Main *bmain = CTX_data_main(C); + ED_object_mode_generic_exit(bmain, vc.depsgraph, scene, basact->object); + } + if (!BKE_object_is_mode_compat(basact->object, object_mode)) { + basact = NULL; + } } } #endif |