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

Comparing ray/src/cv/bsdfmesh.c (file contents):
Revision 2.3 by greg, Thu Nov 8 22:05:04 2012 UTC vs.
Revision 2.4 by greg, Thu Nov 8 23:11:41 2012 UTC

# Line 213 | Line 213 | min_cost(double amt2move, const double *avail, const P
213   static double
214   migration_step(MIGRATION *mig, double *src_rem, double *dst_rem, const PRICEMAT *pm)
215   {
216 <        const double    maxamt = .1;
216 >        const double    maxamt = 1./(double)pm->ncols;
217          const double    minamt = maxamt*5e-6;
218          static double   *src_cost = NULL;
219          static int      n_alloc = 0;
# Line 241 | Line 241 | migration_step(MIGRATION *mig, double *src_rem, double
241                                                  /* find best source & dest. */
242          best.s = best.d = -1; best.price = FHUGE; best.amt = 0;
243          for (cur.s = pm->nrows; cur.s--; ) {
244            const float *price = pricerow(pm,cur.s);
244              double      cost_others = 0;
245              if (src_rem[cur.s] <= minamt)
246                      continue;
247 <            cur.d = -1;                         /* examine cheapest dest. */
248 <            for (i = pm->ncols; i--; )
249 <                if (dst_rem[i] > minamt &&
250 <                                (cur.d < 0 || price[i] < price[cur.d]))
251 <                        cur.d = i;
253 <            if (cur.d < 0)
247 >                                                /* examine cheapest dest. */
248 >            for (i = 0; i < pm->ncols; i++)
249 >                if (dst_rem[cur.d = psortrow(pm,cur.s)[i]] > minamt)
250 >                        break;
251 >            if (i >= pm->ncols)
252                      return(.0);
253 <            if ((cur.price = price[cur.d]) >= best.price)
253 >            if ((cur.price = pricerow(pm,cur.s)[cur.d]) >= best.price)
254                      continue;                   /* no point checking further */
255              cur.amt = (src_rem[cur.s] < dst_rem[cur.d]) ?
256                                  src_rem[cur.s] : dst_rem[cur.d];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines