15 |
|
#include "random.h" |
16 |
|
|
17 |
|
|
18 |
+ |
static int cyl_partit(), flt_partit(); |
19 |
+ |
|
20 |
+ |
|
21 |
|
double |
22 |
|
nextssamp(r, si) /* compute sample for source, rtn. distance */ |
23 |
|
register RAY *r; /* origin is read, direction is set */ |
27 |
|
FVECT vpos; |
28 |
|
double d; |
29 |
|
register int i; |
30 |
< |
|
30 |
> |
nextsample: |
31 |
|
while (++si->sp >= si->np) { /* get next sample */ |
32 |
|
if (++si->sn >= nsources) |
33 |
|
return(0.0); /* no more */ |
34 |
< |
if (srcsizerat <= FTINY) |
34 |
> |
if (source[si->sn].sflags & SSKIP) |
35 |
> |
si->np = 0; |
36 |
> |
else if (srcsizerat <= FTINY) |
37 |
|
nopart(si, r); |
38 |
|
else { |
39 |
|
for (i = si->sn; source[i].sflags & SVIRTUAL; |
79 |
|
r->rdir[i] -= r->rorg[i]; |
80 |
|
/* compute distance */ |
81 |
|
if ((d = normalize(r->rdir)) == 0.0) |
82 |
< |
return(nextssamp(r, si)); /* at source! */ |
82 |
> |
goto nextsample; /* at source! */ |
83 |
|
|
84 |
|
/* compute sample size */ |
85 |
|
si->dom = source[si->sn].ss2; |
86 |
|
if (source[si->sn].sflags & SFLAT) { |
87 |
|
si->dom *= sflatform(si->sn, r->rdir); |
88 |
< |
si->dom *= (double)(size[SU]*size[SV])/(MAXSPART*MAXSPART); |
88 |
> |
si->dom *= size[SU]*size[SV]/(MAXSPART*(double)MAXSPART); |
89 |
|
} else if (source[si->sn].sflags & SCYL) { |
90 |
|
si->dom *= scylform(si->sn, r->rdir); |
91 |
< |
si->dom *= (double)size[SU]/MAXSPART; |
91 |
> |
si->dom *= size[SU]/(double)MAXSPART; |
92 |
|
} else { |
93 |
< |
si->dom *= (double)(size[SU]*size[SV]*size[SW]) / |
94 |
< |
(MAXSPART*MAXSPART*MAXSPART) ; |
93 |
> |
si->dom *= size[SU]*size[SV]*(double)size[SW] / |
94 |
> |
(MAXSPART*MAXSPART*(double)MAXSPART) ; |
95 |
|
} |
96 |
|
if (source[si->sn].sflags & SDISTANT) |
97 |
|
return(FHUGE); |
98 |
+ |
if (si->dom <= 1e-4) |
99 |
+ |
goto nextsample; /* behind source? */ |
100 |
|
si->dom /= d*d; |
101 |
|
return(d); /* sample OK, return distance */ |
102 |
|
} |