| 237 |
|
/* domega constant */ |
| 238 |
|
return(source[sn].ss2); |
| 239 |
|
|
| 240 |
– |
else { |
| 240 |
|
/* check proximity */ |
| 241 |
< |
if (source[sn].sflags & SPROX && |
| 242 |
< |
d > source[sn].sl.prox) |
| 243 |
< |
return(0.0); |
| 244 |
< |
|
| 245 |
< |
if (norm != NULL) |
| 246 |
< |
ddot /= d; |
| 247 |
< |
else |
| 248 |
< |
ddot = 1.0; |
| 241 |
> |
if (source[sn].sflags & SPROX && |
| 242 |
> |
d > source[sn].sl.prox) |
| 243 |
> |
return(0.0); |
| 244 |
> |
/* compute dot product */ |
| 245 |
> |
if (norm != NULL) |
| 246 |
> |
ddot /= d; |
| 247 |
> |
else |
| 248 |
> |
ddot = 1.0; |
| 249 |
|
/* check angle */ |
| 250 |
< |
if (source[sn].sflags & SSPOT) { |
| 251 |
< |
if (source[sn].sl.s->siz < 2.0*PI * |
| 250 |
> |
if (source[sn].sflags & SSPOT) { |
| 251 |
> |
if (source[sn].sl.s->siz < 2.0*PI * |
| 252 |
|
(1.0 + DOT(source[sn].sl.s->aim,sr->rdir))) |
| 253 |
< |
return(0.0); |
| 254 |
< |
d += source[sn].sl.s->flen; |
| 256 |
< |
} |
| 257 |
< |
/* return domega */ |
| 258 |
< |
return(ddot*source[sn].ss2/(d*d)); |
| 253 |
> |
return(0.0); |
| 254 |
> |
d += source[sn].sl.s->flen; /* adjust length */ |
| 255 |
|
} |
| 256 |
+ |
/* compute domega */ |
| 257 |
+ |
return(ddot*source[sn].ss2/(d*d)); |
| 258 |
|
} |
| 259 |
|
|
| 260 |
|
|
| 313 |
|
extern double pow(); |
| 314 |
|
register int sn; |
| 315 |
|
int nshadcheck, ncnts; |
| 316 |
< |
double prob, ourthresh, hwt, test2, hit2; |
| 316 |
> |
int nhits; |
| 317 |
> |
double prob, ourthresh, hwt; |
| 318 |
|
RAY sr; |
| 319 |
|
/* NOTE: srccnt and cntord global so no recursion */ |
| 320 |
|
if (nsources <= 0) |
| 345 |
|
"aiming failure for light source \"%s\"", |
| 346 |
|
source[sn].so->oname); |
| 347 |
|
error(WARNING, errmsg); |
| 348 |
+ |
cntord[sn].brt = 0.0; |
| 349 |
|
continue; |
| 350 |
|
} |
| 351 |
|
/* compute contribution */ |
| 370 |
|
/* accumulate tail */ |
| 371 |
|
for (sn = ncnts-1; sn > 0; sn--) |
| 372 |
|
cntord[sn-1].brt += cntord[sn].brt; |
| 373 |
– |
/* start with prob=.5 */ |
| 374 |
– |
hit2 = 0.5; test2 = 1.0; |
| 373 |
|
/* test for shadows */ |
| 374 |
+ |
nhits = 0; |
| 375 |
|
for (sn = 0; sn < ncnts; sn++) { |
| 376 |
|
/* check threshold */ |
| 377 |
|
if ((sn+nshadcheck>=ncnts ? cntord[sn].brt : |
| 378 |
< |
cntord[sn].brt-cntord[sn+nshadcheck].brt) < |
| 379 |
< |
ourthresh*bright(r->rcol)) |
| 378 |
> |
cntord[sn].brt-cntord[sn+nshadcheck].brt) |
| 379 |
> |
< ourthresh*bright(r->rcol)) |
| 380 |
|
break; |
| 381 |
|
/* get statistics */ |
| 383 |
– |
hwt = (double)source[cntord[sn].sno].nhits / |
| 384 |
– |
(double)source[cntord[sn].sno].ntests; |
| 385 |
– |
test2 += hwt; |
| 382 |
|
source[cntord[sn].sno].ntests++; |
| 383 |
|
/* test for hit */ |
| 384 |
|
rayorigin(&sr, r, SHADOW, 1.0); |
| 397 |
|
} |
| 398 |
|
/* add contribution if hit */ |
| 399 |
|
addcolor(r->rcol, srccnt[cntord[sn].sno].val); |
| 400 |
< |
hit2 += hwt; |
| 400 |
> |
nhits++; |
| 401 |
|
source[cntord[sn].sno].nhits++; |
| 402 |
|
} |
| 403 |
< |
/* weighted hit rate */ |
| 404 |
< |
hwt = hit2 / test2; |
| 403 |
> |
/* surface hit rate */ |
| 404 |
> |
if (sn > 0) |
| 405 |
> |
hwt = (double)nhits / (double)sn; |
| 406 |
> |
else |
| 407 |
> |
hwt = 0.5; |
| 408 |
|
#ifdef DEBUG |
| 409 |
|
sprintf(errmsg, "%d tested, %d untested, %f hit rate\n", |
| 410 |
|
sn, ncnts-sn, hwt); |