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.46 by greg, Thu Jul 4 15:14:45 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 619 | Line 618 | SDsizeBSDF(double *projSA, const FVECT v1, const RREAL
618                  projSA[0] = M_PI;
619                  if (qflags == SDqueryMin+SDqueryMax)
620                          projSA[1] = M_PI;
621 <        }
621 >        } else if (qflags == SDqueryMin+SDqueryMax && projSA[0] > projSA[1])
622 >                projSA[0] = projSA[1];
623          return SDEnone;
624   }
625  
# Line 756 | Line 756 | SDsampBSDF(SDValue *sv, FVECT ioVec, double randX, int
756                  return SDEmemory;
757          while (j-- > 0) {               /* non-diffuse transmission */
758                  cdarr[i+j] = (*tdf->comp[j].func->getCDist)(inVec, &tdf->comp[j]);
759 <                if (cdarr[i+j] == NULL) {
760 <                        free(cdarr);
761 <                        return SDEmemory;
762 <                }
759 >                if (cdarr[i+j] == NULL)
760 >                        cdarr[i+j] = &SDemptyCD;
761                  sv->cieY += cdarr[i+j]->cTotal;
762          }
763          while (i-- > 0) {               /* non-diffuse reflection */
764                  cdarr[i] = (*rdf->comp[i].func->getCDist)(inVec, &rdf->comp[i]);
765 <                if (cdarr[i] == NULL) {
766 <                        free(cdarr);
767 <                        return SDEmemory;
768 <                }
771 <                sv->cieY += cdarr[i]->cTotal;
765 >                if (cdarr[i] == NULL)
766 >                        cdarr[i] = &SDemptyCD;
767 >                else
768 >                        sv->cieY += cdarr[i]->cTotal;
769          }
770          if (sv->cieY <= 1e-6) {         /* anything to sample? */
771                  sv->cieY = .0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines