--- ray/src/common/bsdf.c 2011/04/08 23:23:28 2.18 +++ ray/src/common/bsdf.c 2011/04/11 03:47:46 2.20 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdf.c,v 2.18 2011/04/08 23:23:28 greg Exp $"; +static const char RCSid[] = "$Id: bsdf.c,v 2.20 2011/04/11 03:47:46 greg Exp $"; #endif /* * bsdf.c @@ -269,10 +269,14 @@ SDclipName(char *res, const char *fname) /* Initialize an unused BSDF struct (simply clears to zeroes) */ void -SDclearBSDF(SDData *sd) +SDclearBSDF(SDData *sd, const char *fname) { - if (sd != NULL) - memset(sd, 0, sizeof(SDData)); + if (sd == NULL) + return; + memset(sd, 0, sizeof(SDData)); + if (fname == NULL) + return; + SDclipName(sd->name, fname); } /* Free data associated with BSDF struct */ @@ -451,7 +455,7 @@ SDmultiSamp(double t[], int n, double randX) bitmask_t ndx, coord[MS_MAXDIM]; while (n > MS_MAXDIM) /* punt for higher dimensions */ - t[--n] = rand()*(1./RAND_MAX); + t[--n] = rand()*(1./(RAND_MAX+.5)); nBits = (8*sizeof(bitmask_t) - 1) / n; ndx = randX * (double)((bitmask_t)1 << (nBits*n)); /* get coordinate on Hilbert curve */ @@ -459,7 +463,7 @@ SDmultiSamp(double t[], int n, double randX) /* convert back to [0,1) range */ scale = 1. / (double)((bitmask_t)1 << nBits); while (n--) - t[n] = scale * ((double)coord[n] + rand()*(1./RAND_MAX)); + t[n] = scale * ((double)coord[n] + rand()*(1./(RAND_MAX+.5))); } #undef MS_MAXDIM