rendered paste bodyIndex: source/blender/include/BSE_view.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BSE_view.h,v
retrieving revision 1.14
diff -u -r1.14 BSE_view.h
--- source/blender/include/BSE_view.h 28 Jan 2006 18:33:13 -0000 1.14
+++ source/blender/include/BSE_view.h 24 Oct 2006 22:37:54 -0000
@@ -55,6 +55,7 @@
void initgrabz(float x, float y, float z);
void window_to_3d(float *vec, short mx, short my);
+void window_to_3d_f(float *vec, float mx, float my);
void project_short(float *vec, short *adr);
void project_short_noclip(float *vec, short *adr);
void project_int(float *vec, int *adr);
Index: source/blender/makesdna/DNA_userdef_types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_userdef_types.h,v
retrieving revision 1.58
diff -u -r1.58 DNA_userdef_types.h
--- source/blender/makesdna/DNA_userdef_types.h 19 Oct 2006 05:06:41 -0000 1.58
+++ source/blender/makesdna/DNA_userdef_types.h 24 Oct 2006 14:32:14 -0000
@@ -225,6 +225,7 @@
#define USER_HIDE_DOT 65536
#define USER_SHOW_ROTVIEWICON 131072
#define USER_SHOW_VIEWPORTNAME 262144
+#define USER_ZOOM_TOCURSOR 524288
/* transopts */
Index: source/blender/src/editview.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editview.c,v
retrieving revision 1.112
diff -u -r1.112 editview.c
--- source/blender/src/editview.c 12 Oct 2006 09:32:47 -0000 1.112
+++ source/blender/src/editview.c 25 Oct 2006 00:43:08 -0000
@@ -1976,8 +1976,6 @@
{
rcti rect;
short val;
-
- if(G.vd->persp!=2) return;
val= get_border(&rect, 3);
if(val) {
@@ -2002,6 +2000,58 @@
}
}
+void border_zoom(void)
+{
+ //Zooms in on a border drawn by the user
+
+ rcti rect;
+ short val;
+ float dvec[3], vb[2], xscale, yscale, scale;
+
+ 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 relative_zoom(unsigned short event)
+{
+ short mval[2];
+ float scaleFactor, dvec[3];
+
+ if(event==PADPLUSKEY)
+ scaleFactor=.83333f;
+ else if(event==PADMINUS)
+ scaleFactor=1.2f;
+
+ getmouseco_areawin(mval);
+
+ initgrabz(G.vd->ofs[0], G.vd->ofs[1], G.vd->ofs[2]);
+
+ window_to_3d_f(dvec, (mval[0]-((G.vd->area->winx-1)/2))*(scaleFactor-1), (mval[1]-((G.vd->area->winy-1)/2))*(scaleFactor-1));
+
+ G.vd->dist*=scaleFactor;
+
+ VecAddf(G.vd->ofs, G.vd->ofs, dvec);
+}
void fly(void)
{
Index: source/blender/src/header_view3d.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/header_view3d.c,v
retrieving revision 1.189
diff -u -r1.189 header_view3d.c
--- source/blender/src/header_view3d.c 12 Oct 2006 14:26:14 -0000 1.189
+++ source/blender/src/header_view3d.c 23 Oct 2006 20:49:15 -0000
@@ -239,6 +239,9 @@
case 11: /* Camera Fly mode */
fly();
break;
+ case 12: /* Border zoom */
+ border_zoom();
+ break;
}
allqueue(REDRAWVIEW3D, 0);
}
@@ -253,6 +256,7 @@
uiBlockSetButmFunc(block, do_view3d_view_cameracontrolsmenu, NULL);
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Camera Fly Mode|Shift F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 11, "");
+ if (G.vd->persp != 2) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Zoom|Shift B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 12, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, 140, 6, NULL, 0.0, 0.0, 0, 0, "");
Index: source/blender/src/space.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/space.c,v
retrieving revision 1.385
diff -u -r1.385 space.c
--- source/blender/src/space.c 19 Oct 2006 05:06:41 -0000 1.385
+++ source/blender/src/space.c 25 Oct 2006 00:54:11 -0000
@@ -1278,7 +1278,12 @@
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
+ border_zoom();
+ }
else if(G.qual==LR_CTRLKEY) {
if(okee("Bake all selected")) {
extern void softbody_bake(Object *ob);
@@ -2810,9 +2815,13 @@
uiDefButI(block, NUM, 0, "Scroll Lines:",
(xpos+edgsp+(4*mpref)+(6*midsp)+spref-edgsp),y3,spref+edgsp,buth,
&U.wheellinescroll, 0.0, 32.0, 0, 0,
- "The number of lines scrolled at a time with the mouse wheel");
+ "The number of lines scrolled at a time with the mouse wheel");
uiBlockEndAlign(block);
+ uiDefButBitI(block, TOG, USER_ZOOM_TOCURSOR, 0, "Zoom to cursor",
+ (xpos+edgsp+(4*mpref)+(5*midsp)),y1,mpref,buth,
+ &(U.uiflag), 0, 0, 0, 0,
+ "Zoom relative to the mouse cursor position");
uiDefBut(block, LABEL,0,"3D Transform Widget:",
(xpos+(2*edgsp)+(5*mpref)+(5*midsp)),y6label,mpref,buth,
Index: source/blender/src/toets.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/toets.c,v
retrieving revision 1.84
diff -u -r1.84 toets.c
--- source/blender/src/toets.c 28 Sep 2006 01:55:44 -0000 1.84
+++ source/blender/src/toets.c 24 Oct 2006 23:07:59 -0000
@@ -241,14 +241,26 @@
if(G.vd->persp==2) {
G.vd->camzoom= MAX2(-30, G.vd->camzoom-5);
}
- else if(G.vd->dist<10.0*G.vd->far) G.vd->dist*=1.2f;
+ else if(G.vd->dist<10.0*G.vd->far)
+ {
+ if(U.uiflag & USER_ZOOM_TOCURSOR)
+ relative_zoom(event);
+ else
+ G.vd->dist*=1.2f;
+ }
if(G.vd->persp!=1) preview3d_event= 0;
}
else if(event==PADPLUSKEY) {
if(G.vd->persp==2) {
G.vd->camzoom= MIN2(300, G.vd->camzoom+5);
}
- else if(G.vd->dist> 0.001*G.vd->grid) G.vd->dist*=.83333f;
+ else if(G.vd->dist> 0.001*G.vd->grid)
+ {
+ if(U.uiflag & USER_ZOOM_TOCURSOR)
+ relative_zoom(event);
+ else
+ G.vd->dist*=.83333f;
+ }
if(G.vd->persp!=1) preview3d_event= 0;
}
else if(event==PAD5) {
Index: source/blender/src/view.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/view.c,v
retrieving revision 1.71
diff -u -r1.71 view.c
--- source/blender/src/view.c 23 Oct 2006 16:15:23 -0000 1.71
+++ source/blender/src/view.c 25 Oct 2006 18:17:40 -0000
@@ -151,6 +151,11 @@
void window_to_3d(float *vec, short mx, short my)
{
+ window_to_3d_f(vec, mx, my);
+}
+
+void window_to_3d_f(float *vec, float mx, float my)
+{
/* always call initgrabz */
float dx, dy;