Back to index

radiance  4R0+20100331
Classes | Defines | Typedefs | Functions | Variables
ray.h File Reference
#include "standard.h"
#include "octree.h"
#include "object.h"
#include "color.h"

Go to the source code of this file.

Classes

struct  ray
struct  RAYPARAMS

Defines

#define RNUMBER   unsigned long /* ray counter (>= sizeof pointer) */
#define MAXDIM   32 /* maximum number of dimensions */
#define PRIMARY   01 /* original ray */
#define SHADOW   02 /* ray to light source */
#define REFLECTED   04 /* reflected ray */
#define REFRACTED   010 /* refracted (bent) ray */
#define TRANS   020 /* transmitted/transferred ray */
#define AMBIENT   040 /* ray scattered for interreflection */
#define SPECULAR   0100 /* ray scattered for specular */
#define RAYREFL   (SHADOW|REFLECTED|AMBIENT|SPECULAR)
#define rayvalue(r)   (*(r)->revf)(r)
#define AMBLLEN   512 /* max. ambient list length */
#define AMBWORD   12 /* average word length */
#define rpambmod(p, i)

Typedefs

typedef struct ray RAY

Functions

void headclean (void)
void openheader (void)
void dupheader (void)
void persistfile (char *pfn)
void pfdetach (void)
void pfclean (void)
void pflock (int lf)
void pfhold (void)
void io_process (void)
int free_objs (OBJECT on, OBJECT no)
void free_objmem (void)
int load_os (OBJREC *op)
void preload_objs (void)
void ray_init (char *otnm)
void ray_trace (RAY *r)
void ray_done (int freall)
void ray_save (RAYPARAMS *rp)
void ray_restore (RAYPARAMS *rp)
void ray_defaults (RAYPARAMS *rp)
void ray_pinit (char *otnm, int nproc)
int ray_psend (RAY *r)
int ray_pqueue (RAY *r)
int ray_presult (RAY *r, int poll)
void ray_pdone (int freall)
void ray_popen (int nadd)
void ray_pclose (int nsub)
int ray_fifo_in (RAY *r)
int ray_fifo_flush (void)
int rayorigin (RAY *r, int rt, const RAY *ro, const COLOR rc)
void rayclear (RAY *r)
void raytrace (RAY *r)
void rayhit (OBJECT *oset, RAY *r)
void raycont (RAY *r)
void raytrans (RAY *r)
int rayshade (RAY *r, int mod)
void rayparticipate (RAY *r)
void raytexture (RAY *r, OBJECT mod)
int raymixture (RAY *r, OBJECT fore, OBJECT back, double coef)
void raycontrib (double rc[3], const RAY *r, int flags)
double raydist (const RAY *r, int flags)
double raynormal (FVECT norm, RAY *r)
void newrayxf (RAY *r)
void flipsurface (RAY *r)
int localhit (RAY *r, CUBE *scene)
int getrenderopt (int ac, char *av[])
void print_rdefaults (void)
void drawsources (COLOR *pic[], float *zbf[], int x0, int xsiz, int y0, int ysiz)
void init_drawsources (int rad)
void initotypes (void)
void rtrace (char *fname, int nproc)
char * formstr (int f)
void rview (void)
void rpict (int seq, char *pout, char *zout, char *prvr)

Variables

char VersionID []
CUBE thescene
OBJECT nsceneobjs
unsigned long raynum
unsigned long nrays
OBJREC Lamb
OBJREC Aftplane
void(* trace )()
int dimlist []
int ndims
int samplendx
int ray_savesiz
int do_irrad
int rand_samp
double dstrsrc
double shadthresh
double shadcert
int directrelay
int vspretest
int directvis
double srcsizerat
double specthresh
double specjitter
COLOR cextinction
COLOR salbedo
double seccg
double ssampdist
int backvis
int maxdepth
double minweight
char * ambfile
COLOR ambval
int ambvwt
double ambacc
int ambres
int ambdiv
int ambssamp
int ambounce
char * amblist []
int ambincl
int ray_pnprocs
int ray_pnidle
int(* ray_fifo_out )(RAY *r)

Class Documentation

struct RAYPARAMS

Definition at line 137 of file ray.h.

Class Members
double ambacc
int ambdiv
char ambfile
int ambincl
short amblndx
char amblval
int ambounce
int ambres
int ambssamp
COLOR ambval
int ambvwt
int backvis
COLOR cextinction
int directrelay
int directvis
int do_irrad
double dstrsrc
int maxdepth
double minweight
int rand_samp
COLOR salbedo
double seccg
double shadcert
double shadthresh
double specjitter
double specthresh
double srcsizerat
double ssampdist
int vspretest

Define Documentation

#define AMBIENT   040 /* ray scattered for interreflection */

Definition at line 29 of file ray.h.

#define AMBLLEN   512 /* max. ambient list length */

Definition at line 133 of file ray.h.

#define AMBWORD   12 /* average word length */

Definition at line 135 of file ray.h.

#define MAXDIM   32 /* maximum number of dimensions */

Definition at line 21 of file ray.h.

#define PRIMARY   01 /* original ray */

Definition at line 24 of file ray.h.

Definition at line 33 of file ray.h.

#define rayvalue (   r)    (*(r)->revf)(r)

Definition at line 72 of file ray.h.

#define REFLECTED   04 /* reflected ray */

Definition at line 26 of file ray.h.

#define REFRACTED   010 /* refracted (bent) ray */

Definition at line 27 of file ray.h.

#define RNUMBER   unsigned long /* ray counter (>= sizeof pointer) */

Definition at line 18 of file ray.h.

#define rpambmod (   p,
  i 
)
Value:
( (i)>=AMBLLEN||(p)->amblndx[i]<0 ? \
                       (char *)NULL : (p)->amblval+(p)->amblndx[i] )

Definition at line 169 of file ray.h.

#define SHADOW   02 /* ray to light source */

Definition at line 25 of file ray.h.

#define SPECULAR   0100 /* ray scattered for specular */

Definition at line 30 of file ray.h.

#define TRANS   020 /* transmitted/transferred ray */

Definition at line 28 of file ray.h.


Typedef Documentation

typedef struct ray RAY

Function Documentation

void drawsources ( COLOR pic[],
float *  zbf[],
int  x0,
int  xsiz,
int  y0,
int  ysiz 
)

Definition at line 396 of file srcdraw.c.

{
       RREAL  spoly[MAXVERT][2], ppoly[MAXVERT][2];
       int    nsv, npv;
       int    xmin, xmax, ymin, ymax, x, y;
       RREAL  cxy[2];
       double w;
       RAY    sr;
       register SPLIST      *sp;
       register int  i;
                                   /* check each source in our list */
       for (sp = sphead; sp != NULL; sp = sp->next) {
                                   /* clip source poly to subimage */
              nsv = box_clip_poly(sp->vl, sp->nv,
                            (double)x0/hres, (double)(x0+xsiz)/hres,
                            (double)y0/vres, (double)(y0+ysiz)/vres, spoly);
              if (!nsv)
                     continue;
                                   /* find common subimage (BBox) */
              xmin = x0 + xsiz; xmax = x0;
              ymin = y0 + ysiz; ymax = y0;
              for (i = 0; i < nsv; i++) {
                     if ((double)xmin/hres > spoly[i][0])
                            xmin = spoly[i][0]*hres + FTINY;
                     if ((double)xmax/hres < spoly[i][0])
                            xmax = spoly[i][0]*hres - FTINY;
                     if ((double)ymin/vres > spoly[i][1])
                            ymin = spoly[i][1]*vres + FTINY;
                     if ((double)ymax/vres < spoly[i][1])
                            ymax = spoly[i][1]*vres - FTINY;
              }
                                   /* evaluate each pixel in BBox */
              for (y = ymin; y <= ymax; y++)
                     for (x = xmin; x <= xmax; x++) {
                                                 /* subarea for pixel */
                            npv = box_clip_poly(spoly, nsv,
                                          (double)x/hres, (x+1.)/hres,
                                          (double)y/vres, (y+1.)/vres,
                                          ppoly);
                            if (!npv)
                                   continue;     /* no overlap */
                            convex_center(ppoly, npv, cxy);
                            if ((sr.rmax = viewray(sr.rorg,sr.rdir,&ourview,
                                          cxy[0],cxy[1])) < -FTINY)
                                   continue;     /* not in view */
                            if (source[sp->sn].sflags & SSPOT &&
                                          spotout(&sr, source[sp->sn].sl.s))
                                   continue;     /* outside spot */
                            rayorigin(&sr, SHADOW, NULL, NULL);
                            sr.rsrc = sp->sn;
                            rayvalue(&sr);              /* compute value */
                            if (bright(sr.rcol) <= FTINY)
                                   continue;     /* missed/blocked */
                                                 /* modify pixel */
                            w = poly_area(ppoly, npv) * hres * vres;
                            if (zbf[y-y0] != NULL &&
                                          sr.rt < 0.99*zbf[y-y0][x-x0]) {
                                   zbf[y-y0][x-x0] = sr.rt;
                            } else if (!bigdiff(sr.rcol, pic[y-y0][x-x0],
                                          0.01)) { /* source sample */
                                   scalecolor(pic[y-y0][x-x0], w);
                                   continue;
                            }
                            scalecolor(sr.rcol, w);
                            scalecolor(pic[y-y0][x-x0], 1.-w);
                            addcolor(pic[y-y0][x-x0], sr.rcol);
                     }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dupheader ( void  )

Definition at line 49 of file duphead.c.

{
       register int  c;

       if (headfp == NULL) {
              if ((headfp = fopen(headfname, "r")) == NULL)
                     error(SYSTEM, "error reopening header file");
              SET_FILE_BINARY(headfp);
       } else if (fseek(headfp, 0L, 0) < 0)
              error(SYSTEM, "seek error on header file");
       while ((c = getc(headfp)) != EOF)
              putchar(c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void flipsurface ( RAY r)

Here is the caller graph for this function:

char* formstr ( int  f)

Definition at line 96 of file rtrace.c.

{
       switch (f) {
       case 'a': return("ascii");
       case 'f': return("float");
       case 'd': return("double");
       case 'c': return(COLRFMT);
       }
       return("unknown");
}

Here is the caller graph for this function:

void free_objmem ( void  )

Definition at line 89 of file freeobjmem.c.

{
       free_objs(0, nobjects);
       freedata(NULL);
       freefont(NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int free_objs ( OBJECT  on,
OBJECT  no 
)
int getrenderopt ( int  ac,
char *  av[] 
)

Definition at line 17 of file renderopts.c.

{
#define        check(ol,al)        if (av[0][ol] || \
                            badarg(ac-1,av+1,al)) \
                            return(-1)
#define        bool(olen,var)             switch (av[0][olen]) { \
                            case '\0': var = !var; break; \
                            case 'y': case 'Y': case 't': case 'T': \
                            case '+': case '1': var = 1; break; \
                            case 'n': case 'N': case 'f': case 'F': \
                            case '-': case '0': var = 0; break; \
                            default: return(-1); }
       static char  **amblp;              /* pointer to build ambient list */
       int    rval;
                                   /* is it even an option? */
       if (ac < 1 || av[0] == NULL || av[0][0] != '-')
              return(-1);
                                   /* check if it's one we know */
       switch (av[0][1]) {
       case 'u':                          /* uncorrelated sampling */
              bool(2,rand_samp);
              return(0);
       case 'b':                          /* back face vis. */
              if (av[0][2] == 'v') {
                     bool(3,backvis);
                     return(0);
              }
              break;
       case 'd':                          /* direct */
              switch (av[0][2]) {
              case 't':                          /* threshold */
                     check(3,"f");
                     shadthresh = atof(av[1]);
                     return(1);
              case 'c':                          /* certainty */
                     check(3,"f");
                     shadcert = atof(av[1]);
                     return(1);
              case 'j':                          /* jitter */
                     check(3,"f");
                     dstrsrc = atof(av[1]);
                     return(1);
              case 'r':                          /* relays */
                     check(3,"i");
                     directrelay = atoi(av[1]);
                     return(1);
              case 'p':                          /* pretest */
                     check(3,"i");
                     vspretest = atoi(av[1]);
                     return(1);
              case 'v':                          /* visibility */
                     bool(3,directvis);
                     return(0);
              case 's':                          /* size */
                     check(3,"f");
                     srcsizerat = atof(av[1]);
                     return(1);
              }
              break;
       case 's':                          /* specular */
              switch (av[0][2]) {
              case 't':                          /* threshold */
                     check(3,"f");
                     specthresh = atof(av[1]);
                     return(1);
              case 'j':                          /* jitter */
                     check(3,"f");
                     specjitter = atof(av[1]);
                     return(1);
              }
              break;
       case 'l':                          /* limit */
              switch (av[0][2]) {
              case 'r':                          /* recursion */
                     check(3,"i");
                     maxdepth = atoi(av[1]);
                     return(1);
              case 'w':                          /* weight */
                     check(3,"f");
                     minweight = atof(av[1]);
                     return(1);
              }
              break;
       case 'i':                          /* irradiance */
              bool(2,do_irrad);
              return(0);
       case 'a':                          /* ambient */
              switch (av[0][2]) {
              case 'v':                          /* value */
                     check(3,"fff");
                     setcolor(ambval, atof(av[1]),
                                   atof(av[2]),
                                   atof(av[3]));
                     return(3);
              case 'w':                          /* weight */
                     check(3,"i");
                     ambvwt = atoi(av[1]);
                     return(1);
              case 'a':                          /* accuracy */
                     check(3,"f");
                     ambacc = atof(av[1]);
                     return(1);
              case 'r':                          /* resolution */
                     check(3,"i");
                     ambres = atoi(av[1]);
                     return(1);
              case 'd':                          /* divisions */
                     check(3,"i");
                     ambdiv = atoi(av[1]);
                     return(1);
              case 's':                          /* super-samp */
                     check(3,"i");
                     ambssamp = atoi(av[1]);
                     return(1);
              case 'b':                          /* bounces */
                     check(3,"i");
                     ambounce = atoi(av[1]);
                     return(1);
              case 'i':                          /* include */
              case 'I':
                     check(3,"s");
                     if (ambincl != 1) {
                            ambincl = 1;
                            amblp = amblist;
                     }
                     if (av[0][2] == 'I') {      /* file */
                            rval = wordfile(amblp,
                                   getpath(av[1],getrlibpath(),R_OK));
                            if (rval < 0) {
                                   sprintf(errmsg,
                     "cannot open ambient include file \"%s\"", av[1]);
                                   error(SYSTEM, errmsg);
                            }
                            amblp += rval;
                     } else {
                            *amblp++ = savqstr(av[1]);
                            *amblp = NULL;
                     }
                     return(1);
              case 'e':                          /* exclude */
              case 'E':
                     check(3,"s");
                     if (ambincl != 0) {
                            ambincl = 0;
                            amblp = amblist;
                     }
                     if (av[0][2] == 'E') {      /* file */
                            rval = wordfile(amblp,
                                   getpath(av[1],getrlibpath(),R_OK));
                            if (rval < 0) {
                                   sprintf(errmsg,
                     "cannot open ambient exclude file \"%s\"", av[1]);
                                   error(SYSTEM, errmsg);
                            }
                            amblp += rval;
                     } else {
                            *amblp++ = savqstr(av[1]);
                            *amblp = NULL;
                     }
                     return(1);
              case 'f':                          /* file */
                     check(3,"s");
                     ambfile = savqstr(av[1]);
                     return(1);
              }
              break;
       case 'm':                          /* medium */
              switch (av[0][2]) {
              case 'e':                          /* extinction */
                     check(3,"fff");
                     setcolor(cextinction, atof(av[1]),
                                   atof(av[2]),
                                   atof(av[3]));
                     return(3);
              case 'a':                          /* albedo */
                     check(3,"fff");
                     setcolor(salbedo, atof(av[1]),
                                   atof(av[2]),
                                   atof(av[3]));
                     return(3);
              case 'g':                          /* eccentr. */
                     check(3,"f");
                     seccg = atof(av[1]);
                     return(1);
              case 's':                          /* sampling */
                     check(3,"f");
                     ssampdist = atof(av[1]);
                     return(1);
              }
              break;
       }
       return(-1);          /* unknown option */

#undef check
#undef bool
}

Here is the call graph for this function:

Here is the caller graph for this function:

void headclean ( void  )

Definition at line 24 of file duphead.c.

{
       if (headfname == NULL)
              return;
       if (headfp != NULL)
              fclose(headfp);
       if (headismine)
              unlink(headfname);
}

Here is the caller graph for this function:

void init_drawsources ( int  rad)

Definition at line 362 of file srcdraw.c.

{
       RREAL  spoly[MAXVERT][2];
       int    nsv;
       register SPLIST      *sp;
       register int  i;
                                   /* free old source list if one */
       for (sp = sphead; sp != NULL; sp = sphead) {
              sphead = sp->next;
              free((void *)sp);
       }
                                   /* loop through all sources */
       for (i = nsources; i--; ) {
                                   /* skip illum's */
              if (findmaterial(source[i].so)->otype == MAT_ILLUM)
                     continue;
                                   /* compute image polygon for source */
              if (!(nsv = sourcepoly(i, spoly)))
                     continue;
                                   /* clip to image boundaries */
              if (!(nsv = box_clip_poly(spoly, nsv, 0., 1., 0., 1., spoly)))
                     continue;
                                   /* big enough for standard sampling? */
              if (minw2(spoly, nsv, ourview.vn2/ourview.hn2) >
                            (double)rad*rad/hres/hres)
                     continue;
                                   /* OK, add to our list */
              spinsert(i, spoly, nsv);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void initotypes ( void  )
void io_process ( void  )
int load_os ( OBJREC op)
int localhit ( RAY r,
CUBE scene 
)

Here is the caller graph for this function:

void newrayxf ( RAY r)

Definition at line 425 of file raytrace.c.

{
       static struct xfn {
              struct xfn  *next;
              FULLXF  xf;
       }  xfseed = { &xfseed }, *xflast = &xfseed;
       register struct xfn  *xp;
       register const RAY  *rp;

       /*
        * Search for transform in circular list that
        * has no associated ray in the tree.
        */
       xp = xflast;
       for (rp = r->parent; rp != NULL; rp = rp->parent)
              if (rp->rox == &xp->xf) {          /* xp in use */
                     xp = xp->next;                     /* move to next */
                     if (xp == xflast) {         /* need new one */
                            xp = (struct xfn *)malloc(sizeof(struct xfn));
                            if (xp == NULL)
                                   error(SYSTEM,
                                          "out of memory in newrayxf");
                                                 /* insert in list */
                            xp->next = xflast->next;
                            xflast->next = xp;
                            break;               /* we're done */
                     }
                     rp = r;                     /* start check over */
              }
                                   /* got it */
       r->rox = &xp->xf;
       xflast = xp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void openheader ( void  )

Definition at line 36 of file duphead.c.

{
       static char  template[] = TEMPLATE;

       headfname = mktemp(template);
       if (freopen(headfname, "w", stdout) == NULL) {
              sprintf(errmsg, "cannot open header file \"%s\"", headfname);
              error(SYSTEM, errmsg);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void persistfile ( char *  pfn)

Here is the caller graph for this function:

void pfclean ( void  )

Definition at line 348 of file persist.c.

{}

Here is the caller graph for this function:

void pfdetach ( void  )

Here is the caller graph for this function:

void pfhold ( void  )

Here is the caller graph for this function:

void pflock ( int  lf)

Here is the caller graph for this function:

void preload_objs ( void  )

Definition at line 135 of file preload.c.

{
       register OBJECT on;
                            /* note that nobjects may change during loop */
       for (on = 0; on < nobjects; on++)
              load_os(objptr(on));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void print_rdefaults ( void  )

Definition at line 219 of file renderopts.c.

{
       printf(do_irrad ? "-i+\t\t\t\t# irradiance calculation on\n" :
                     "-i-\t\t\t\t# irradiance calculation off\n");
       printf(rand_samp ? "-u+\t\t\t\t# uncorrelated Monte Carlo sampling\n" :
                     "-u-\t\t\t\t# correlated quasi-Monte Carlo sampling\n");
       printf(backvis ? "-bv+\t\t\t\t# back face visibility on\n" :
                     "-bv-\t\t\t\t# back face visibility off\n");
       printf("-dt %f\t\t\t# direct threshold\n", shadthresh);
       printf("-dc %f\t\t\t# direct certainty\n", shadcert);
       printf("-dj %f\t\t\t# direct jitter\n", dstrsrc);
       printf("-ds %f\t\t\t# direct sampling\n", srcsizerat);
       printf("-dr %-9d\t\t\t# direct relays\n", directrelay);
       printf("-dp %-9d\t\t\t# direct pretest density\n", vspretest);
       printf(directvis ? "-dv+\t\t\t\t# direct visibility on\n" :
                     "-dv-\t\t\t\t# direct visibility off\n");
       printf("-sj %f\t\t\t# specular jitter\n", specjitter);
       printf("-st %f\t\t\t# specular threshold\n", specthresh);
       printf("-av %f %f %f\t# ambient value\n", colval(ambval,RED),
                     colval(ambval,GRN), colval(ambval, BLU));
       printf("-aw %-9d\t\t\t# ambient value weight\n", ambvwt);
       printf("-ab %-9d\t\t\t# ambient bounces\n", ambounce);
       printf("-aa %f\t\t\t# ambient accuracy\n", ambacc);
       printf("-ar %-9d\t\t\t# ambient resolution\n", ambres);
       printf("-ad %-9d\t\t\t# ambient divisions\n", ambdiv);
       printf("-as %-9d\t\t\t# ambient super-samples\n", ambssamp);
       printf("-me %.2e %.2e %.2e\t# mist extinction coefficient\n",
                     colval(cextinction,RED),
                     colval(cextinction,GRN),
                     colval(cextinction,BLU));
       printf("-ma %f %f %f\t# mist scattering albedo\n", colval(salbedo,RED),
                     colval(salbedo,GRN), colval(salbedo,BLU));
       printf("-mg %f\t\t\t# mist scattering eccentricity\n", seccg);
       printf("-ms %f\t\t\t# mist sampling distance\n", ssampdist);
       printf("-lr %-9d\t\t\t# limit reflection%s\n", maxdepth,
                     maxdepth<=0 ? " (Russian roulette)" : "");
       printf("-lw %.2e\t\t\t# limit weight\n", minweight);
}

Here is the caller graph for this function:

void ray_defaults ( RAYPARAMS rp)

Definition at line 344 of file raycalls.c.

{
       int    i;

       if (rp == NULL)
              return;

       rp->do_irrad = 0;
       rp->dstrsrc = 0.0;
       rp->shadthresh = .03;
       rp->shadcert = .75;
       rp->directrelay = 2;
       rp->vspretest = 512;
       rp->directvis = 1;
       rp->srcsizerat = .2;
       setcolor(rp->cextinction, 0., 0., 0.);
       setcolor(rp->salbedo, 0., 0., 0.);
       rp->seccg = 0.;
       rp->ssampdist = 0.;
       rp->specthresh = .15;
       rp->specjitter = 1.;
       rp->backvis = 1;
       rp->maxdepth = 8;
       rp->minweight = 2e-3;
       setcolor(rp->ambval, 0., 0., 0.);
       memset(rp->ambfile, '\0', sizeof(rp->ambfile));
       rp->ambvwt = 0;
       rp->ambres = 256;
       rp->ambacc = 0.15;
       rp->ambdiv = 1024;
       rp->ambssamp = 512;
       rp->ambounce = 0;
       rp->ambincl = -1;
       memset(rp->amblval, '\0', sizeof(rp->amblval));
       for (i = AMBLLEN+1; i--; )
              rp->amblndx[i] = -1;
}

Here is the caller graph for this function:

void ray_done ( int  freall)

Definition at line 197 of file raycalls.c.

{
       retainfonts = 1;
       ambdone();
       ambnotify(OVOID);
       freesources();
       freeobjects(0, nobjects);
       donesets();
       octdone();
       thescene.cutree = EMPTY;
       octname = NULL;
       if (freall) {
              retainfonts = 0;
              freefont(NULL);
              freedata(NULL);
              initurand(0);
       }
       if (nobjects > 0) {
              sprintf(errmsg, "%ld objects left after call to ray_done()",
                            nobjects);
              error(WARNING, errmsg);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ray_fifo_flush ( void  )

Definition at line 148 of file rayfifo.c.

{
       RAY    myRay;
       int    rv, rval = 0;
                                          /* clear parallel queue */
       while ((rv = ray_presult(&myRay, 0)) > 0 &&
                     (rv = ray_fifo_push(&myRay)) >= 0)
              rval += rv;

       if (rv < 0)                        /* check for exception */
              return(-1);

       if (r_fifo_start != r_fifo_end)
              error(INTERNAL, "could not empty queue in ray_fifo_flush()");

       if (r_fifo_buf != NULL) {
              free(r_fifo_buf);
              r_fifo_buf = NULL; r_fifo_len = 0;
       }
       r_fifo_next = r_fifo_end = r_fifo_start = 1;

       return(rval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ray_fifo_in ( RAY r)

Definition at line 113 of file rayfifo.c.

{
       static int    incall = 0;          /* prevent recursion */
       int           rv, rval = 0;

       if (incall++)
              error(INTERNAL, "recursive call to ray_fifo_in()");

       if (r_fifo_start >= 1L<<30) {             /* reset our counters */
              if ((rv = ray_fifo_flush()) < 0)
                     {--incall; return(-1);}
              rval += rv;
       }
                                          /* queue ray */
       r->rno = r_fifo_next++;
       if ((rv = ray_pqueue(r)) < 0)
              {--incall; return(-1);}

       if (!rv)                           /* no result this time? */
              {--incall; return(rval);}
       
       do {                               /* else send/queue result */
              if ((rv = ray_fifo_push(r)) < 0)
                     {--incall; return(-1);}
              rval += rv;

       } while (ray_presult(r, -1) > 0);  /* empty in-core queue */

       --incall; return(rval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ray_init ( char *  otnm)

Definition at line 158 of file raycalls.c.

{
       if (nobjects > 0)           /* free old scene data */
              ray_done(0);
                                   /* initialize object types */
       if (ofun[OBJ_SPHERE].funp == o_default)
              initotypes();
                                   /* initialize urand */
       if (rand_samp) {
              srandom((long)time(0));
              initurand(0);
       } else {
              srandom(0L);
              initurand(2048);
       }
                                   /* read scene octree */
       readoct(octname = otnm, ~(IO_FILES|IO_INFO), &thescene, NULL);
       nsceneobjs = nobjects;
                                   /* find and mark sources */
       marksources();
                                   /* initialize ambient calculation */
       setambient();
                                   /* ready to go... */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ray_pclose ( int  nsub)

Definition at line 499 of file raypcalls.c.

{
       static int    inclose = 0;
       RAY    res;
                                   /* check recursion */
       if (inclose)
              return;
       inclose++;
                                   /* check no child / in child */
       if (ray_pnprocs <= 0)
              return;
                                   /* check argument */
       if ((nsub <= 0) | (nsub > ray_pnprocs))
              nsub = ray_pnprocs;
                                   /* clear our ray queue */
       while (ray_presult(&res,0) > 0)
              ;
       r_send_next = 0;            /* hard reset in case of error */
       r_recv_first = r_recv_next = RAYQLEN;
                                   /* clean up children */
       while (nsub--) {
              int    status;
              ray_pnprocs--;
              close(r_proc[ray_pnprocs].fd_send);
              if (waitpid(r_proc[ray_pnprocs].pid, &status, 0) < 0)
                     status = 127<<8;
              close(r_proc[ray_pnprocs].fd_recv);
              if (status) {
                     sprintf(errmsg,
                            "rendering process %d exited with code %d",
                                   r_proc[ray_pnprocs].pid, status>>8);
                     error(WARNING, errmsg);
              }
              ray_pnidle--;
       }
       inclose--;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ray_pdone ( int  freall)

Definition at line 383 of file raypcalls.c.

{
       ray_pclose(0);                     /* close child processes */

       if (shm_boundary != NULL) { /* clear shared memory boundary */
              free((void *)shm_boundary);
              shm_boundary = NULL;
       }

       ray_done(freall);           /* free rendering data */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ray_pinit ( char *  otnm,
int  nproc 
)

Definition at line 186 of file raypcalls.c.

{
       if (nobjects > 0)           /* close old calculation */
              ray_pdone(0);

       ray_init(otnm);                    /* load the shared scene */

       ray_popen(nproc);           /* fork children */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ray_popen ( int  nadd)

Definition at line 448 of file raypcalls.c.

{
                                   /* check if our table has room */
       if (ray_pnprocs + nadd > MAX_NPROCS)
              nadd = MAX_NPROCS - ray_pnprocs;
       if (nadd <= 0)
              return;
       ambsync();                  /* load any new ambient values */
       if (shm_boundary == NULL) { /* first child process? */
              preload_objs();             /* preload auxiliary data */
                                   /* set shared memory boundary */
              shm_boundary = (char *)malloc(16);
              strcpy(shm_boundary, "SHM_BOUNDARY");
       }
       fflush(NULL);               /* clear pending output */
       while (nadd--) {            /* fork each new process */
              int    p0[2], p1[2];
              if (pipe(p0) < 0 || pipe(p1) < 0)
                     error(SYSTEM, "cannot create pipe");
              if ((r_proc[ray_pnprocs].pid = fork()) == 0) {
                     int    pn;    /* close others' descriptors */
                     for (pn = ray_pnprocs; pn--; ) {
                            close(r_proc[pn].fd_send);
                            close(r_proc[pn].fd_recv);
                     }
                     close(p0[0]); close(p1[1]);
                     close(0);     /* don't share stdin */
                                   /* following call never returns */
                     ray_pchild(p1[0], p0[1]);
              }
              if (r_proc[ray_pnprocs].pid < 0)
                     error(SYSTEM, "cannot fork child process");
              close(p1[0]); close(p0[1]);
              /*
               * Close write stream on exec to avoid multiprocessing deadlock.
               * No use in read stream without it, so set flag there as well.
               */
              fcntl(p1[1], F_SETFD, FD_CLOEXEC);
              fcntl(p0[0], F_SETFD, FD_CLOEXEC);
              r_proc[ray_pnprocs].fd_send = p1[1];
              r_proc[ray_pnprocs].fd_recv = p0[0];
              r_proc[ray_pnprocs].npending = 0;
              ray_pnprocs++;
              ray_pnidle++;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ray_pqueue ( RAY r)

Definition at line 254 of file raypcalls.c.

{
       if (r == NULL)
              return(0);
                                   /* check for full send queue */
       if (sendq_full()) {
              RAY    mySend = *r;
                                   /* wait for a result */
              if (ray_presult(r, 0) <= 0)
                     return(-1);
                                   /* put new ray in queue */
              r_queue[r_send_next++] = mySend;

              return(1);
       }
                                   /* else add ray to send queue */
       r_queue[r_send_next++] = *r;
                                   /* check for returned ray... */
       if (r_recv_first >= r_recv_next)
              return(0);
                                   /* ...one is sitting in queue */
       *r = r_queue[r_recv_first++];
       return(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ray_presult ( RAY r,
int  poll 
)

Definition at line 283 of file raypcalls.c.

{
       static struct timeval       tpoll; /* zero timeval struct */
       static fd_set readset, errset;
       int    n, ok;
       register int  pn;

       if (r == NULL)
              return(0);
                                   /* check queued results first */
       if (r_recv_first < r_recv_next) {
              *r = r_queue[r_recv_first++];
              return(1);
       }
       if (poll < 0)               /* immediate polling mode? */
              return(0);

       n = ray_pnprocs - ray_pnidle;      /* pending before flush? */

       if (ray_pflush() < 0)              /* send new rays to process */
              return(-1);
                                   /* reset receive queue */
       r_recv_first = r_recv_next = RAYQLEN;

       if (!poll)                  /* count newly sent unless polling */
              n = ray_pnprocs - ray_pnidle;
       if (n <= 0)                 /* return if nothing to await */
              return(0);
       if (!poll && ray_pnprocs == 1)     /* one process -> skip select() */
              FD_SET(r_proc[0].fd_recv, &readset);

getready:                          /* any children waiting for us? */
       for (pn = ray_pnprocs; pn--; )
              if (FD_ISSET(r_proc[pn].fd_recv, &readset) ||
                            FD_ISSET(r_proc[pn].fd_recv, &errset))
                     break;
                                   /* call select() if we must */
       if (pn < 0) {
              FD_ZERO(&readset); FD_ZERO(&errset); n = 0;
              for (pn = ray_pnprocs; pn--; ) {
                     if (r_proc[pn].npending > 0)
                            FD_SET(r_proc[pn].fd_recv, &readset);
                     FD_SET(r_proc[pn].fd_recv, &errset);
                     if (r_proc[pn].fd_recv >= n)
                            n = r_proc[pn].fd_recv + 1;
              }
                                   /* find out who is ready */
              while ((n = select(n, &readset, (fd_set *)NULL, &errset,
                            poll ? &tpoll : (struct timeval *)NULL)) < 0)
                     if (errno != EINTR) {
                            error(WARNING,
                                   "select call failed in ray_presult()");
                            ray_pclose(0);
                            return(-1);
                     }
              if (n > 0)           /* go back and get it */
                     goto getready;
              return(0);           /* else poll came up empty */
       }
       if (r_recv_next + r_proc[pn].npending > sizeof(r_queue)/sizeof(RAY))
              error(CONSISTENCY, "buffer shortage in ray_presult()");

                                   /* read rendered ray data */
       n = readbuf(r_proc[pn].fd_recv, (char *)&r_queue[r_recv_next],
                     sizeof(RAY)*r_proc[pn].npending);
       if (n > 0) {
              r_recv_next += n/sizeof(RAY);
              ok = (n == sizeof(RAY)*r_proc[pn].npending);
       } else
              ok = 0;
                                   /* reset child's status */
       FD_CLR(r_proc[pn].fd_recv, &readset);
       if (n <= 0)
              FD_CLR(r_proc[pn].fd_recv, &errset);
       r_proc[pn].npending = 0;
       ray_pnidle++;
                                   /* check for rendering errors */
       if (!ok) {
              ray_pclose(0);              /* process died -- clean up */
              return(-1);
       }
                                   /* preen returned rays */
       for (n = r_recv_next - r_recv_first; n--; ) {
              register RAY  *rp = &r_queue[r_recv_first + n];
              rp->rno = r_proc[pn].rno[n];
              rp->parent = NULL;
              rp->newcset = rp->clipset = NULL;
              rp->rox = NULL;
              rp->slights = NULL;
       }
                                   /* return first ray received */
       *r = r_queue[r_recv_first++];
       return(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ray_psend ( RAY r)

Definition at line 236 of file raypcalls.c.

{
       int    rv;

       if ((r == NULL) | (ray_pnidle <= 0))
              return(0);
                                   /* flush output if necessary */
       if (sendq_full() && (rv = ray_pflush()) <= 0)
              return(rv);

       r_queue[r_send_next++] = *r;
       return(1);
}

Here is the call graph for this function:

void ray_restore ( RAYPARAMS rp)

Definition at line 276 of file raycalls.c.

{
       register int  i;

       if (rp == NULL) {           /* restore defaults */
              RAYPARAMS     dflt;
              ray_defaults(&dflt);
              ray_restore(&dflt);
              return;
       }
                                   /* restore saved settings */
       do_irrad = rp->do_irrad;
       dstrsrc = rp->dstrsrc;
       shadthresh = rp->shadthresh;
       shadcert = rp->shadcert;
       directrelay = rp->directrelay;
       vspretest = rp->vspretest;
       directvis = rp->directvis;
       srcsizerat = rp->srcsizerat;
       copycolor(cextinction, rp->cextinction);
       copycolor(salbedo, rp->salbedo);
       seccg = rp->seccg;
       ssampdist = rp->ssampdist;
       specthresh = rp->specthresh;
       specjitter = rp->specjitter;
       backvis = rp->backvis;
       maxdepth = rp->maxdepth;
       minweight = rp->minweight;
       copycolor(ambval, rp->ambval);
       ambvwt = rp->ambvwt;
       ambdiv = rp->ambdiv;
       ambssamp = rp->ambssamp;
       ambounce = rp->ambounce;
       for (i = 0; rp->amblndx[i] >= 0; i++)
              amblist[i] = rp->amblval + rp->amblndx[i];
       while (i <= AMBLLEN)
              amblist[i++] = NULL;
       ambincl = rp->ambincl;
                                   /* update ambient calculation */
       ambnotify(OVOID);
       if (thescene.cutree != EMPTY) {
              int    newamb = (ambfile == NULL) ?  rp->ambfile[0] :
                                   strcmp(ambfile, rp->ambfile) ;

              if (amblist[0] != NULL)
                     for (i = 0; i < nobjects; i++)
                            ambnotify(i);

              ambfile = (rp->ambfile[0]) ? rp->ambfile : (char *)NULL;
              if (newamb) {
                     ambres = rp->ambres;
                     ambacc = rp->ambacc;
                     setambient();
              } else {
                     setambres(rp->ambres);
                     setambacc(rp->ambacc);
              }
       } else {
              ambfile = (rp->ambfile[0]) ? rp->ambfile : (char *)NULL;
              ambres = rp->ambres;
              ambacc = rp->ambacc;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ray_save ( RAYPARAMS rp)

Definition at line 225 of file raycalls.c.

{
       int    i, ndx;

       if (rp == NULL)
              return;
       rp->do_irrad = do_irrad;
       rp->dstrsrc = dstrsrc;
       rp->shadthresh = shadthresh;
       rp->shadcert = shadcert;
       rp->directrelay = directrelay;
       rp->vspretest = vspretest;
       rp->directvis = directvis;
       rp->srcsizerat = srcsizerat;
       copycolor(rp->cextinction, cextinction);
       copycolor(rp->salbedo, salbedo);
       rp->seccg = seccg;
       rp->ssampdist = ssampdist;
       rp->specthresh = specthresh;
       rp->specjitter = specjitter;
       rp->backvis = backvis;
       rp->maxdepth = maxdepth;
       rp->minweight = minweight;
       copycolor(rp->ambval, ambval);
       memset(rp->ambfile, '\0', sizeof(rp->ambfile));
       if (ambfile != NULL)
              strncpy(rp->ambfile, ambfile, sizeof(rp->ambfile)-1);
       rp->ambvwt = ambvwt;
       rp->ambacc = ambacc;
       rp->ambres = ambres;
       rp->ambdiv = ambdiv;
       rp->ambssamp = ambssamp;
       rp->ambounce = ambounce;
       rp->ambincl = ambincl;
       memset(rp->amblval, '\0', sizeof(rp->amblval));
       ndx = 0;
       for (i = 0; i < AMBLLEN && amblist[i] != NULL; i++) {
              int    len = strlen(amblist[i]);
              if (ndx+len >= sizeof(rp->amblval))
                     break;
              strcpy(rp->amblval+ndx, amblist[i]);
              ndx += len+1;
       }
       while (i <= AMBLLEN)
              rp->amblndx[i++] = -1;
}

Here is the caller graph for this function:

void ray_trace ( RAY r)

Definition at line 186 of file raycalls.c.

{
       rayorigin(r, PRIMARY, NULL, NULL);
       samplendx++;
       rayvalue(r);         /* assumes origin and direction are set */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rayclear ( RAY r)

Here is the caller graph for this function:

void raycont ( RAY r)

Here is the caller graph for this function:

void raycontrib ( double  rc[3],
const RAY r,
int  flags 
)

Definition at line 363 of file raytrace.c.

{
       double eext[3];
       int    i;

       eext[0] = eext[1] = eext[2] = 0.;
       rc[0] = rc[1] = rc[2] = 1.;

       while (r != NULL && r->crtype&flags) {
              for (i = 3; i--; ) {
                     rc[i] *= colval(r->rcoef,i);
                     eext[i] += r->rot * colval(r->cext,i);
              }
              r = r->parent;
       }
       for (i = 3; i--; )
              rc[i] *= (eext[i] <= FTINY) ? 1. :
                            (eext[i] > 92.) ? 0. : exp(-eext[i]);
}

Here is the caller graph for this function:

double raydist ( const RAY r,
int  flags 
)

Here is the caller graph for this function:

void rayhit ( OBJECT oset,
RAY r 
)

Definition at line 478 of file raytrace.c.

{
       OBJREC  *o;
       int    i;

       for (i = oset[0]; i > 0; i--) {
              o = objptr(oset[i]);
              if ((*ofun[o->otype].funp)(o, r))
                     r->robj = oset[i];
       }
}

Here is the caller graph for this function:

int raymixture ( RAY r,
OBJECT  fore,
OBJECT  back,
double  coef 
)

Here is the caller graph for this function:

double raynormal ( FVECT  norm,
RAY r 
)

Here is the caller graph for this function:

int rayorigin ( RAY r,
int  rt,
const RAY ro,
const COLOR  rc 
)

Definition at line 39 of file raytrace.c.

{
       double rw, re;
                                          /* assign coefficient/weight */
       if (rc == NULL) {
              rw = 1.0;
              setcolor(r->rcoef, 1., 1., 1.);
       } else {
              rw = intens(rc);
              if (rc != r->rcoef)
                     copycolor(r->rcoef, rc);
       }
       if ((r->parent = ro) == NULL) {           /* primary ray */
              r->rlvl = 0;
              r->rweight = rw;
              r->crtype = r->rtype = rt;
              r->rsrc = -1;
              r->clipset = NULL;
              r->revf = raytrace;
              copycolor(r->cext, cextinction);
              copycolor(r->albedo, salbedo);
              r->gecc = seccg;
              r->slights = NULL;
       } else {                           /* spawned ray */
              if (ro->rot >= FHUGE) {
                     memset(r, 0, sizeof(RAY));
                     return(-1);          /* illegal continuation */
              }
              r->rlvl = ro->rlvl;
              if (rt & RAYREFL) {
                     r->rlvl++;
                     r->rsrc = -1;
                     r->clipset = ro->clipset;
                     r->rmax = 0.0;
              } else {
                     r->rsrc = ro->rsrc;
                     r->clipset = ro->newcset;
                     r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot;
              }
              r->revf = ro->revf;
              copycolor(r->cext, ro->cext);
              copycolor(r->albedo, ro->albedo);
              r->gecc = ro->gecc;
              r->slights = ro->slights;
              r->crtype = ro->crtype | (r->rtype = rt);
              VCOPY(r->rorg, ro->rop);
              r->rweight = ro->rweight * rw;
                                          /* estimate extinction */
              re = colval(ro->cext,RED) < colval(ro->cext,GRN) ?
                            colval(ro->cext,RED) : colval(ro->cext,GRN);
              if (colval(ro->cext,BLU) < re) re = colval(ro->cext,BLU);
              re *= ro->rot;
              if (re > 0.1) {
                     if (re > 92.) {
                            r->rweight = 0.0;
                     } else {
                            r->rweight *= exp(-re);
                     }
              }
       }
       rayclear(r);
       if (r->rweight <= 0.0)                    /* check for expiration */
              return(-1);
       if (r->crtype & SHADOW)                   /* shadow commitment */
              return(0);
       if (maxdepth <= 0 && rc != NULL) { /* Russian roulette */
              if (minweight <= 0.0)
                     error(USER, "zero ray weight in Russian roulette");
              if (maxdepth < 0 && r->rlvl > -maxdepth)
                     return(-1);          /* upper reflection limit */
              if (r->rweight >= minweight)
                     return(0);
              if (frandom() > r->rweight/minweight)
                     return(-1);
              rw = minweight/r->rweight;  /* promote survivor */
              scalecolor(r->rcoef, rw);
              r->rweight = minweight;
              return(0);
       }
       return(r->rlvl <= abs(maxdepth) && r->rweight >= minweight ? 0 : -1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rayparticipate ( RAY r)

Here is the caller graph for this function:

int rayshade ( RAY r,
int  mod 
)

Here is the caller graph for this function:

void raytexture ( RAY r,
OBJECT  mod 
)

Definition at line 262 of file raytrace.c.

{
       register OBJREC  *m;
                                   /* execute textures and patterns */
       for ( ; mod != OVOID; mod = m->omod) {
              m = objptr(mod);
              /****** unnecessary test since modifier() is always called
              if (!ismodifier(m->otype)) {
                     sprintf(errmsg, "illegal modifier \"%s\"", m->oname);
                     error(USER, errmsg);
              }
              ******/
              if ((*ofun[m->otype].funp)(m, r)) {
                     sprintf(errmsg, "conflicting material \"%s\"",
                                   m->oname);
                     objerror(r->ro, USER, errmsg);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void raytrace ( RAY r)

Definition at line 147 of file raytrace.c.

{
       if (localhit(r, &thescene))
              raycont(r);          /* hit local surface, evaluate */
       else if (r->ro == &Aftplane) {
              r->ro = NULL;        /* hit aft clipping plane */
              r->rot = FHUGE;
       } else if (sourcehit(r))
              rayshade(r, r->ro->omod);   /* distant source */

       if (trace != NULL)
              (*trace)(r);         /* trace execution */

       rayparticipate(r);          /* for participating medium */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void raytrans ( RAY r)

Here is the caller graph for this function:

void rpict ( int  seq,
char *  pout,
char *  zout,
char *  prvr 
)

Definition at line 224 of file rpict.c.

{
       char  fbuf[128], fbuf2[128];
       int  npicts;
       register char  *cp;
       RESOLU rs;
       double pa;
                                   /* check sampling */
       if (psample < 1)
              psample = 1;
       else if (psample > MAXDIV) {
              sprintf(errmsg, "pixel sampling reduced from %d to %d",
                            psample, MAXDIV);
              error(WARNING, errmsg);
              psample = MAXDIV;
       }
                                   /* get starting frame */
       if (seq <= 0)
              seq = 0;
       else if (prvr != NULL && isint(prvr)) {
              register int  rn;           /* skip to specified view */
              if ((rn = atoi(prvr)) < seq)
                     error(USER, "recover frame less than start frame");
              if (pout == NULL)
                     error(USER, "missing output file specification");
              for ( ; seq < rn; seq++)
                     if (nextview(stdin) == EOF)
                            error(USER, "unexpected EOF on view input");
              setview(&ourview);
              prvr = fbuf;                /* mark for renaming */
       }
       if ((pout != NULL) & (prvr != NULL)) {
              sprintf(fbuf, pout, seq);
              if (!strcmp(prvr, fbuf)) {  /* rename */
                     strcpy(fbuf2, fbuf);
                     for (cp = fbuf2; *cp; cp++)
                            ;
                     while (cp > fbuf2 && !ISDIRSEP(cp[-1]))
                            cp--;
                     strcpy(cp, RFTEMPLATE);
                     prvr = mktemp(fbuf2);
                     if (rename(fbuf, prvr) < 0) {
                            if (errno == ENOENT) {      /* ghost file */
                                   sprintf(errmsg,
                                          "new output file \"%s\"",
                                          fbuf);
                                   error(WARNING, errmsg);
                                   prvr = NULL;
                            } else {             /* serious error */
                                   sprintf(errmsg,
                                   "cannot rename \"%s\" to \"%s\"",
                                          fbuf, prvr);
                                   error(SYSTEM, errmsg);
                            }
                     }
              }
       }
       npicts = 0;                 /* render sequence */
       do {
              if (seq && nextview(stdin) == EOF)
                     break;
              pctdone = 0.0;
              if (pout != NULL) {
                     sprintf(fbuf, pout, seq);
                     if (file_exists(fbuf)) {
                            if (prvr != NULL || !strcmp(fbuf, pout)) {
                                   sprintf(errmsg,
                                          "output file \"%s\" exists",
                                          fbuf);
                                   error(USER, errmsg);
                            }
                            setview(&ourview);
                            continue;            /* don't clobber */
                     }
                     if (freopen(fbuf, "w", stdout) == NULL) {
                            sprintf(errmsg,
                                   "cannot open output file \"%s\"", fbuf);
                            error(SYSTEM, errmsg);
                     }
                     SET_FILE_BINARY(stdout);
                     dupheader();
              }
              hres = hresolu; vres = vresolu; pa = pixaspect;
              if (prvr != NULL) {
                     if (viewfile(prvr, &ourview, &rs) <= 0) {
                            sprintf(errmsg,
                     "cannot recover view parameters from \"%s\"", prvr);
                            error(WARNING, errmsg);
                     } else {
                            pa = 0.0;
                            hres = scanlen(&rs);
                            vres = numscans(&rs);
                     }
              }
              if ((cp = setview(&ourview)) != NULL)
                     error(USER, cp);
              normaspect(viewaspect(&ourview), &pa, &hres, &vres);
              if (seq) {
                     if (ralrm > 0) {
                            fprintf(stderr, "FRAME %d:", seq);
                            fprintview(&ourview, stderr);
                            putc('\n', stderr);
                            fflush(stderr);
                     }
                     printf("FRAME=%d\n", seq);
              }
              fputs(VIEWSTR, stdout);
              fprintview(&ourview, stdout);
              putchar('\n');
              if (pa < .99 || pa > 1.01)
                     fputaspect(pa, stdout);
              fputnow(stdout);
              fputformat(COLRFMT, stdout);
              putchar('\n');
              if (zout != NULL)
                     sprintf(cp=fbuf, zout, seq);
              else
                     cp = NULL;
              render(cp, prvr);
              prvr = NULL;
              npicts++;
       } while (seq++);
                                   /* check that we did something */
       if (npicts == 0)
              error(WARNING, "no output produced");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rtrace ( char *  fname,
int  nproc 
)

Definition at line 111 of file rtrace.c.

{
       unsigned long  vcount = (hresolu > 1) ? (unsigned long)hresolu*vresolu
                                         : vresolu;
       long  nextflush = hresolu;
       FILE  *fp;
       double d;
       FVECT  orig, direc;
                                   /* set up input */
       if (fname == NULL)
              fp = stdin;
       else if ((fp = fopen(fname, "r")) == NULL) {
              sprintf(errmsg, "cannot open input file \"%s\"", fname);
              error(SYSTEM, errmsg);
       }
       if (inform != 'a')
              SET_FILE_BINARY(fp);
                                   /* set up output */
       setoutput(outvals);
       if (imm_irrad)
              castonly = 0;
       else if (castonly)
              nproc = 1;           /* don't bother multiprocessing */
       switch (outform) {
       case 'a': putreal = puta; break;
       case 'f': putreal = putf; break;
       case 'd': putreal = putd; break;
       case 'c': 
              if (strcmp(outvals, "v"))
                     error(USER, "color format with value output only");
              break;
       default:
              error(CONSISTENCY, "botched output format");
       }
       if (nproc > 1) {            /* start multiprocessing */
              ray_popen(nproc);
              ray_fifo_out = printvals;
       }
       if (hresolu > 0) {
              if (vresolu > 0)
                     fprtresolu(hresolu, vresolu, stdout);
              fflush(stdout);
       }
                                   /* process file */
       while (getvec(orig, inform, fp) == 0 &&
                     getvec(direc, inform, fp) == 0) {

              d = normalize(direc);
              if (d == 0.0) {                           /* zero ==> flush */
                     if (--nextflush <= 0 || !vcount) {
                            if (nproc > 1 && ray_fifo_flush() < 0)
                                   error(USER, "lost children");
                            bogusray();
                            fflush(stdout);
                            nextflush = hresolu;
                     } else
                            bogusray();
              } else {                           /* compute and print */
                     rtcompute(orig, direc, lim_dist ? d : 0.0);
                                                 /* flush if time */
                     if (!--nextflush) {
                            if (nproc > 1 && ray_fifo_flush() < 0)
                                   error(USER, "lost children");
                            fflush(stdout);
                            nextflush = hresolu;
                     }
              }
              if (ferror(stdout))
                     error(SYSTEM, "write error");
              if (vcount && !--vcount)           /* check for end */
                     break;
       }
       if (nproc > 1) {                          /* clean up children */
              if (ray_fifo_flush() < 0)
                     error(USER, "unable to complete processing");
              ray_pclose(0);
       }
       if (fflush(stdout) < 0)
              error(SYSTEM, "write error");
       if (vcount)
              error(USER, "unexpected EOF on input");
       if (fname != NULL)
              fclose(fp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rview ( void  )

Definition at line 84 of file rview.c.

{
       char  buf[32];

       devopen(dvcname);           /* open device */
       newimage(NULL);                    /* start image */

       for ( ; ; ) {               /* quit in command() */
              while (hresolu <= 1<<pdepth && vresolu <= 1<<pdepth)
                     command("done: ");
              errno = 0;
              if (hresolu <= psample<<pdepth && vresolu <= psample<<pdepth) {
                     sprintf(buf, "%d sampling...\n", 1<<pdepth);
                     (*dev->comout)(buf);
                     rsample();
              } else {
                     sprintf(buf, "%d refining...\n", 1<<pdepth);
                     (*dev->comout)(buf);
                     refine(&ptrunk, pdepth+1);
              }
              if (dev->inpready)          /* noticed some input */
                     command(": ");
              else                        /* finished this depth */
                     pdepth++;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 29 of file raytrace.c.

double ambacc

Definition at line 148 of file raycalls.c.

int ambdiv

Definition at line 150 of file raycalls.c.

char* ambfile

Definition at line 145 of file raycalls.c.

int ambincl

Definition at line 154 of file raycalls.c.

char* amblist[]

Definition at line 153 of file raycalls.c.

int ambounce

Definition at line 152 of file raycalls.c.

int ambres

Definition at line 149 of file raycalls.c.

int ambssamp

Definition at line 151 of file raycalls.c.

Definition at line 14 of file rglsrc.c.

int ambvwt

Definition at line 147 of file raycalls.c.

int backvis

Definition at line 140 of file raycalls.c.

Definition at line 132 of file raycalls.c.

int dimlist[]

Definition at line 112 of file raycalls.c.

Definition at line 127 of file raycalls.c.

int directvis

Definition at line 129 of file raycalls.c.

int do_irrad

Definition at line 120 of file raycalls.c.

double dstrsrc

Definition at line 124 of file raycalls.c.

Definition at line 24 of file raytrace.c.

int maxdepth

Definition at line 142 of file raycalls.c.

double minweight

Definition at line 143 of file raycalls.c.

int ndims

Definition at line 113 of file raycalls.c.

unsigned long nrays

Definition at line 21 of file raytrace.c.

Definition at line 110 of file raycalls.c.

int rand_samp

Definition at line 122 of file raycalls.c.

int(* ray_fifo_out)(RAY *r)

Definition at line 39 of file rayfifo.c.

Definition at line 164 of file raypcalls.c.

Definition at line 163 of file raypcalls.c.

unsigned long raynum

Definition at line 20 of file raytrace.c.

Definition at line 133 of file raycalls.c.

int samplendx

Definition at line 114 of file raycalls.c.

double seccg

Definition at line 134 of file raycalls.c.

double shadcert

Definition at line 126 of file raycalls.c.

double shadthresh

Definition at line 125 of file raycalls.c.

double specjitter

Definition at line 138 of file raycalls.c.

double specthresh

Definition at line 137 of file raycalls.c.

double srcsizerat

Definition at line 130 of file raycalls.c.

double ssampdist

Definition at line 135 of file raycalls.c.

Definition at line 31 of file oconv.c.

void(* trace)()

Definition at line 116 of file raycalls.c.

char VersionID[]
int vspretest

Definition at line 128 of file raycalls.c.