diff options
author | Ton Roosendaal <ton@blender.org> | 2006-11-08 18:22:58 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-11-08 18:22:58 +0300 |
commit | a65fc1e38177c05854c7a8d879d6526204f35a7b (patch) | |
tree | a3753864d620f9f5a89572233fba1c9ea795a9ff /source | |
parent | a0354619c77747abe47e4f60a3b26f63f433d40a (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/include/BIF_editview.h | 2 | ||||
-rw-r--r-- | source/blender/src/editview.c | 36 | ||||
-rw-r--r-- | source/blender/src/space.c | 7 |
3 files changed, 41 insertions, 4 deletions
diff --git a/source/blender/include/BIF_editview.h b/source/blender/include/BIF_editview.h index c98057c80bc..676bc3bd9f0 100644 --- a/source/blender/include/BIF_editview.h +++ b/source/blender/include/BIF_editview.h @@ -53,7 +53,7 @@ void mouse_select(void); void set_active_base(struct Base *base); void set_active_object(struct Object *ob); void set_render_border(void); - +void view3d_border_zoom(void); void view3d_edit_clipping(struct View3D *v3d); #endif 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) { diff --git a/source/blender/src/space.c b/source/blender/src/space.c index a2365cf7e2f..af5b44adb22 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -1321,7 +1321,12 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) if(G.qual==LR_ALTKEY) view3d_edit_clipping(v3d); else if(G.qual==LR_SHIFTKEY) - set_render_border(); + { + if(G.vd->persp==2) + set_render_border(); + else + view3d_border_zoom(); + } else if(G.qual==LR_CTRLKEY) { if(okee("Bake all selected")) { extern void softbody_bake(Object *ob); |