|
|
The bugreport http://news.povray.org/3C1A5D47.EA38F6E5@amc.uva.nl
(from http://www.povray.org/download/3.5-bugs.php) describes strange
bands of discontinuous normals when rendering a particular scene.
The scene has a catmull_rom_spline attribute, changing that to
cubic_spline does nothing, the bands remain. They disappear if you
change the value of ZERO_TOLERANCE (in the file sphsweep.cpp) to
a value closer to zero:
#define ZERO_TOLERANCE 1.0e-4
for instance. It is now 1.0e-1.
Beside the bug report I implemented the same optimization that is
in blob.cpp, to exclude the presence of a root of a polynomial in
(0 1), for sphere_sweep. The rendering time decreases impressively.
Here's the patch to be applied to sphsweep.cpp, as it is in the source
tar for linux (version 3.50a).
Comments are welcome.
Massimo
--- src/sphsweep.cpp.ex 2002-11-15 10:49:07.000000000 +0000
+++ src/sphsweep.cpp 2002-11-15 10:51:26.000000000 +0000
@@ -88,7 +88,7 @@
******************************************************************************/
#define DEPTH_TOLERANCE 1.0e-6
-#define ZERO_TOLERANCE 1.0e-1
+#define ZERO_TOLERANCE 1.0e-4
/* Just to be sure use twice as much plus old maximum. However,
from looking at the code this may still not always be enough!
@@ -122,6 +122,7 @@
static void Rotate_Sphere_Sweep (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans);
static void Scale_Sphere_Sweep (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans);
static void Invert_Sphere_Sweep (OBJECT *Object);
+static int bezier_01(int degree, DBL* Coef, DBL* Roots, bool sturm, DBL tolerance);
@@ -646,7 +647,7 @@
Coef[9] = 4.0 * j * k - 2.0 * c * k * e - 2.0 * d * j * e + 4.0 * c * d * l;
Coef[10] = Sqr(k) - d * k * e + l * Sqr(d);
- Num_Poly_Roots = Solve_Polynomial(10, Coef, Root, true, 1e-10);
+ Num_Poly_Roots = bezier_01(10, Coef, Root, true, 1e-10);
break;
}
@@ -951,7 +952,7 @@
Coef[6] -= Sqr(Sphere_Sweep->Segment[i].Radius_Coef[0]);
/* Find roots */
- Num_Poly_Roots = Solve_Polynomial(6, Coef, Root, true, 1e-10);
+ Num_Poly_Roots = bezier_01(6, Coef, Root, true, 1e-10);
/* Test for interval [0, 1] */
for (j = 0; j < Num_Poly_Roots; j++)
@@ -1963,3 +1964,34 @@
return (1);
}
}
+
+static int lcm_bezier_01[] =
+{
+ 60, 10, 4, 3, 4, 10, 60,
+ 2520, 252, 56, 21, 12, 10, 12, 21, 56, 252, 2520
+};
+
+static int bezier_01(int degree, DBL* Coef, DBL* Roots, bool sturm, DBL tolerance)
+{
+ DBL d[11];
+ bool non_negative = true, non_positive = true;
+ int i, j,* lcm = &lcm_bezier_01[degree == 6 ? 0 : 7];
+
+ for (i = 0; i <= degree; ++i)
+ d[i] = Coef[i] * lcm[i];
+
+ for (i = 0; i <= degree; ++i)
+ {
+ non_negative = non_negative && d[degree - i] >= 0;
+ non_positive = non_positive && d[degree - i] <= 0;
+ if (!(non_negative || non_positive))
+ {
+ return Solve_Polynomial(degree, Coef, Roots, sturm, tolerance);
+ }
+ for (j = 0; j < degree - i; ++j)
+ {
+ d[j] += d[j+1];
+ }
+ }
+ return 0;
+}
Post a reply to this message
|
|