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 | 32 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 70 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 6 |
5 files changed, 61 insertions, 58 deletions
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index a5155b5b945..d8a31e93a87 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -277,7 +277,4 @@ 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 f2ba00190e0..6a6a392e4a6 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -255,22 +255,22 @@ 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; + if (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) { + 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) { @@ -282,13 +282,11 @@ static eOLDrawState tree_element_set_active_object( } else { /* deleselect all */ -#ifdef USE_OBJECT_MODE_STRICT + /* Only in object mode so we can switch the active object, * keeping all objects in the current 'mode' selected, useful for multi-pose/edit mode. * This keeps the convention that all objects in the current mode are also selected. see T55246. */ - if (ob->mode == OB_MODE_OBJECT) -#endif - { + if ((scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) ? (ob->mode == OB_MODE_OBJECT) : true) { BKE_view_layer_base_deselect_all(view_layer); } ED_object_base_select(base, BA_SELECT); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 08c6a6c328f..9b40f03a54a 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -424,10 +424,8 @@ static void do_lasso_select_objects( for (base = vc->view_layer->object_bases.first; base; base = base->next) { if (BASE_SELECTABLE(base)) { /* use this to avoid un-needed lasso lookups */ - if ( -#ifdef USE_OBJECT_MODE_STRICT - (is_pose_mode == false) && -#endif + if (((vc->scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) ? + (is_pose_mode == false) : true) && ED_view3d_project_base(vc->ar, base) == V3D_PROJ_RET_OK) { if (BLI_lasso_is_point_inside(mcords, moves, base->sx, base->sy, IS_CLIPPED)) { @@ -1256,8 +1254,7 @@ static int mixed_bones_object_selectbuffer( finally: view3d_opengl_select_cache_end(); -#ifdef USE_OBJECT_MODE_STRICT - { + if (vc->scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) { const bool is_pose_mode = (vc->obact && vc->obact->mode & OB_MODE_POSE); struct { uint data[4]; @@ -1273,7 +1270,6 @@ finally: } hits = j; } -#endif return hits; } @@ -1470,19 +1466,19 @@ static bool ed_object_select_pick( if (base == startbase) break; } } -#ifdef USE_OBJECT_MODE_STRICT - if (is_obedit == false) { - 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; + if (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) { + if (is_obedit == false) { + 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 } else { unsigned int buffer[MAXPICKBUF]; @@ -1507,19 +1503,19 @@ static bool ed_object_select_pick( basact = mouse_select_eval_buffer(&vc, buffer, hits, startbase, has_bones, do_nearest); } -#ifdef USE_OBJECT_MODE_STRICT - if (is_obedit == false) { - 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; + if (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) { + if (is_obedit == false) { + 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 if (has_bones && basact) { if (basact->object->type == OB_CAMERA) { @@ -1609,19 +1605,19 @@ static bool ed_object_select_pick( } } -#ifdef USE_OBJECT_MODE_STRICT - /* Disallow switching modes, - * special exception for edit-mode - vertex-parent operator. */ - if (is_obedit == false) { - if (oldbasact && basact) { - if ((oldbasact->object->mode != basact->object->mode) && - (oldbasact->object->mode & basact->object->mode) == 0) - { - basact = NULL; + if (scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) { + /* Disallow switching modes, + * special exception for edit-mode - vertex-parent operator. */ + if (is_obedit == false) { + if (oldbasact && basact) { + if ((oldbasact->object->mode != basact->object->mode) && + (oldbasact->object->mode & basact->object->mode) == 0) + { + basact = NULL; + } } } } -#endif /* so, do we have something selected? */ if (basact) { diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index f1c07f5b121..3a0568112a0 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1219,7 +1219,8 @@ typedef struct ToolSettings { float vgroup_weight; float doublimit; /* remove doubles limit */ - short automerge; + char automerge; + char object_flag; /* Selection Mode for Mesh */ short selectmode; @@ -1771,6 +1772,11 @@ enum { SCE_XFORM_AXIS_ALIGN = (1 << 0), }; +/* ToolSettings.object_flag */ +enum { + SCE_OBJECT_MODE_LOCK = (1 << 0), +}; + /* ToolSettings.snap_flag */ #define SCE_SNAP 1 #define SCE_SNAP_ROTATE 2 diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 8d60e96ef01..7932a316b0a 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2529,6 +2529,12 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, uv_sculpt_relaxation_items); RNA_def_property_ui_text(prop, "Relaxation Method", "Algorithm used for UV relaxation"); + prop = RNA_def_property(srna, "lock_object_mode", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "object_flag", SCE_OBJECT_MODE_LOCK); + RNA_def_property_ui_text(prop, "Lock Object Mode", ""); + RNA_def_property_ui_icon(prop, ICON_LOCKVIEW_OFF, 1); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); + /* Transform */ prop = RNA_def_property(srna, "proportional_edit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "proportional"); |