19 |
|
|
20 |
|
#include "random.h" |
21 |
|
|
22 |
+ |
#define MINSAMPLES 3 /* minimum number of pretest samples */ |
23 |
+ |
#define STESTMAX 30 /* maximum seeks per sample */ |
24 |
|
|
25 |
+ |
|
26 |
|
double getdisk(); |
27 |
|
|
28 |
|
static OBJECT *vobject; /* virtual source objects */ |
182 |
|
} |
183 |
|
if (source[sn].sflags & SFLAT) { /* behind source? */ |
184 |
|
multv3(nsnorm, source[sn].snorm, pm); |
185 |
< |
if (checkspot(&ourspot, nsnorm) < 0) |
185 |
> |
if (!checkspot(&ourspot, nsnorm)) |
186 |
|
return(-1); |
187 |
|
} |
188 |
|
} |
257 |
|
double or, d; |
258 |
|
int infront; |
259 |
|
int ssn; |
260 |
< |
int nhit; |
260 |
> |
int nhit, nok; |
261 |
|
register int i, n; |
262 |
|
/* return if pretesting disabled */ |
263 |
|
if (vspretest <= 0) |
275 |
|
n = or2/DOT(offsdir,offsdir)*vspretest + .5; |
276 |
|
infront = DOT(onorm, offsdir) > 0.; |
277 |
|
} |
278 |
< |
if (n < 1) n = 1; |
278 |
> |
if (n < MINSAMPLES) n = MINSAMPLES; |
279 |
|
#ifdef DEBUG |
280 |
|
fprintf(stderr, "pretesting source %d in object %s with %d rays\n", |
281 |
|
sn, o->oname, n); |
282 |
|
#endif |
283 |
|
/* sample */ |
284 |
|
or = sqrt(or2); |
285 |
< |
ssn = 25*n; |
286 |
< |
nhit = 0; |
285 |
> |
ssn = STESTMAX*n; |
286 |
> |
nhit = nok = 0; |
287 |
|
while (n-- > 0) { |
288 |
|
/* get sample point */ |
289 |
|
do { |
319 |
|
rayvalue(&sr); |
320 |
|
if (bright(sr.rcol) <= FTINY) |
321 |
|
continue; |
322 |
+ |
nok++; |
323 |
|
/* check against obstructions */ |
324 |
|
srcray(&sr, NULL, sn); |
325 |
|
rayvalue(&sr); |
326 |
< |
if (bright(sr.rcol) <= FTINY) { |
326 |
> |
if (bright(sr.rcol) > FTINY) |
327 |
> |
nhit++; |
328 |
> |
if (nhit > 0 && nhit < nok) { |
329 |
|
#ifdef DEBUG |
330 |
< |
fprintf(stderr, "\tfound an occlusion\n"); |
330 |
> |
fprintf(stderr, "\tpartially occluded\n"); |
331 |
|
#endif |
332 |
< |
return(f); /* need to shadow test */ |
332 |
> |
return(f); /* need to shadow test */ |
333 |
|
} |
328 |
– |
nhit++; |
334 |
|
} |
335 |
|
if (nhit == 0) { |
336 |
|
#ifdef DEBUG |