| 24 |
|
FVECT vpos; |
| 25 |
|
double d; |
| 26 |
|
register int i; |
| 27 |
< |
tryagain: |
| 27 |
> |
|
| 28 |
|
while (++si->sp >= si->np) { /* get next sample */ |
| 29 |
|
if (++si->sn >= nsources) |
| 30 |
|
return(0.0); /* no more */ |
| 31 |
< |
if (srcsizerat <= FTINY) |
| 31 |
> |
if (source[si->sn].sflags & SSKIP) |
| 32 |
> |
si->np = 0; |
| 33 |
> |
else if (srcsizerat <= FTINY) |
| 34 |
|
nopart(si, r); |
| 35 |
|
else { |
| 36 |
|
for (i = si->sn; source[i].sflags & SVIRTUAL; |
| 76 |
|
r->rdir[i] -= r->rorg[i]; |
| 77 |
|
/* compute distance */ |
| 78 |
|
if ((d = normalize(r->rdir)) == 0.0) |
| 79 |
< |
goto tryagain; /* at source! */ |
| 79 |
> |
return(nextssamp(r, si)); /* at source! */ |
| 80 |
|
|
| 81 |
|
/* compute sample size */ |
| 82 |
|
si->dom = source[si->sn].ss2; |
| 83 |
|
if (source[si->sn].sflags & SFLAT) { |
| 84 |
|
si->dom *= sflatform(si->sn, r->rdir); |
| 83 |
– |
if (si->dom <= FTINY) { /* behind source */ |
| 84 |
– |
si->np = 0; |
| 85 |
– |
goto tryagain; |
| 86 |
– |
} |
| 85 |
|
si->dom *= (double)(size[SU]*size[SV])/(MAXSPART*MAXSPART); |
| 86 |
|
} else if (source[si->sn].sflags & SCYL) { |
| 87 |
|
si->dom *= scylform(si->sn, r->rdir); |
| 163 |
|
return; |
| 164 |
|
} |
| 165 |
|
safedist2 *= 4.*r->rweight*r->rweight/(srcsizerat*srcsizerat); |
| 166 |
< |
if (dist2 <= 4.*rad2 || /* point too close to subdivide? */ |
| 167 |
< |
dist2cent >= safedist2) { /* too far? */ |
| 166 |
> |
if (dist2 <= 4.*rad2 || /* point too close to subdivide */ |
| 167 |
> |
dist2cent >= safedist2) { /* or too far */ |
| 168 |
|
setpart(si->spt, 0, S0); |
| 169 |
|
si->np = 1; |
| 170 |
|
return; |
| 216 |
|
|
| 217 |
|
flatpart(si, r) /* partition a flat source */ |
| 218 |
|
register SRCINDEX *si; |
| 219 |
< |
RAY *r; |
| 219 |
> |
register RAY *r; |
| 220 |
|
{ |
| 221 |
< |
register double *vp; |
| 221 |
> |
register FLOAT *vp; |
| 222 |
> |
FVECT v; |
| 223 |
|
double du2, dv2; |
| 224 |
|
int pi; |
| 225 |
|
|
| 226 |
+ |
clrpart(si->spt); |
| 227 |
+ |
vp = source[si->sn].sloc; |
| 228 |
+ |
v[0] = r->rorg[0] - vp[0]; |
| 229 |
+ |
v[1] = r->rorg[1] - vp[1]; |
| 230 |
+ |
v[2] = r->rorg[2] - vp[2]; |
| 231 |
+ |
vp = source[si->sn].snorm; |
| 232 |
+ |
if (DOT(v,vp) <= FTINY) { /* behind source */ |
| 233 |
+ |
si->np = 0; |
| 234 |
+ |
return; |
| 235 |
+ |
} |
| 236 |
|
dv2 = 2.*r->rweight/srcsizerat; |
| 237 |
|
dv2 *= dv2; |
| 238 |
|
vp = source[si->sn].ss[SU]; |
| 239 |
|
du2 = dv2 * DOT(vp,vp); |
| 240 |
|
vp = source[si->sn].ss[SV]; |
| 241 |
|
dv2 *= DOT(vp,vp); |
| 233 |
– |
clrpart(si->spt); |
| 242 |
|
pi = 0; |
| 243 |
|
si->np = flt_partit(r->rorg, si->spt, &pi, MAXSPART, |
| 244 |
|
source[si->sn].sloc, |
| 302 |
|
int sn; |
| 303 |
|
register FVECT dir; /* assume normalized */ |
| 304 |
|
{ |
| 305 |
< |
register double *dv; |
| 305 |
> |
register FLOAT *dv; |
| 306 |
|
double d; |
| 307 |
|
|
| 308 |
|
dv = source[sn].ss[SU]; |