From a65fc1e38177c05854c7a8d879d6526204f35a7b Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 8 Nov 2006 15:22:58 +0000 Subject: Patch #5126 by Ben Stabler In 3D window, ortho view, you can use SHIFT+B to zoom in to a border. I've disabled it for perspective, that doesn't work at all with this. --- source/blender/src/editview.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'source/blender/src/editview.c') diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c index 39aae4be851..2fa409b18f2 100644 --- a/source/blender/src/editview.c +++ b/source/blender/src/editview.c @@ -1985,8 +1985,6 @@ void set_render_border(void) { rcti rect; short val; - - if(G.vd->persp!=2) return; val= get_border(&rect, 3); if(val) { @@ -2011,6 +2009,40 @@ void set_render_border(void) } } +void view3d_border_zoom(void) +{ + /* Zooms in on a border drawn by the user */ + rcti rect; + short val; + float dvec[3], vb[2], xscale, yscale, scale; + + /* doesn't work fine for perspective */ + if(G.vd->persp==1) + return; + + val = get_border(&rect, 3); //box select input + if(val) + { + /* find the current window width and height */ + vb[0] = G.vd->area->winx; + vb[1] = G.vd->area->winy; + + /* convert the drawn rectangle into 3d space */ + initgrabz(-G.vd->ofs[0], -G.vd->ofs[1], -G.vd->ofs[2]); + window_to_3d(dvec, (rect.xmin+rect.xmax-vb[0])/2, (rect.ymin+rect.ymax-vb[1])/2); + + /* center the view to the center of the rectangle */ + VecSubf(G.vd->ofs, G.vd->ofs, dvec); + + /* work out the ratios, so that everything selected fits when we zoom */ + xscale = ((rect.xmax-rect.xmin)/vb[0]); + yscale = ((rect.ymax-rect.ymin)/vb[1]); + scale = (xscale >= yscale)?xscale:yscale; + + /* zoom in as required, or as far as we can go */ + G.vd->dist = ((G.vd->dist*scale) >= 0.001*G.vd->grid)? G.vd->dist*scale:0.001*G.vd->grid; + } +} void fly(void) { -- cgit v1.2.3