8 |
|
*/ |
9 |
|
|
10 |
|
#include "ray.h" |
11 |
– |
|
11 |
|
#include "otypes.h" |
12 |
< |
|
12 |
> |
#include "rtotypes.h" |
13 |
|
#include "source.h" |
15 |
– |
|
14 |
|
#include "random.h" |
15 |
|
|
16 |
|
extern double ssampdist; /* scatter sampling distance */ |
39 |
|
static CNTPTR *cntord; /* source ordering in direct() */ |
40 |
|
static int maxcntr = 0; /* size of contribution arrays */ |
41 |
|
|
42 |
+ |
static int cntcmp(const void *p1, const void *p2); |
43 |
|
|
44 |
< |
OBJREC * /* find an object's actual material */ |
44 |
> |
|
45 |
> |
extern OBJREC * /* find an object's actual material */ |
46 |
|
findmaterial(register OBJREC *o) |
47 |
|
{ |
48 |
|
while (!ismaterial(o->otype)) { |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
< |
void |
70 |
< |
marksources() /* find and mark source objects */ |
69 |
> |
extern void |
70 |
> |
marksources(void) /* find and mark source objects */ |
71 |
|
{ |
72 |
|
int foundsource = 0; |
73 |
|
int i; |
83 |
|
if (!issurface(o->otype) || o->omod == OVOID) |
84 |
|
continue; |
85 |
|
/* find material */ |
86 |
< |
m = findmaterial(o); |
86 |
> |
m = findmaterial(objptr(o->omod)); |
87 |
|
if (m == NULL || !islight(m->otype)) |
88 |
|
continue; /* not source modifier */ |
89 |
|
|
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
< |
void |
151 |
< |
freesources() /* free all source structures */ |
150 |
> |
extern void |
151 |
> |
freesources(void) /* free all source structures */ |
152 |
|
{ |
153 |
|
if (nsources > 0) { |
154 |
|
#if SHADCACHE |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
< |
int |
172 |
> |
extern int |
173 |
|
srcray( /* send a ray to a source, return domega */ |
174 |
< |
register RAY *sr, /* returned source ray */ |
175 |
< |
RAY *r, /* ray which hit object */ |
176 |
< |
SRCINDEX *si /* source sample index */ |
174 |
> |
register RAY *sr, /* returned source ray */ |
175 |
> |
RAY *r, /* ray which hit object */ |
176 |
> |
SRCINDEX *si /* source sample index */ |
177 |
|
) |
178 |
|
{ |
179 |
|
double d; /* distance to source */ |
208 |
|
} |
209 |
|
|
210 |
|
|
211 |
< |
void |
211 |
> |
extern void |
212 |
|
srcvalue( /* punch ray to source and compute value */ |
213 |
< |
register RAY *r |
213 |
> |
register RAY *r |
214 |
|
) |
215 |
|
{ |
216 |
|
register SRCREC *sp; |
250 |
|
} |
251 |
|
|
252 |
|
|
253 |
< |
int |
253 |
> |
extern int |
254 |
|
sourcehit( /* check to see if ray hit distant source */ |
255 |
< |
register RAY *r |
255 |
> |
register RAY *r |
256 |
|
) |
257 |
|
{ |
258 |
|
int first, last; |
292 |
|
|
293 |
|
static int |
294 |
|
cntcmp( /* contribution compare (descending) */ |
295 |
< |
const void *p1, |
296 |
< |
const void *p2 |
295 |
> |
const void *p1, |
296 |
> |
const void *p2 |
297 |
|
) |
298 |
|
{ |
299 |
|
register const CNTPTR *sc1 = (const CNTPTR *)p1; |
307 |
|
} |
308 |
|
|
309 |
|
|
310 |
< |
void |
310 |
> |
extern void |
311 |
|
direct( /* add direct component */ |
312 |
< |
RAY *r, /* ray that hit surface */ |
313 |
< |
void (*f)(), /* direct component coefficient function */ |
314 |
< |
char *p /* data for f */ |
312 |
> |
RAY *r, /* ray that hit surface */ |
313 |
> |
srcdirf_t *f, /* direct component coefficient function */ |
314 |
> |
void *p /* data for f */ |
315 |
|
) |
316 |
|
{ |
317 |
– |
extern void (*trace)(); |
317 |
|
register int sn; |
318 |
|
register CONTRIB *scp; |
319 |
|
SRCINDEX si; |
451 |
|
} |
452 |
|
|
453 |
|
|
454 |
< |
void |
454 |
> |
extern void |
455 |
|
srcscatter( /* compute source scattering into ray */ |
456 |
< |
register RAY *r |
456 |
> |
register RAY *r |
457 |
|
) |
458 |
|
{ |
459 |
|
int oldsampndx; |
609 |
|
distglow(m, r, raydist(r,PRIMARY))) |
610 |
|
|
611 |
|
|
612 |
< |
int |
612 |
> |
extern int |
613 |
|
m_light( /* ray hit a light source */ |
614 |
< |
register OBJREC *m, |
615 |
< |
register RAY *r |
614 |
> |
register OBJREC *m, |
615 |
> |
register RAY *r |
616 |
|
) |
617 |
|
{ |
618 |
|
/* check for over-counting */ |