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.24 by greg, Sun Sep 2 15:33:15 2012 UTC vs.
Revision 3.31 by greg, Thu Aug 8 05:26:56 2013 UTC

# Line 468 | Line 468 | SDqueryTre(const SDTre *sdt, const FVECT outVec, const
468                                          /* convert vector coordinates */
469          if (sdt->st->ndim == 3) {
470                  spinvector(rOutVec, outVec, zvec, -atan2(-inVec[1],-inVec[0]));
471 <                gridPos[0] = .5 - .5*sqrt(inVec[0]*inVec[0] + inVec[1]*inVec[1]);
471 >                gridPos[0] = (.5-FTINY) -
472 >                                .5*sqrt(inVec[0]*inVec[0] + inVec[1]*inVec[1]);
473                  SDdisk2square(gridPos+1, rOutVec[0], rOutVec[1]);
474          } else if (sdt->st->ndim == 4) {
475                  SDdisk2square(gridPos, -inVec[0], -inVec[1]);
# Line 499 | Line 500 | build_scaffold(float val, const double *cmin, double c
500   {
501          SDdistScaffold  *sp = (SDdistScaffold *)cptr;
502          int             wid = csiz*(double)iwmax + .5;
503 +        double          revcmin[2];
504          bitmask_t       bmin[2], bmax[2];
505  
506 <        cmin += sp->nic * !sp->rev;     /* skip to output coords */
506 >        if (sp->rev) {                  /* need to reverse sense? */
507 >                revcmin[0] = 1. - cmin[0] - csiz;
508 >                revcmin[1] = 1. - cmin[1] - csiz;
509 >                cmin = revcmin;
510 >        } else {
511 >                cmin += sp->nic;        /* else skip to output coords */
512 >        }
513          if (wid < sp->wmin)             /* new minimum width? */
514                  sp->wmin = wid;
515          if (wid > sp->wmax)             /* new maximum? */
# Line 596 | Line 604 | make_cdist(const SDTre *sdt, const double *invec, int
604                                          /* record input range */
605          scale = myScaffold.wmin / (double)iwmax;
606          for (i = myScaffold.nic; i--; ) {
607 <                cd->clim[i][0] = floor(pos[i]/scale) * scale;
607 >                cd->clim[i][0] = floor(pos[i+2*rev]/scale) * scale;
608                  cd->clim[i][1] = cd->clim[i][0] + scale;
609          }
610          if (cd->isodist) {              /* avoid issue in SDqueryTreProjSA() */
# Line 665 | Line 673 | SDgetTreCDist(const FVECT inVec, SDComponent *sdc)
673          if (sdt->st->ndim == 3) {       /* isotropic BSDF? */
674                  if (mode != sdt->sidef) /* XXX unhandled reciprocity */
675                          return &SDemptyCD;
676 <                inCoord[0] = .5 - .5*sqrt(inVec[0]*inVec[0] + inVec[1]*inVec[1]);
676 >                inCoord[0] = (.5-FTINY) -
677 >                                .5*sqrt(inVec[0]*inVec[0] + inVec[1]*inVec[1]);
678          } else if (sdt->st->ndim == 4) {
679 <                SDdisk2square(inCoord, -inVec[0], -inVec[1]);
679 >                if (mode != sdt->sidef) /* use reciprocity? */
680 >                        SDdisk2square(inCoord, inVec[0], inVec[1]);
681 >                else
682 >                        SDdisk2square(inCoord, -inVec[0], -inVec[1]);
683          } else
684                  return NULL;            /* should be internal error */
685                                          /* quantize to avoid f.p. errors */
# Line 718 | Line 730 | SDqueryTreProjSA(double *psa, const FVECT v1, const RR
730          } else {
731                  const SDTreCDst *cd = (const SDTreCDst *)SDgetTreCDist(v1, sdc);
732                  if (cd == NULL)
733 <                        return SDEmemory;
734 <                myPSA[0] = M_PI * (cd->clim[0][1] - cd->clim[0][0]) *
735 <                                (cd->clim[1][1] - cd->clim[1][0]);
736 <                myPSA[1] = cd->max_psa;
733 >                        myPSA[0] = myPSA[1] = 0;
734 >                else {
735 >                        myPSA[0] = M_PI * (cd->clim[0][1] - cd->clim[0][0]) *
736 >                                        (cd->clim[1][1] - cd->clim[1][0]);
737 >                        myPSA[1] = cd->max_psa;
738 >                }
739          }
740          switch (qflags) {               /* record based on flag settings */
741          case SDqueryVal:
# Line 736 | Line 750 | SDqueryTreProjSA(double *psa, const FVECT v1, const RR
750                          psa[1] = myPSA[1];
751                  /* fall through */
752          case SDqueryMin:
753 <                if (myPSA[0] < psa[0])
753 >                if ((myPSA[0] > 0) & (myPSA[0] < psa[0]))
754                          psa[0] = myPSA[0];
755                  break;
756          }
# Line 947 | Line 961 | load_bsdf_data(SDData *sd, ezxml_t wdb, int ndim)
961           * Remember that front and back are reversed from WINDOW 6 orientations
962           */
963          if (!strcasecmp(sdata, "Transmission Front")) {
950                if (sd->tf != NULL)
951                        SDfreeSpectralDF(sd->tf);
952                if ((sd->tf = SDnewSpectralDF(1)) == NULL)
953                        return SDEmemory;
954                df = sd->tf;
955        } else if (!strcasecmp(sdata, "Transmission Back")) {
964                  if (sd->tb != NULL)
965                          SDfreeSpectralDF(sd->tb);
966                  if ((sd->tb = SDnewSpectralDF(1)) == NULL)
967                          return SDEmemory;
968                  df = sd->tb;
969 +        } else if (!strcasecmp(sdata, "Transmission Back")) {
970 +                if (sd->tf != NULL)
971 +                        SDfreeSpectralDF(sd->tf);
972 +                if ((sd->tf = SDnewSpectralDF(1)) == NULL)
973 +                        return SDEmemory;
974 +                df = sd->tf;
975          } else if (!strcasecmp(sdata, "Reflection Front")) {
976 <                if (sd->rb != NULL)     /* note back-front reversal */
976 >                if (sd->rb != NULL)
977                          SDfreeSpectralDF(sd->rb);
978                  if ((sd->rb = SDnewSpectralDF(1)) == NULL)
979                          return SDEmemory;
980                  df = sd->rb;
981          } else if (!strcasecmp(sdata, "Reflection Back")) {
982 <                if (sd->rf != NULL)     /* note front-back reversal */
982 >                if (sd->rf != NULL)
983                          SDfreeSpectralDF(sd->rf);
984                  if ((sd->rf = SDnewSpectralDF(1)) == NULL)
985                          return SDEmemory;
# Line 1153 | Line 1167 | SDloadTre(SDData *sd, ezxml_t wtl)
1167                                          /* separate diffuse components */
1168          extract_diffuse(&sd->rLambFront, sd->rf);
1169          extract_diffuse(&sd->rLambBack, sd->rb);
1170 <        extract_diffuse(&sd->tLamb, (sd->tf != NULL) ? sd->tf : sd->tb);
1170 >        if (sd->tf != NULL)
1171 >                extract_diffuse(&sd->tLamb, sd->tf);
1172 >        if (sd->tb != NULL)
1173 >                extract_diffuse(&sd->tLamb, sd->tb);
1174                                          /* return success */
1175          return SDEnone;
1176   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines