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

Comparing ray/src/common/bsdf.c (file contents):
Revision 2.15 by greg, Fri Feb 18 00:40:25 2011 UTC vs.
Revision 2.31 by greg, Fri Jun 10 01:11:26 2011 UTC

# Line 10 | Line 10 | static const char RCSid[] = "$Id$";
10   *
11   */
12  
13 + #define _USE_MATH_DEFINES
14   #include <stdio.h>
15   #include <stdlib.h>
16 + #include <string.h>
17   #include <math.h>
18   #include "ezxml.h"
19   #include "hilbert.h"
# Line 45 | Line 47 | int                    SDretainSet = SDretainNone;
47   SDError
48   SDreportEnglish(SDError ec, FILE *fp)
49   {
48        if (fp == NULL)
49                return ec;
50          if (!ec)
51                  return SDEnone;
52 +        if ((ec < SDEnone) | (ec > SDEunknown)) {
53 +                SDerrorDetail[0] = '\0';
54 +                ec = SDEunknown;
55 +        }
56 +        if (fp == NULL)
57 +                return ec;
58          fputs(SDerrorEnglish[ec], fp);
59          if (SDerrorDetail[0]) {
60                  fputs(": ", fp);
# Line 77 | Line 83 | to_meters(             /* return factor to convert given unit to
83  
84   /* Load geometric dimensions and description (if any) */
85   static SDError
86 < SDloadGeometry(SDData *dp, ezxml_t wdb)
86 > SDloadGeometry(SDData *sd, ezxml_t wdb)
87   {
88          ezxml_t         geom;
89          double          cfact;
90          const char      *fmt, *mgfstr;
91  
92 <        sprintf(SDerrorDetail, "Negative size in \"%s\"", dp->name);
93 <        dp->dim[0] = dp->dim[1] = dp->dim[2] = .0;
92 >        if (wdb == NULL)                /* no geometry section? */
93 >                return SDEnone;
94 >        sd->dim[0] = sd->dim[1] = sd->dim[2] = .0;
95          if ((geom = ezxml_child(wdb, "Width")) != NULL)
96 <                dp->dim[0] = atof(ezxml_txt(geom)) *
96 >                sd->dim[0] = atof(ezxml_txt(geom)) *
97                                  to_meters(ezxml_attr(geom, "unit"));
98          if ((geom = ezxml_child(wdb, "Height")) != NULL)
99 <                dp->dim[1] = atof(ezxml_txt(geom)) *
99 >                sd->dim[1] = atof(ezxml_txt(geom)) *
100                                  to_meters(ezxml_attr(geom, "unit"));
101          if ((geom = ezxml_child(wdb, "Thickness")) != NULL)
102 <                dp->dim[2] = atof(ezxml_txt(geom)) *
102 >                sd->dim[2] = atof(ezxml_txt(geom)) *
103                                  to_meters(ezxml_attr(geom, "unit"));
104 <        if ((dp->dim[0] < .0) | (dp->dim[1] < .0) | (dp->dim[2] < .0))
104 >        if ((sd->dim[0] < 0) | (sd->dim[1] < 0) | (sd->dim[2] < 0)) {
105 >                sprintf(SDerrorDetail, "Negative size in \"%s\"", sd->name);
106                  return SDEdata;
107 +        }
108          if ((geom = ezxml_child(wdb, "Geometry")) == NULL ||
109                          (mgfstr = ezxml_txt(geom)) == NULL)
110                  return SDEnone;
# Line 103 | Line 112 | SDloadGeometry(SDData *dp, ezxml_t wdb)
112                          strcasecmp(fmt, "MGF")) {
113                  sprintf(SDerrorDetail,
114                          "Unrecognized geometry format '%s' in \"%s\"",
115 <                                        fmt, dp->name);
115 >                                        fmt, sd->name);
116                  return SDEsupport;
117          }
118          cfact = to_meters(ezxml_attr(geom, "unit"));
119 <        dp->mgf = (char *)malloc(strlen(mgfstr)+32);
120 <        if (dp->mgf == NULL) {
119 >        sd->mgf = (char *)malloc(strlen(mgfstr)+32);
120 >        if (sd->mgf == NULL) {
121                  strcpy(SDerrorDetail, "Out of memory in SDloadGeometry");
122                  return SDEmemory;
123          }
124          if (cfact < 0.99 || cfact > 1.01)
125 <                sprintf(dp->mgf, "xf -s %.5f\n%s\nxf\n", cfact, mgfstr);
125 >                sprintf(sd->mgf, "xf -s %.5f\n%s\nxf\n", cfact, mgfstr);
126          else
127 <                strcpy(dp->mgf, mgfstr);
127 >                strcpy(sd->mgf, mgfstr);
128          return SDEnone;
129   }
130  
122
131   /* Load a BSDF struct from the given file (free first and keep name) */
132   SDError
133   SDloadFile(SDData *sd, const char *fname)
134   {
135          SDError         lastErr;
136 <        ezxml_t         fl;
136 >        ezxml_t         fl, wtl;
137  
138          if ((sd == NULL) | (fname == NULL || !*fname))
139                  return SDEargument;
# Line 142 | Line 150 | SDloadFile(SDData *sd, const char *fname)
150                  ezxml_free(fl);
151                  return SDEformat;
152          }
153 +        if (strcmp(ezxml_name(fl), "WindowElement")) {
154 +                sprintf(SDerrorDetail,
155 +                        "BSDF \"%s\": top level node not 'WindowElement'",
156 +                                sd->name);
157 +                ezxml_free(fl);
158 +                return SDEformat;
159 +        }
160 +        wtl = ezxml_child(ezxml_child(fl, "Optical"), "Layer");
161 +        if (wtl == NULL) {
162 +                sprintf(SDerrorDetail, "BSDF \"%s\": no optical layer'",
163 +                                sd->name);
164 +                ezxml_free(fl);
165 +                return SDEformat;
166 +        }
167                                  /* load geometry if present */
168 <        if ((lastErr = SDloadGeometry(sd, fl)))
168 >        lastErr = SDloadGeometry(sd, ezxml_child(wtl, "Material"));
169 >        if (lastErr)
170                  return lastErr;
171                                  /* try loading variable resolution data */
172 <        lastErr = SDloadTre(sd, fl);
172 >        lastErr = SDloadTre(sd, wtl);
173                                  /* check our result */
174 <        switch (lastErr) {
175 <        case SDEformat:
176 <        case SDEdata:
154 <        case SDEsupport:        /* possibly we just tried the wrong format */
155 <                lastErr = SDloadMtx(sd, fl);
156 <                break;
157 <        default:                /* variable res. OK else serious error */
158 <                break;
159 <        }
174 >        if (lastErr == SDEsupport)      /* try matrix BSDF if not tree data */
175 >                lastErr = SDloadMtx(sd, wtl);
176 >                
177                                  /* done with XML file */
178          ezxml_free(fl);
179 <                                /* return success or failure */
180 <        return lastErr;
179 >        
180 >        if (lastErr) {          /* was there a load error? */
181 >                SDfreeBSDF(sd);
182 >                return lastErr;
183 >        }
184 >                                /* remove any insignificant components */
185 >        if (sd->rf != NULL && sd->rf->maxHemi <= .001) {
186 >                SDfreeSpectralDF(sd->rf); sd->rf = NULL;
187 >        }
188 >        if (sd->rb != NULL && sd->rb->maxHemi <= .001) {
189 >                SDfreeSpectralDF(sd->rb); sd->rb = NULL;
190 >        }
191 >        if (sd->tf != NULL && sd->tf->maxHemi <= .001) {
192 >                SDfreeSpectralDF(sd->tf); sd->tf = NULL;
193 >        }
194 >                                /* return success */
195 >        return SDEnone;
196   }
197  
198   /* Allocate new spectral distribution function */
# Line 219 | Line 251 | SDfreeSpectralDF(SDSpectralDF *df)
251  
252   /* Shorten file path to useable BSDF name, removing suffix */
253   void
254 < SDclipName(char res[SDnameLn], const char *fname)
254 > SDclipName(char *res, const char *fname)
255   {
256          const char      *cp, *dot = NULL;
257          
# Line 237 | Line 269 | SDclipName(char res[SDnameLn], const char *fname)
269  
270   /* Initialize an unused BSDF struct (simply clears to zeroes) */
271   void
272 < SDclearBSDF(SDData *sd)
272 > SDclearBSDF(SDData *sd, const char *fname)
273   {
274 <        if (sd != NULL)
275 <                memset(sd, 0, sizeof(SDData));
274 >        if (sd == NULL)
275 >                return;
276 >        memset(sd, 0, sizeof(SDData));
277 >        if (fname == NULL)
278 >                return;
279 >        SDclipName(sd->name, fname);
280   }
281  
282   /* Free data associated with BSDF struct */
# Line 266 | Line 302 | SDfreeBSDF(SDData *sd)
302                  sd->tf = NULL;
303          }
304          sd->rLambFront.cieY = .0;
305 <        sd->rLambFront.spec.clock = 0;
305 >        sd->rLambFront.spec.flags = 0;
306          sd->rLambBack.cieY = .0;
307 <        sd->rLambBack.spec.clock = 0;
307 >        sd->rLambBack.spec.flags = 0;
308          sd->tLamb.cieY = .0;
309 <        sd->tLamb.spec.clock = 0;
309 >        sd->tLamb.spec.flags = 0;
310   }
311  
312   /* Find writeable BSDF by name, or allocate new cache entry if absent */
# Line 298 | Line 334 | SDgetCache(const char *bname)
334          sdl->next = SDcacheList;
335          SDcacheList = sdl;
336  
337 <        sdl->refcnt++;
337 >        sdl->refcnt = 1;
338          return &sdl->bsdf;
339   }
340  
# Line 342 | Line 378 | SDfreeCache(const SDData *sd)
378          for (sdl = SDcacheList; sdl != NULL; sdl = (sdLast=sdl)->next)
379                  if (&sdl->bsdf == sd)
380                          break;
381 <        if (sdl == NULL || --sdl->refcnt)
381 >        if (sdl == NULL || (sdl->refcnt -= (sdl->refcnt > 0)))
382                  return;                 /* missing or still in use */
383                                          /* keep unreferenced data? */
384          if (SDisLoaded(sd) && SDretainSet) {
# Line 365 | Line 401 | SDfreeCache(const SDData *sd)
401  
402   /* Sample an individual BSDF component */
403   SDError
404 < SDsampComponent(SDValue *sv, FVECT outVec, const FVECT inVec,
369 <                        double randX, SDComponent *sdc)
404 > SDsampComponent(SDValue *sv, FVECT ioVec, double randX, SDComponent *sdc)
405   {
406          float           coef[SDmaxCh];
407          SDError         ec;
408 +        FVECT           inVec;
409          const SDCDst    *cd;
410          double          d;
411          int             n;
412                                          /* check arguments */
413 <        if ((sv == NULL) | (outVec == NULL) | (inVec == NULL) | (sdc == NULL))
413 >        if ((sv == NULL) | (ioVec == NULL) | (sdc == NULL))
414                  return SDEargument;
415                                          /* get cumulative distribution */
416 +        VCOPY(inVec, ioVec);
417          cd = (*sdc->func->getCDist)(inVec, sdc);
418          if (cd == NULL)
419                  return SDEmemory;
420          if (cd->cTotal <= 1e-7) {       /* anything to sample? */
421                  sv->spec = c_dfcolor;
422                  sv->cieY = .0;
423 <                memset(outVec, 0, 3*sizeof(double));
423 >                memset(ioVec, 0, 3*sizeof(double));
424                  return SDEnone;
425          }
426          sv->cieY = cd->cTotal;
427                                          /* compute sample direction */
428 <        ec = (*sdc->func->sampCDist)(outVec, randX, cd);
428 >        ec = (*sdc->func->sampCDist)(ioVec, randX, cd);
429          if (ec)
430                  return ec;
431                                          /* get BSDF color */
432 <        n = (*sdc->func->getBSDFs)(coef, outVec, inVec, sdc->dist);
432 >        n = (*sdc->func->getBSDFs)(coef, ioVec, inVec, sdc);
433          if (n <= 0) {
434                  strcpy(SDerrorDetail, "BSDF sample value error");
435                  return SDEinternal;
# Line 419 | Line 456 | SDmultiSamp(double t[], int n, double randX)
456          bitmask_t       ndx, coord[MS_MAXDIM];
457          
458          while (n > MS_MAXDIM)           /* punt for higher dimensions */
459 <                t[--n] = drand48();
459 >                t[--n] = rand()*(1./(RAND_MAX+.5));
460          nBits = (8*sizeof(bitmask_t) - 1) / n;
461          ndx = randX * (double)((bitmask_t)1 << (nBits*n));
462                                          /* get coordinate on Hilbert curve */
# Line 427 | Line 464 | SDmultiSamp(double t[], int n, double randX)
464                                          /* convert back to [0,1) range */
465          scale = 1. / (double)((bitmask_t)1 << nBits);
466          while (n--)
467 <                t[n] = scale * ((double)coord[n] + drand48());
467 >                t[n] = scale * ((double)coord[n] + rand()*(1./(RAND_MAX+.5)));
468   }
469  
470   #undef MS_MAXDIM
# Line 440 | Line 477 | SDdiffuseSamp(FVECT outVec, int outFront, double randX
477          SDmultiSamp(outVec, 2, randX);
478          SDsquare2disk(outVec, outVec[0], outVec[1]);
479          outVec[2] = 1. - outVec[0]*outVec[0] - outVec[1]*outVec[1];
480 <        if (outVec[2] > .0)             /* a bit of paranoia */
480 >        if (outVec[2] > 0)              /* a bit of paranoia */
481                  outVec[2] = sqrt(outVec[2]);
482          if (!outFront)                  /* going out back? */
483                  outVec[2] = -outVec[2];
# Line 448 | Line 485 | SDdiffuseSamp(FVECT outVec, int outFront, double randX
485  
486   /* Query projected solid angle coverage for non-diffuse BSDF direction */
487   SDError
488 < SDsizeBSDF(double *projSA, const FVECT vec, int qflags, const SDData *sd)
488 > SDsizeBSDF(double *projSA, const FVECT v1, const RREAL *v2,
489 >                                int qflags, const SDData *sd)
490   {
491 <        SDSpectralDF    *rdf;
491 >        SDSpectralDF    *rdf, *tdf;
492          SDError         ec;
493          int             i;
494                                          /* check arguments */
495 <        if ((projSA == NULL) | (vec == NULL) | (sd == NULL))
495 >        if ((projSA == NULL) | (v1 == NULL) | (sd == NULL))
496                  return SDEargument;
497                                          /* initialize extrema */
498 <        switch (qflags & SDqueryMin+SDqueryMax) {
498 >        switch (qflags) {
499          case SDqueryMax:
500                  projSA[0] = .0;
501                  break;
# Line 470 | Line 508 | SDsizeBSDF(double *projSA, const FVECT vec, int qflags
508          case 0:
509                  return SDEargument;
510          }
511 <        if (vec[2] > .0)                /* front surface query? */
511 >        if (v1[2] > 0)                  /* front surface query? */
512                  rdf = sd->rf;
513          else
514                  rdf = sd->rb;
515 +        tdf = sd->tf;
516 +        if (v2 != NULL)                 /* bidirectional? */
517 +                if (v1[2] > 0 ^ v2[2] > 0)
518 +                        rdf = NULL;
519 +                else
520 +                        tdf = NULL;
521          ec = SDEdata;                   /* run through components */
522          for (i = (rdf==NULL) ? 0 : rdf->ncomp; i--; ) {
523 <                ec = (*rdf->comp[i].func->queryProjSA)(projSA, vec, qflags,
524 <                                                        rdf->comp[i].dist);
523 >                ec = (*rdf->comp[i].func->queryProjSA)(projSA, v1, v2,
524 >                                                qflags, &rdf->comp[i]);
525                  if (ec)
526                          return ec;
527          }
528 <        for (i = (sd->tf==NULL) ? 0 : sd->tf->ncomp; i--; ) {
529 <                ec = (*sd->tf->comp[i].func->queryProjSA)(projSA, vec, qflags,
530 <                                                        sd->tf->comp[i].dist);
528 >        for (i = (tdf==NULL) ? 0 : tdf->ncomp; i--; ) {
529 >                ec = (*tdf->comp[i].func->queryProjSA)(projSA, v1, v2,
530 >                                                qflags, &tdf->comp[i]);
531                  if (ec)
532                          return ec;
533          }
534 <        return ec;
534 >        if (ec) {                       /* all diffuse? */
535 >                projSA[0] = M_PI;
536 >                if (qflags == SDqueryMin+SDqueryMax)
537 >                        projSA[1] = M_PI;
538 >        }
539 >        return SDEnone;
540   }
541  
542   /* Return BSDF for the given incident and scattered ray vectors */
# Line 502 | Line 551 | SDevalBSDF(SDValue *sv, const FVECT outVec, const FVEC
551          if ((sv == NULL) | (outVec == NULL) | (inVec == NULL) | (sd == NULL))
552                  return SDEargument;
553                                          /* whose side are we on? */
554 <        inFront = (inVec[2] > .0);
555 <        outFront = (outVec[2] > .0);
554 >        inFront = (inVec[2] > 0);
555 >        outFront = (outVec[2] > 0);
556                                          /* start with diffuse portion */
557          if (inFront & outFront) {
558                  *sv = sd->rLambFront;
# Line 520 | Line 569 | SDevalBSDF(SDValue *sv, const FVECT outVec, const FVEC
569          i = (sdf != NULL) ? sdf->ncomp : 0;
570          while (i-- > 0) {
571                  nch = (*sdf->comp[i].func->getBSDFs)(coef, outVec, inVec,
572 <                                                        sdf->comp[i].dist);
572 >                                                        &sdf->comp[i]);
573                  while (nch-- > 0) {
574                          c_cmix(&sv->spec, sv->cieY, &sv->spec,
575                                          coef[nch], &sdf->comp[i].cspec[nch]);
# Line 544 | Line 593 | SDdirectHemi(const FVECT inVec, int sflags, const SDDa
593          if ((inVec == NULL) | (sd == NULL))
594                  return .0;
595                                          /* gather diffuse components */
596 <        if (inVec[2] > .0) {
596 >        if (inVec[2] > 0) {
597                  hsum = sd->rLambFront.cieY;
598                  rdf = sd->rf;
599          } else /* !inFront */ {
# Line 575 | Line 624 | SDdirectHemi(const FVECT inVec, int sflags, const SDDa
624  
625   /* Sample BSDF direction based on the given random variable */
626   SDError
627 < SDsampBSDF(SDValue *sv, FVECT outVec, const FVECT inVec,
579 <                        double randX, int sflags, const SDData *sd)
627 > SDsampBSDF(SDValue *sv, FVECT ioVec, double randX, int sflags, const SDData *sd)
628   {
629          SDError         ec;
630 +        FVECT           inVec;
631          int             inFront;
632          SDSpectralDF    *rdf;
633          double          rdiff;
# Line 587 | Line 636 | SDsampBSDF(SDValue *sv, FVECT outVec, const FVECT inVe
636          SDComponent     *sdc;
637          const SDCDst    **cdarr = NULL;
638                                          /* check arguments */
639 <        if ((sv == NULL) | (outVec == NULL) | (inVec == NULL) | (sd == NULL) |
640 <                        (randX < .0) | (randX >= 1.))
639 >        if ((sv == NULL) | (ioVec == NULL) | (sd == NULL) |
640 >                        (randX < 0) | (randX >= 1.))
641                  return SDEargument;
642                                          /* whose side are we on? */
643 <        inFront = (inVec[2] > .0);
643 >        VCOPY(inVec, ioVec);
644 >        inFront = (inVec[2] > 0);
645                                          /* remember diffuse portions */
646          if (inFront) {
647                  *sv = sd->rLambFront;
# Line 631 | Line 681 | SDsampBSDF(SDValue *sv, FVECT outVec, const FVECT inVe
681          }
682          if (sv->cieY <= 1e-7) {         /* anything to sample? */
683                  sv->cieY = .0;
684 <                memset(outVec, 0, 3*sizeof(double));
684 >                memset(ioVec, 0, 3*sizeof(double));
685                  return SDEnone;
686          }
687                                          /* scale random variable */
688          randX *= sv->cieY;
689                                          /* diffuse reflection? */
690          if (randX < rdiff) {
691 <                SDdiffuseSamp(outVec, inFront, randX/rdiff);
691 >                SDdiffuseSamp(ioVec, inFront, randX/rdiff);
692                  goto done;
693          }
694          randX -= rdiff;
# Line 646 | Line 696 | SDsampBSDF(SDValue *sv, FVECT outVec, const FVECT inVe
696          if ((sflags & SDsampDf+SDsampT) == SDsampDf+SDsampT) {
697                  if (randX < sd->tLamb.cieY) {
698                          sv->spec = sd->tLamb.spec;
699 <                        SDdiffuseSamp(outVec, !inFront, randX/sd->tLamb.cieY);
699 >                        SDdiffuseSamp(ioVec, !inFront, randX/sd->tLamb.cieY);
700                          goto done;
701                  }
702                  randX -= sd->tLamb.cieY;
# Line 658 | Line 708 | SDsampBSDF(SDValue *sv, FVECT outVec, const FVECT inVe
708                  return SDEinternal;
709                                          /* compute sample direction */
710          sdc = (i < nr) ? &rdf->comp[i] : &sd->tf->comp[i-nr];
711 <        ec = (*sdc->func->sampCDist)(outVec, randX/cdarr[i]->cTotal, cdarr[i]);
711 >        ec = (*sdc->func->sampCDist)(ioVec, randX/cdarr[i]->cTotal, cdarr[i]);
712          if (ec)
713                  return ec;
714                                          /* compute color */
715 <        j = (*sdc->func->getBSDFs)(coef, outVec, inVec, sdc->dist);
715 >        j = (*sdc->func->getBSDFs)(coef, ioVec, inVec, sdc);
716          if (j <= 0) {
717                  sprintf(SDerrorDetail, "BSDF \"%s\" sampling value error",
718                                  sd->name);
# Line 689 | Line 739 | SDcompXform(RREAL vMtx[3][3], const FVECT sNrm, const
739          if ((vMtx == NULL) | (sNrm == NULL) | (uVec == NULL))
740                  return SDEargument;
741          VCOPY(vMtx[2], sNrm);
742 <        if (normalize(vMtx[2]) == .0)
742 >        if (normalize(vMtx[2]) == 0)
743                  return SDEargument;
744          fcross(vMtx[0], uVec, vMtx[2]);
745 <        if (normalize(vMtx[0]) == .0)
745 >        if (normalize(vMtx[0]) == 0)
746                  return SDEargument;
747          fcross(vMtx[1], vMtx[2], vMtx[0]);
748          return SDEnone;
# Line 712 | Line 762 | SDinvXform(RREAL iMtx[3][3], RREAL vMtx[3][3])
762          mTmp[0][1] = vMtx[2][1]*vMtx[0][2] - vMtx[2][2]*vMtx[0][1];
763          mTmp[0][2] = vMtx[1][2]*vMtx[0][1] - vMtx[1][1]*vMtx[0][2];
764          d = vMtx[0][0]*mTmp[0][0] + vMtx[1][0]*mTmp[0][1] + vMtx[2][0]*mTmp[0][2];
765 <        if (d == .0) {
765 >        if (d == 0) {
766                  strcpy(SDerrorDetail, "Zero determinant in matrix inversion");
767                  return SDEargument;
768          }
# Line 739 | Line 789 | SDmapDir(FVECT resVec, RREAL vMtx[3][3], const FVECT i
789          if (vMtx == NULL) {             /* assume they just want to normalize */
790                  if (resVec != inpVec)
791                          VCOPY(resVec, inpVec);
792 <                return (normalize(resVec) > .0) ? SDEnone : SDEargument;
792 >                return (normalize(resVec) > 0) ? SDEnone : SDEargument;
793          }
794          vTmp[0] = DOT(vMtx[0], inpVec);
795          vTmp[1] = DOT(vMtx[1], inpVec);
796          vTmp[2] = DOT(vMtx[2], inpVec);
797 <        if (normalize(vTmp) == .0)
797 >        if (normalize(vTmp) == 0)
798                  return SDEargument;
799          VCOPY(resVec, vTmp);
800          return SDEnone;
# Line 816 | Line 866 | static int     nabases = 3;    /* current number of defined b
866   static int
867   fequal(double a, double b)
868   {
869 <        if (b != .0)
869 >        if (b != 0)
870                  a = a/b - 1.;
871          return((a <= 1e-6) & (a >= -1e-6));
872   }
# Line 1077 | Line 1127 | load_bsdf_data(                /* load BSDF distribution for this wa
1127                          break;
1128                  }
1129          if (i < 0) {
1130 <                sprintf(errmsg, "undefined RowAngleBasis '%s'", cbasis);
1130 >                sprintf(errmsg, "undefined RowAngleBasis '%s'", rbasis);
1131                  error(WARNING, errmsg);
1132                  return;
1133          }
# Line 1134 | Line 1184 | check_bsdf_data(       /* check that BSDF data is sane */
1184          hemi_total = .0;
1185          for (i = dp->ninc; i--; ) {
1186                  dom = getBSDF_incohm(dp,i);
1187 <                if (dom <= .0) {
1187 >                if (dom <= 0) {
1188                          error(WARNING, "zero/negative incoming solid angle");
1189                          continue;
1190                  }
# Line 1157 | Line 1207 | check_bsdf_data(       /* check that BSDF data is sane */
1207          hemi_total = .0;
1208          for (o = dp->nout; o--; ) {
1209                  dom = getBSDF_outohm(dp,o);
1210 <                if (dom <= .0) {
1210 >                if (dom <= 0) {
1211                          error(WARNING, "zero/negative outgoing solid angle");
1212                          continue;
1213                  }
# Line 1181 | Line 1231 | check_bsdf_data(       /* check that BSDF data is sane */
1231                  hemi_total = .0;
1232                  for (o = dp->nout; o--; ) {
1233                          double  f = BSDF_value(dp,i,o);
1234 <                        if (f >= .0)
1234 >                        if (f >= 0)
1235                                  hemi_total += f*omega_oarr[o];
1236                          else {
1237                                  nneg += (f < -FTINY);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines