Reworked the camera dolly/parallel axis constraint code a bit. Works pretty much like the Shrink/Fatten code, meaning pull the mouse toward you pulls the camera, push pushes it away.

Also added a T_CAMERA flag for camera grab, which gets set on TransData conversion.
This commit is contained in:
2005-03-24 21:32:52 +00:00
parent 9e90f1407e
commit 4bcf80bf4f
3 changed files with 33 additions and 29 deletions

View File

@@ -196,37 +196,29 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
Normalise(axis);
VECCOPY(n, axis);
Mat4MulVecfl(G.vd->viewmat, n);
n[2] = G.vd->viewmat[3][2];
Mat4MulVecfl(G.vd->viewinv, n);
Mat4MulVecfl(t->viewmat, n);
n[2] = t->viewmat[3][2];
Mat4MulVecfl(t->viewinv, n);
/* For when view is parallel to constraint... will cause NaNs otherwise
So; we mix mouse motion with size of 'in' (unconstrainted motion),
which gives a sorta exponentional effect, nice for camera grab + MMB */
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) {
short mval[2];
getmouseco_areawin(mval);
VECCOPY(vec, in);
factor= Normalise(vec); // len original delta
factor*= 0.05*(t->imval[1] - mval[1]); // 5% of vertical mouse motion
Projf(vec, in, t->viewinv[1]);
factor = Inpf(t->viewinv[1], vec) * 2.0f;
VECCOPY(out, axis);
Normalise(out);
VecMulf(out, factor);
}
else {
Projf(vec, in, n);
factor = Normalise(vec);
factor /= Inpf(axis, vec);
if (Inpf(axis, norm) != 1.0f) {
Projf(vec, in, n);
factor = Normalise(vec);
factor /= Inpf(axis, vec);
VecMulf(axis, factor);
VECCOPY(out, axis);
}
else {
out[0] = out[1] = out[2] = 0.0f;
}
}
VecMulf(axis, factor);
VECCOPY(out, axis);
}
}
static void planeProjection(TransInfo *t, float in[3], float out[3]) {