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.8 by greg, Wed Apr 27 20:05:15 2011 UTC vs.
Revision 3.9 by greg, Wed Apr 27 23:05:51 2011 UTC

# Line 151 | Line 151 | SDsimplifyTre(SDNode *st)
151                          return NULL;    /* propogate error up call stack */
152                  match &= (st->u.t[n]->log2GR == st->u.t[0]->log2GR);
153          }
154 <        if (match && st->u.t[0]->log2GR >= 0) {
155 <                SDNode  *stn = SDnewNode(st->ndim, st->u.t[0]->log2GR + 1);
154 >        if (match && (match = st->u.t[0]->log2GR) >= 0) {
155 >                SDNode  *stn = SDnewNode(st->ndim, match + 1);
156                  if (stn == NULL)        /* out of memory? */
157                          return st;
158                                          /* transfer values to new grid */
159                  for (n = 1 << st->ndim; n--; )
160                          fill_grid_branch(grid_branch_start(stn, n),
161 <                                        st->u.t[n]->u.v, st->ndim, st->log2GR);
161 >                                        st->u.t[n]->u.v, stn->ndim, stn->log2GR);
162                  SDfreeTre(st);          /* free old tree */
163                  st = stn;               /* return new one */
164          }
# Line 712 | Line 712 | next_token(char **spp)
712          return **spp;
713   }
714  
715 + #define eat_token(spp,c)        (next_token(spp)==(c) ? *(*(spp))++ : 0)
716 +
717   /* Count words from this point in string to '}' */
718   static int
719   count_values(char *cp)
720   {
721          int     n = 0;
722  
723 <        while (next_token(&cp) != '}') {
723 >        while (next_token(&cp) != '}' && *cp) {
724                  if (*cp == '{')
725                          return -1;
726 <                while (*cp && !isspace(*cp))
726 >                while (*cp && (*cp != ',') & (*cp != '}') & !isspace(*cp))
727                          ++cp;
728                  ++n;
729 <                cp += (next_token(&cp) == ',');
729 >                eat_token(&cp, ',');
730          }
731          return n;
732   }
# Line 739 | Line 741 | load_values(char **spp, float *va, int n)
741          while (n-- > 0 && (svnext = fskip(*spp)) != NULL) {
742                  *v++ = atof(*spp);
743                  *spp = svnext;
744 <                *spp += (next_token(spp) == ',');
744 >                eat_token(spp, ',');
745          }
746          return v - va;
747   }
# Line 751 | Line 753 | load_tree_data(char **spp, int nd)
753          SDNode  *st;
754          int     n;
755  
756 <        if (next_token(spp) != '{') {
756 >        if (!eat_token(spp, '{')) {
757                  strcpy(SDerrorDetail, "Missing '{' in tensor tree");
758                  return NULL;
759          }
758        ++*spp;                         /* in tree, now */
760          if (next_token(spp) == '{') {   /* tree branches */
761                  st = SDnewNode(nd, -1);
762                  if (st == NULL)
# Line 788 | Line 789 | load_tree_data(char **spp, int nd)
789                          return NULL;
790                  }
791          }
792 <        if (next_token(spp) != '}') {
792 >        if (!eat_token(spp, '}')) {
793                  strcpy(SDerrorDetail, "Missing '}' in tensor tree");
794                  SDfreeTre(st);
795                  return NULL;
796          }
797 <        ++*spp;                         /* walk past close and return */
797 <        *spp += (next_token(spp) == ',');
797 >        eat_token(spp, ',');
798          return st;
799   }
800  
# Line 992 | Line 992 | extract_diffuse(SDValue *dv, SDSpectralDF *df)
992                  return;
993          }
994          dv->spec = df->comp[0].cspec[0];
995 <        dv->cieY = subtract_min((*(SDTre *)df->comp[n].dist).st);
995 >        dv->cieY = subtract_min((*(SDTre *)df->comp[0].dist).st);
996                                          /* in case of multiple components */
997          for (n = df->ncomp; --n; ) {
998                  double  ymin = subtract_min((*(SDTre *)df->comp[n].dist).st);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines