ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/dctimestep.c
(Generate patch)

Comparing ray/src/util/dctimestep.c (file contents):
Revision 2.15 by greg, Fri Apr 8 18:13:48 2011 UTC vs.
Revision 2.19 by greg, Tue Feb 21 20:09:25 2012 UTC

# Line 297 | Line 297 | cm_print(const CMATRIX *cm, FILE *fp)
297   static CMATRIX *
298   cm_bsdf(const COLOR bsdfLamb, const COLOR specCol, const SDMat *bsdf)
299   {
300 <        CMATRIX *cm;
300 >        CMATRIX *cm = cm_alloc(bsdf->nout, bsdf->ninc);
301          int     nbadohm = 0;
302          int     nneg = 0;
303        FVECT   v;
304        float   dom;
305        int     doforward;
303          int     r, c;
304 +                                        /* reciprocity is "transparent" */
305 +        for (c = 0; c < cm->ncols; c++) {
306 +                const double    dom = mBSDF_incohm(bsdf,c);
307 +                                        /* projected solid angle */
308 +                nbadohm += (dom <= 0);
309  
310 <        mBSDF_incvec(v, bsdf, .5);      /* check BTDF orientation */
311 <
312 <        if (v[2] < 0) {                 /* incident from outside */
313 <                cm = cm_alloc(bsdf->nout, bsdf->ninc);
314 <                for (c = 0; c < cm->ncols; c++) {
315 <                        dom = mBSDF_incohm(bsdf,c);
316 <                        
315 <                        nbadohm += (dom <= 0);
316 <
317 <                        if (!mBSDF_incvec(v,bsdf,c+.5) || v[2] > 0)
318 <                                error(USER, "illegal incoming BTDF direction");
319 <                        dom *= -v[2];
320 <
321 <                        for (r = 0; r < cm->nrows; r++) {
322 <                                float   f = mBSDF_value(bsdf,c,r);
323 <                                COLORV  *mp = cm_lval(cm,r,c);
324 <
325 <                                if ((f <= 0) | (dom <= 0)) {
326 <                                        nneg += (f < -FTINY);
327 <                                        f = .0f;
328 <                                }
329 <                                copycolor(mp, specCol);
330 <                                f *= dom;
331 <                                scalecolor(mp, f);
332 <                                addcolor(mp, bsdfLamb);
310 >                for (r = 0; r < cm->nrows; r++) {
311 >                        float   f = mBSDF_value(bsdf,c,r);
312 >                        COLORV  *mp = cm_lval(cm,r,c);
313 >                                        /* check BSDF value */
314 >                        if ((f <= 0) | (dom <= 0)) {
315 >                                nneg += (f < -FTINY);
316 >                                f = .0f;
317                          }
318 +                        copycolor(mp, specCol);
319 +                        scalecolor(mp, f);
320 +                        addcolor(mp, bsdfLamb);
321 +                        scalecolor(mp, dom);
322                  }
335        } else {                        /* rely on reciprocity */
336                cm = cm_alloc(bsdf->ninc, bsdf->nout);
337                for (c = 0; c < cm->ncols; c++) {
338                        dom = mBSDF_outohm(bsdf,c);
339                        
340                        nbadohm += (dom <= 0);
341
342                        if (!mBSDF_outvec(v,bsdf,c+.5) || v[2] > 0)
343                                error(USER, "illegal outgoing BTDF direction");
344                        dom *= -v[2];
345
346                        for (r = 0; r < cm->nrows; r++) {
347                                float   f = mBSDF_value(bsdf,r,c);
348                                COLORV  *mp = cm_lval(cm,r,c);
349
350                                if ((f <= 0) | (dom <= 0)) {
351                                        nneg += (f < -FTINY);
352                                        f = .0f;
353                                }
354                                copycolor(mp, specCol);
355                                f *= dom;
356                                scalecolor(mp, f);
357                                addcolor(mp, bsdfLamb);
358                        }
359                }
323          }
324          if (nneg | nbadohm) {
325                  sprintf(errmsg,
# Line 382 | Line 345 | cm_loadBSDF(char *fname)
345                  sprintf(errmsg, "cannot find BSDF file '%s'", fname);
346                  error(USER, errmsg);
347          }
348 <        SDclipName(myBSDF.name, fname);
386 <                                        /* load XML and check type */
348 >        SDclearBSDF(&myBSDF, fname);    /* load XML and check type */
349          ec = SDloadFile(&myBSDF, fpath);
350          if (ec)
351                  error(USER, transSDError(ec));
# Line 420 | Line 382 | sum_images(const char *fspec, const CMATRIX *cv, FILE
382                  int             dt, xr, yr;
383                  COLORV          *psp;
384                                                          /* check for zero */
385 <                if ((scv[RED] == 0) & (scv[GRN] == 0) & (scv[BLU] == 0))
385 >                if ((scv[RED] == 0) & (scv[GRN] == 0) & (scv[BLU] == 0) &&
386 >                                (myDT != DTfromHeader) | (i < cv->nrows-1))
387                          continue;
388                                                          /* open next picture */
389                  sprintf(fname, fspec, i);
# Line 482 | Line 445 | sum_images(const char *fspec, const CMATRIX *cv, FILE
445   static int
446   hasNumberFormat(const char *s)
447   {
448 <        while (*s && *s != '%')
449 <                s++;
450 <        if (!*s)
451 <                return(0);
452 <        do
453 <                ++s;
454 <        while (isdigit(*s));
455 <
456 <        return((*s == 'd') | (*s == 'i') | (*s == 'o') |
457 <                        (*s == 'x') | (*s == 'X'));
448 >        while (*s) {
449 >                while (*s != '%')
450 >                        if (!*s++)
451 >                                return(0);
452 >                if (*++s == '%') {              /* ignore "%%" */
453 >                        ++s;
454 >                        continue;
455 >                }
456 >                while (isdigit(*s))             /* field length */
457 >                        ++s;
458 >                                                /* field we'll use? */
459 >                if ((*s == 'd') | (*s == 'i') | (*s == 'o') |
460 >                                        (*s == 'x') | (*s == 'X'))
461 >                        return(1);
462 >        }
463 >        return(0);                              /* didn't find one */
464   }
465  
466   int

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines