Fix bugs: problem drag-rotating normals with the mouse, a failure

to save our registry stuff (because we were calling exit() instead
of doing a PostQuitMessage()), and a misclassification of triangles
coplanar with the test surface, when the test surface contained
zero-area triangles.

[git-p4: depot-paths = "//depot/solvespace/": change = 1773]
solver
Jonathan Westhues 2008-06-03 10:48:47 -08:00
parent ea6db67c7d
commit 64c7a4e61b
5 changed files with 15 additions and 6 deletions

View File

@ -649,17 +649,17 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
double theta = atan2(orig.mouse.y-p2.y, orig.mouse.x-p2.x);
theta -= atan2(y-p2.y, x-p2.x);
Vector normal = orig.projRight.Cross(orig.projUp);
Vector normal = projRight.Cross(projUp);
u = u.RotatedAbout(normal, -theta);
v = v.RotatedAbout(normal, -theta);
} else {
double dx = -(x - orig.mouse.x);
double dy = -(y - orig.mouse.y);
double s = 0.3*(PI/180); // degrees per pixel
u = u.RotatedAbout(orig.projUp, -s*dx);
u = u.RotatedAbout(orig.projRight, s*dy);
v = v.RotatedAbout(orig.projUp, -s*dx);
v = v.RotatedAbout(orig.projRight, s*dy);
u = u.RotatedAbout(projUp, -s*dx);
u = u.RotatedAbout(projRight, s*dy);
v = v.RotatedAbout(projUp, -s*dx);
v = v.RotatedAbout(projRight, s*dy);
}
orig.mouse = mp;
normal->NormalForceTo(Quaternion::From(u, v));

View File

@ -7,6 +7,10 @@ Vector STriangle::Normal(void) {
bool STriangle::ContainsPoint(Vector p) {
Vector n = Normal();
if(n.Magnitude() < LENGTH_EPS*LENGTH_EPS) {
// shouldn't happen; zero-area triangle
return false;
}
return ContainsPointProjd(n.WithMagnitude(1), p);
}

View File

@ -459,7 +459,7 @@ void SolveSpace::MenuFile(int id) {
case GraphicsWindow::MNU_EXIT:
if(!SS.OkayToStartNewFile()) break;
exit(0);
ExitNow();
break;
default: oops();

View File

@ -79,6 +79,7 @@ void dbp(char *str, ...);
CO((tri).a), CO((tri).b), CO((tri).c))
void Error(char *str, ...);
void ExitNow(void);
void *AllocTemporary(int n);
void FreeAllTemporary(void);

View File

@ -67,6 +67,10 @@ void Error(char *str, ...)
MessageBox(h, buf, "SolveSpace Error", MB_OK | MB_ICONERROR);
}
void ExitNow(void) {
PostQuitMessage(0);
}
//-----------------------------------------------------------------------------
// A separate heap, on which we allocate expressions. Maybe a bit faster,
// since no fragmentation issues whatsoever, and it also makes it possible