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

Comparing ray/src/common/bsdf_t.c (file contents):
Revision 3.20 by greg, Sun Aug 21 22:38:12 2011 UTC vs.
Revision 3.21 by greg, Mon Aug 22 05:48:39 2011 UTC

# Line 607 | Line 607 | const SDCDst *
607   SDgetTreCDist(const FVECT inVec, SDComponent *sdc)
608   {
609          const SDTre     *sdt;
610 <        double          inCoord[2];
610 >        double          inCoord[2], quantum;
611          int             i;
612          SDTreCDst       *cd, *cdlast;
613                                          /* check arguments */
614          if ((inVec == NULL) | (sdc == NULL) ||
615                          (sdt = (SDTre *)sdc->dist) == NULL)
616                  return NULL;
617 <        if (sdt->st->ndim == 3)         /* isotropic BSDF? */
617 >        if (sdt->st->ndim == 3) {       /* isotropic BSDF? */
618                  inCoord[0] = .5 - .5*sqrt(inVec[0]*inVec[0] + inVec[1]*inVec[1]);
619 <        else if (sdt->st->ndim == 4)
619 >        } else if (sdt->st->ndim == 4) {
620                  SDdisk2square(inCoord, -inVec[0], -inVec[1]);
621 <        else
621 >        } else
622                  return NULL;            /* should be internal error */
623 +                                        /* quantize to avoid f.p. errors */
624 +        quantum = SDsmallestLeaf(sdt->st);
625 +        for (i = sdt->st->ndim - 2; i--; )
626 +                inCoord[i] = floor(inCoord[i]/quantum)*quantum + .5*quantum;
627          cdlast = NULL;                  /* check for direction in cache list */
628          for (cd = (SDTreCDst *)sdc->cdList; cd != NULL;
629                                          cdlast = cd, cd = cd->next) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines