--- ray/src/rt/srcsamp.c 2008/12/07 19:25:23 2.13 +++ ray/src/rt/srcsamp.c 2008/12/10 17:33:23 2.15 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: srcsamp.c,v 2.13 2008/12/07 19:25:23 greg Exp $"; +static const char RCSid[] = "$Id: srcsamp.c,v 2.15 2008/12/10 17:33:23 greg Exp $"; #endif /* * Source sampling routines @@ -71,7 +71,6 @@ nextsample: /* avoid circular aiming failures */ if ((source[si->sn].sflags & SCIR) && (si->np > 1 || dstrsrc > 0.7)) { FVECT trim; - double d; if (source[si->sn].sflags & (SFLAT|SDISTANT)) { d = 1.12837917; /* correct setflatss() */ trim[SU] = d*sqrt(1.0 - 0.5*vpos[SV]*vpos[SV]); @@ -85,9 +84,12 @@ nextsample: d = vpos[SW]*vpos[SW]; if (d > trim[SW]) trim[SW] = d; trim[SU] += d; - d = 1.0/0.7236; /* correct sphsetsrc() */ - trim[SW] = trim[SV] = trim[SU] = - d*sqrt(trim[SW]/trim[SU]); + if (trim[SU] > FTINY*FTINY) { + d = 1.0/0.7236; /* correct sphsetsrc() */ + trim[SW] = trim[SV] = trim[SU] = + d*sqrt(trim[SW]/trim[SU]); + } else + trim[SW] = trim[SV] = trim[SU] = 0.0; } for (i = 0; i < 3; i++) vpos[i] *= trim[i];