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.22 by greg, Wed Nov 2 22:09:14 2016 UTC vs.
Revision 2.25 by greg, Fri Apr 19 16:29:10 2019 UTC

# Line 121 | Line 121 | void   (*addobjnotify[8])() = {ambnotify, NULL};
121  
122   int     do_irrad = 0;                   /* compute irradiance? */
123  
124 < int     rand_samp = 0;                  /* pure Monte Carlo sampling? */
124 > int     rand_samp = 1;                  /* pure Monte Carlo sampling? */
125  
126   double  dstrsrc = 0.0;                  /* square source distribution */
127   double  shadthresh = .03;               /* shadow threshold */
# Line 141 | Line 141 | double specjitter = 1.;                /* specular sampling jitter *
141  
142   int     backvis = 1;                    /* back face visibility */
143  
144 < int     maxdepth = 8;                   /* maximum recursion depth */
145 < double  minweight = 5e-4;               /* minimum ray weight */
144 > int     maxdepth = -10;                 /* maximum recursion depth */
145 > double  minweight = 2e-3;               /* minimum ray weight */
146  
147   char    *ambfile = NULL;                /* ambient file name */
148   COLOR   ambval = BLKCOLOR;              /* ambient value */
# 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 238 | Line 246 | ray_save(                      /* save current parameter settings */
246          if (rp == NULL)
247                  return;
248          rp->do_irrad = do_irrad;
249 +        rp->rand_samp = rand_samp;
250          rp->dstrsrc = dstrsrc;
251          rp->shadthresh = shadthresh;
252          rp->shadcert = shadcert;
# Line 254 | Line 263 | ray_save(                      /* save current parameter settings */
263          rp->backvis = backvis;
264          rp->maxdepth = maxdepth;
265          rp->minweight = minweight;
257        copycolor(rp->ambval, ambval);
258        memset(rp->ambfile, '\0', sizeof(rp->ambfile));
266          if (ambfile != NULL)
267                  strncpy(rp->ambfile, ambfile, sizeof(rp->ambfile)-1);
268 +        else
269 +                memset(rp->ambfile, '\0', sizeof(rp->ambfile));
270 +        copycolor(rp->ambval, ambval);
271          rp->ambvwt = ambvwt;
272          rp->ambacc = ambacc;
273          rp->ambres = ambres;
# Line 272 | Line 282 | ray_save(                      /* save current parameter settings */
282                  if (ndx+len >= sizeof(rp->amblval))
283                          break;
284                  strcpy(rp->amblval+ndx, amblist[i]);
285 +                rp->amblndx[i] = ndx;
286                  ndx += len+1;
287          }
288          while (i <= AMBLLEN)
# Line 287 | 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 297 | Line 308 | ray_restore(                   /* restore parameter settings */
308          }
309                                          /* restore saved settings */
310          do_irrad = rp->do_irrad;
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 318 | 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)
# Line 364 | Line 380 | ray_defaults(          /* get default parameter values */
380                  return;
381  
382          rp->do_irrad = 0;
383 +        rp->rand_samp = 1;
384          rp->dstrsrc = 0.0;
385          rp->shadthresh = .03;
386          rp->shadcert = .75;
# Line 378 | Line 395 | ray_defaults(          /* get default parameter values */
395          rp->specthresh = .15;
396          rp->specjitter = 1.;
397          rp->backvis = 1;
398 <        rp->maxdepth = 8;
398 >        rp->maxdepth = -10;
399          rp->minweight = 2e-3;
383        setcolor(rp->ambval, 0., 0., 0.);
400          memset(rp->ambfile, '\0', sizeof(rp->ambfile));
401 +        setcolor(rp->ambval, 0., 0., 0.);
402          rp->ambvwt = 0;
403          rp->ambres = 256;
404          rp->ambacc = 0.15;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines