--- ray/src/rt/ray.h 2003/03/04 19:02:22 2.14 +++ ray/src/rt/ray.h 2009/12/12 00:03:42 2.30 @@ -1,18 +1,23 @@ -/* RCSid $Id: ray.h,v 2.14 2003/03/04 19:02:22 greg Exp $ */ +/* RCSid $Id: ray.h,v 2.30 2009/12/12 00:03:42 greg Exp $ */ /* * ray.h - header file for routines using rays. */ +#ifndef _RAD_RAY_H_ +#define _RAD_RAY_H_ -#include "copyright.h" - #include "standard.h" - #include "octree.h" - #include "object.h" - #include "color.h" +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef RNUMBER +#define RNUMBER unsigned long /* ray counter (>= sizeof pointer) */ +#endif + #define MAXDIM 32 /* maximum number of dimensions */ /* ray type flags */ @@ -27,36 +32,41 @@ /* 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 of this ray */ - short rtype; /* ray type */ - short crtype; /* cumulative ray type */ - 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)(); /* evaluation function for this ray */ - void (*hitf)(); /* custom hit test for this traversal */ - OBJECT robj; /* intersected object number */ + void (*revf)(struct ray *); /* ray evaluation function */ + void (*hitf)(OBJECT *, struct ray *); /* custom hit test */ 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 */ - 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 ray value */ - double rt; /* returned effective ray length */ + COLOR rcol; /* returned radiance value */ 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) @@ -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 */ @@ -117,11 +129,14 @@ extern int ambincl; /* include == 1, exclude == 0 */ extern int ray_pnprocs; /* number of child processes */ extern int ray_pnidle; /* number of idle processes */ -#define AMBLLEN 128 /* max. ambient list length */ -#define AMBWORD 8 /* average word length */ +#ifndef AMBLLEN +#define AMBLLEN 512 /* max. ambient list length */ +#endif +#define AMBWORD 12 /* average word length */ typedef struct { /* rendering parameter holder */ int do_irrad; + int rand_samp; double dstrsrc; double shadthresh; double shadcert; @@ -154,59 +169,12 @@ typedef struct { /* rendering parameter holder */ #define rpambmod(p,i) ( (i)>=AMBLLEN||(p)->amblndx[i]<0 ? \ (char *)NULL : (p)->amblval+(p)->amblndx[i] ) -#ifdef NOPROTO - -extern void headclean(); -extern void openheader(); -extern void dupheader(); -extern void pfdetach(); -extern void pfclean(); -extern void pflock(); -extern void pfhold(); -extern void io_process(); -extern int free_objs(); -extern void free_objmem(); -extern int load_os(); -extern void preload_objs(); -extern void ray_init(); -extern void ray_trace(); -extern void ray_done(); -extern void ray_save(); -extern void ray_restore(); -extern void ray_defaults(); -extern void ray_pinit(); -extern void ray_psend(); -extern int ray_pqueue(); -extern int ray_presult(); -extern void ray_pdone(); -extern void ray_popen(); -extern void ray_pclose(); -extern int rayorigin(); -extern void rayclear(); -extern void raytrace(); -extern void rayhit(); -extern void raycont(); -extern void raytrans(); -extern int rayshade(); -extern void rayparticipate(); -extern int raymixture(); -extern double raydist(); -extern double raynormal(); -extern void newrayxf(); -extern void flipsurface(); -extern int localhit(); -extern int getrenderopt(); -extern void print_rdefaults(); -extern void drawsources(); -extern void rtrace(); -extern void rview(); -extern void rpict(); - -#else /* defined in duphead.c */ extern void headclean(void); extern void openheader(void); extern void dupheader(void); + /* defined in persist.c */ +extern void persistfile(char *pfn); extern void pfdetach(void); extern void pfclean(void); extern void pflock(int lf); @@ -234,7 +202,7 @@ extern void ray_pdone(int freall); extern void ray_popen(int nadd); extern void ray_pclose(int nsub); /* defined in raytrace.c */ -extern int rayorigin(RAY *r, RAY *ro, int rt, double rw); +extern int rayorigin(RAY *r, int rt, const RAY *ro, const COLOR rc); extern void rayclear(RAY *r); extern void raytrace(RAY *r); extern void rayhit(OBJECT *oset, RAY *r); @@ -242,8 +210,10 @@ extern void raycont(RAY *r); extern void raytrans(RAY *r); 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 double raydist(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); extern void flipsurface(RAY *r); @@ -254,9 +224,18 @@ extern void print_rdefaults(void); /* defined in srcdraw.c */ extern void drawsources(COLOR *pic[], float *zbf[], int x0, int xsiz, int y0, int ysiz); +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 rview(void); extern void rpict(int seq, char *pout, char *zout, char *prvr); + +#ifdef __cplusplus +} #endif +#endif /* _RAD_RAY_H_ */ +