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.10 by greg, Thu Apr 28 04:05:11 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 +        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          return (int)((*(const struct outdir_s *)p1).hent -
510                          (*(const struct outdir_s *)p2).hent);
511 + */
512   }
513  
514   /* Create a new cumulative distribution for the given input direction */
# Line 922 | Line 931 | load_bsdf_data(SDData *sd, ezxml_t wdb, int ndim)
931   static float
932   SDgetTreMin(const SDNode *st)
933   {
934 <        float   vmin = 1./M_PI;
934 >        float   vmin = FHUGE;
935          int     n;
936  
937          if (st->log2GR < 0) {
# Line 960 | Line 969 | subtract_min(SDNode *st)
969   {
970          float   vmin;
971                                          /* be sure to skip unused portion */
972 <        if ((st->ndim == 3) & (st->log2GR < 0)) {
973 <                float   v;
965 <                int     i;
972 >        if (st->ndim == 3) {
973 >                int     n;
974                  vmin = 1./M_PI;
975 <                for (i = 0; i < 4; i++) {
976 <                        v = SDgetTreMin(st->u.t[i]);
977 <                        if (v < vmin)
978 <                                vmin = v;
979 <                }
975 >                if (st->log2GR < 0) {
976 >                        for (n = 0; n < 4; n++) {
977 >                                float   v = SDgetTreMin(st->u.t[n]);
978 >                                if (v < vmin)
979 >                                        vmin = v;
980 >                        }
981 >                } else if (st->log2GR) {
982 >                        for (n = 1 << (3*st->log2GR - 1); n--; )
983 >                                if (st->u.v[n] < vmin)
984 >                                        vmin = st->u.v[n];
985 >                } else
986 >                        vmin = st->u.v[0];
987          } else                          /* anisotropic covers entire tree */
988                  vmin = SDgetTreMin(st);
989  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines