diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-11-30 04:44:37 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-11-30 07:28:41 +0300 |
commit | a687d98e67823932f95bc3c1b1452109282a3e41 (patch) | |
tree | 77d23fffc955c4ee8c2f68c28a38674dc810e1ae /source/blender | |
parent | 8f8c23865922a77458f548752ffccb048b96ea5b (diff) |
Remove from Local View operator
This was the old, obscure, little known, M shortcut operator when in local view
back in the 2.7x days.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 57 |
4 files changed, 65 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 5852fcff7e9..2723198b279 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1834,6 +1834,12 @@ static bool move_to_collection_poll(bContext *C) return ED_outliner_collections_editor_poll(C); } else { + View3D *v3d = CTX_wm_view3d(C); + + if (v3d && v3d->localvd) { + return false; + } + return ED_operator_object_active_editable(C); } } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 9f77f671a7d..164c444d9a5 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -177,6 +177,7 @@ void VIEW3D_OT_camera_to_view(struct wmOperatorType *ot); void VIEW3D_OT_camera_to_view_selected(struct wmOperatorType *ot); void VIEW3D_OT_object_as_camera(struct wmOperatorType *ot); void VIEW3D_OT_localview(struct wmOperatorType *ot); +void VIEW3D_OT_localview_remove_from(struct wmOperatorType *ot); bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d, const struct BoundBox *bb, float obmat[4][4]); bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 8092dc9f0f7..7e4f04feaef 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -205,6 +205,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_camera_to_view_selected); WM_operatortype_append(VIEW3D_OT_object_as_camera); WM_operatortype_append(VIEW3D_OT_localview); + WM_operatortype_append(VIEW3D_OT_localview_remove_from); WM_operatortype_append(VIEW3D_OT_fly); WM_operatortype_append(VIEW3D_OT_walk); WM_operatortype_append(VIEW3D_OT_navigate); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 059274a14fd..98ae57e9c42 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1412,6 +1412,63 @@ void VIEW3D_OT_localview(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; } +static int localview_remove_from_exec(bContext *C, wmOperator *op) +{ + View3D *v3d = CTX_wm_view3d(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + bool changed = false; + + for (Base *base = FIRSTBASE(view_layer); base; base = base->next) { + if (TESTBASE(v3d, base)) { + base->local_view_bits &= ~v3d->local_view_uuid; + ED_object_base_select(base, BA_DESELECT); + + if (base == BASACT(view_layer)) { + view_layer->basact = NULL; + } + changed = true; + } + } + + if (changed) { + DEG_on_visible_update(bmain, false); + DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); + return OPERATOR_FINISHED; + } + else { + BKE_report(op->reports, RPT_ERROR, "No object selected"); + return OPERATOR_CANCELLED; + } +} + +static bool localview_remove_from_poll(bContext *C) +{ + if (CTX_data_edit_object(C) != NULL) { + return false; + } + + View3D *v3d = CTX_wm_view3d(C); + return v3d && v3d->localvd; +} + +void VIEW3D_OT_localview_remove_from(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove from Local View"; + ot->description = "Move selected objects out of local view"; + ot->idname = "VIEW3D_OT_localview_remove_from"; + + /* api callbacks */ + ot->exec = localview_remove_from_exec; + ot->invoke = WM_operator_confirm; + ot->poll = localview_remove_from_poll; + ot->flag = OPTYPE_UNDO; +} + /** \} */ /* -------------------------------------------------------------------- */ |