--- ray/src/rt/ray.h 2005/04/19 01:15:06 2.25 +++ ray/src/rt/ray.h 2009/12/13 19:13:04 2.32 @@ -1,4 +1,4 @@ -/* RCSid $Id: ray.h,v 2.25 2005/04/19 01:15:06 greg Exp $ */ +/* RCSid $Id: ray.h,v 2.32 2009/12/13 19:13:04 greg Exp $ */ /* * ray.h - header file for routines using rays. */ @@ -14,6 +14,10 @@ extern "C" { #endif +#ifndef RNUMBER +#define RNUMBER unsigned long /* ray counter (>= sizeof pointer) */ +#endif + #define MAXDIM 32 /* maximum number of dimensions */ /* ray type flags */ @@ -28,39 +32,45 @@ extern "C" { /* reflected ray types */ #define RAYREFL (SHADOW|REFLECTED|AMBIENT|SPECULAR) +/* Arrange so double's come first for optimal alignment */ +/* Pointers and long's come second for 64-bit mode */ +/* Int's next (unknown length), then floats, followed by short's & char's */ typedef struct ray { - unsigned long rno; /* unique ray number */ - int rlvl; /* number of reflections for this ray */ - float rweight; /* cumulative weight (for termination) */ - COLOR rcoef; /* contribution coefficient w.r.t. parent */ - short rtype; /* ray type */ - short crtype; /* cumulative ray type */ - const struct ray *parent; /* ray this originated from */ FVECT rorg; /* origin of ray */ FVECT rdir; /* normalized direction of ray */ - double rmax; /* maximum distance (aft clipping plane) */ - int rsrc; /* source we're aiming for */ + RREAL rmax; /* maximum distance (aft clipping plane) */ + RREAL rot; /* distance to object */ + FVECT rop; /* intersection point */ + FVECT ron; /* intersection surface normal */ + RREAL rod; /* -DOT(rdir, ron) */ + RREAL uv[2]; /* local coordinates */ + FVECT pert; /* surface normal perturbation */ + RREAL rt; /* returned effective ray length */ + const struct ray *parent; /* ray this originated from */ OBJECT *clipset; /* set of objects currently clipped */ OBJECT *newcset; /* next clipset, used for transmission */ + void (*revf)(struct ray *); /* ray evaluation function */ void (*hitf)(OBJECT *, struct ray *); /* custom hit test */ - OBJECT robj; /* intersected object number */ OBJREC *ro; /* intersected object (one with material) */ - double rot; /* distance to object */ - FVECT rop; /* intersection point */ - FVECT ron; /* intersection surface normal */ - double rod; /* -DOT(rdir, ron) */ FULLXF *rox; /* object transformation */ - RREAL uv[2]; /* local coordinates */ - FVECT pert; /* surface normal perturbation */ + int *slights; /* list of lights to test for scattering */ + RNUMBER rno; /* unique ray number */ + int rlvl; /* number of reflections for this ray */ + int rsrc; /* source we're aiming for */ + float rweight; /* cumulative weight (for termination) */ + COLOR rcoef; /* contribution coefficient w.r.t. parent */ COLOR pcol; /* pattern color */ COLOR rcol; /* returned radiance value */ - double rt; /* returned effective ray length */ COLOR cext; /* medium extinction coefficient */ COLOR albedo; /* medium scattering albedo */ float gecc; /* scattering eccentricity coefficient */ - int *slights; /* list of lights to test for scattering */ + OBJECT robj; /* intersected object number */ + short rtype; /* ray type */ + short crtype; /* cumulative ray type */ } RAY; +#define rayvalue(r) (*(r)->revf)(r) + extern char VersionID[]; /* Radiance version ID string */ extern CUBE thescene; /* our scene */ @@ -82,6 +92,8 @@ extern int ray_savesiz; /* size of parameter save buff extern int do_irrad; /* compute irradiance? */ +extern int rand_samp; /* pure Monte Carlo sampling? */ + extern double dstrsrc; /* square source distribution */ extern double shadthresh; /* shadow threshold */ extern double shadcert; /* shadow testing certainty */ @@ -124,6 +136,7 @@ extern int ray_pnidle; /* number of idle processes */ typedef struct { /* rendering parameter holder */ int do_irrad; + int rand_samp; double dstrsrc; double shadthresh; double shadcert; @@ -188,10 +201,14 @@ extern int ray_presult(RAY *r, int poll); extern void ray_pdone(int freall); extern void ray_popen(int nadd); extern void ray_pclose(int nsub); + /* defined in ray_fifo.c */ +extern int (*ray_fifo_out)(RAY *r); +extern int ray_fifo_in(RAY *r); +extern int ray_fifo_flush(void); /* defined in raytrace.c */ extern int rayorigin(RAY *r, int rt, const RAY *ro, const COLOR rc); extern void rayclear(RAY *r); -extern void rayvalue(RAY *r); +extern void raytrace(RAY *r); extern void rayhit(OBJECT *oset, RAY *r); extern void raycont(RAY *r); extern void raytrans(RAY *r); @@ -199,7 +216,7 @@ extern int rayshade(RAY *r, int mod); extern void rayparticipate(RAY *r); extern void raytexture(RAY *r, OBJECT mod); extern int raymixture(RAY *r, OBJECT fore, OBJECT back, double coef); -extern void raycontrib(COLOR rc, const RAY *r, int flags); +extern void raycontrib(double rc[3], const RAY *r, int flags); extern double raydist(const RAY *r, int flags); extern double raynormal(FVECT norm, RAY *r); extern void newrayxf(RAY *r); @@ -215,8 +232,8 @@ extern void init_drawsources(int rad); /* defined in rt/initotypes.c */ extern void initotypes(void); /* module main procedures */ -extern void rtrace(char *fname); -extern char * formstr(int f); +extern void rtrace(char *fname, int nproc); +extern char *formstr(int f); extern void rview(void); extern void rpict(int seq, char *pout, char *zout, char *prvr);