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-25 14:17:59 +0300
committerTon Roosendaal <ton@blender.org>2005-03-25 14:17:59 +0300
commit727a056de4e83ee0013c9007ec8d6b9de8863c4c (patch)
tree93caea9dcfc89f35d8f6da7f3f81f28c7ab20595
parentcf30d9443d76b2502a91b1d3f20847c85d3b88e8 (diff)
A couple of wee transform featurettes;
- center of rotation for camera in cameraview rotate has to remain the camera center itself, drawing the dashed helpline then doesn't work, since it's behind the camera clipplane. Just disabled that line. - made MMB switch for cameraview grab to become quadratic, for a dolly this feels OK, and makes it possible to move in small and large scenes. - restored SHIFT modifier for translation and scaling. This based on old convention that allowed precision editing on top of the transform you already applied before pressing SHIFT. Solved it with a new flag (T_SHIFT_MOD), since the G.qual cannot be used. Transform() innerloop has to detect the SHIFT event itself. Also coded it with storing the mouseposition while SHIFT event happened. Hope Martin can approve! :) - Martin's last commit made Manipulator Translate not work, it passed on a zero translation to the constrainter, causing NaN's. Nicely catched the exception. - Fixed 'Trackball' to accept number input too
-rw-r--r--source/blender/src/drawobject.c34
-rwxr-xr-xsource/blender/src/transform.c68
-rwxr-xr-xsource/blender/src/transform.h3
-rwxr-xr-xsource/blender/src/transform_constraints.c22
-rwxr-xr-xsource/blender/src/transform_generics.c13
5 files changed, 96 insertions, 44 deletions
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index b6ea49c607b..0a508805198 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -244,6 +244,7 @@ static void draw_icon_centered(float *pos, unsigned int *rect, int rectsize)
glDrawPixels(rectsize, rectsize, GL_RGBA, GL_UNSIGNED_BYTE, rect);
}
+/* bad frontbuffer call... because it is used in transform after force_draw() */
void helpline(float *vec)
{
float vecrot[3], cent[2];
@@ -255,23 +256,24 @@ void helpline(float *vec)
getmouseco_areawin(mval);
project_float(vecrot, cent); // no overflow in extreme cases
+ if(cent[0]!=3200.0f) {
+ persp(PERSP_WIN);
+
+ glDrawBuffer(GL_FRONT);
+
+ BIF_ThemeColor(TH_WIRE);
- persp(PERSP_WIN);
-
- glDrawBuffer(GL_FRONT);
-
- BIF_ThemeColor(TH_WIRE);
-
- setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2sv(mval);
- glVertex2fv(cent);
- glEnd();
- setlinestyle(0);
-
- persp(PERSP_VIEW);
- glFlush(); // flush display for frontbuffer
- glDrawBuffer(GL_BACK);
+ setlinestyle(3);
+ glBegin(GL_LINE_STRIP);
+ glVertex2sv(mval);
+ glVertex2fv(cent);
+ glEnd();
+ setlinestyle(0);
+
+ persp(PERSP_VIEW);
+ glFlush(); // flush display for frontbuffer
+ glDrawBuffer(GL_BACK);
+ }
}
void drawaxes(float size)
diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c
index 08b34c19e46..6a7dd06fbbd 100755
--- a/source/blender/src/transform.c
+++ b/source/blender/src/transform.c
@@ -1385,8 +1385,13 @@ void Transform(int mode)
/* enforce redraw of transform when modifiers are used */
case LEFTCTRLKEY:
case RIGHTCTRLKEY:
+ Trans.redraw = 1;
+ break;
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
+ /* shift is modifier for higher resolution transform, works nice to store this mouse position */
+ getmouseco_areawin(Trans.shiftmval);
+ Trans.flag |= T_SHIFT_MOD;
Trans.redraw = 1;
break;
@@ -1550,6 +1555,11 @@ void Transform(int mode)
/* commented out, doesn't work for actions started with menu */
// ret_val = TRANS_CONFIRM;
break;
+ case LEFTSHIFTKEY:
+ case RIGHTSHIFTKEY:
+ /* shift is modifier for higher resolution transform */
+ Trans.flag &= ~T_SHIFT_MOD;
+ break;
}
}
}
@@ -1665,9 +1675,17 @@ void ManipulatorTransform(int mode)
/* enforce redraw of transform when modifiers are used */
case LEFTCTRLKEY:
case RIGHTCTRLKEY:
+ if(val) Trans.redraw = 1;
+ break;
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
- if(val) Trans.redraw = 1;
+ /* shift is modifier for higher resolution transform, works nice to store this mouse position */
+ if(val) {
+ getmouseco_areawin(Trans.shiftmval);
+ Trans.flag |= T_SHIFT_MOD;
+ Trans.redraw = 1;
+ }
+ else Trans.flag &= ~T_SHIFT_MOD;
break;
case ESCKEY:
@@ -2018,12 +2036,23 @@ int Resize(TransInfo *t, short mval[2])
ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1]))/100.0f;
}
else {
- ratio = (float)sqrt( (float)
- (
- (t->center2d[1] - mval[1])*(t->center2d[1] - mval[1])
- +
- (t->center2d[0] - mval[0])*(t->center2d[0] - mval[0])
- ) ) / t->fac;
+
+ if(t->flag & T_SHIFT_MOD) {
+ /* calculate ratio for shiftkey pos, and for total, and blend these for precision */
+ float dx= (float)(t->center2d[0] - t->shiftmval[0]);
+ float dy= (float)(t->center2d[1] - t->shiftmval[1]);
+ ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
+
+ dx= (float)(t->center2d[0] - mval[0]);
+ dy= (float)(t->center2d[1] - mval[1]);
+ ratio+= 0.1f*(sqrt( dx*dx + dy*dy)/t->fac -ratio);
+
+ }
+ else {
+ float dx= (float)(t->center2d[0] - mval[0]);
+ float dy= (float)(t->center2d[1] - mval[1]);
+ ratio = (float)sqrt( dx*dx + dy*dy)/t->fac;
+ }
}
if ((t->center2d[0] - mval[0]) * (t->center2d[0] - t->imval[0]) < 0)
@@ -2486,7 +2515,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
int Trackball(TransInfo *t, short mval[2])
{
- char str[50];
+ char str[80];
float axis1[3], axis2[3];
float mat[3][3], totmat[3][3], smat[3][3];
float phi[2];
@@ -2506,15 +2535,16 @@ int Trackball(TransInfo *t, short mval[2])
snapGrid(t, phi);
if (hasNumInput(&t->num)) {
- //char c[20];
+ char c[40];
- //applyNumInput(&t->num, phi);
+ applyNumInput(&t->num, phi);
- //outputNumInput(&(t->num), c);
+ outputNumInput(&(t->num), c);
- //sprintf(str, "Trackball: %s %s", &c[0], t->proptext);
+ sprintf(str, "Trackball: %s %s %s", &c[0], &c[20], t->proptext);
- //final *= (float)(M_PI / 180.0);
+ phi[0] *= (float)(M_PI / 180.0);
+ phi[1] *= (float)(M_PI / 180.0);
}
else {
sprintf(str, "Trackball: %.2f %.2f %s", 180.0*phi[0]/M_PI, 180.0*phi[1]/M_PI, t->proptext);
@@ -2626,8 +2656,16 @@ int Translation(TransInfo *t, short mval[2])
{
float tvec[3];
char str[200];
-
- window_to_3d(t->vec, (short)(mval[0] - t->imval[0]), (short)(mval[1] - t->imval[1]));
+
+ if(t->flag & T_SHIFT_MOD) {
+ float dvec[3];
+ /* calculate the main translation and the precise one separate */
+ window_to_3d(dvec, (short)(mval[0] - t->shiftmval[0]), (short)(mval[1] - t->shiftmval[1]));
+ VecMulf(dvec, 0.1f);
+ window_to_3d(t->vec, (short)(t->shiftmval[0] - t->imval[0]), (short)(t->shiftmval[1] - t->imval[1]));
+ VecAddf(t->vec, t->vec, dvec);
+ }
+ else window_to_3d(t->vec, (short)(mval[0] - t->imval[0]), (short)(mval[1] - t->imval[1]));
if (t->con.mode & CON_APPLY) {
float pvec[3] = {0.0f, 0.0f, 0.0f};
diff --git a/source/blender/src/transform.h b/source/blender/src/transform.h
index baf6f600863..97938b3684b 100755
--- a/source/blender/src/transform.h
+++ b/source/blender/src/transform.h
@@ -117,6 +117,7 @@ typedef struct TransInfo {
float center[3]; /* center of transformation */
short center2d[2]; /* center in screen coordinates */
short imval[2]; /* initial mouse position */
+ short shiftmval[2]; /* mouse position when shift was pressed */
short idx_max;
float snap[3]; /* Snapping Gears */
TransData *data; /* transformed data (array) */
@@ -151,6 +152,8 @@ typedef struct TransInfo {
#define T_POSE 4
#define T_TEXTURE 8
#define T_CAMERA 16
+ // when shift pressed, higher resolution transform. cannot rely on G.qual, need event!
+#define T_SHIFT_MOD 32
// for manipulator exceptions, like scaling using center point, drawing help lines
#define T_USES_MANIPULATOR 128
diff --git a/source/blender/src/transform_constraints.c b/source/blender/src/transform_constraints.c
index dc99d6209a5..1d66e7e92e0 100755
--- a/source/blender/src/transform_constraints.c
+++ b/source/blender/src/transform_constraints.c
@@ -203,21 +203,27 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
/* For when view is parallel to constraint... will cause NaNs otherwise
So we take vertical motion in 3D space and apply it to the
constraint axis. Nice for camera grab + MMB */
- if(n[0]*n[0] + n[1]*n[1] + n[2]*n[2] < 0.000001) {
+ if(n[0]*n[0] + n[1]*n[1] + n[2]*n[2] < 0.000001f) {
Projf(vec, in, t->viewinv[1]);
factor = Inpf(t->viewinv[1], vec) * 2.0f;
-
+ /* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */
+ if(factor<0.0f) factor*= -factor;
+ else factor*= factor;
+
VECCOPY(out, axis);
Normalise(out);
- VecMulf(out, factor);
+ VecMulf(out, -factor); /* -factor makes move down going backwards */
}
else {
- Projf(vec, in, n);
- factor = Normalise(vec);
- factor /= Inpf(axis, vec);
+ // prevent division by zero, happens on constrainting without initial delta transform */
+ if(in[0]!=0.0f || in[1]!=0.0f || in[2]!=0.0) {
+ Projf(vec, in, n);
+ factor = Normalise(vec);
+ factor /= Inpf(axis, vec);
- VecMulf(axis, factor);
- VECCOPY(out, axis);
+ VecMulf(axis, factor);
+ VECCOPY(out, axis);
+ }
}
}
diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c
index 817b6255b66..8e462e83663 100755
--- a/source/blender/src/transform_generics.c
+++ b/source/blender/src/transform_generics.c
@@ -682,13 +682,16 @@ void calculateCenter(TransInfo *t)
float axis[3];
VECCOPY(axis, G.vd->persinv[2]);
Normalise(axis);
-
+
/* 6.0 = 6 grid units */
- t->center[0]+= 6.0f*axis[0];
- t->center[1]+= 6.0f*axis[1];
- t->center[2]+= 6.0f*axis[2];
+ axis[0]= t->center[0]+ 6.0f*axis[0];
+ axis[1]= t->center[1]+ 6.0f*axis[1];
+ axis[2]= t->center[2]+ 6.0f*axis[2];
+
+ project_short_noclip(axis, t->center2d);
- project_short_noclip(t->center, t->center2d);
+ /* rotate only needs correct 2d center, grab needs initgrabz() value */
+ if(t->mode==TFM_TRANSLATION) VECCOPY(t->center, axis);
}
}
initgrabz(t->center[0], t->center[1], t->center[2]);