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.8 by greg, Wed Mar 20 01:00:22 2013 UTC vs.
Revision 2.10 by greg, Thu Sep 26 14:57:18 2013 UTC

# Line 27 | Line 27 | typedef struct {
27          int             nrows, ncols;   /* array size (matches migration) */
28          float           *price;         /* migration prices */
29          short           *sord;          /* sort for each row, low to high */
30 +        float           *prow;          /* current price row */
31   } PRICEMAT;                     /* sorted pricing matrix */
32  
33   #define pricerow(p,i)   ((p)->price + (i)*(p)->ncols)
# Line 139 | Line 140 | static int
140   msrt_cmp(void *b, const void *p1, const void *p2)
141   {
142          PRICEMAT        *pm = (PRICEMAT *)b;
143 <        int             ri = ((const short *)p1 - pm->sord) / pm->ncols;
144 <        float           c1 = pricerow(pm,ri)[*(const short *)p1];
144 <        float           c2 = pricerow(pm,ri)[*(const short *)p2];
143 >        float           c1 = pm->prow[*(const short *)p1];
144 >        float           c2 = pm->prow[*(const short *)p2];
145  
146          if (c1 > c2) return(1);
147          if (c1 < c2) return(-1);
# Line 171 | Line 171 | price_routes(PRICEMAT *pm, const RBFNODE *from_rbf, co
171          for (i = from_rbf->nrbf; i--; ) {
172              const double        from_ang = R2ANG(from_rbf->rbfa[i].crad);
173              FVECT               vfrom;
174 +            short               *srow;
175              ovec_from_pos(vfrom, from_rbf->rbfa[i].gx, from_rbf->rbfa[i].gy);
176 +            pm->prow = pricerow(pm,i);
177 +            srow = psortrow(pm,i);
178              for (j = to_rbf->nrbf; j--; ) {
179                  double          dprod = DOT(vfrom, vto[j]);
180 <                pricerow(pm,i)[j] = ((dprod >= 1.) ? .0 : acos(dprod)) +
180 >                pm->prow[j] = ((dprod >= 1.) ? .0 : acos(dprod)) +
181                                  fabs(R2ANG(to_rbf->rbfa[j].crad) - from_ang);
182 <                psortrow(pm,i)[j] = j;
182 >                srow[j] = j;
183              }
184 <            qsort_r(psortrow(pm,i), pm->ncols, sizeof(short), pm, &msrt_cmp);
184 >            qsort_r(srow, pm->ncols, sizeof(short), pm, &msrt_cmp);
185          }
186          free(vto);
187   }
# Line 438 | Line 441 | mesh_from_edge(MIGRATION *edge)
441                  }
442          }
443   }
441
442 /* Compute minimum BSDF from histogram and clear it */
443 static void
444 comp_bsdf_min()
445 {
446        int     cnt;
447        int     i, target;
448
449        cnt = 0;
450        for (i = HISTLEN; i--; )
451                cnt += bsdf_hist[i];
452
453        target = cnt/100;                       /* ignore bottom 1% */
454        cnt = 0;
455        for (i = 0; cnt <= target; i++)
456                cnt += bsdf_hist[i];
457        bsdf_min = histval(i-1);
458        memset(bsdf_hist, 0, sizeof(bsdf_hist));
459 }
444          
445   /* Build our triangle mesh from recorded RBFs */
446   void
# Line 492 | Line 476 | build_mesh(void)
476                  mesh_from_edge(create_migration(shrt_edj[0], shrt_edj[1]));
477          else
478                  mesh_from_edge(create_migration(shrt_edj[1], shrt_edj[0]));
495                                                /* compute minimum BSDF */
496        comp_bsdf_min();
479                                                  /* complete migrations */
480          await_children(nchild);
481   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines