--- ray/src/common/bsdf_t.c 2013/07/04 15:14:45 3.30 +++ ray/src/common/bsdf_t.c 2014/03/17 01:53:51 3.32 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdf_t.c,v 3.30 2013/07/04 15:14:45 greg Exp $"; +static const char RCSid[] = "$Id: bsdf_t.c,v 3.32 2014/03/17 01:53:51 greg Exp $"; #endif /* * bsdf_t.c @@ -284,7 +284,7 @@ SDdotravTre(const SDNode *st, const double *pos, int c unsigned skipmask = 0; csiz *= .5; for (i = st->ndim; i--; ) - if (1<ndim; n--; ) { if (n & 1<ndim; n--; ) { if (1<st->ndim == 3) { spinvector(rOutVec, outVec, zvec, -atan2(-inVec[1],-inVec[0])); - gridPos[0] = .5 - .5*sqrt(inVec[0]*inVec[0] + inVec[1]*inVec[1]); + gridPos[0] = (.5-FTINY) - + .5*sqrt(inVec[0]*inVec[0] + inVec[1]*inVec[1]); SDdisk2square(gridPos+1, rOutVec[0], rOutVec[1]); } else if (sdt->st->ndim == 4) { SDdisk2square(gridPos, -inVec[0], -inVec[1]); @@ -672,7 +674,8 @@ SDgetTreCDist(const FVECT inVec, SDComponent *sdc) if (sdt->st->ndim == 3) { /* isotropic BSDF? */ if (mode != sdt->sidef) /* XXX unhandled reciprocity */ return &SDemptyCD; - inCoord[0] = .5 - .5*sqrt(inVec[0]*inVec[0] + inVec[1]*inVec[1]); + inCoord[0] = (.5-FTINY) - + .5*sqrt(inVec[0]*inVec[0] + inVec[1]*inVec[1]); } else if (sdt->st->ndim == 4) { if (mode != sdt->sidef) /* use reciprocity? */ SDdisk2square(inCoord, inVec[0], inVec[1]); @@ -797,8 +800,7 @@ SDsampTreCDist(FVECT ioVec, double randX, const SDCDst SDsquare2disk(gpos, gpos[0], gpos[1]); /* compute Z-coordinate */ gpos[2] = 1. - gpos[0]*gpos[0] - gpos[1]*gpos[1]; - if (gpos[2] > 0) /* paranoia, I hope */ - gpos[2] = sqrt(gpos[2]); + gpos[2] = sqrt(gpos[2]*(gpos[2]>0)); /* emit from back? */ if ((cd->sidef == SD_BREFL) | (cd->sidef == SD_FXMIT)) gpos[2] = -gpos[2];