Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-07-19 15:28:48 +0400
committerTon Roosendaal <ton@blender.org>2006-07-19 15:28:48 +0400
commitf4737af50435b4f1dc0532a21b1f440994ca47b0 (patch)
tree04da09688beb147acc16d1a964d7d2124ad68260 /source
parentfe43c5e6f02660189094ef144e112e668b340eb6 (diff)
Bugfix #4724
Actually a bug since dark ages... the code that tries to find the view correction (zoom) factor for grabbing stored result in a global. With multiple 3d windows open, with different views, that could result in wrong correction. Just made the factor a local property in View3D.
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h2
-rw-r--r--source/blender/src/editview.c7
-rw-r--r--source/blender/src/view.c12
3 files changed, 9 insertions, 12 deletions
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index ed339243402..659c65a53f2 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -81,7 +81,7 @@ typedef struct View3D {
float winmat1[4][4]; // persp(1) storage, for swap matrices
float viewmat1[4][4];
- float viewquat[4], dist;
+ float viewquat[4], dist, zfac, pad0; /* zfac is initgrabz() result */
/**
* 0 - ortho
diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c
index be48adc1170..c5bf0e9c487 100644
--- a/source/blender/src/editview.c
+++ b/source/blender/src/editview.c
@@ -827,7 +827,6 @@ int gesture(void)
void mouse_cursor(void)
{
- extern float zfac; /* view.c */
float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3];
short mval[2], mx, my, lr_click=0;
@@ -855,11 +854,11 @@ void mouse_cursor(void)
}
else {
- dx= ((float)(mx-(curarea->winx/2)))*zfac/(curarea->winx/2);
- dy= ((float)(my-(curarea->winy/2)))*zfac/(curarea->winy/2);
+ dx= ((float)(mx-(curarea->winx/2)))*G.vd->zfac/(curarea->winx/2);
+ dy= ((float)(my-(curarea->winy/2)))*G.vd->zfac/(curarea->winy/2);
fz= G.vd->persmat[0][3]*fp[0]+ G.vd->persmat[1][3]*fp[1]+ G.vd->persmat[2][3]*fp[2]+ G.vd->persmat[3][3];
- fz= fz/zfac;
+ fz= fz/G.vd->zfac;
fp[0]= (G.vd->persinv[0][0]*dx + G.vd->persinv[1][0]*dy+ G.vd->persinv[2][0]*fz)-G.vd->ofs[0];
fp[1]= (G.vd->persinv[0][1]*dx + G.vd->persinv[1][1]*dy+ G.vd->persinv[2][1]*fz)-G.vd->ofs[1];
diff --git a/source/blender/src/view.c b/source/blender/src/view.c
index 00325dbbe5c..34888dd8e18 100644
--- a/source/blender/src/view.c
+++ b/source/blender/src/view.c
@@ -138,17 +138,15 @@ void persp(int a)
}
-float zfac=1.0;
-
void initgrabz(float x, float y, float z)
{
- if(G.vd==0) return;
- zfac= G.vd->persmat[0][3]*x+ G.vd->persmat[1][3]*y+ G.vd->persmat[2][3]*z+ G.vd->persmat[3][3];
+ if(G.vd==NULL) return;
+ G.vd->zfac= G.vd->persmat[0][3]*x+ G.vd->persmat[1][3]*y+ G.vd->persmat[2][3]*z+ G.vd->persmat[3][3];
/* if x,y,z is exactly the viewport offset, zfac is 0 and we don't want that
* (accounting for near zero values)
* */
- if (zfac < 1.e-6f && zfac > -1.e-6f) zfac = 1.0f;
+ if (G.vd->zfac < 1.e-6f && G.vd->zfac > -1.e-6f) G.vd->zfac = 1.0f;
}
void window_to_3d(float *vec, short mx, short my)
@@ -156,8 +154,8 @@ void window_to_3d(float *vec, short mx, short my)
/* always call initgrabz */
float dx, dy;
- dx= 2.0f*mx*zfac/curarea->winx;
- dy= 2.0f*my*zfac/curarea->winy;
+ dx= 2.0f*mx*G.vd->zfac/curarea->winx;
+ dy= 2.0f*my*G.vd->zfac/curarea->winy;
vec[0]= (G.vd->persinv[0][0]*dx + G.vd->persinv[1][0]*dy);
vec[1]= (G.vd->persinv[0][1]*dx + G.vd->persinv[1][1]*dy);