From 2013f9f4667d81ae60a5834501cc4a82d17b8e10 Mon Sep 17 00:00:00 2001 From: Jonathan Westhues Date: Wed, 10 Jun 2009 00:04:35 -0800 Subject: [PATCH] Oops, was computing numerical by perturbing a point in uv; but the xyz point that I subtracted off had been refined to lie exactly on our edge's curve, and the uv point that I started with had not. So normals got randomly screwed up. [git-p4: depot-paths = "//depot/solvespace/": change = 1978] --- solvespace.cpp | 2 +- srf/boolean.cpp | 5 +++-- util.cpp | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/solvespace.cpp b/solvespace.cpp index 43ff666..1ace0e8 100644 --- a/solvespace.cpp +++ b/solvespace.cpp @@ -57,7 +57,7 @@ void SolveSpace::Init(char *cmdLine) { lightDir[1].y = CnfThawFloat( 0.0f, "LightDir_1_Up" ); lightDir[1].z = CnfThawFloat( 0.0f, "LightDir_1_Forward" ); // Chord tolerance - chordTol = CnfThawFloat(1.5f, "ChordTolerance"); + chordTol = CnfThawFloat(2.0f, "ChordTolerance"); // Max pwl segments to generate maxSegments = CnfThawDWORD(10, "MaxSegments"); // View units diff --git a/srf/boolean.cpp b/srf/boolean.cpp index 30789dc..b8a368f 100644 --- a/srf/boolean.cpp +++ b/srf/boolean.cpp @@ -276,7 +276,6 @@ void SSurface::EdgeNormalsWithinSurface(Point2d auv, Point2d buv, Point2d enuv = abuv.Normal(); *pt = PointAt(muv); - *surfn = NormalAt(muv.x, muv.y); // If this edge just approximates a curve, then refine our midpoint so // so that it actually lies on that curve too. Otherwise stuff like @@ -288,8 +287,11 @@ void SSurface::EdgeNormalsWithinSurface(Point2d auv, Point2d buv, double t; sc->exact.ClosestPointTo(*pt, &t, false); *pt = sc->exact.PointAt(t); + ClosestPointTo(*pt, &muv); } + *surfn = NormalAt(muv.x, muv.y); + // Compute the inner and outer normals of this edge (within the srf), // in xyz space. These are not necessarily antiparallel, if the // surface is curved. @@ -487,7 +489,6 @@ void SShell::MakeIntersectionCurvesAgainst(SShell *agnst, SShell *into) { // list for into. sa->IntersectAgainst(sb, this, agnst, into); } - FLAG++; } } diff --git a/util.cpp b/util.cpp index 0b58aed..e2a8006 100644 --- a/util.cpp +++ b/util.cpp @@ -510,8 +510,11 @@ Vector Vector::ScaledBy(double v) { Vector Vector::WithMagnitude(double v) { double m = Magnitude(); if(m == 0) { - dbp("Vector::WithMagnitude of zero vector!"); - return From(v, 0, 0); + // We can do a zero vector with zero magnitude, but not any other cases. + if(fabs(v) > 1e-100) { + dbp("Vector::WithMagnitude of zero vector!"); + } + return From(0, 0, 0); } else { return ScaledBy(v/m); }