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

Comparing ray/src/hd/rhdisp2.c (file contents):
Revision 3.29 by gwlarson, Fri Dec 18 11:56:10 1998 UTC vs.
Revision 3.30 by gwlarson, Tue Dec 22 15:57:20 1998 UTC

# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ SGI";
20   #define NVSAMPS         16384   /* number of ray samples per view */
21   #endif
22   #ifndef MEYERNG
23 < #define MEYERNG         0.1     /* target mean eye range (rel. to grid) */
23 > #define MEYERNG         0.2     /* target mean eye range (rel. to grid) */
24   #endif
25   #ifndef MAXTODO
26   #define MAXTODO         3       /* maximum sections to look at */
# Line 222 | Line 222 | VIEW   *vw;
222  
223  
224   int
225 < addview(hd, vw, hres, vres)     /* add view for section */
225 > addview(hd, vw, rad, hres, vres)        /* add view for section */
226   int     hd;
227   VIEW    *vw;
228 + double  rad;
229   int     hres, vres;
230   {
231          int     sampquant, samptot = 0;
# Line 246 | Line 247 | int    hres, vres;
247                          if (viewray(rorg, rdir, vw, (v+frandom())/svr,
248                                                  (h+frandom())/shr) < -FTINY)
249                                  continue;
250 +                        if (rad > FTINY) {
251 +                                rorg[0] += (1.-2.*frandom())*rad;
252 +                                rorg[1] += (1.-2.*frandom())*rad;
253 +                                rorg[2] += (1.-2.*frandom())*rad;
254 +                        }
255                          if (hdinter(gc, NULL, NULL, hdlist[hd], rorg, rdir)
256 <                                                >= FHUGE)
256 >                                                >= 0.99*FHUGE)
257                                  continue;
258                          cbeam[getcbeam(hd,hdbindex(hdlist[hd],gc))].nr +=
259                                          sampquant;
# Line 278 | Line 284 | int    hr, vr;
284   {
285          static int      todo[MAXTODO+1];
286          int     n;
287 <        double  hdgsiz, d;
287 >        double  er, eravg, d;
288          register HOLO   *hp;
289          register int    i;
290                                          /* find nearby sections */
291          if (!(n = comptodo(todo, vn)))
292                  return(NULL);
293 <                                        /* sort our list */
293 >                                        /* sort current beam list */
294          cbeamsort(1);
295 <                                        /* add view to flagged sections */
296 <        for (i = 0; i < n; i++)
297 <                if (!addview(todo[i], vn, hr, vr)) {    /* whoops! */
298 <                        register int    j;
295 >                                        /* add view to nearby sections */
296 >        eravg = 0.;
297 >        for (i = 0; i < n; i++) {
298 >                hp = hdlist[todo[i]];
299 >                if (MEYERNG > FTINY)
300 >                        er =    MEYERNG/3. / VLEN(hp->wg[0]) +
301 >                                MEYERNG/3. / VLEN(hp->wg[1]) +
302 >                                MEYERNG/3. / VLEN(hp->wg[2]) ;
303 >                else
304 >                        er = 0.;
305 >                if (!addview(todo[i], vn, 0.25*er, hr, vr)) {
306 >                        register int    j;              /* whoops! */
307                          n--;                            /* delete from list */
308                          for (j = i--; j <= n; j++)
309                                  todo[j] = todo[j+1];
310 <                }
311 <        if (!n || MEYERNG <= FTINY || vn->type == VT_PAR)
298 <                return(todo);
299 <        hdgsiz = 0.;                    /* compute mean grid size */
300 <        for (i = 0; i < n; i++) {
301 <                hp = hdlist[todo[i]];
302 <                hdgsiz +=       1./3. / VLEN(hp->wg[0]) +
303 <                                1./3. / VLEN(hp->wg[1]) +
304 <                                1./3. / VLEN(hp->wg[2]) ;
310 >                } else
311 >                        eravg += er;
312          }
313 <        hdgsiz /= (double)n;
313 >        if (eravg <= FTINY)
314 >                return(todo);
315 >                                        /* compute average eye range */
316 >        eravg /= (double)n;
317                                          /* add to current eye position */
318          if (cureye.rng <= FTINY) {
319                  VCOPY(cureye.vpt, vn->vp);
320 <                cureye.rng = MEYERNG * hdgsiz;
321 <        } else if ((d = sqrt(dist2(vn->vp,cureye.vpt))) + MEYERNG*hdgsiz >
312 <                        cureye.rng) {
320 >                cureye.rng = eravg;
321 >        } else if ((d = sqrt(dist2(vn->vp,cureye.vpt))) + eravg > cureye.rng) {
322                  for (i = 3; i--; )
323                          cureye.vpt[i] = 0.5*(cureye.vpt[i] + vn->vp[i]);
324 <                cureye.rng = 0.5*(cureye.rng + MEYERNG*hdgsiz + d);
324 >                cureye.rng = 0.5*(cureye.rng + eravg + d);
325          }
326          return(todo);
327   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines