--- ray/src/util/dctimestep.c 2009/06/21 21:42:12 2.7 +++ ray/src/util/dctimestep.c 2009/12/09 20:33:48 2.11 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: dctimestep.c,v 2.7 2009/06/21 21:42:12 greg Exp $"; +static const char RCSid[] = "$Id: dctimestep.c,v 2.11 2009/12/09 20:33:48 greg Exp $"; #endif /* * Compute time-step result using Daylight Coefficient method. @@ -38,7 +38,7 @@ cm_alloc(int nrows, int ncols) CMATRIX *cm; if ((nrows <= 0) | (ncols <= 0)) - return(NULL); + error(USER, "attempt to create empty matrix"); cm = (CMATRIX *)malloc(sizeof(CMATRIX) + 3*sizeof(COLORV)*(nrows*ncols - 1)); if (cm == NULL) @@ -294,12 +294,11 @@ static CMATRIX * cm_bsdf(const struct BSDF_data *bsdf) { CMATRIX *cm = cm_alloc(bsdf->nout, bsdf->ninc); - COLORV *mp = cm->cmem; int nbadohm = 0; int nneg = 0; int r, c; - for (c = 0; c < cm->ncols; c++, mp += 3) { + for (c = 0; c < cm->ncols; c++) { float dom = getBSDF_incohm(bsdf,c); FVECT v; @@ -313,10 +312,11 @@ cm_bsdf(const struct BSDF_data *bsdf) for (r = 0; r < cm->nrows; r++) { float f = BSDF_value(bsdf,c,r); + COLORV *mp = cm_lval(cm,r,c); if (f <= .0) { nneg += (f < -FTINY); - continue; + f = .0f; } mp[0] = mp[1] = mp[2] = f * dom; } @@ -404,9 +404,9 @@ sum_images(const char *fspec, const CMATRIX *cv) return(fflush(stdout) == 0); } -/* check to see if a string contains a %d specification */ -int -hasDecimalSpec(const char *s) +/* check to see if a string contains a %d or %o specification */ +static int +hasNumberFormat(const char *s) { while (*s && *s != '%') s++; @@ -416,7 +416,7 @@ hasDecimalSpec(const char *s) ++s; while (isdigit(*s)); - return(*s == 'd'); + return(*s == 'd' | *s == 'i' | *s == 'o' | *s == 'x' | *s == 'X'); } int @@ -447,7 +447,7 @@ main(int argc, char *argv[]) free_BSDF(btdf); cvec = cm_multiply(Tmat, ivec); /* cvec = component vector */ cm_free(Tmat); cm_free(ivec); - if (hasDecimalSpec(argv[1])) { /* generating image */ + if (hasNumberFormat(argv[1])) { /* generating image */ SET_FILE_BINARY(stdout); newheader("RADIANCE", stdout); printargs(argc, argv, stdout);