Transform 2D center was using short. Not good enough when it's it's way off screen. Switched to ints, that fixed the bug in the tracker.

Switching to floats would probably be safer in the long term, but too many things to test to do that now.
This commit is contained in:
Martin Poirier 2005-06-05 13:50:21 +00:00
parent 38202abff8
commit c00adc5ff8
5 changed files with 38 additions and 13 deletions

@ -50,6 +50,7 @@ void initgrabz(float x, float y, float z);
void window_to_3d(float *vec, short mx, short my); void window_to_3d(float *vec, short mx, short my);
void project_short(float *vec, short *adr); void project_short(float *vec, short *adr);
void project_short_noclip(float *vec, short *adr); void project_short_noclip(float *vec, short *adr);
void project_int(float *vec, int *adr);
void project_float(float *vec, float *adr); void project_float(float *vec, float *adr);
int boundbox_clip(float obmat[][4], struct BoundBox *bb); int boundbox_clip(float obmat[][4], struct BoundBox *bb);
void fdrawline(float x1, float y1, float x2, float y2); void fdrawline(float x1, float y1, float x2, float y2);

@ -135,7 +135,7 @@ typedef struct TransInfo {
float propsize; /* proportional circle radius */ float propsize; /* proportional circle radius */
char proptext[20]; /* proportional falloff text */ char proptext[20]; /* proportional falloff text */
float center[3]; /* center of transformation */ float center[3]; /* center of transformation */
short center2d[2]; /* center in screen coordinates */ int center2d[2]; /* center in screen coordinates */
short imval[2]; /* initial mouse position */ short imval[2]; /* initial mouse position */
short shiftmval[2]; /* mouse position when shift was pressed */ short shiftmval[2]; /* mouse position when shift was pressed */
short idx_max; short idx_max;

@ -842,8 +842,8 @@ void setNearestAxis(TransInfo *t)
float zfac; float zfac;
float mvec[3], axis[3], proj[3]; float mvec[3], axis[3], proj[3];
float len[3]; float len[3];
int i, icoord[2];
short coord[2]; short coord[2];
int i;
t->con.mode &= ~CON_AXIS0; t->con.mode &= ~CON_AXIS0;
t->con.mode &= ~CON_AXIS1; t->con.mode &= ~CON_AXIS1;
@ -871,10 +871,10 @@ void setNearestAxis(TransInfo *t)
VecMulf(axis, zfac); VecMulf(axis, zfac);
/* now we can project to get window coordinate */ /* now we can project to get window coordinate */
VecAddf(axis, axis, t->con.center); VecAddf(axis, axis, t->con.center);
project_short_noclip(axis, coord); project_int(axis, icoord);
axis[0] = (float)(coord[0] - t->center2d[0]); axis[0] = (float)(icoord[0] - t->center2d[0]);
axis[1] = (float)(coord[1] - t->center2d[1]); axis[1] = (float)(icoord[1] - t->center2d[1]);
axis[2] = 0.0f; axis[2] = 0.0f;
if (Normalise(axis) != 0.0f) { if (Normalise(axis) != 0.0f) {

@ -608,10 +608,10 @@ void calculateCenterCursor(TransInfo *t)
VECCOPY(vec, t->center); VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec); Mat4MulVecfl(ob->obmat, vec);
project_short_noclip(vec, t->center2d); project_int(vec, t->center2d);
} }
else { else {
project_short_noclip(t->center, t->center2d); project_int(t->center, t->center2d);
} }
} }
@ -640,10 +640,10 @@ void calculateCenterMedian(TransInfo *t)
VECCOPY(vec, t->center); VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec); Mat4MulVecfl(ob->obmat, vec);
project_short_noclip(vec, t->center2d); project_int(vec, t->center2d);
} }
else { else {
project_short_noclip(t->center, t->center2d); project_int(t->center, t->center2d);
} }
} }
@ -679,10 +679,10 @@ void calculateCenterBound(TransInfo *t)
VECCOPY(vec, t->center); VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec); Mat4MulVecfl(ob->obmat, vec);
project_short_noclip(vec, t->center2d); project_int(vec, t->center2d);
} }
else { else {
project_short_noclip(t->center, t->center2d); project_int(t->center, t->center2d);
} }
} }
@ -709,7 +709,7 @@ void calculateCenter(TransInfo *t)
Object *ob= OBACT; Object *ob= OBACT;
if(ob) { if(ob) {
VECCOPY(t->center, ob->obmat[3]); VECCOPY(t->center, ob->obmat[3]);
project_short_noclip(t->center, t->center2d); project_int(t->center, t->center2d);
} }
} }
@ -735,7 +735,7 @@ void calculateCenter(TransInfo *t)
axis[1]= t->center[1]- 6.0f*axis[1]; axis[1]= t->center[1]- 6.0f*axis[1];
axis[2]= t->center[2]- 6.0f*axis[2]; axis[2]= t->center[2]- 6.0f*axis[2];
project_short_noclip(axis, t->center2d); project_int(axis, t->center2d);
/* rotate only needs correct 2d center, grab needs initgrabz() value */ /* rotate only needs correct 2d center, grab needs initgrabz() value */
if(t->mode==TFM_TRANSLATION) VECCOPY(t->center, axis); if(t->mode==TFM_TRANSLATION) VECCOPY(t->center, axis);

@ -192,6 +192,30 @@ void project_short(float *vec, short *adr) /* clips */
} }
} }
void project_int(float *vec, int *adr)
{
float fx, fy, vec4[4];
adr[0]= 2140000000.0f;
VECCOPY(vec4, vec);
vec4[3]= 1.0;
Mat4MulVec4fl(G.vd->persmat, vec4);
if( vec4[3]>BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */
fx= (curarea->winx/2)*(1 + vec4[0]/vec4[3]);
if( fx>-2140000000.0f && fx<2140000000.0f) {
fy= (curarea->winy/2)*(1 + vec4[1]/vec4[3]);
if(fy>-2140000000.0f && fy<2140000000.0f) {
adr[0]= floor(fx);
adr[1]= floor(fy);
}
}
}
}
void project_short_noclip(float *vec, short *adr) void project_short_noclip(float *vec, short *adr)
{ {
float fx, fy, vec4[4]; float fx, fy, vec4[4];