--- ray/src/rt/ray.h 2009/12/13 19:13:04 2.32 +++ ray/src/rt/ray.h 2019/07/25 16:50:54 2.41 @@ -1,4 +1,4 @@ -/* RCSid $Id: ray.h,v 2.32 2009/12/13 19:13:04 greg Exp $ */ +/* RCSid $Id: ray.h,v 2.41 2019/07/25 16:50:54 greg Exp $ */ /* * ray.h - header file for routines using rays. */ @@ -9,6 +9,7 @@ #include "octree.h" #include "object.h" #include "color.h" +#include "pmapparm.h" #ifdef __cplusplus extern "C" { @@ -45,7 +46,8 @@ typedef struct ray { RREAL rod; /* -DOT(rdir, ron) */ RREAL uv[2]; /* local coordinates */ FVECT pert; /* surface normal perturbation */ - RREAL rt; /* returned effective ray length */ + RREAL rmt; /* returned mirrored ray length */ + RREAL rxt; /* returned unmirrored ray length */ const struct ray *parent; /* ray this originated from */ OBJECT *clipset; /* set of objects currently clipped */ OBJECT *newcset; /* next clipset, used for transmission */ @@ -55,11 +57,13 @@ typedef struct ray { FULLXF *rox; /* object transformation */ int *slights; /* list of lights to test for scattering */ RNUMBER rno; /* unique ray number */ - int rlvl; /* number of reflections for this ray */ + short rflips; /* surface orientation has been reversed */ + short 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 mcol; /* mirrored color contribution */ COLOR rcol; /* returned radiance value */ COLOR cext; /* medium extinction coefficient */ COLOR albedo; /* medium scattering albedo */ @@ -71,13 +75,18 @@ typedef struct ray { #define rayvalue(r) (*(r)->revf)(r) +#define raydistance(r) (bright((r)->mcol) > 0.5*bright((r)->rcol) ? \ + (r)->rmt : (r)->rxt) + +#define rayreorient(r) if ((r)->rflips & 1) flipsurface(r); else + extern char VersionID[]; /* Radiance version ID string */ extern CUBE thescene; /* our scene */ extern OBJECT nsceneobjs; /* number of objects in our scene */ -extern unsigned long raynum; /* next ray ID */ -extern unsigned long nrays; /* total rays traced so far */ +extern RNUMBER raynum; /* next ray ID */ +extern RNUMBER nrays; /* total rays traced so far */ extern OBJREC Lamb; /* a Lambertian surface */ extern OBJREC Aftplane; /* aft clipping object */ @@ -164,6 +173,9 @@ typedef struct { /* rendering parameter holder */ int ambincl; short amblndx[AMBLLEN+1]; char amblval[AMBLLEN*AMBWORD]; + + /* PMAP: photon mapping parameters */ + PhotonMapParams pmapParams [NUM_PMAP_TYPES]; } RAYPARAMS; #define rpambmod(p,i) ( (i)>=AMBLLEN||(p)->amblndx[i]<0 ? \ @@ -195,7 +207,7 @@ extern void ray_restore(RAYPARAMS *rp); extern void ray_defaults(RAYPARAMS *rp); /* defined in raypcalls.c */ extern void ray_pinit(char *otnm, int nproc); -extern void ray_psend(RAY *r); +extern int ray_psend(RAY *r); extern int ray_pqueue(RAY *r); extern int ray_presult(RAY *r, int poll); extern void ray_pdone(int freall); @@ -212,11 +224,12 @@ extern void raytrace(RAY *r); extern void rayhit(OBJECT *oset, RAY *r); extern void raycont(RAY *r); extern void raytrans(RAY *r); +extern int raytirrad(OBJREC *m, 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 void raycontrib(double rc[3], const RAY *r, int flags); +extern void raycontrib(RREAL 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); @@ -237,6 +250,11 @@ extern char *formstr(int f); extern void rview(void); extern void rpict(int seq, char *pout, char *zout, char *prvr); +#ifdef __FAST_MATH__ +#define checknorm(vn) (void)normalize(vn) +#else +#define checknorm(vn) +#endif #ifdef __cplusplus }