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.34 by greg, Thu Jul 7 15:25:09 2011 UTC vs.
Revision 2.37 by greg, Sun Mar 4 20:11:10 2012 UTC

# Line 171 | Line 171 | SDloadFile(SDData *sd, const char *fname)
171          }
172                                  /* load geometry if present */
173          lastErr = SDloadGeometry(sd, ezxml_child(wtl, "Material"));
174 <        if (lastErr)
174 >        if (lastErr) {
175 >                ezxml_free(fl);
176                  return lastErr;
177 +        }
178                                  /* try loading variable resolution data */
179          lastErr = SDloadTre(sd, wtl);
180                                  /* check our result */
# Line 224 | Line 226 | SDnewSpectralDF(int nc)
226          return df;
227   }
228  
229 + /* Add component(s) to spectral distribution function */
230 + SDSpectralDF *
231 + SDaddComponent(SDSpectralDF *odf, int nadd)
232 + {
233 +        SDSpectralDF    *df;
234 +
235 +        if (odf == NULL)
236 +                return SDnewSpectralDF(nadd);
237 +        if (nadd <= 0)
238 +                return odf;
239 +        df = (SDSpectralDF *)realloc(odf, sizeof(SDSpectralDF) +
240 +                                (odf->ncomp+nadd-1)*sizeof(SDComponent));
241 +        if (df == NULL) {
242 +                sprintf(SDerrorDetail,
243 +                        "Cannot add %d component(s) to spectral DF", nadd);
244 +                SDfreeSpectralDF(odf);
245 +                return NULL;
246 +        }
247 +        memset(df->comp+df->ncomp, 0, nadd*sizeof(SDComponent));
248 +        df->ncomp += nadd;
249 +        return df;
250 + }
251 +
252   /* Free cached cumulative distributions for BSDF component */
253   void
254   SDfreeCumulativeCache(SDSpectralDF *df)
# Line 423 | Line 448 | SDsampComponent(SDValue *sv, FVECT ioVec, double randX
448          cd = (*sdc->func->getCDist)(inVec, sdc);
449          if (cd == NULL)
450                  return SDEmemory;
451 <        if (cd->cTotal <= 1e-7) {       /* anything to sample? */
451 >        if (cd->cTotal <= 1e-6) {       /* anything to sample? */
452                  sv->spec = c_dfcolor;
453                  sv->cieY = .0;
454                  memset(ioVec, 0, 3*sizeof(double));
# Line 685 | Line 710 | SDsampBSDF(SDValue *sv, FVECT ioVec, double randX, int
710                  }
711                  sv->cieY += cdarr[i]->cTotal;
712          }
713 <        if (sv->cieY <= 1e-7) {         /* anything to sample? */
713 >        if (sv->cieY <= 1e-6) {         /* anything to sample? */
714                  sv->cieY = .0;
715                  memset(ioVec, 0, 3*sizeof(double));
716                  return SDEnone;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines