| 16 |
|
#include "random.h" |
| 17 |
|
|
| 18 |
|
|
| 19 |
< |
static int |
| 20 |
< |
srcskip( /* pre-emptive test for out-of-range glow */ |
| 21 |
< |
SRCREC *sp, |
| 22 |
< |
FVECT orig |
| 19 |
> |
int |
| 20 |
> |
srcskip( /* pre-emptive test for source to skip */ |
| 21 |
> |
int sn, |
| 22 |
> |
RAY *r |
| 23 |
|
) |
| 24 |
|
{ |
| 25 |
+ |
SRCREC *sp = source + sn; |
| 26 |
+ |
|
| 27 |
|
if (sp->sflags & SSKIP) |
| 28 |
|
return(1); |
| 29 |
|
|
| 30 |
|
if ((sp->sflags & (SPROX|SDISTANT)) != SPROX) |
| 31 |
|
return(0); |
| 32 |
|
|
| 33 |
< |
return(dist2(orig, sp->sloc) > |
| 33 |
> |
return(dist2(r->rorg, sp->sloc) > |
| 34 |
|
(sp->sl.prox + sp->srad)*(sp->sl.prox + sp->srad)); |
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
double |
| 38 |
|
nextssamp( /* compute sample for source, rtn. distance */ |
| 39 |
|
RAY *r, /* origin is read, direction is set */ |
| 40 |
< |
SRCINDEX *si /* source index (modified to current) */\ |
| 40 |
> |
SRCINDEX *si /* source index (modified to current) */ |
| 41 |
|
) |
| 42 |
|
{ |
| 43 |
|
int cent[3], size[3], parr[2]; |
| 44 |
|
SRCREC *srcp; |
| 45 |
< |
FVECT vpos; |
| 45 |
> |
double vpos[3]; |
| 46 |
|
double d; |
| 47 |
|
int i; |
| 48 |
|
nextsample: |
| 49 |
|
while (++si->sp >= si->np) { /* get next sample */ |
| 50 |
|
if (++si->sn >= nsources) |
| 51 |
|
return(0.0); /* no more */ |
| 52 |
< |
if (srcskip(source+si->sn, r->rorg)) |
| 52 |
> |
if (srcskip(si->sn, r)) |
| 53 |
|
si->np = 0; |
| 54 |
|
else if (srcsizerat <= FTINY) |
| 55 |
|
nopart(si, r); |
| 86 |
|
|
| 87 |
|
VSUM(vpos, vpos, cent, 1.0/MAXSPART); |
| 88 |
|
/* avoid circular aiming failures */ |
| 89 |
< |
if ((srcp->sflags & SCIR) && (si->np > 1 || dstrsrc > 0.7)) { |
| 89 |
> |
if ((srcp->sflags & SCIR) && (si->np > 1) | (dstrsrc > 0.7)) { |
| 90 |
|
FVECT trim; |
| 91 |
|
if (srcp->sflags & (SFLAT|SDISTANT)) { |
| 92 |
|
d = 1.12837917; /* correct setflatss() */ |