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.25 by gwlarson, Tue Nov 24 12:01:17 1998 UTC vs.
Revision 3.29 by gwlarson, Fri Dec 18 11:56:10 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 <
22 > #ifndef MEYERNG
23 > #define MEYERNG         0.1     /* target mean eye range (rel. to grid) */
24 > #endif
25 > #ifndef MAXTODO
26   #define MAXTODO         3       /* maximum sections to look at */
27 < #define MAXDRAT         3.0     /* maximum distance ratio */
27 > #endif
28 > #ifndef MAXDRAT
29 > #define MAXDRAT         3.0     /* maximum distance ratio btwn. cand. sect. */
30 > #endif
31  
32   #define CBEAMBLK        1024    /* cbeam allocation block size */
33  
# Line 31 | Line 37 | static struct beamcomp {
37          int4    nr;             /* number of samples desired */
38   } *cbeam = NULL;        /* current beam list */
39  
40 + VIEWPOINT       cureye;         /* current eye position */
41 +
42   static int      ncbeams = 0;    /* number of sorted beams in cbeam */
43   static int      xcbeams = 0;    /* extra (unregistered) beams past ncbeams */
44   static int      maxcbeam = 0;   /* size of cbeam array */
# Line 170 | 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 213 | Line 221 | VIEW   *vw;
221   }
222  
223  
224 + int
225   addview(hd, vw, hres, vres)     /* add view for section */
226   int     hd;
227   VIEW    *vw;
228   int     hres, vres;
229   {
230 <        int     sampquant;
230 >        int     sampquant, samptot = 0;
231          int     h, v, shr, svr;
232          GCOORD  gc[2];
233          FVECT   rorg, rdir;
# Line 242 | Line 251 | int    hres, vres;
251                                  continue;
252                          cbeam[getcbeam(hd,hdbindex(hdlist[hd],gc))].nr +=
253                                          sampquant;
254 +                        samptot += sampquant;
255                  }
256 +        return(samptot);
257   }
258  
259  
# Line 256 | Line 267 | int    fresh;
267          else                            /* else clear sample requests */
268                  for (i = ncbeams+xcbeams; i--; )
269                          cbeam[i].nr = 0;
270 +        cureye.rng = 0.;
271   }
272  
273  
274 + int *
275   beam_view(vn, hr, vr)           /* add beam view (if advisable) */
276   VIEW    *vn;
277   int     hr, vr;
278   {
279 <        int     todo[MAXTODO+1];
279 >        static int      todo[MAXTODO+1];
280          int     n;
281 +        double  hdgsiz, d;
282 +        register HOLO   *hp;
283 +        register int    i;
284 +                                        /* find nearby sections */
285 +        if (!(n = comptodo(todo, vn)))
286 +                return(NULL);
287                                          /* sort our list */
288          cbeamsort(1);
289 <                                        /* add view to nearby sections */
290 <        if (!(n = comptodo(todo, vn)))
291 <                return(0);
292 <        while (n--)
293 <                addview(todo[n], vn, hr, vr);
294 <        return(1);
289 >                                        /* add view to flagged sections */
290 >        for (i = 0; i < n; i++)
291 >                if (!addview(todo[i], vn, hr, vr)) {    /* whoops! */
292 >                        register int    j;
293 >                        n--;                            /* delete from list */
294 >                        for (j = i--; j <= n; j++)
295 >                                todo[j] = todo[j+1];
296 >                }
297 >        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]) ;
305 >        }
306 >        hdgsiz /= (double)n;
307 >                                        /* add to current eye position */
308 >        if (cureye.rng <= FTINY) {
309 >                VCOPY(cureye.vpt, vn->vp);
310 >                cureye.rng = MEYERNG * hdgsiz;
311 >        } else if ((d = sqrt(dist2(vn->vp,cureye.vpt))) + MEYERNG*hdgsiz >
312 >                        cureye.rng) {
313 >                for (i = 3; i--; )
314 >                        cureye.vpt[i] = 0.5*(cureye.vpt[i] + vn->vp[i]);
315 >                cureye.rng = 0.5*(cureye.rng + MEYERNG*hdgsiz + d);
316 >        }
317 >        return(todo);
318   }
319  
320  
# Line 280 | Line 322 | int
322   beam_sync(all)                  /* update beam list on server */
323   int     all;
324   {
325 +                                        /* set new eye position */
326 +        serv_request(DR_VIEWPOINT, sizeof(VIEWPOINT), (char *)&cureye);
327                                          /* sort list (put orphans at end) */
328          cbeamsort(all < 0);
329 +                                        /* send beam request */
330          if (all)
331                  cbeamop(DR_NEWSET, cbeam, ncbeams);
332          else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines