Back to index

radiance  4R0+20100331
Functions | Variables
raycalls.c File Reference
#include "copyright.h"
#include <string.h>
#include <time.h>
#include "ray.h"
#include "source.h"
#include "ambient.h"
#include "otypes.h"
#include "random.h"
#include "data.h"
#include "font.h"

Go to the source code of this file.

Functions

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)

Variables

static const char RCSid [] = "$Id: raycalls.c,v 2.17 2009/12/12 05:20:10 greg Exp $"
char * progname = "unknown_app"
char * octname
char * shm_boundary = NULL
CUBE thescene
OBJECT nsceneobjs
int dimlist [MAXDIM]
int ndims = 0
int samplendx = 0
void(* trace )() = NULL
void(* addobjnotify [8])() = {ambnotify, NULL}
int do_irrad = 0
int rand_samp = 0
double dstrsrc = 0.0
double shadthresh = .03
double shadcert = .75
int directrelay = 2
int vspretest = 512
int directvis = 1
double srcsizerat = .2
COLOR cextinction = BLKCOLOR
COLOR salbedo = BLKCOLOR
double seccg = 0.
double ssampdist = 0.
double specthresh = .15
double specjitter = 1.
int backvis = 1
int maxdepth = 8
double minweight = 2e-3
char * ambfile = NULL
COLOR ambval = BLKCOLOR
int ambvwt = 0
double ambacc = 0.1
int ambres = 256
int ambdiv = 1024
int ambssamp = 512
int ambounce = 0
char * amblist [AMBLLEN+1]
int ambincl = -1

Function Documentation

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:

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_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:


Variable Documentation

void(* addobjnotify[8])() = {ambnotify, NULL}

Definition at line 118 of file raycalls.c.

double ambacc = 0.1

Definition at line 148 of file raycalls.c.

int ambdiv = 1024

Definition at line 150 of file raycalls.c.

char* ambfile = NULL

Definition at line 145 of file raycalls.c.

int ambincl = -1

Definition at line 154 of file raycalls.c.

char* amblist[AMBLLEN+1]

Definition at line 153 of file raycalls.c.

int ambounce = 0

Definition at line 152 of file raycalls.c.

int ambres = 256

Definition at line 149 of file raycalls.c.

int ambssamp = 512

Definition at line 151 of file raycalls.c.

Definition at line 146 of file raycalls.c.

int ambvwt = 0

Definition at line 147 of file raycalls.c.

int backvis = 1

Definition at line 140 of file raycalls.c.

Definition at line 132 of file raycalls.c.

Definition at line 112 of file raycalls.c.

int directrelay = 2

Definition at line 127 of file raycalls.c.

int directvis = 1

Definition at line 129 of file raycalls.c.

int do_irrad = 0

Definition at line 120 of file raycalls.c.

double dstrsrc = 0.0

Definition at line 124 of file raycalls.c.

int maxdepth = 8

Definition at line 142 of file raycalls.c.

double minweight = 2e-3

Definition at line 143 of file raycalls.c.

int ndims = 0

Definition at line 113 of file raycalls.c.

Definition at line 110 of file raycalls.c.

char* octname

Definition at line 105 of file raycalls.c.

char* progname = "unknown_app"

Definition at line 103 of file raycalls.c.

int rand_samp = 0

Definition at line 122 of file raycalls.c.

const char RCSid[] = "$Id: raycalls.c,v 2.17 2009/12/12 05:20:10 greg Exp $" [static]

Definition at line 2 of file raycalls.c.

Definition at line 133 of file raycalls.c.

int samplendx = 0

Definition at line 114 of file raycalls.c.

double seccg = 0.

Definition at line 134 of file raycalls.c.

double shadcert = .75

Definition at line 126 of file raycalls.c.

double shadthresh = .03

Definition at line 125 of file raycalls.c.

char* shm_boundary = NULL

Definition at line 107 of file raycalls.c.

double specjitter = 1.

Definition at line 138 of file raycalls.c.

double specthresh = .15

Definition at line 137 of file raycalls.c.

double srcsizerat = .2

Definition at line 130 of file raycalls.c.

double ssampdist = 0.

Definition at line 135 of file raycalls.c.

Definition at line 109 of file raycalls.c.

void(* trace)() = NULL

Definition at line 116 of file raycalls.c.

int vspretest = 512

Definition at line 128 of file raycalls.c.