POV-Ray : Newsgroups : povray.programming : Sphere sweep bug (job000200) Server Time
23 Dec 2024 07:10:54 EST (-0500)
  Sphere sweep bug (job000200) (Message 1 to 2 of 2)  
From: Massimo Valentini
Subject: Sphere sweep bug (job000200)
Date: 15 Nov 2002 05:19:47
Message: <3dd4ca43@news.povray.org>
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

From: Thorsten Froehlich
Subject: Re: Sphere sweep bug (job000200)
Date: 15 Nov 2002 13:48:06
Message: <3dd54166$1@news.povray.org>
In article <3dd4ca43@news.povray.org> , "Massimo Valentini" 
<six### [at] inwindit> wrote:

> #define ZERO_TOLERANCE  1.0e-4
>
> for instance. It is now 1.0e-1.

Hmm, 0.1 is really a bit more than unreasonable ... I agree.

    Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.