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.17 by greg, Sat Feb 19 23:42:09 2011 UTC vs.
Revision 2.40 by greg, Mon Mar 5 15:27:08 2012 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 <ctype.h>
19   #include "ezxml.h"
20   #include "hilbert.h"
21   #include "bsdf.h"
# Line 45 | Line 48 | int                    SDretainSet = SDretainNone;
48   SDError
49   SDreportEnglish(SDError ec, FILE *fp)
50   {
48        if (fp == NULL)
49                return ec;
51          if (!ec)
52                  return SDEnone;
53 +        if ((ec < SDEnone) | (ec > SDEunknown)) {
54 +                SDerrorDetail[0] = '\0';
55 +                ec = SDEunknown;
56 +        }
57 +        if (fp == NULL)
58 +                return ec;
59          fputs(SDerrorEnglish[ec], fp);
60          if (SDerrorDetail[0]) {
61                  fputs(": ", fp);
# Line 85 | Line 92 | SDloadGeometry(SDData *sd, ezxml_t wdb)
92  
93          if (wdb == NULL)                /* no geometry section? */
94                  return SDEnone;
95 +        if ((geom = ezxml_child(wdb, "Name")) != NULL) {
96 +                strncpy(sd->matn, ezxml_txt(geom), SDnameLn);
97 +                if (sd->matn[SDnameLn-1])
98 +                        strcpy(sd->matn+(SDnameLn-4), "...");
99 +        }
100 +        if ((geom = ezxml_child(wdb, "Manufacturer")) != NULL) {
101 +                strncpy(sd->makr, ezxml_txt(geom), SDnameLn);
102 +                if (sd->makr[SDnameLn-1])
103 +                        strcpy(sd->makr+(SDnameLn-4), "...");
104 +        }
105          sd->dim[0] = sd->dim[1] = sd->dim[2] = .0;
106 +        SDerrorDetail[0] = '\0';
107          if ((geom = ezxml_child(wdb, "Width")) != NULL)
108                  sd->dim[0] = atof(ezxml_txt(geom)) *
109                                  to_meters(ezxml_attr(geom, "unit"));
# Line 95 | Line 113 | SDloadGeometry(SDData *sd, ezxml_t wdb)
113          if ((geom = ezxml_child(wdb, "Thickness")) != NULL)
114                  sd->dim[2] = atof(ezxml_txt(geom)) *
115                                  to_meters(ezxml_attr(geom, "unit"));
116 <        if ((sd->dim[0] < .0) | (sd->dim[1] < .0) | (sd->dim[2] < .0)) {
117 <                sprintf(SDerrorDetail, "Negative size in \"%s\"", sd->name);
116 >        if ((sd->dim[0] < 0) | (sd->dim[1] < 0) | (sd->dim[2] < 0)) {
117 >                if (!SDerrorDetail[0])
118 >                        sprintf(SDerrorDetail, "Negative dimension in \"%s\"",
119 >                                                sd->name);
120                  return SDEdata;
121          }
122          if ((geom = ezxml_child(wdb, "Geometry")) == NULL ||
123                          (mgfstr = ezxml_txt(geom)) == NULL)
124                  return SDEnone;
125 +        while (isspace(*mgfstr))
126 +                ++mgfstr;
127 +        if (!*mgfstr)
128 +                return SDEnone;
129          if ((fmt = ezxml_attr(geom, "format")) != NULL &&
130                          strcasecmp(fmt, "MGF")) {
131                  sprintf(SDerrorDetail,
# Line 110 | Line 134 | SDloadGeometry(SDData *sd, ezxml_t wdb)
134                  return SDEsupport;
135          }
136          cfact = to_meters(ezxml_attr(geom, "unit"));
137 +        if (cfact <= 0)
138 +                return SDEformat;
139          sd->mgf = (char *)malloc(strlen(mgfstr)+32);
140          if (sd->mgf == NULL) {
141                  strcpy(SDerrorDetail, "Out of memory in SDloadGeometry");
# Line 153 | Line 179 | SDloadFile(SDData *sd, const char *fname)
179          }
180          wtl = ezxml_child(ezxml_child(fl, "Optical"), "Layer");
181          if (wtl == NULL) {
182 <                sprintf(SDerrorDetail, "BSDF \"%s\": no optical layer'",
182 >                sprintf(SDerrorDetail, "BSDF \"%s\": no optical layers'",
183                                  sd->name);
184                  ezxml_free(fl);
185                  return SDEformat;
186          }
187                                  /* load geometry if present */
188          lastErr = SDloadGeometry(sd, ezxml_child(wtl, "Material"));
189 <        if (lastErr)
189 >        if (lastErr) {
190 >                ezxml_free(fl);
191                  return lastErr;
192 +        }
193                                  /* try loading variable resolution data */
194          lastErr = SDloadTre(sd, wtl);
195                                  /* check our result */
196 <        switch (lastErr) {
169 <        case SDEformat:
170 <        case SDEdata:
171 <        case SDEsupport:        /* possibly we just tried the wrong format */
196 >        if (lastErr == SDEsupport)      /* try matrix BSDF if not tree data */
197                  lastErr = SDloadMtx(sd, wtl);
198 <                break;
174 <        default:                /* variable res. OK else serious error */
175 <                break;
176 <        }
198 >                
199                                  /* done with XML file */
200          ezxml_free(fl);
201          
# Line 219 | Line 241 | SDnewSpectralDF(int nc)
241          return df;
242   }
243  
244 + /* Add component(s) to spectral distribution function */
245 + SDSpectralDF *
246 + SDaddComponent(SDSpectralDF *odf, int nadd)
247 + {
248 +        SDSpectralDF    *df;
249 +
250 +        if (odf == NULL)
251 +                return SDnewSpectralDF(nadd);
252 +        if (nadd <= 0)
253 +                return odf;
254 +        df = (SDSpectralDF *)realloc(odf, sizeof(SDSpectralDF) +
255 +                                (odf->ncomp+nadd-1)*sizeof(SDComponent));
256 +        if (df == NULL) {
257 +                sprintf(SDerrorDetail,
258 +                        "Cannot add %d component(s) to spectral DF", nadd);
259 +                SDfreeSpectralDF(odf);
260 +                return NULL;
261 +        }
262 +        memset(df->comp+df->ncomp, 0, nadd*sizeof(SDComponent));
263 +        df->ncomp += nadd;
264 +        return df;
265 + }
266 +
267   /* Free cached cumulative distributions for BSDF component */
268   void
269   SDfreeCumulativeCache(SDSpectralDF *df)
# Line 245 | Line 290 | SDfreeSpectralDF(SDSpectralDF *df)
290                  return;
291          SDfreeCumulativeCache(df);
292          for (n = df->ncomp; n-- > 0; )
293 <                (*df->comp[n].func->freeSC)(df->comp[n].dist);
293 >                if (df->comp[n].dist != NULL)
294 >                        (*df->comp[n].func->freeSC)(df->comp[n].dist);
295          free(df);
296   }
297  
# Line 269 | Line 315 | SDclipName(char *res, const char *fname)
315  
316   /* Initialize an unused BSDF struct (simply clears to zeroes) */
317   void
318 < SDclearBSDF(SDData *sd)
318 > SDclearBSDF(SDData *sd, const char *fname)
319   {
320 <        if (sd != NULL)
321 <                memset(sd, 0, sizeof(SDData));
320 >        if (sd == NULL)
321 >                return;
322 >        memset(sd, 0, sizeof(SDData));
323 >        if (fname == NULL)
324 >                return;
325 >        SDclipName(sd->name, fname);
326   }
327  
328   /* Free data associated with BSDF struct */
# Line 330 | Line 380 | SDgetCache(const char *bname)
380          sdl->next = SDcacheList;
381          SDcacheList = sdl;
382  
383 <        sdl->refcnt++;
383 >        sdl->refcnt = 1;
384          return &sdl->bsdf;
385   }
386  
# Line 374 | Line 424 | SDfreeCache(const SDData *sd)
424          for (sdl = SDcacheList; sdl != NULL; sdl = (sdLast=sdl)->next)
425                  if (&sdl->bsdf == sd)
426                          break;
427 <        if (sdl == NULL || --sdl->refcnt)
427 >        if (sdl == NULL || (sdl->refcnt -= (sdl->refcnt > 0)))
428                  return;                 /* missing or still in use */
429                                          /* keep unreferenced data? */
430          if (SDisLoaded(sd) && SDretainSet) {
# Line 397 | Line 447 | SDfreeCache(const SDData *sd)
447  
448   /* Sample an individual BSDF component */
449   SDError
450 < SDsampComponent(SDValue *sv, FVECT outVec, const FVECT inVec,
401 <                        double randX, SDComponent *sdc)
450 > SDsampComponent(SDValue *sv, FVECT ioVec, double randX, SDComponent *sdc)
451   {
452          float           coef[SDmaxCh];
453          SDError         ec;
454 +        FVECT           inVec;
455          const SDCDst    *cd;
456          double          d;
457          int             n;
458                                          /* check arguments */
459 <        if ((sv == NULL) | (outVec == NULL) | (inVec == NULL) | (sdc == NULL))
459 >        if ((sv == NULL) | (ioVec == NULL) | (sdc == NULL))
460                  return SDEargument;
461                                          /* get cumulative distribution */
462 +        VCOPY(inVec, ioVec);
463          cd = (*sdc->func->getCDist)(inVec, sdc);
464          if (cd == NULL)
465                  return SDEmemory;
466 <        if (cd->cTotal <= 1e-7) {       /* anything to sample? */
466 >        if (cd->cTotal <= 1e-6) {       /* anything to sample? */
467                  sv->spec = c_dfcolor;
468                  sv->cieY = .0;
469 <                memset(outVec, 0, 3*sizeof(double));
469 >                memset(ioVec, 0, 3*sizeof(double));
470                  return SDEnone;
471          }
472          sv->cieY = cd->cTotal;
473                                          /* compute sample direction */
474 <        ec = (*sdc->func->sampCDist)(outVec, randX, cd);
474 >        ec = (*sdc->func->sampCDist)(ioVec, randX, cd);
475          if (ec)
476                  return ec;
477                                          /* get BSDF color */
478 <        n = (*sdc->func->getBSDFs)(coef, outVec, inVec, sdc->dist);
478 >        n = (*sdc->func->getBSDFs)(coef, ioVec, inVec, sdc);
479          if (n <= 0) {
480                  strcpy(SDerrorDetail, "BSDF sample value error");
481                  return SDEinternal;
# Line 451 | Line 502 | SDmultiSamp(double t[], int n, double randX)
502          bitmask_t       ndx, coord[MS_MAXDIM];
503          
504          while (n > MS_MAXDIM)           /* punt for higher dimensions */
505 <                t[--n] = drand48();
505 >                t[--n] = rand()*(1./(RAND_MAX+.5));
506          nBits = (8*sizeof(bitmask_t) - 1) / n;
507          ndx = randX * (double)((bitmask_t)1 << (nBits*n));
508                                          /* get coordinate on Hilbert curve */
# Line 459 | Line 510 | SDmultiSamp(double t[], int n, double randX)
510                                          /* convert back to [0,1) range */
511          scale = 1. / (double)((bitmask_t)1 << nBits);
512          while (n--)
513 <                t[n] = scale * ((double)coord[n] + drand48());
513 >                t[n] = scale * ((double)coord[n] + rand()*(1./(RAND_MAX+.5)));
514   }
515  
516   #undef MS_MAXDIM
# Line 472 | Line 523 | SDdiffuseSamp(FVECT outVec, int outFront, double randX
523          SDmultiSamp(outVec, 2, randX);
524          SDsquare2disk(outVec, outVec[0], outVec[1]);
525          outVec[2] = 1. - outVec[0]*outVec[0] - outVec[1]*outVec[1];
526 <        if (outVec[2] > .0)             /* a bit of paranoia */
526 >        if (outVec[2] > 0)              /* a bit of paranoia */
527                  outVec[2] = sqrt(outVec[2]);
528          if (!outFront)                  /* going out back? */
529                  outVec[2] = -outVec[2];
# Line 480 | Line 531 | SDdiffuseSamp(FVECT outVec, int outFront, double randX
531  
532   /* Query projected solid angle coverage for non-diffuse BSDF direction */
533   SDError
534 < SDsizeBSDF(double *projSA, const FVECT vec, int qflags, const SDData *sd)
534 > SDsizeBSDF(double *projSA, const FVECT v1, const RREAL *v2,
535 >                                int qflags, const SDData *sd)
536   {
537 <        SDSpectralDF    *rdf;
537 >        SDSpectralDF    *rdf, *tdf;
538          SDError         ec;
539          int             i;
540                                          /* check arguments */
541 <        if ((projSA == NULL) | (vec == NULL) | (sd == NULL))
541 >        if ((projSA == NULL) | (v1 == NULL) | (sd == NULL))
542                  return SDEargument;
543                                          /* initialize extrema */
544          switch (qflags) {
# Line 502 | Line 554 | SDsizeBSDF(double *projSA, const FVECT vec, int qflags
554          case 0:
555                  return SDEargument;
556          }
557 <        if (vec[2] > .0)                /* front surface query? */
557 >        if (v1[2] > 0)                  /* front surface query? */
558                  rdf = sd->rf;
559          else
560                  rdf = sd->rb;
561 +        tdf = sd->tf;
562 +        if (v2 != NULL)                 /* bidirectional? */
563 +                if (v1[2] > 0 ^ v2[2] > 0)
564 +                        rdf = NULL;
565 +                else
566 +                        tdf = NULL;
567          ec = SDEdata;                   /* run through components */
568          for (i = (rdf==NULL) ? 0 : rdf->ncomp; i--; ) {
569 <                ec = (*rdf->comp[i].func->queryProjSA)(projSA, vec, qflags,
570 <                                                        rdf->comp[i].dist);
569 >                ec = (*rdf->comp[i].func->queryProjSA)(projSA, v1, v2,
570 >                                                qflags, &rdf->comp[i]);
571                  if (ec)
572                          return ec;
573          }
574 <        for (i = (sd->tf==NULL) ? 0 : sd->tf->ncomp; i--; ) {
575 <                ec = (*sd->tf->comp[i].func->queryProjSA)(projSA, vec, qflags,
576 <                                                        sd->tf->comp[i].dist);
574 >        for (i = (tdf==NULL) ? 0 : tdf->ncomp; i--; ) {
575 >                ec = (*tdf->comp[i].func->queryProjSA)(projSA, v1, v2,
576 >                                                qflags, &tdf->comp[i]);
577                  if (ec)
578                          return ec;
579          }
# Line 539 | Line 597 | SDevalBSDF(SDValue *sv, const FVECT outVec, const FVEC
597          if ((sv == NULL) | (outVec == NULL) | (inVec == NULL) | (sd == NULL))
598                  return SDEargument;
599                                          /* whose side are we on? */
600 <        inFront = (inVec[2] > .0);
601 <        outFront = (outVec[2] > .0);
600 >        inFront = (inVec[2] > 0);
601 >        outFront = (outVec[2] > 0);
602                                          /* start with diffuse portion */
603          if (inFront & outFront) {
604                  *sv = sd->rLambFront;
# Line 557 | Line 615 | SDevalBSDF(SDValue *sv, const FVECT outVec, const FVEC
615          i = (sdf != NULL) ? sdf->ncomp : 0;
616          while (i-- > 0) {
617                  nch = (*sdf->comp[i].func->getBSDFs)(coef, outVec, inVec,
618 <                                                        sdf->comp[i].dist);
618 >                                                        &sdf->comp[i]);
619                  while (nch-- > 0) {
620                          c_cmix(&sv->spec, sv->cieY, &sv->spec,
621                                          coef[nch], &sdf->comp[i].cspec[nch]);
# Line 581 | Line 639 | SDdirectHemi(const FVECT inVec, int sflags, const SDDa
639          if ((inVec == NULL) | (sd == NULL))
640                  return .0;
641                                          /* gather diffuse components */
642 <        if (inVec[2] > .0) {
642 >        if (inVec[2] > 0) {
643                  hsum = sd->rLambFront.cieY;
644                  rdf = sd->rf;
645          } else /* !inFront */ {
# Line 612 | Line 670 | SDdirectHemi(const FVECT inVec, int sflags, const SDDa
670  
671   /* Sample BSDF direction based on the given random variable */
672   SDError
673 < SDsampBSDF(SDValue *sv, FVECT outVec, const FVECT inVec,
616 <                        double randX, int sflags, const SDData *sd)
673 > SDsampBSDF(SDValue *sv, FVECT ioVec, double randX, int sflags, const SDData *sd)
674   {
675          SDError         ec;
676 +        FVECT           inVec;
677          int             inFront;
678          SDSpectralDF    *rdf;
679          double          rdiff;
# Line 624 | Line 682 | SDsampBSDF(SDValue *sv, FVECT outVec, const FVECT inVe
682          SDComponent     *sdc;
683          const SDCDst    **cdarr = NULL;
684                                          /* check arguments */
685 <        if ((sv == NULL) | (outVec == NULL) | (inVec == NULL) | (sd == NULL) |
686 <                        (randX < .0) | (randX >= 1.))
685 >        if ((sv == NULL) | (ioVec == NULL) | (sd == NULL) |
686 >                        (randX < 0) | (randX >= 1.))
687                  return SDEargument;
688                                          /* whose side are we on? */
689 <        inFront = (inVec[2] > .0);
689 >        VCOPY(inVec, ioVec);
690 >        inFront = (inVec[2] > 0);
691                                          /* remember diffuse portions */
692          if (inFront) {
693                  *sv = sd->rLambFront;
# Line 666 | Line 725 | SDsampBSDF(SDValue *sv, FVECT outVec, const FVECT inVe
725                  }
726                  sv->cieY += cdarr[i]->cTotal;
727          }
728 <        if (sv->cieY <= 1e-7) {         /* anything to sample? */
728 >        if (sv->cieY <= 1e-6) {         /* anything to sample? */
729                  sv->cieY = .0;
730 <                memset(outVec, 0, 3*sizeof(double));
730 >                memset(ioVec, 0, 3*sizeof(double));
731                  return SDEnone;
732          }
733                                          /* scale random variable */
734          randX *= sv->cieY;
735                                          /* diffuse reflection? */
736          if (randX < rdiff) {
737 <                SDdiffuseSamp(outVec, inFront, randX/rdiff);
737 >                SDdiffuseSamp(ioVec, inFront, randX/rdiff);
738                  goto done;
739          }
740          randX -= rdiff;
# Line 683 | Line 742 | SDsampBSDF(SDValue *sv, FVECT outVec, const FVECT inVe
742          if ((sflags & SDsampDf+SDsampT) == SDsampDf+SDsampT) {
743                  if (randX < sd->tLamb.cieY) {
744                          sv->spec = sd->tLamb.spec;
745 <                        SDdiffuseSamp(outVec, !inFront, randX/sd->tLamb.cieY);
745 >                        SDdiffuseSamp(ioVec, !inFront, randX/sd->tLamb.cieY);
746                          goto done;
747                  }
748                  randX -= sd->tLamb.cieY;
# Line 695 | Line 754 | SDsampBSDF(SDValue *sv, FVECT outVec, const FVECT inVe
754                  return SDEinternal;
755                                          /* compute sample direction */
756          sdc = (i < nr) ? &rdf->comp[i] : &sd->tf->comp[i-nr];
757 <        ec = (*sdc->func->sampCDist)(outVec, randX/cdarr[i]->cTotal, cdarr[i]);
757 >        ec = (*sdc->func->sampCDist)(ioVec, randX/cdarr[i]->cTotal, cdarr[i]);
758          if (ec)
759                  return ec;
760                                          /* compute color */
761 <        j = (*sdc->func->getBSDFs)(coef, outVec, inVec, sdc->dist);
761 >        j = (*sdc->func->getBSDFs)(coef, ioVec, inVec, sdc);
762          if (j <= 0) {
763                  sprintf(SDerrorDetail, "BSDF \"%s\" sampling value error",
764                                  sd->name);
# Line 726 | Line 785 | SDcompXform(RREAL vMtx[3][3], const FVECT sNrm, const
785          if ((vMtx == NULL) | (sNrm == NULL) | (uVec == NULL))
786                  return SDEargument;
787          VCOPY(vMtx[2], sNrm);
788 <        if (normalize(vMtx[2]) == .0)
788 >        if (normalize(vMtx[2]) == 0)
789                  return SDEargument;
790          fcross(vMtx[0], uVec, vMtx[2]);
791 <        if (normalize(vMtx[0]) == .0)
791 >        if (normalize(vMtx[0]) == 0)
792                  return SDEargument;
793          fcross(vMtx[1], vMtx[2], vMtx[0]);
794          return SDEnone;
# Line 749 | Line 808 | SDinvXform(RREAL iMtx[3][3], RREAL vMtx[3][3])
808          mTmp[0][1] = vMtx[2][1]*vMtx[0][2] - vMtx[2][2]*vMtx[0][1];
809          mTmp[0][2] = vMtx[1][2]*vMtx[0][1] - vMtx[1][1]*vMtx[0][2];
810          d = vMtx[0][0]*mTmp[0][0] + vMtx[1][0]*mTmp[0][1] + vMtx[2][0]*mTmp[0][2];
811 <        if (d == .0) {
811 >        if (d == 0) {
812                  strcpy(SDerrorDetail, "Zero determinant in matrix inversion");
813                  return SDEargument;
814          }
# Line 776 | Line 835 | SDmapDir(FVECT resVec, RREAL vMtx[3][3], const FVECT i
835          if (vMtx == NULL) {             /* assume they just want to normalize */
836                  if (resVec != inpVec)
837                          VCOPY(resVec, inpVec);
838 <                return (normalize(resVec) > .0) ? SDEnone : SDEargument;
838 >                return (normalize(resVec) > 0) ? SDEnone : SDEargument;
839          }
840          vTmp[0] = DOT(vMtx[0], inpVec);
841          vTmp[1] = DOT(vMtx[1], inpVec);
842          vTmp[2] = DOT(vMtx[2], inpVec);
843 <        if (normalize(vTmp) == .0)
843 >        if (normalize(vTmp) == 0)
844                  return SDEargument;
845          VCOPY(resVec, vTmp);
846          return SDEnone;
# Line 796 | Line 855 | SDmapDir(FVECT resVec, RREAL vMtx[3][3], const FVECT i
855  
856   #include "standard.h"
857   #include "paths.h"
799 #include <ctype.h>
858  
859   #define MAXLATS         46              /* maximum number of latitudes */
860  
# Line 853 | Line 911 | static int     nabases = 3;    /* current number of defined b
911   static int
912   fequal(double a, double b)
913   {
914 <        if (b != .0)
914 >        if (b != 0)
915                  a = a/b - 1.;
916          return((a <= 1e-6) & (a >= -1e-6));
917   }
# Line 916 | Line 974 | ab_getndx(             /* get index corresponding to the given ve
974   {
975          ANGLE_BASIS  *ab = (ANGLE_BASIS *)p;
976          int     li, ndx;
977 <        double  pol, azi, d;
977 >        double  pol, azi;
978  
979          if ((v[2] < -1.0) | (v[2] > 1.0))
980                  return(-1);
# Line 1156 | Line 1214 | check_bsdf_data(       /* check that BSDF data is sane */
1214   )
1215   {
1216          double          *omega_iarr, *omega_oarr;
1217 <        double          dom, contrib, hemi_total, full_total;
1217 >        double          dom, hemi_total, full_total;
1218          int             nneg;
1219          FVECT           v;
1220          int             i, o;
# Line 1171 | Line 1229 | check_bsdf_data(       /* check that BSDF data is sane */
1229          hemi_total = .0;
1230          for (i = dp->ninc; i--; ) {
1231                  dom = getBSDF_incohm(dp,i);
1232 <                if (dom <= .0) {
1232 >                if (dom <= 0) {
1233                          error(WARNING, "zero/negative incoming solid angle");
1234                          continue;
1235                  }
# Line 1194 | Line 1252 | check_bsdf_data(       /* check that BSDF data is sane */
1252          hemi_total = .0;
1253          for (o = dp->nout; o--; ) {
1254                  dom = getBSDF_outohm(dp,o);
1255 <                if (dom <= .0) {
1255 >                if (dom <= 0) {
1256                          error(WARNING, "zero/negative outgoing solid angle");
1257                          continue;
1258                  }
# Line 1218 | Line 1276 | check_bsdf_data(       /* check that BSDF data is sane */
1276                  hemi_total = .0;
1277                  for (o = dp->nout; o--; ) {
1278                          double  f = BSDF_value(dp,i,o);
1279 <                        if (f >= .0)
1279 >                        if (f >= 0)
1280                                  hemi_total += f*omega_oarr[o];
1281                          else {
1282                                  nneg += (f < -FTINY);
# Line 1306 | Line 1364 | load_BSDF(             /* load BSDF data from file */
1364                  error(WARNING, errmsg);
1365                  ezxml_free(fl);
1366                  return(NULL);
1367 <        }              
1368 <        load_angle_basis(ezxml_child(ezxml_child(wtl,
1369 <                                "DataDefinition"), "AngleBasis"));
1367 >        }
1368 >        for (wld = ezxml_child(ezxml_child(wtl,
1369 >                                "DataDefinition"), "AngleBasis");
1370 >                        wld != NULL; wld = wld->next)
1371 >                load_angle_basis(wld);
1372          dp = (struct BSDF_data *)calloc(1, sizeof(struct BSDF_data));
1373          load_geometry(dp, ezxml_child(wtl, "Material"));
1374          for (wld = ezxml_child(wtl, "WavelengthData");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines