diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-30 08:25:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-30 08:25:58 +0400 |
commit | c3406db4f5e87402d43a5d2a5e0049b16479d2d5 (patch) | |
tree | a93b1ecf654e7dbc436d3f3de757cef074c49bfb /source/blender/editors | |
parent | 5321669ef6935cb4863637d8068c2d265eef0a31 (diff) |
fix for view-all operator not taking the view-angle into account.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 9 |
3 files changed, 11 insertions, 1 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index bd85e93f1af..27204d89bc5 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -219,6 +219,7 @@ void ED_view3d_clipping_enable(void); void ED_view3d_clipping_disable(void); float ED_view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]); +float ED_view3d_dist_from_radius(struct View3D *v3d, const float radius); void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 0d8567b256d..a37ce64b7c8 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2224,6 +2224,8 @@ static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar, /* fix up zoom distance if needed */ if (rv3d->is_persp) { + /* offset the view based on the lens */ + size = ED_view3d_dist_from_radius(v3d, size / 2.0f); if (size <= v3d->near * 1.5f) { /* do not zoom closer than the near clipping plane */ size = v3d->near * 1.5f; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 714898fed21..ea09aca900f 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1511,7 +1511,7 @@ static void UNUSED_FUNCTION(view3d_align_axis_to_vector)(View3D *v3d, RegionView } } -float ED_view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]) +float ED_view3d_pixel_size(RegionView3D *rv3d, const float co[3]) { return (rv3d->persmat[3][3] + ( rv3d->persmat[0][3] * co[0] + @@ -1520,6 +1520,13 @@ float ED_view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]) ) * rv3d->pixsize; } +/* use for perspective view only */ +float ED_view3d_dist_from_radius(View3D *v3d, const float radius) +{ + const float angle = (((float)M_PI) - focallength_to_fov(v3d->lens, DEFAULT_SENSOR_WIDTH)); + return radius * fabsf(1.0f / cosf(angle / 2.0f)); +} + /* view matrix properties utilities */ /* unused */ |