6 |
|
*/ |
7 |
|
#ifndef _RAD_SOURCE_H_ |
8 |
|
#define _RAD_SOURCE_H_ |
9 |
+ |
|
10 |
+ |
#include <string.h> |
11 |
+ |
|
12 |
|
#ifdef __cplusplus |
13 |
|
extern "C" { |
14 |
|
#endif |
15 |
|
|
16 |
< |
|
14 |
< |
#include "copyright.h" |
15 |
< |
|
16 |
> |
#ifndef AIMREQT |
17 |
|
#define AIMREQT 100 /* required aim success/failure */ |
18 |
+ |
#endif |
19 |
+ |
#ifndef SHADCACHE |
20 |
+ |
#define SHADCACHE 20 /* shadow cache resolution */ |
21 |
+ |
#endif |
22 |
|
|
23 |
|
#define SDISTANT 01 /* source distant flag */ |
24 |
|
#define SSKIP 02 /* source skip flag */ |
36 |
|
} SPOT; /* spotlight */ |
37 |
|
|
38 |
|
typedef struct { |
39 |
< |
int sflags; /* source flags */ |
39 |
> |
union { |
40 |
> |
struct { |
41 |
> |
FVECT u, v; /* unit vectors */ |
42 |
> |
} f; /* flat source indexing */ |
43 |
> |
struct { |
44 |
> |
FVECT o; /* origin position */ |
45 |
> |
RREAL e1, e2; /* 1/extent */ |
46 |
> |
int ax; /* major direction */ |
47 |
> |
} d; /* distant source indexing */ |
48 |
> |
} p; /* indexing parameters */ |
49 |
> |
OBJECT obs[1]; /* cache obstructors (extends struct) */ |
50 |
> |
} OBSCACHE; /* obstructor cache */ |
51 |
> |
|
52 |
> |
typedef struct { |
53 |
|
FVECT sloc; /* direction or position of source */ |
54 |
|
FVECT ss[3]; /* source dimension vectors, U, V, and W */ |
55 |
|
float srad; /* maximum source radius */ |
56 |
|
float ss2; /* solid angle or projected area */ |
57 |
+ |
OBJREC *so; /* source destination object */ |
58 |
|
struct { |
59 |
|
float prox; /* proximity */ |
60 |
|
SPOT *s; /* spot */ |
68 |
|
} sa; /* source aiming information */ |
69 |
|
unsigned long |
70 |
|
ntests, nhits; /* shadow tests and hits */ |
71 |
< |
OBJREC *so; /* source destination object */ |
71 |
> |
#ifdef SHADCACHE |
72 |
> |
OBSCACHE *obscache; /* obstructor cache */ |
73 |
> |
#endif |
74 |
> |
int sflags; /* source flags */ |
75 |
|
} SRCREC; /* light source */ |
76 |
|
|
77 |
|
#define MAXSPART 64 /* maximum partitions per source */ |
84 |
|
#define snorm ss[SW] /* normal vector for flat source */ |
85 |
|
|
86 |
|
typedef struct { |
87 |
+ |
double dom; /* solid angle of partition */ |
88 |
|
int sn; /* source number */ |
89 |
|
short np; /* number of partitions */ |
90 |
|
short sp; /* this partition number */ |
68 |
– |
double dom; /* solid angle of partition */ |
91 |
|
unsigned char spt[MAXSPART/2]; /* source partitioning */ |
92 |
|
} SRCINDEX; /* source index structure */ |
93 |
|
|
94 |
|
#define initsrcindex(s) ((s)->sn = (s)->sp = -1, (s)->np = 0) |
95 |
|
|
96 |
< |
#define clrpart(pt) bzero((char *)(pt), MAXSPART/2) |
96 |
> |
#define clrpart(pt) memset((char *)(pt), '\0', MAXSPART/2) |
97 |
|
#define setpart(pt,i,v) ((pt)[(i)>>2] |= (v)<<(((i)&3)<<1)) |
98 |
|
#define spart(pt,pi) ((pt)[(pi)>>2] >> (((pi)&3)<<1) & 3) |
99 |
|
|
142 |
|
#define setsource(s,o) (*sfun[(o)->otype].of->setsrc)(s,o) |
143 |
|
|
144 |
|
/* defined in source.c */ |
145 |
+ |
extern OBJREC *findmaterial(OBJREC *o); |
146 |
|
extern void marksources(void); |
147 |
|
extern void freesources(void); |
148 |
|
extern int srcray(RAY *sr, RAY *r, SRCINDEX *si); |
149 |
|
extern void srcvalue(RAY *r); |
150 |
|
extern int sourcehit(RAY *r); |
151 |
< |
extern void direct(RAY *r, void (*f)(), char *p); |
151 |
> |
typedef void srcdirf_t(COLOR cv, void *np, FVECT ldir, double omega); |
152 |
> |
extern void direct(RAY *r, srcdirf_t *f, void *p); |
153 |
|
extern void srcscatter(RAY *r); |
154 |
|
extern int m_light(OBJREC *m, RAY *r); |
155 |
+ |
/* defined in srcobstr.c */ |
156 |
+ |
extern void initobscache(int sn); |
157 |
+ |
extern int srcblocker(RAY *r); |
158 |
+ |
extern int srcblocked(RAY *r); |
159 |
+ |
extern void freeobscache(SRCREC *s); |
160 |
+ |
extern void markclip(OBJREC *m); |
161 |
|
/* defined in srcsamp.c */ |
162 |
|
extern double nextssamp(RAY *r, SRCINDEX *si); |
163 |
|
extern int skipparts(int ct[3], int sz[3], int pp[2], unsigned char *pt); |