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.9 by greg, Wed Apr 27 23:05:51 2011 UTC vs.
Revision 3.11 by greg, Thu Apr 28 17:46:25 2011 UTC

# Line 129 | Line 129 | grid_branch_start(SDNode *st, int n)
129          float           *vptr = st->u.v;
130          int             i;
131  
132 <        for (i = st->ndim; i--; skipsiz <<= st->log2GR)
133 <                if (1<<i & n)
132 >        for (i = 0; i < st->ndim; skipsiz <<= st->log2GR)
133 >                if (1<<i++ & n)
134                          vptr += skipsiz >> 1;
135          return vptr;
136   }
# Line 187 | Line 187 | SDsmallestLeaf(const SDNode *st)
187   static double
188   SDiterSum(const float *va, int nd, int shft, const int *imin, const int *imax)
189   {
190 <        const unsigned  skipsiz = 1 << nd*shft;
190 >        const unsigned  skipsiz = 1 << --nd*shft;
191          double          sum = .0;
192          int             i;
193          
# Line 196 | Line 196 | SDiterSum(const float *va, int nd, int shft, const int
196                          sum += va[i];
197          else
198                  for (i = *imin; i < *imax; i++)
199 <                        sum += SDiterSum(va + i*skipsiz,
200 <                                        nd-1, shft, imin+1, imax+1);
199 >                        sum += SDiterSum(va + i*skipsiz, nd, shft, imin+1, imax+1);
200          return sum;
201   }
202  
# Line 484 | Line 483 | build_scaffold(float val, const double *cmin, double c
483                                          /* find Hilbert entry index */
484          bmin[0] = cmin[0]*(double)iwmax + .5;
485          bmin[1] = cmin[1]*(double)iwmax + .5;
486 <        bmax[0] = bmin[0] + wid;
487 <        bmax[1] = bmin[1] + wid;
486 >        bmax[0] = bmin[0] + wid-1;
487 >        bmax[1] = bmin[1] + wid-1;
488          hilbert_box_vtx(2, sizeof(bitmask_t), iwbits, 1, bmin, bmax);
489          sp->darr[sp->alen].hent = hilbert_c2i(2, iwbits, bmin);
490          sp->darr[sp->alen].wid = wid;
# Line 498 | Line 497 | build_scaffold(float val, const double *cmin, double c
497   static int
498   sscmp(const void *p1, const void *p2)
499   {
500 <        return (int)((*(const struct outdir_s *)p1).hent -
501 <                        (*(const struct outdir_s *)p2).hent);
500 >        unsigned        h1 = (*(const struct outdir_s *)p1).hent;
501 >        unsigned        h2 = (*(const struct outdir_s *)p2).hent;
502 >
503 >        if (h1 > h2)
504 >                return 1;
505 >        if (h1 < h2)
506 >                return -1;
507 >        return 0;
508   }
509  
510   /* Create a new cumulative distribution for the given input direction */
# Line 721 | Line 726 | count_values(char *cp)
726          int     n = 0;
727  
728          while (next_token(&cp) != '}' && *cp) {
729 <                if (*cp == '{')
730 <                        return -1;
731 <                while (*cp && (*cp != ',') & (*cp != '}') & !isspace(*cp))
727 <                        ++cp;
729 >                while (!isspace(*cp) & (*cp != ',') & (*cp != '}'))
730 >                        if (!*++cp)
731 >                                break;
732                  ++n;
733                  eat_token(&cp, ',');
734          }
# Line 769 | Line 773 | load_tree_data(char **spp, int nd)
773          } else {                        /* else load value grid */
774                  int     bsiz;
775                  n = count_values(*spp); /* see how big the grid is */
772                if (n <= 0) {
773                        strcpy(SDerrorDetail, "Bad tensor tree data");
774                        return NULL;
775                }
776                  for (bsiz = 0; bsiz < 8*sizeof(size_t)-1; bsiz += nd)
777                          if (1<<bsiz == n)
778                                  break;
# Line 922 | Line 922 | load_bsdf_data(SDData *sd, ezxml_t wdb, int ndim)
922   static float
923   SDgetTreMin(const SDNode *st)
924   {
925 <        float   vmin = 1./M_PI;
925 >        float   vmin = FHUGE;
926          int     n;
927  
928          if (st->log2GR < 0) {
# Line 960 | Line 960 | subtract_min(SDNode *st)
960   {
961          float   vmin;
962                                          /* be sure to skip unused portion */
963 <        if ((st->ndim == 3) & (st->log2GR < 0)) {
964 <                float   v;
965 <                int     i;
963 >        if (st->ndim == 3) {
964 >                int     n;
965                  vmin = 1./M_PI;
966 <                for (i = 0; i < 4; i++) {
967 <                        v = SDgetTreMin(st->u.t[i]);
968 <                        if (v < vmin)
969 <                                vmin = v;
970 <                }
966 >                if (st->log2GR < 0) {
967 >                        for (n = 0; n < 4; n++) {
968 >                                float   v = SDgetTreMin(st->u.t[n]);
969 >                                if (v < vmin)
970 >                                        vmin = v;
971 >                        }
972 >                } else if (st->log2GR) {
973 >                        for (n = 1 << (3*st->log2GR - 1); n--; )
974 >                                if (st->u.v[n] < vmin)
975 >                                        vmin = st->u.v[n];
976 >                } else
977 >                        vmin = st->u.v[0];
978          } else                          /* anisotropic covers entire tree */
979                  vmin = SDgetTreMin(st);
980  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines