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.26 by gwlarson, Tue Nov 24 17:05:36 1998 UTC vs.
Revision 3.30 by gwlarson, Tue Dec 22 15:57:20 1998 UTC

# Line 17 | Line 17 | static char SCCSid[] = "$SunId$ SGI";
17   #define MAXDIST         42      /* maximum distance outside section */
18   #endif
19   #ifndef NVSAMPS
20 < #define NVSAMPS         4096    /* number of ray samples per view */
20 > #define NVSAMPS         16384   /* number of ray samples per view */
21   #endif
22   #ifndef MEYERNG
23   #define MEYERNG         0.2     /* target mean eye range (rel. to grid) */
# Line 178 | Line 178 | int    n;
178   }
179  
180  
181 < int
181 > static int
182   comptodo(tdl, vw)               /* compute holodeck sections in view */
183   int     tdl[MAXTODO+1];
184   VIEW    *vw;
# Line 221 | Line 221 | VIEW   *vw;
221   }
222  
223  
224 < addview(hd, vw, hres, vres)     /* add view for section */
224 > int
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;
231 >        int     sampquant, samptot = 0;
232          int     h, v, shr, svr;
233          GCOORD  gc[2];
234          FVECT   rorg, rdir;
# Line 245 | 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;
260 +                        samptot += sampquant;
261                  }
262 +        return(samptot);
263   }
264  
265  
# Line 268 | Line 277 | int    fresh;
277   }
278  
279  
280 + int *
281   beam_view(vn, hr, vr)           /* add beam view (if advisable) */
282   VIEW    *vn;
283   int     hr, vr;
284   {
285 <        int     todo[MAXTODO+1], n;
286 <        double  hdgsiz, d;
285 >        static int      todo[MAXTODO+1];
286 >        int     n;
287 >        double  er, eravg, d;
288          register HOLO   *hp;
289          register int    i;
290 <                                        /* sort our list */
290 >                                        /* find nearby sections */
291 >        if (!(n = comptodo(todo, vn)))
292 >                return(NULL);
293 >                                        /* sort current beam list */
294          cbeamsort(1);
295                                          /* add view to nearby sections */
296 <        if (!(n = comptodo(todo, vn)))
283 <                return(0);
284 <        for (i = 0; i < n; i++)
285 <                addview(todo[i], vn, hr, vr);
286 <        if (MEYERNG <= FTINY || vn->type == VT_PAR)
287 <                return(1);
288 <        hdgsiz = 0.; d = 1./3. / n;     /* compute mean grid size */
296 >        eravg = 0.;
297          for (i = 0; i < n; i++) {
298                  hp = hdlist[todo[i]];
299 <                hdgsiz += d * ( VLEN(hp->xv[0])/hp->grid[0] +
300 <                                VLEN(hp->xv[1])/hp->grid[1] +
301 <                                VLEN(hp->xv[2])/hp->grid[2] ) ;
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 >                } else
311 >                        eravg += er;
312          }
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 >
300 <                        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(1);
326 >        return(todo);
327   }
328  
329  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines