ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/raycalls.c
(Generate patch)

Comparing ray/src/rt/raycalls.c (file contents):
Revision 2.24 by greg, Thu Apr 18 23:58:22 2019 UTC vs.
Revision 2.25 by greg, Fri Apr 19 16:29:10 2019 UTC

# Line 156 | Line 156 | char   *amblist[AMBLLEN+1];            /* ambient include/exclude
156   int     ambincl = -1;                   /* include == 1, exclude == 0 */
157  
158  
159 + static void
160 + reset_random(void)              /* re-initialize random number generator */
161 + {
162 +        if (rand_samp) {
163 +                srandom((long)time(0));
164 +                initurand(0);
165 +        } else {
166 +                srandom(0L);
167 +                initurand(2048);
168 +        }
169 + }
170 +
171 +
172   void
173   ray_init(                       /* initialize ray-tracing calculation */
174          char    *otnm
# Line 167 | Line 180 | ray_init(                      /* initialize ray-tracing calculation */
180          if (ofun[OBJ_SPHERE].funp == o_default)
181                  initotypes();
182                                          /* initialize urand */
183 <        if (rand_samp) {
171 <                srandom((long)time(0));
172 <                initurand(0);
173 <        } else {
174 <                srandom(0L);
175 <                initurand(2048);
176 <        }
183 >        reset_random();
184                                          /* read scene octree */
185          readoct(octname = otnm, ~(IO_FILES|IO_INFO), &thescene, NULL);
186          nsceneobjs = nobjects;
# Line 186 | Line 193 | ray_init(                      /* initialize ray-tracing calculation */
193                                          /* ready to go... (almost) */
194   }
195  
196 +
197   void
198   ray_trace(                      /* trace a primary ray */
199          RAY     *r
# Line 290 | Line 298 | ray_restore(                   /* restore parameter settings */
298          RAYPARAMS       *rp
299   )
300   {
301 <        register int    i;
301 >        int     i;
302  
303          if (rp == NULL) {               /* restore defaults */
304                  RAYPARAMS       dflt;
# Line 300 | Line 308 | ray_restore(                   /* restore parameter settings */
308          }
309                                          /* restore saved settings */
310          do_irrad = rp->do_irrad;
311 <        rand_samp = rp->rand_samp;
311 >        if (!rand_samp != !rp->rand_samp) {
312 >                rand_samp = rp->rand_samp;
313 >                reset_random();
314 >        }
315          dstrsrc = rp->dstrsrc;
316          shadthresh = rp->shadthresh;
317          shadcert = rp->shadcert;
# Line 322 | Line 333 | ray_restore(                   /* restore parameter settings */
333          ambdiv = rp->ambdiv;
334          ambssamp = rp->ambssamp;
335          ambounce = rp->ambounce;
336 +                                        /* a bit dangerous if not static */
337          for (i = 0; rp->amblndx[i] >= 0; i++)
338                  amblist[i] = rp->amblval + rp->amblndx[i];
339          while (i <= AMBLLEN)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines