Various Transform bugfixes.

- Trackball rotate was missing the NoConstraints flag
- Zooming didn't recalculate the 2D center correctly
- Zooming in transform was sending event to the 3D window even when working on UVs. (disabled when working on UVs for now, will need to send events to a 2D window handler eventually)
- In camera mode, when the selection was exactly on the camera, initgrabz was barfing, fallback to 1.0 now, which gives ok results.
This commit is contained in:
2005-09-24 18:00:32 +00:00
parent 8b7c690a0b
commit 6e94b02616
4 changed files with 46 additions and 50 deletions

View File

@@ -338,6 +338,7 @@ void restoreTransObjects(TransInfo *t);
void recalcData(TransInfo *t);
void calculateCenter(TransInfo *t);
void calculateCenter2D(TransInfo *t);
void calculateCenterBound(TransInfo *t);
void calculateCenterMedian(TransInfo *t);
void calculateCenterCursor(TransInfo *t);

View File

@@ -194,6 +194,9 @@ void setTransformViewMatrices(TransInfo *t)
Mat4One(t->persinv);
t->persp = 0; // ortho
}
calculateCenter2D(t);
}
void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
@@ -334,6 +337,12 @@ static void view_editmove(unsigned short event)
/* Alt-Shift: Rotate up */
/* Alt-Ctrl: Rotate right */
/* only work in 3D window for now
* In the end, will have to send to event to a 2D window handler instead
*/
if (Trans.flag & T_2D_EDIT)
return;
switch(event) {
case WHEELUPMOUSE:
@@ -1792,6 +1801,8 @@ void initTrackball(TransInfo *t)
t->snap[2] = t->snap[1] * 0.2f;
t->fac = 0;
t->transform = Trackball;
t->flag |= T_NO_CONSTRAINT; /* making sure the flag is always set */
}
static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float angles[2])
@@ -2365,7 +2376,7 @@ void Mirror(short mode)
Trans.context = CTX_NO_PET;
initTrans(&Trans); // internal data, mouse, vectors
initTrans(&Trans); // internal data, mouse, vectors
Mat3One(mati);
Mat3CpyMat4(matview, Trans.viewinv); // t->viewinv was set in initTrans
@@ -2373,7 +2384,7 @@ void Mirror(short mode)
initTransModeFlags(&Trans, TFM_MIRROR); // modal settings in struct Trans
createTransData(&Trans); // make TransData structs from selection
createTransData(&Trans); // make TransData structs from selection
calculatePropRatio(&Trans);
calculateCenter(&Trans);

View File

@@ -555,25 +555,14 @@ void restoreTransObjects(TransInfo *t)
restoreElement(td);
}
recalcData(t);
}
}
void calculateCenterCursor(TransInfo *t)
void calculateCenter2D(TransInfo *t)
{
float *cursor;
cursor = give_cursor();
VECCOPY(t->center, cursor);
if(t->flag & (T_EDIT|T_POSE)) {
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= G.obedit?G.obedit:t->poseobj;
float mat[3][3], imat[3][3];
float vec[3];
VecSubf(t->center, t->center, ob->obmat[3]);
Mat3CpyMat4(mat, ob->obmat);
Mat3Inv(imat, mat);
Mat3MulVecfl(imat, t->center);
VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec);
projectIntView(t, vec, t->center2d);
@@ -583,6 +572,27 @@ void calculateCenterCursor(TransInfo *t)
}
}
void calculateCenterCursor(TransInfo *t)
{
float *cursor;
cursor = give_cursor();
VECCOPY(t->center, cursor);
/* If edit or pose mode, move cursor in local space */
if(t->flag & (T_EDIT|T_POSE)) {
Object *ob= G.obedit?G.obedit:t->poseobj;
float mat[3][3], imat[3][3];
VecSubf(t->center, t->center, ob->obmat[3]);
Mat3CpyMat4(mat, ob->obmat);
Mat3Inv(imat, mat);
Mat3MulVecfl(imat, t->center);
}
calculateCenter2D(t);
}
void calculateCenterMedian(TransInfo *t)
{
float partial[3] = {0.0f, 0.0f, 0.0f};
@@ -602,17 +612,7 @@ void calculateCenterMedian(TransInfo *t)
VecMulf(partial, 1.0f / i);
VECCOPY(t->center, partial);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= G.obedit?G.obedit:t->poseobj;
float vec[3];
VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec);
projectIntView(t, vec, t->center2d);
}
else {
projectIntView(t, t->center, t->center2d);
}
calculateCenter2D(t);
}
void calculateCenterBound(TransInfo *t)
@@ -641,17 +641,7 @@ void calculateCenterBound(TransInfo *t)
VecAddf(t->center, min, max);
VecMulf(t->center, 0.5);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= G.obedit?G.obedit:t->poseobj;
float vec[3];
VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec);
projectIntView(t, vec, t->center2d);
}
else {
projectIntView(t, t->center, t->center2d);
}
calculateCenter2D(t);
}
void calculateCenter(TransInfo *t)

View File

@@ -145,24 +145,18 @@ 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 x,y,z is exactly the viewport offset, zfac is 0 and we don't want that */
if (zfac==0.0f) zfac = 1.0f;
}
void window_to_3d(float *vec, short mx, short my)
{
/* always call initzgrab */
float dx, dy;
float fmx, fmy, winx, winy;
/* stupid! */
winx= curarea->winx;
winy= curarea->winy;
fmx= mx;
fmy= my;
dx= (2.0*fmx)/winx;
dx*= zfac;
dy= (2.0*fmy)/winy;
dy*= zfac;
dx= 2.0f*mx*zfac/curarea->winx;
dy= 2.0f*my*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);