--- ray/src/rt/source.h 2003/07/14 22:24:00 2.11 +++ ray/src/rt/source.h 2020/12/17 03:30:37 2.22 @@ -1,4 +1,4 @@ -/* RCSid $Id: source.h,v 2.11 2003/07/14 22:24:00 schorsch Exp $ */ +/* RCSid $Id: source.h,v 2.22 2020/12/17 03:30:37 greg Exp $ */ /* * source.h - header file for ray tracing sources. * @@ -13,7 +13,15 @@ extern "C" { #endif +#ifndef AIMREQT #define AIMREQT 100 /* required aim success/failure */ +#endif +#ifndef SHADCACHE +#define SHADCACHE 20 /* shadow cache resolution */ +#endif +#ifndef MINSHADCNT +#define MINSHADCNT 2 /* test at least this many shadows */ +#endif #define SDISTANT 01 /* source distant flag */ #define SSKIP 02 /* source skip flag */ @@ -21,8 +29,9 @@ extern "C" { #define SSPOT 010 /* source spotlight flag */ #define SVIRTUAL 020 /* source virtual flag */ #define SFLAT 040 /* source flat flag */ -#define SCYL 0100 /* source cylindrical flag */ -#define SFOLLOW 0200 /* source follow path flag */ +#define SCIR 0100 /* source circular flag */ +#define SCYL 0200 /* source cylindrical flag */ +#define SFOLLOW 0400 /* source follow path flag */ typedef struct { FVECT aim; /* aim direction or center */ @@ -31,11 +40,25 @@ typedef struct { } SPOT; /* spotlight */ typedef struct { - int sflags; /* source flags */ + union { + struct { + FVECT u, v; /* unit vectors */ + } f; /* flat source indexing */ + struct { + FVECT o; /* origin position */ + RREAL e1, e2; /* 1/extent */ + int ax; /* major direction */ + } d; /* distant source indexing */ + } p; /* indexing parameters */ + OBJECT obs[1]; /* cache obstructors (extends struct) */ +} OBSCACHE; /* obstructor cache */ + +typedef struct { FVECT sloc; /* direction or position of source */ FVECT ss[3]; /* source dimension vectors, U, V, and W */ float srad; /* maximum source radius */ float ss2; /* solid angle or projected area */ + OBJREC *so; /* source destination object */ struct { float prox; /* proximity */ SPOT *s; /* spot */ @@ -49,7 +72,10 @@ typedef struct { } sa; /* source aiming information */ unsigned long ntests, nhits; /* shadow tests and hits */ - OBJREC *so; /* source destination object */ +#ifdef SHADCACHE + OBSCACHE *obscache; /* obstructor cache */ +#endif + int sflags; /* source flags */ } SRCREC; /* light source */ #define MAXSPART 64 /* maximum partitions per source */ @@ -62,10 +88,10 @@ typedef struct { #define snorm ss[SW] /* normal vector for flat source */ typedef struct { + double dom; /* solid angle of partition */ int sn; /* source number */ short np; /* number of partitions */ short sp; /* this partition number */ - double dom; /* solid angle of partition */ unsigned char spt[MAXSPART/2]; /* source partitioning */ } SRCINDEX; /* source index structure */ @@ -121,13 +147,21 @@ extern int nsources; /* the number of sources */ /* defined in source.c */ extern void marksources(void); +extern void distantsources(void); extern void freesources(void); extern int srcray(RAY *sr, RAY *r, SRCINDEX *si); extern void srcvalue(RAY *r); extern int sourcehit(RAY *r); -extern void direct(RAY *r, void (*f)(), char *p); +typedef void srcdirf_t(COLOR cv, void *np, FVECT ldir, double omega); +extern void direct(RAY *r, srcdirf_t *f, void *p); extern void srcscatter(RAY *r); extern int m_light(OBJREC *m, RAY *r); + /* defined in srcobstr.c */ +extern void initobscache(int sn); +extern int srcblocker(RAY *r); +extern int srcblocked(RAY *r); +extern void freeobscache(SRCREC *s); +extern void markclip(OBJREC *m); /* defined in srcsamp.c */ extern double nextssamp(RAY *r, SRCINDEX *si); extern int skipparts(int ct[3], int sz[3], int pp[2], unsigned char *pt);