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

Comparing ray/src/cv/bsdfinterp.c (file contents):
Revision 2.12 by greg, Thu Sep 26 17:05:00 2013 UTC vs.
Revision 2.14 by greg, Tue Oct 22 04:29:27 2013 UTC

# Line 260 | Line 260 | get_interp(MIGRATION *miga[3], FVECT invec)
260  
261   /* Advect and allocate new RBF along edge */
262   static RBFNODE *
263 < e_advect_rbf(const MIGRATION *mig, const FVECT invec)
263 > e_advect_rbf(const MIGRATION *mig, const FVECT invec, int lobe_lim)
264   {
265 +        double          cthresh = FTINY;
266          RBFNODE         *rbf;
267          int             n, i, j;
268          double          t, full_dist;
# Line 286 | Line 287 | e_advect_rbf(const MIGRATION *mig, const FVECT invec)
287                  rbf->next = NULL; rbf->ejl = NULL;
288                  return(rbf);
289          }
290 <        t /= full_dist;
290 >        t /= full_dist;
291 > tryagain:
292          n = 0;                                  /* count migrating particles */
293          for (i = 0; i < mtx_nrows(mig); i++)
294              for (j = 0; j < mtx_ncols(mig); j++)
295 <                n += (mtx_coef(mig,i,j) > FTINY);
295 >                n += (mtx_coef(mig,i,j) > cthresh);
296 >                                                /* are we over our limit? */
297 >        if ((lobe_lim > 0) & (n > lobe_lim)) {
298 >                cthresh = cthresh*2. + 10.*FTINY;
299 >                goto tryagain;
300 >        }
301   #ifdef DEBUG
302          fprintf(stderr, "Input RBFs have %d, %d nodes -> output has %d\n",
303                          mig->rbfv[0]->nrbf, mig->rbfv[1]->nrbf, n);
# Line 311 | Line 318 | e_advect_rbf(const MIGRATION *mig, const FVECT invec)
318              float               mv;
319              ovec_from_pos(v0, rbf0i->gx, rbf0i->gy);
320              for (j = 0; j < mtx_ncols(mig); j++)
321 <                if ((mv = mtx_coef(mig,i,j)) > FTINY) {
321 >                if ((mv = mtx_coef(mig,i,j)) > cthresh) {
322                          const RBFVAL    *rbf1j = &mig->rbfv[1]->rbfa[j];
323 <                        double          rad1 = R2ANG(rbf1j->crad);
323 >                        double          rad2;
324                          FVECT           v;
325                          int             pos[2];
326 <                        rbf->rbfa[n].peak = peak0 * mv * rbf->vtotal;
327 <                        rbf->rbfa[n].crad = ANG2R(sqrt(rad0*rad0*(1.-t) +
328 <                                                        rad1*rad1*t));
326 >                        rad2 = R2ANG(rbf1j->crad);
327 >                        rad2 = rad0*rad0*(1.-t) + rad2*rad2*t;
328 >                        rbf->rbfa[n].peak = peak0 * mv * rbf->vtotal *
329 >                                                rad0*rad0/rad2;
330 >                        rbf->rbfa[n].crad = ANG2R(sqrt(rad2));
331                          ovec_from_pos(v, rbf1j->gx, rbf1j->gy);
332                          geodesic(v, v0, v, t, GEOD_REL);
333                          pos_from_vec(pos, v);
# Line 354 | Line 363 | advect_rbf(const FVECT invec, int lobe_lim)
363          if (sym < 0)                            /* can't interpolate? */
364                  return(NULL);
365          if (miga[1] == NULL) {                  /* advect along edge? */
366 <                rbf = e_advect_rbf(miga[0], sivec);
366 >                rbf = e_advect_rbf(miga[0], sivec, lobe_lim);
367                  if (single_plane_incident)
368                          rotate_rbf(rbf, invec);
369                  else
# Line 388 | Line 397 | tryagain:
397                                          mtx_ncols(miga[2]); k--; )
398                          n += (mtx_coef(miga[2],i,k) > cthresh ||
399                                  mtx_coef(miga[1],j,k) > cthresh);
400 +                                                /* are we over our limit? */
401          if ((lobe_lim > 0) & (n > lobe_lim)) {
402                  cthresh = cthresh*2. + 10.*FTINY;
403                  goto tryagain;
# Line 418 | Line 428 | tryagain:
428              for (j = 0; j < mtx_ncols(miga[0]); j++) {
429                  const float     ma = mtx_coef(miga[0],i,j);
430                  const RBFVAL    *rbf1j;
431 <                double          rad1j, srad2;
431 >                double          srad2;
432                  if (ma <= cthresh)
433                          continue;
434                  rbf1j = &miga[0]->rbfv[1]->rbfa[j];
435 <                rad1j = R2ANG(rbf1j->crad);
436 <                srad2 = (1.-s)*(1.-t)*rad0i*rad0i + s*(1.-t)*rad1j*rad1j;
435 >                srad2 = R2ANG(rbf1j->crad);
436 >                srad2 = (1.-s)*(1.-t)*rad0i*rad0i + s*(1.-t)*srad2*srad2;
437                  ovec_from_pos(v1, rbf1j->gx, rbf1j->gy);
438                  geodesic(v1, v0, v1, s, GEOD_REL);
439                  for (k = 0; k < mtx_ncols(miga[2]); k++) {
440                      float               mb = mtx_coef(miga[1],j,k);
441                      float               mc = mtx_coef(miga[2],i,k);
442                      const RBFVAL        *rbf2k;
443 <                    double              rad2k;
443 >                    double              rad2;
444                      int                 pos[2];
445                      if ((mb <= cthresh) & (mc <= cthresh))
446                          continue;
447                      rbf2k = &miga[2]->rbfv[1]->rbfa[k];
448 <                    rbf->rbfa[n].peak = w0i * ma * (mb*mbfact + mc*mcfact);
449 <                    rad2k = R2ANG(rbf2k->crad);
450 <                    rbf->rbfa[n].crad = ANG2R(sqrt(srad2 + t*rad2k*rad2k));
448 >                    rad2 = R2ANG(rbf2k->crad);
449 >                    rad2 = srad2 + t*rad2*rad2;
450 >                    rbf->rbfa[n].peak = w0i * ma * (mb*mbfact + mc*mcfact) *
451 >                                        rad0i*rad0i/rad2;
452 >                    rbf->rbfa[n].crad = ANG2R(sqrt(rad2));
453                      ovec_from_pos(v2, rbf2k->gx, rbf2k->gy);
454                      geodesic(v2, v1, v2, t, GEOD_REL);
455                      pos_from_vec(pos, v2);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines