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

Comparing ray/src/hd/rholo.c (file contents):
Revision 3.12 by gregl, Thu Nov 20 11:39:24 1997 UTC vs.
Revision 3.15 by gregl, Tue Dec 2 12:29:17 1997 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ SGI";
9   */
10  
11   #include "rholo.h"
12 + #include "random.h"
13   #include "paths.h"
14   #include <signal.h>
15   #include <sys/types.h>
# Line 25 | Line 26 | char   froot[MAXPATH];         /* root file name */
26  
27   int     nowarn = 0;             /* turn warnings off? */
28  
28 double  expval = 1.;            /* global exposure value */
29
29   int     ncprocs = 0;            /* desired number of compute processes */
30  
31   char    *outdev = NULL;         /* output device name */
# Line 61 | Line 60 | char   *argv[];
60          int     force = 0;
61                                                  /* mark start time */
62          starttime = time(NULL);
63 +        initurand(10240);                       /* initialize urand */
64          progname = argv[0];                     /* get arguments */
65          for (i = 1; i < argc && argv[i][0] == '-'; i++)
66                  switch (argv[i][1]) {
# Line 113 | Line 113 | char   *argv[];
113                  creatholo(&hdg);
114          } else {                                /* else load holodeck */
115                  loadholo();
116 <                if (vdef(RIF))                          /* load RIF if any */
116 >                                                        /* check settings */
117 >                checkvalues();
118 >                                                        /* load RIF if any */
119 >                if (vdef(RIF))
120                          getradfile(vval(RIF));
121 +                                                        /* set defaults */
122 +                setdefaults(NULL);
123          }
124                                                  /* initialize */
125          initrholo();
126 <                                                /* run */
126 >                                                /* main loop */
127          while (rholo())
128                  ;
129                                                  /* done */
# Line 333 | Line 338 | register HDGRID        *gp;
338                  sprintf(errmsg, "ignoring all but first %s", vnam(SECTION));
339                  error(WARNING, errmsg);
340          }
341 +        if (!vdef(OCTREE)) {
342 +                if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL)
343 +                        error(SYSTEM, "out of memory");
344 +                sprintf(vval(OCTREE), "%s.oct", froot);
345 +                vdef(OCTREE)++;
346 +        }
347 +        if (!vdef(OBSTRUCTIONS)) {
348 +                vval(OBSTRUCTIONS) = "T";
349 +                vdef(OBSTRUCTIONS)++;
350 +        }
351 +        if (!vdef(VDIST)) {
352 +                vval(VDIST) = "F";
353 +                vdef(VDIST)++;
354 +        }
355 +        if (!vdef(OCCUPANCY)) {
356 +                vval(OCCUPANCY) = "U";
357 +                vdef(OCCUPANCY)++;
358 +        }
359 +                                /* append rendering options */
360 +        if (vdef(RENDER))
361 +                rtargc += wordstring(rtargv+rtargc, vval(RENDER));
362 +        
363 +        if (gp == NULL)         /* already initialized? */
364 +                return;
365 +                                /* set grid parameters */
366          if (sscanf(vval(SECTION),
367                          "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",
368                          &gp->orig[0], &gp->orig[1], &gp->orig[2],
# Line 353 | Line 383 | register HDGRID        *gp;
383                  badvalue(GRID);
384          for (i = 0; i < 3; i++)
385                  gp->grid[i] = len[i]/d + (1.-FTINY);
356        if (!vdef(EXPOSURE)) {
357                sprintf(errmsg, "%s must be defined", vnam(EXPOSURE));
358                error(USER, errmsg);
359        }
360        expval = vval(EXPOSURE)[0] == '-' || vval(EXPOSURE)[0] == '+' ?
361                        pow(2., vflt(EXPOSURE)) : vflt(EXPOSURE);
362        if (!vdef(OCTREE)) {
363                if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL)
364                        error(SYSTEM, "out of memory");
365                sprintf(vval(OCTREE), "%s.oct", froot);
366                vdef(OCTREE)++;
367        }
368        if (!vdef(OBSTRUCTIONS)) {
369                vval(OBSTRUCTIONS) = "T";
370                vdef(OBSTRUCTIONS)++;
371        }
372        if (!vdef(OCCUPANCY)) {
373                vval(OCCUPANCY) = "U";
374                vdef(OCCUPANCY)++;
375        }
376                                /* append rendering options */
377        if (vdef(RENDER))
378                rtargc += wordstring(rtargv+rtargc, vval(RENDER));
386   }
387  
388  
# Line 463 | Line 470 | loadholo()                     /* start loading a holodeck from fname */
470   done_packets(pl)                /* handle finished packets */
471   PACKET  *pl;
472   {
473 <        static int      nunflushed = 0;
473 >        static int      n2flush = 0;
474          register PACKET *p;
475  
476          while (pl != NULL) {
# Line 474 | Line 481 | PACKET *pl;
481                                  p->nr*sizeof(RAYVAL));
482                          if (outdev != NULL)     /* display it */
483                                  disp_packet((PACKHEAD *)p);
484 <                        else
485 <                                nunflushed += p->nr;
484 >                        if (hdcachesize <= 0)   /* manual flushing */
485 >                                n2flush += p->nr;
486                          nraysdone += p->nr;
487                          npacksdone++;
488                  }
# Line 483 | Line 490 | PACKET *pl;
490                  p->next = freepacks;
491                  freepacks = p;
492          }
493 <        if (nunflushed >= 256*RPACKSIZ) {
493 >        if (n2flush > 512*RPACKSIZ*ncprocs) {
494                  hdflush(NULL);                  /* flush holodeck buffers */
495 <                nunflushed = 0;
495 >                n2flush = 0;
496          }
497   }
498  
# Line 493 | Line 500 | PACKET *pl;
500   getradfile(rfargs)              /* run rad and get needed variables */
501   char    *rfargs;
502   {
503 <        static short    mvar[] = {OCTREE,EXPOSURE,-1};
503 >        static short    mvar[] = {OCTREE,-1};
504          static char     tf1[] = TEMPLATE;
505          char    tf2[64];
506          char    combuf[256];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines