diff options
author | Martin Poirier <theeth@yahoo.com> | 2005-05-16 12:25:49 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2005-05-16 12:25:49 +0400 |
commit | 7373dcf7054953a330cd5605040c27bcdd253d37 (patch) | |
tree | b442a06e60323c3efa0a4cdf22358b571abb8294 | |
parent | 9306ff787e040e3e9b8bc8da7a5cb0efca189325 (diff) |
Transform MMB code fixing Ton's last fix.
His fix was good, except that it switched to project_float instead of project_short, and that's not good because we're renormalizing the vector after that, which maximizes the float errors. Since it's scalling the axis anyway with the zfac method, it can use project_short safely (I tested it with the bug tracker file that triggered the fix in the first place).
-rwxr-xr-x | source/blender/src/transform_constraints.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/source/blender/src/transform_constraints.c b/source/blender/src/transform_constraints.c index d8bc064679e..e08a62fff8a 100755 --- a/source/blender/src/transform_constraints.c +++ b/source/blender/src/transform_constraints.c @@ -824,36 +824,37 @@ void postSelectConstraint(TransInfo *t) void setNearestAxis(TransInfo *t) { - float zfac, coord[2]; + float zfac; float mvec[3], axis[3], proj[3]; float len[3]; - short mval[2]; + short coord[2]; int i; t->con.mode &= ~CON_AXIS0; t->con.mode &= ~CON_AXIS1; t->con.mode &= ~CON_AXIS2; - getmouseco_areawin(mval); - mvec[0] = (float)(mval[0] - t->con.imval[0]); - mvec[1] = (float)(mval[1] - t->con.imval[1]); + getmouseco_areawin(coord); + mvec[0] = (float)(coord[0] - t->con.imval[0]); + mvec[1] = (float)(coord[1] - t->con.imval[1]); mvec[2] = 0.0f; + + /* we need to correct axis length for the current zoomlevel of view, + this to prevent projected values to be clipped behind the camera. + code is actually a copy of initgrabz() in view.c. + Vector is made 30 pixels long, which is fine for accurate axis choosing. (ton) + */ + zfac= G.vd->persmat[0][3]*t->center[0]+ G.vd->persmat[1][3]*t->center[1]+ G.vd->persmat[2][3]*t->center[2]+ G.vd->persmat[3][3]; + zfac= 30.0*zfac/(float)curarea->winx; + for (i = 0; i<3; i++) { VECCOPY(axis, t->con.mtx[i]); - /* we need to correct axis length for the current zoomlevel of view, - this to prevent projected values to be clipped behind the camera. - code is actually a copy of initgrabz() in view.c. - Vector is made 30 pixels long, which is fine for accurate axis choosing. (ton) - */ - zfac= G.vd->persmat[0][3]*axis[0]+ G.vd->persmat[1][3]*axis[1]+ G.vd->persmat[2][3]*axis[2]+ G.vd->persmat[3][3]; - zfac= 30.0*zfac/(float)curarea->winx; VecMulf(axis, zfac); - /* now we can project to get window coordinate */ VecAddf(axis, axis, t->con.center); - project_float(axis, coord); + project_short_noclip(axis, coord); axis[0] = (float)(coord[0] - t->center2d[0]); axis[1] = (float)(coord[1] - t->center2d[1]); |