13 |
|
#include "source.h" |
14 |
|
#include "random.h" |
15 |
|
|
16 |
– |
extern double ssampdist; /* scatter sampling distance */ |
17 |
– |
|
16 |
|
#ifndef MAXSSAMP |
17 |
|
#define MAXSSAMP 16 /* maximum samples per ray */ |
18 |
|
#endif |
40 |
|
static int cntcmp(const void *p1, const void *p2); |
41 |
|
|
42 |
|
|
43 |
< |
extern OBJREC * /* find an object's actual material */ |
44 |
< |
findmaterial(register OBJREC *o) |
43 |
> |
OBJREC * /* find an object's actual material */ |
44 |
> |
findmaterial(OBJREC *o) |
45 |
|
{ |
46 |
|
while (!ismaterial(o->otype)) { |
47 |
|
if (o->otype == MOD_ALIAS && o->oargs.nsargs) { |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
< |
extern void |
69 |
> |
void |
70 |
|
marksources(void) /* find and mark source objects */ |
71 |
|
{ |
72 |
|
int foundsource = 0; |
73 |
|
int i; |
74 |
< |
register OBJREC *o, *m; |
75 |
< |
register int ns; |
74 |
> |
OBJREC *o, *m; |
75 |
> |
int ns; |
76 |
|
/* initialize dispatch table */ |
77 |
|
initstypes(); |
78 |
|
/* find direct sources */ |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
< |
extern void |
158 |
> |
void |
159 |
|
freesources(void) /* free all source structures */ |
160 |
|
{ |
161 |
|
if (nsources > 0) { |
178 |
|
} |
179 |
|
|
180 |
|
|
181 |
< |
extern int |
181 |
> |
int |
182 |
|
srcray( /* send a ray to a source, return domega */ |
183 |
< |
register RAY *sr, /* returned source ray */ |
183 |
> |
RAY *sr, /* returned source ray */ |
184 |
|
RAY *r, /* ray which hit object */ |
185 |
|
SRCINDEX *si /* source sample index */ |
186 |
|
) |
187 |
|
{ |
188 |
|
double d; /* distance to source */ |
189 |
< |
register SRCREC *srcp; |
189 |
> |
SRCREC *srcp; |
190 |
|
|
191 |
|
rayorigin(sr, SHADOW, r, NULL); /* ignore limits */ |
192 |
|
|
220 |
|
} |
221 |
|
|
222 |
|
|
223 |
< |
extern void |
223 |
> |
void |
224 |
|
srcvalue( /* punch ray to source and compute value */ |
225 |
< |
register RAY *r |
225 |
> |
RAY *r |
226 |
|
) |
227 |
|
{ |
228 |
< |
register SRCREC *sp; |
228 |
> |
SRCREC *sp; |
229 |
|
|
230 |
|
sp = &source[r->rsrc]; |
231 |
|
if (sp->sflags & SVIRTUAL) { /* virtual source */ |
277 |
|
} |
278 |
|
|
279 |
|
|
280 |
< |
extern int |
280 |
> |
int |
281 |
|
sourcehit( /* check to see if ray hit distant source */ |
282 |
< |
register RAY *r |
282 |
> |
RAY *r |
283 |
|
) |
284 |
|
{ |
285 |
|
int glowsrc = -1; |
286 |
|
int transrc = -1; |
287 |
|
int first, last; |
288 |
< |
register int i; |
288 |
> |
int i; |
289 |
|
|
290 |
|
if (r->rsrc >= 0) { /* check only one if aimed */ |
291 |
|
first = last = r->rsrc; |
353 |
|
const void *p2 |
354 |
|
) |
355 |
|
{ |
356 |
< |
register const CNTPTR *sc1 = (const CNTPTR *)p1; |
357 |
< |
register const CNTPTR *sc2 = (const CNTPTR *)p2; |
356 |
> |
const CNTPTR *sc1 = (const CNTPTR *)p1; |
357 |
> |
const CNTPTR *sc2 = (const CNTPTR *)p2; |
358 |
|
|
359 |
|
if (sc1->brt > sc2->brt) |
360 |
|
return(-1); |
364 |
|
} |
365 |
|
|
366 |
|
|
367 |
< |
extern void |
367 |
> |
void |
368 |
|
direct( /* add direct component */ |
369 |
|
RAY *r, /* ray that hit surface */ |
370 |
|
srcdirf_t *f, /* direct component coefficient function */ |
371 |
|
void *p /* data for f */ |
372 |
|
) |
373 |
|
{ |
374 |
< |
register int sn; |
375 |
< |
register CONTRIB *scp; |
374 |
> |
int sn; |
375 |
> |
CONTRIB *scp; |
376 |
|
SRCINDEX si; |
377 |
|
int nshadcheck, ncnts; |
378 |
|
int nhits; |
420 |
|
/* sort contributions */ |
421 |
|
qsort(cntord, sn, sizeof(CNTPTR), cntcmp); |
422 |
|
{ /* find last */ |
423 |
< |
register int l, m; |
423 |
> |
int l, m; |
424 |
|
|
425 |
|
ncnts = l = sn; |
426 |
|
sn = 0; |
515 |
|
} |
516 |
|
|
517 |
|
|
518 |
< |
extern void |
518 |
> |
void |
519 |
|
srcscatter( /* compute source scattering into ray */ |
520 |
< |
register RAY *r |
520 |
> |
RAY *r |
521 |
|
) |
522 |
|
{ |
523 |
|
int oldsampndx; |
680 |
|
distglow(m, r, raydist(r,PRIMARY))) |
681 |
|
|
682 |
|
|
683 |
< |
extern int |
683 |
> |
int |
684 |
|
m_light( /* ray hit a light source */ |
685 |
< |
register OBJREC *m, |
686 |
< |
register RAY *r |
685 |
> |
OBJREC *m, |
686 |
> |
RAY *r |
687 |
|
) |
688 |
|
{ |
689 |
|
/* check for over-counting */ |