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.9 by greg, Fri Dec 14 22:41:44 2012 UTC vs.
Revision 2.12 by greg, Thu Sep 26 17:05:00 2013 UTC

# Line 202 | Line 202 | get_interp(MIGRATION *miga[3], FVECT invec)
202   {
203          miga[0] = miga[1] = miga[2] = NULL;
204          if (single_plane_incident) {            /* isotropic BSDF? */
205 <                RBFNODE *rbf;                   /* find edge we're on */
206 <                for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) {
207 <                        if (input_orient*rbf->invec[2] < input_orient*invec[2])
208 <                                break;
209 <                        if (rbf->next != NULL &&
210 <                                        input_orient*rbf->next->invec[2] <
205 >            RBFNODE     *rbf;                   /* find edge we're on */
206 >            for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) {
207 >                if (input_orient*rbf->invec[2] < input_orient*invec[2])
208 >                        break;
209 >                if (rbf->next != NULL && input_orient*rbf->next->invec[2] <
210                                                          input_orient*invec[2]) {
211 <                                for (miga[0] = rbf->ejl; miga[0] != NULL;
212 <                                                miga[0] = nextedge(rbf,miga[0]))
213 <                                        if (opp_rbf(rbf,miga[0]) == rbf->next) {
214 <                                                double  nf = 1.-rbf->invec[2]*rbf->invec[2];
215 <                                                if (nf > FTINY) {
216 <                                                        nf = sqrt((1.-invec[2]*invec[2])/nf);
217 <                                                        invec[0] = nf*rbf->invec[0];
218 <                                                        invec[1] = nf*rbf->invec[1];
219 <                                                }
220 <                                                return(0);
222 <                                        }
223 <                                break;
211 >                    for (miga[0] = rbf->ejl; miga[0] != NULL;
212 >                                        miga[0] = nextedge(rbf,miga[0]))
213 >                        if (opp_rbf(rbf,miga[0]) == rbf->next) {
214 >                                double  nf = 1. - rbf->invec[2]*rbf->invec[2];
215 >                                if (nf > FTINY) {       /* rotate to match */
216 >                                        nf = sqrt((1.-invec[2]*invec[2])/nf);
217 >                                        invec[0] = nf*rbf->invec[0];
218 >                                        invec[1] = nf*rbf->invec[1];
219 >                                }
220 >                                return(0);
221                          }
222 +                    break;
223                  }
224 <                return(-1);                     /* outside range! */
224 >            }
225 >            return(-1);                         /* outside range! */
226          }
227          {                                       /* else use triangle mesh */
228                  int             sym = use_symmetry(invec);
# Line 267 | Line 266 | e_advect_rbf(const MIGRATION *mig, const FVECT invec)
266          int             n, i, j;
267          double          t, full_dist;
268                                                  /* get relative position */
269 <        t = acos(DOT(invec, mig->rbfv[0]->invec));
269 >        t = Acos(DOT(invec, mig->rbfv[0]->invec));
270          if (t < M_PI/grid_res) {                /* near first DSF */
271                  n = sizeof(RBFNODE) + sizeof(RBFVAL)*(mig->rbfv[0]->nrbf-1);
272                  rbf = (RBFNODE *)malloc(n);
# Line 338 | Line 337 | memerr:
337  
338   /* Partially advect between recorded incident angles and allocate new RBF */
339   RBFNODE *
340 < advect_rbf(const FVECT invec)
340 > advect_rbf(const FVECT invec, int lobe_lim)
341   {
342 +        double          cthresh = FTINY;
343          FVECT           sivec;
344          MIGRATION       *miga[3];
345          RBFNODE         *rbf;
# Line 380 | Line 380 | advect_rbf(const FVECT invec)
380          geodesic(v1, miga[0]->rbfv[0]->invec, miga[0]->rbfv[1]->invec,
381                          s, GEOD_REL);
382          t = acos(DOT(v1,sivec)) / acos(DOT(v1,miga[1]->rbfv[1]->invec));
383 + tryagain:
384          n = 0;                                  /* count migrating particles */
385          for (i = 0; i < mtx_nrows(miga[0]); i++)
386              for (j = 0; j < mtx_ncols(miga[0]); j++)
387 <                for (k = (mtx_coef(miga[0],i,j) > FTINY) *
387 >                for (k = (mtx_coef(miga[0],i,j) > cthresh) *
388                                          mtx_ncols(miga[2]); k--; )
389 <                        n += (mtx_coef(miga[2],i,k) > FTINY ||
390 <                                mtx_coef(miga[1],j,k) > FTINY);
389 >                        n += (mtx_coef(miga[2],i,k) > cthresh ||
390 >                                mtx_coef(miga[1],j,k) > cthresh);
391 >        if ((lobe_lim > 0) & (n > lobe_lim)) {
392 >                cthresh = cthresh*2. + 10.*FTINY;
393 >                goto tryagain;
394 >        }
395   #ifdef DEBUG
396          fprintf(stderr, "Input RBFs have %d, %d, %d nodes -> output has %d\n",
397                          miga[0]->rbfv[0]->nrbf, miga[0]->rbfv[1]->nrbf,
# Line 414 | Line 419 | advect_rbf(const FVECT invec)
419                  const float     ma = mtx_coef(miga[0],i,j);
420                  const RBFVAL    *rbf1j;
421                  double          rad1j, srad2;
422 <                if (ma <= FTINY)
422 >                if (ma <= cthresh)
423                          continue;
424                  rbf1j = &miga[0]->rbfv[1]->rbfa[j];
425                  rad1j = R2ANG(rbf1j->crad);
# Line 427 | Line 432 | advect_rbf(const FVECT invec)
432                      const RBFVAL        *rbf2k;
433                      double              rad2k;
434                      int                 pos[2];
435 <                    if ((mb <= FTINY) & (mc <= FTINY))
435 >                    if ((mb <= cthresh) & (mc <= cthresh))
436                          continue;
437                      rbf2k = &miga[2]->rbfv[1]->rbfa[k];
438                      rbf->rbfa[n].peak = w0i * ma * (mb*mbfact + mc*mcfact);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines