Patch #5126 by Ben Stabler
authorTon Roosendaal <ton@blender.org>
Wed, 8 Nov 2006 15:22:58 +0000 (15:22 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 8 Nov 2006 15:22:58 +0000 (15:22 +0000)
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/include/BIF_editview.h
source/blender/src/editview.c
source/blender/src/space.c

index c98057c80bc5013a16299ce8cc986a3059d69bfc..676bc3bd9f0ff1d8df069b034c0edfc4f8db723d 100644 (file)
@@ -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
index 39aae4be851e846a41fbea2514d5f1ac017bcfc6..2fa409b18f2eab372c7af78f6aec3ef830786b0b 100644 (file)
@@ -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)
 {
index a2365cf7e2f83736d500833dc813108716682b78..af5b44adb2282b7fc905f84d20fc30824a3c436a 100644 (file)
@@ -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);