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
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2005-03-23 17:24:43 +0300
committerTon Roosendaal <ton@blender.org>2005-03-23 17:24:43 +0300
commit09ed2cef75b17ef1e3dfe7e08184b53297ca210b (patch)
treedf4497a83af0b47fd189fb301422fbd29fea8af6
parent7e6a65bc624e80f7fbb04613b7c51fc3a7683924 (diff)
New feature, since long on todo;
The grid function (transform translate, snap-to) now uses the grid step as displayed in the 3d window, so it depends on how much you zoomed in/out. The threshold for it is a bit tricky... it follows the drawing, but the blending in/out of grid makes it sometimes not obvious. might need slight tweak?
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h2
-rw-r--r--source/blender/src/drawview.c11
-rw-r--r--source/blender/src/edit.c22
-rwxr-xr-xsource/blender/src/transform.c16
4 files changed, 29 insertions, 22 deletions
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 19bee996a59..f7857f5d52a 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -97,7 +97,7 @@ typedef struct View3D {
int lay, layact;
short scenelock, around, camzoom, flag;
- float lens, grid, near, far;
+ float lens, grid, gridview, pad, near, far;
float ofs[3], cursor[3];
short mx, my; /* have to remain together, because used as single pointer */
diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c
index 7f60adc2099..0a07d594348 100644
--- a/source/blender/src/drawview.c
+++ b/source/blender/src/drawview.c
@@ -549,18 +549,23 @@ static void drawgrid(void)
if(dx==0) dx= fabs(y-(wy)*fy/fw);
glDepthMask(0); // disable write in zbuffer
-
+
/* check zoom out */
BIF_ThemeColor(TH_GRID);
persp(PERSP_WIN);
-
+
+ G.vd->gridview= G.vd->grid;
+
if(dx<6.0) {
+ G.vd->gridview*= 10.0;
dx*= 10.0;
if(dx<6.0) {
+ G.vd->gridview*= 10.0;
dx*= 10.0;
if(dx<6.0) {
+ G.vd->gridview*= 10.0;
dx*=10;
if(dx<6.0);
else {
@@ -586,8 +591,10 @@ static void drawgrid(void)
}
else {
if(dx>60.0) { // start blending in
+ G.vd->gridview/= 10.0;
dx/= 10.0;
if(dx>60.0) { // start blending in
+ G.vd->gridview/= 10.0;
dx/= 10.0;
if(dx>60.0) {
BIF_ThemeColor(TH_GRID);
diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c
index 747eacbf763..0aee2bfa17a 100644
--- a/source/blender/src/edit.c
+++ b/source/blender/src/edit.c
@@ -733,7 +733,7 @@ void snap_sel_to_grid()
float gridf, imat[3][3], bmat[3][3], vec[3];
int a;
- gridf= G.vd->grid;
+ gridf= G.vd->gridview;
if(G.obedit) {
@@ -755,9 +755,9 @@ void snap_sel_to_grid()
VECCOPY(vec, tv->loc);
Mat3MulVecfl(bmat, vec);
VecAddf(vec, vec, G.obedit->obmat[3]);
- vec[0]= G.vd->grid*floor(.5+ vec[0]/gridf);
- vec[1]= G.vd->grid*floor(.5+ vec[1]/gridf);
- vec[2]= G.vd->grid*floor(.5+ vec[2]/gridf);
+ vec[0]= G.vd->gridview*floor(.5+ vec[0]/gridf);
+ vec[1]= G.vd->gridview*floor(.5+ vec[1]/gridf);
+ vec[2]= G.vd->gridview*floor(.5+ vec[2]/gridf);
VecSubf(vec, vec, G.obedit->obmat[3]);
Mat3MulVecfl(imat, vec);
@@ -786,9 +786,9 @@ void snap_sel_to_grid()
if( ( ((base)->flag & SELECT) && ((base)->lay & G.vd->lay) && ((base)->object->id.lib==0))) {
ob= base->object;
- vec[0]= -ob->obmat[3][0]+G.vd->grid*floor(.5+ ob->obmat[3][0]/gridf);
- vec[1]= -ob->obmat[3][1]+G.vd->grid*floor(.5+ ob->obmat[3][1]/gridf);
- vec[2]= -ob->obmat[3][2]+G.vd->grid*floor(.5+ ob->obmat[3][2]/gridf);
+ vec[0]= -ob->obmat[3][0]+G.vd->gridview*floor(.5+ ob->obmat[3][0]/gridf);
+ vec[1]= -ob->obmat[3][1]+G.vd->gridview*floor(.5+ ob->obmat[3][1]/gridf);
+ vec[2]= -ob->obmat[3][2]+G.vd->gridview*floor(.5+ ob->obmat[3][2]/gridf);
if(ob->parent) {
where_is_object(ob);
@@ -902,12 +902,12 @@ void snap_curs_to_grid()
{
float gridf, *curs;
- gridf= G.vd->grid;
+ gridf= G.vd->gridview;
curs= give_cursor();
- curs[0]= G.vd->grid*floor(.5+curs[0]/gridf);
- curs[1]= G.vd->grid*floor(.5+curs[1]/gridf);
- curs[2]= G.vd->grid*floor(.5+curs[2]/gridf);
+ curs[0]= G.vd->gridview*floor(.5+curs[0]/gridf);
+ curs[1]= G.vd->gridview*floor(.5+curs[1]/gridf);
+ curs[2]= G.vd->gridview*floor(.5+curs[2]/gridf);
allqueue(REDRAWVIEW3D, 0);
diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c
index f82bd9a9fc5..a057768d405 100755
--- a/source/blender/src/transform.c
+++ b/source/blender/src/transform.c
@@ -1861,7 +1861,7 @@ void initShear(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
- t->snap[1] = G.vd->grid * 0.1f;
+ t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
t->transform = Shear;
t->fac = (float)(t->center2d[0] - t->imval[0]);
@@ -1954,7 +1954,7 @@ void initResize(TransInfo *t)
t->idx_max = 2;
t->num.idx_max = 2;
t->snap[0] = 0.0f;
- t->snap[1] = G.vd->grid * 0.1f;
+ t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
t->transform = Resize;
}
@@ -2140,7 +2140,7 @@ void initToSphere(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
- t->snap[1] = G.vd->grid * 0.1f;
+ t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
t->transform = ToSphere;
}
@@ -2218,7 +2218,7 @@ void initRotation(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
- t->snap[1] = G.vd->grid * (float)((5.0/180)*M_PI);
+ t->snap[1] = (5.0/180)*M_PI;
t->snap[2] = t->snap[1] * 0.2f;
t->fac = 0;
t->transform = Rotation;
@@ -2431,7 +2431,7 @@ void initTrackball(TransInfo *t)
t->idx_max = 1;
t->num.idx_max = 1;
t->snap[0] = 0.0f;
- t->snap[1] = G.vd->grid * (float)((5.0/180)*M_PI);
+ t->snap[1] = (5.0/180)*M_PI;
t->snap[2] = t->snap[1] * 0.2f;
t->fac = 0;
t->transform = Trackball;
@@ -2530,7 +2530,7 @@ void initTranslation(TransInfo *t)
t->idx_max = 2;
t->num.idx_max = 2;
t->snap[0] = 0.0f;
- t->snap[1] = G.vd->grid * 1.0f;
+ t->snap[1] = G.vd->gridview * 1.0f;
t->snap[2] = t->snap[1] * 0.1f;
t->transform = Translation;
@@ -2648,7 +2648,7 @@ void initShrinkFatten(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
- t->snap[1] = G.vd->grid * 1.0f;
+ t->snap[1] = 1.0f;
t->snap[2] = t->snap[1] * 0.1f;
t->transform = ShrinkFatten;
}
@@ -2715,7 +2715,7 @@ void initTilt(TransInfo *t)
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
- t->snap[1] = G.vd->grid * (float)((5.0/180)*M_PI);
+ t->snap[1] = ((5.0/180)*M_PI);
t->snap[2] = t->snap[1] * 0.2f;
t->fac = 0;
t->transform = Tilt;