- camera max zoom limit was inconsistent
authorCampbell Barton <ideasman42@gmail.com>
Sat, 11 Sep 2010 04:39:00 +0000 (04:39 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 11 Sep 2010 04:39:00 +0000 (04:39 +0000)
- camera pan now follows the mouse

source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/makesdna/DNA_view3d_types.h

index 56e66e21a720b0b91d9b963c2224618dbbb13d8c..17516f6a40cd33c4ced79400873b247bae90ba21 100644 (file)
@@ -923,7 +923,7 @@ void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar)
        view3d_get_viewborder_size(scene, ar, size);
        
        rv3d->camzoom= (sqrt(4.0*im_width/size[0]) - M_SQRT2)*50.0;
        view3d_get_viewborder_size(scene, ar, size);
        
        rv3d->camzoom= (sqrt(4.0*im_width/size[0]) - M_SQRT2)*50.0;
-       rv3d->camzoom= CLAMPIS(rv3d->camzoom, -30, 300);
+       rv3d->camzoom= CLAMPIS(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
 }
 
 
 }
 
 
index 3614717e9e07475c4a0cbe472fed5d855d89ae01..e2c12386dd357cd2d476175a40d3d474222725cc 100644 (file)
@@ -854,10 +854,11 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf)
 static void viewmove_apply(ViewOpsData *vod, int x, int y)
 {
        if(vod->rv3d->persp==RV3D_CAMOB) {
 static void viewmove_apply(ViewOpsData *vod, int x, int y)
 {
        if(vod->rv3d->persp==RV3D_CAMOB) {
-               float max= (float)MAX2(vod->ar->winx, vod->ar->winy);
+               float zoomfac= (M_SQRT2 + vod->rv3d->camzoom/50.0);
+               zoomfac= (zoomfac*zoomfac)*0.5;
 
 
-               vod->rv3d->camdx += (vod->oldx - x)/(max);
-               vod->rv3d->camdy += (vod->oldy - y)/(max);
+               vod->rv3d->camdx += (vod->oldx - x)/(vod->ar->winx * zoomfac);
+               vod->rv3d->camdy += (vod->oldy - y)/(vod->ar->winy * zoomfac);
                CLAMP(vod->rv3d->camdx, -1.0f, 1.0f);
                CLAMP(vod->rv3d->camdy, -1.0f, 1.0f);
 // XXX         preview3d_event= 0;
                CLAMP(vod->rv3d->camdx, -1.0f, 1.0f);
                CLAMP(vod->rv3d->camdy, -1.0f, 1.0f);
 // XXX         preview3d_event= 0;
@@ -1165,7 +1166,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
                /* this min and max is also in viewmove() */
                if(rv3d->persp==RV3D_CAMOB) {
                        rv3d->camzoom-= 10;
                /* this min and max is also in viewmove() */
                if(rv3d->persp==RV3D_CAMOB) {
                        rv3d->camzoom-= 10;
-                       if(rv3d->camzoom<-30) rv3d->camzoom= -30;
+                       if(rv3d->camzoom < RV3D_CAMZOOM_MIN) rv3d->camzoom= RV3D_CAMZOOM_MIN;
                }
                else if(rv3d->dist<10.0*v3d->far) {
                        view_zoom_mouseloc(CTX_wm_region(C), 1.2f, mx, my);
                }
                else if(rv3d->dist<10.0*v3d->far) {
                        view_zoom_mouseloc(CTX_wm_region(C), 1.2f, mx, my);
@@ -1174,7 +1175,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
        else {
                if(rv3d->persp==RV3D_CAMOB) {
                        rv3d->camzoom+= 10;
        else {
                if(rv3d->persp==RV3D_CAMOB) {
                        rv3d->camzoom+= 10;
-                       if(rv3d->camzoom>600) rv3d->camzoom= 600;
+                       if(rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom= RV3D_CAMZOOM_MAX;
                }
                else if(rv3d->dist> 0.001*v3d->grid) {
                        view_zoom_mouseloc(CTX_wm_region(C), .83333f, mx, my);
                }
                else if(rv3d->dist> 0.001*v3d->grid) {
                        view_zoom_mouseloc(CTX_wm_region(C), .83333f, mx, my);
index 520fc56162c5a7a07ccbb060e267ac4cf9535054..f692c80f81f0a7bf9fe2527eada61eee167a74f9 100644 (file)
@@ -299,6 +299,9 @@ typedef struct View3D {
 /* may want to use 1 for select ?*/
 #define V3D_BGPIC_EXPANDED             2
 
 /* may want to use 1 for select ?*/
 #define V3D_BGPIC_EXPANDED             2
 
+#define RV3D_CAMZOOM_MIN -30
+#define RV3D_CAMZOOM_MAX 600
+
 #endif
 
 
 #endif