19 |
|
|
20 |
|
#include "random.h" |
21 |
|
|
22 |
< |
#define MINSAMPLES 5 /* minimum number of pretest samples */ |
23 |
< |
#define STESTMAX 30 /* maximum seeks per sample */ |
22 |
> |
#define MINSAMPLES 16 /* minimum number of pretest samples */ |
23 |
> |
#define STESTMAX 32 /* maximum seeks per sample */ |
24 |
|
|
25 |
|
|
26 |
|
double getdisk(); |
143 |
|
ourspot.flen = 0.; |
144 |
|
if (source[sn].sflags & SSPOT) { |
145 |
|
multp3(theirspot.aim, source[sn].sl.s->aim, pm); |
146 |
+ |
/* adjust for source size */ |
147 |
|
d = sqrt(dist2(ourspot.aim, theirspot.aim)); |
148 |
< |
d = sqrt(source[sn].sl.s->siz/PI) + d*source[sn].ss; |
148 |
> |
d = sqrt(source[sn].sl.s->siz/PI) + d*source[sn].srad; |
149 |
|
theirspot.siz = PI*d*d; |
150 |
|
ourspot.flen = theirspot.flen = source[sn].sl.s->flen; |
151 |
|
d = ourspot.siz; |
170 |
|
if (source[sn].sflags & SPROX && d > source[sn].sl.prox) |
171 |
|
return(-1); /* too far away */ |
172 |
|
ourspot.flen = 0.; |
173 |
< |
d = (sqrt(maxrad2) + source[sn].ss) / d; |
173 |
> |
/* adjust for source size */ |
174 |
> |
d = (sqrt(maxrad2) + source[sn].srad) / d; |
175 |
|
if (d < 1.-FTINY) |
176 |
|
ourspot.siz = 2.*PI*(1. - sqrt(1.-d*d)); |
177 |
|
else |
216 |
|
goto memerr; |
217 |
|
source[i].sflags = nsflags; |
218 |
|
VCOPY(source[i].sloc, nsloc); |
219 |
+ |
multv3(source[i].ss[SU], source[sn].ss[SU], pm); |
220 |
+ |
multv3(source[i].ss[SV], source[sn].ss[SV], pm); |
221 |
|
if (nsflags & SFLAT) |
222 |
|
VCOPY(source[i].snorm, nsnorm); |
223 |
< |
source[i].ss = source[sn].ss; source[i].ss2 = source[sn].ss2; |
223 |
> |
else |
224 |
> |
multv3(source[i].ss[SW], source[sn].ss[SW], pm); |
225 |
> |
source[i].srad = source[sn].srad; |
226 |
> |
source[i].ss2 = source[sn].ss2; |
227 |
|
if (nsflags & SSPOT) { |
228 |
|
if ((source[i].sl.s = (SPOT *)malloc(sizeof(SPOT))) == NULL) |
229 |
|
goto memerr; |
282 |
|
RAY sr; |
283 |
|
FVECT onorm; |
284 |
|
FVECT offsdir; |
285 |
+ |
SRCINDEX si; |
286 |
|
double or, d; |
287 |
|
int infront; |
288 |
|
int stestlim, ssn; |
295 |
|
getplaneq(onorm, o); |
296 |
|
/* set number of rays to sample */ |
297 |
|
if (source[sn].sflags & SDISTANT) { |
298 |
< |
n = (2./3.*PI*PI)*or2/(thescene.cusize*thescene.cusize)* |
299 |
< |
vspretest + .5; |
298 |
> |
/* 32. == heuristic constant */ |
299 |
> |
n = 32.*or2/(thescene.cusize*thescene.cusize)*vspretest + .5; |
300 |
|
infront = DOT(onorm, source[sn].sloc) > 0.; |
301 |
|
} else { |
302 |
|
for (i = 0; i < 3; i++) |
327 |
|
#endif |
328 |
|
return(f); /* too small a target! */ |
329 |
|
} |
330 |
+ |
multisamp(offsdir, 3, urand(sn*931+5827+ssn)); |
331 |
|
for (i = 0; i < 3; i++) |
332 |
< |
offsdir[i] = or*(1. - |
324 |
< |
2.*urand(urind(931*i+5827,ssn))); |
332 |
> |
offsdir[i] = or*(1. - 2.*offsdir[i]); |
333 |
|
ssn++; |
334 |
|
for (i = 0; i < 3; i++) |
335 |
|
sr.rorg[i] = oc[i] + offsdir[i]; |
347 |
|
rayorigin(&sr, NULL, PRIMARY, 1.0); |
348 |
|
} while (!(*ofun[o->otype].funp)(o, &sr)); |
349 |
|
/* check against source */ |
350 |
+ |
initsrcindex(&si); |
351 |
+ |
si.sn = sn; |
352 |
+ |
nopart(&si, sr.rorg); |
353 |
|
samplendx++; |
354 |
< |
if (srcray(&sr, NULL, sn) == 0.) |
354 |
> |
if (!srcray(&sr, NULL, &si) || sr.rsrc != sn) |
355 |
|
continue; |
356 |
|
sr.revf = srcvalue; |
357 |
|
rayvalue(&sr); |