diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-02-23 09:48:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-02-23 09:48:47 +0300 |
commit | 93493743596cb757d4989453197d3ec5e93cdbde (patch) | |
tree | 6f0aae5ba4cd39673d4cd3ac698b622f668d5f54 /source/blender/editors/space_view3d/view3d_edit.c | |
parent | 2f472ccd60f37ad9adcd388575e88bcf78336074 (diff) |
add back view 1:1 operator from 2.4x (Shift+PadEnter)
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_edit.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 7842707d7e8..9b26cae434d 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1843,6 +1843,47 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX); } + +/* sets the view to 1:1 camera/render-pixel */ +static void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar) +{ + RegionView3D *rv3d= ar->regiondata; + float size[2]; + int im_width= (scene->r.size*scene->r.xsch)/100; + + view3d_viewborder_size_get(scene, ar, size); + + rv3d->camzoom= (sqrt(4.0*im_width/size[0]) - M_SQRT2)*50.0; + rv3d->camzoom= CLAMPIS(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); +} + +static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene= CTX_data_scene(C); + ARegion *ar= CTX_wm_region(C); + + view3d_set_1_to_1_viewborder(scene, ar); + + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); + + return OPERATOR_FINISHED; +} + +void VIEW3D_OT_zoom_camera_1_to_1(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Zoom Camera 1:1"; + ot->description = "Match the camera to 1:1 to the render output"; + ot->idname= "VIEW3D_OT_zoom_camera_1_to_1"; + + /* api callbacks */ + ot->exec= view3d_zoom_1_to_1_camera_exec; + ot->poll= view3d_camera_active_poll; + + /* flags */ + ot->flag= 0; +} + /* ********************* Changing view operator ****************** */ static EnumPropertyItem prop_view_items[] = { |