--- ray/src/rt/source.c 2020/04/06 21:09:07 2.72 +++ ray/src/rt/source.c 2020/12/17 03:30:37 2.74 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: source.c,v 2.72 2020/04/06 21:09:07 greg Exp $"; +static const char RCSid[] = "$Id: source.c,v 2.74 2020/12/17 03:30:37 greg Exp $"; #endif /* * source.c - routines dealing with illumination sources. @@ -434,18 +434,17 @@ direct( /* add direct component */ cntord[sn].sndx = sn; scp = srccnt + sn; scp->sno = sr.rsrc; - /* compute coefficient */ - (*f)(scp->coef, p, sr.rdir, si.dom); - cntord[sn].brt = intens(scp->coef); - if (cntord[sn].brt <= 0.0) - continue; -#if SHADCACHE - /* check shadow cache */ +#if SHADCACHE /* check shadow cache */ if (si.np == 1 && srcblocked(&sr)) { cntord[sn].brt = 0.0; continue; } #endif + /* compute coefficient */ + (*f)(scp->coef, p, sr.rdir, si.dom); + cntord[sn].brt = intens(scp->coef); + if (cntord[sn].brt <= 0.0) + continue; VCOPY(scp->dir, sr.rdir); copycolor(sr.rcoef, scp->coef); /* compute potential */ @@ -478,19 +477,17 @@ direct( /* add direct component */ /* compute number to check */ nshadcheck = pow((double)ncnts, shadcert) + .5; /* modify threshold */ - if (ncnts > MINSHADCNT) - ourthresh = shadthresh / r->rweight; - else - ourthresh = 0; + ourthresh = shadthresh / r->rweight; /* test for shadows */ for (nhits = 0, hwt = 0.0, sn = 0; sn < ncnts; hwt += (double)source[scp->sno].nhits / (double)source[scp->sno].ntests, sn++) { /* check threshold */ - if ((sn+nshadcheck>=ncnts ? cntord[sn].brt : + if (sn >= MINSHADCNT && + (sn+nshadcheck>=ncnts ? cntord[sn].brt : cntord[sn].brt-cntord[sn+nshadcheck].brt) - < ourthresh*bright(r->rcol)) + < ourthresh*bright(r->rcol)) break; scp = srccnt + cntord[sn].sndx; /* test for hit */