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.44 by greg, Sun Apr 21 21:36:23 2013 UTC vs.
Revision 2.45 by greg, Wed Jul 3 18:56:19 2013 UTC

# Line 488 | Line 488 | SDsampComponent(SDValue *sv, FVECT ioVec, double randX
488                  return SDEargument;
489                                          /* get cumulative distribution */
490          VCOPY(inVec, ioVec);
491 +        sv->cieY = 0;
492          cd = (*sdc->func->getCDist)(inVec, sdc);
493 <        if (cd == NULL)
494 <                return SDEmemory;
495 <        if (cd->cTotal <= 1e-6) {       /* anything to sample? */
493 >        if (cd != NULL)
494 >                sv->cieY = cd->cTotal;
495 >        if (sv->cieY <= 1e-6) {         /* nothing to sample? */
496                  sv->spec = c_dfcolor;
496                sv->cieY = .0;
497                  memset(ioVec, 0, 3*sizeof(double));
498                  return SDEnone;
499          }
500        sv->cieY = cd->cTotal;
500                                          /* compute sample direction */
501          ec = (*sdc->func->sampCDist)(ioVec, randX, cd);
502          if (ec)
# Line 756 | Line 755 | SDsampBSDF(SDValue *sv, FVECT ioVec, double randX, int
755                  return SDEmemory;
756          while (j-- > 0) {               /* non-diffuse transmission */
757                  cdarr[i+j] = (*tdf->comp[j].func->getCDist)(inVec, &tdf->comp[j]);
758 <                if (cdarr[i+j] == NULL) {
759 <                        free(cdarr);
761 <                        return SDEmemory;
762 <                }
758 >                if (cdarr[i+j] == NULL)
759 >                        cdarr[i+j] = &SDemptyCD;
760                  sv->cieY += cdarr[i+j]->cTotal;
761          }
762          while (i-- > 0) {               /* non-diffuse reflection */
763                  cdarr[i] = (*rdf->comp[i].func->getCDist)(inVec, &rdf->comp[i]);
764 <                if (cdarr[i] == NULL) {
765 <                        free(cdarr);
766 <                        return SDEmemory;
767 <                }
771 <                sv->cieY += cdarr[i]->cTotal;
764 >                if (cdarr[i] == NULL)
765 >                        cdarr[i] = &SDemptyCD;
766 >                else
767 >                        sv->cieY += cdarr[i]->cTotal;
768          }
769          if (sv->cieY <= 1e-6) {         /* anything to sample? */
770                  sv->cieY = .0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines