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.28 by gwlarson, Thu Dec 10 10:45:55 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 256 | Line 264 | int    fresh;
264          else                            /* else clear sample requests */
265                  for (i = ncbeams+xcbeams; i--; )
266                          cbeam[i].nr = 0;
267 +        cureye.rng = 0.;
268   }
269  
270  
# Line 263 | Line 272 | beam_view(vn, hr, vr)          /* add beam view (if advisable)
272   VIEW    *vn;
273   int     hr, vr;
274   {
275 <        int     todo[MAXTODO+1];
276 <        int     n;
275 >        int     todo[MAXTODO+1], n;
276 >        double  hdgsiz, d;
277 >        register HOLO   *hp;
278 >        register int    i;
279                                          /* sort our list */
280          cbeamsort(1);
281                                          /* add view to nearby sections */
282          if (!(n = comptodo(todo, vn)))
283                  return(0);
284 <        while (n--)
285 <                addview(todo[n], vn, hr, vr);
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.;                    /* compute mean grid size */
289 >        for (i = 0; i < n; i++) {
290 >                hp = hdlist[todo[i]];
291 >                hdgsiz +=       1./3. / VLEN(hp->wg[0]) +
292 >                                1./3. / VLEN(hp->wg[1]) +
293 >                                1./3. / VLEN(hp->wg[2]) ;
294 >        }
295 >        hdgsiz /= (double)n;
296 >                                        /* add to current eye position */
297 >        if (cureye.rng <= FTINY) {
298 >                VCOPY(cureye.vpt, vn->vp);
299 >                cureye.rng = MEYERNG * hdgsiz;
300 >        } else if ((d = sqrt(dist2(vn->vp,cureye.vpt))) + MEYERNG*hdgsiz >
301 >                        cureye.rng) {
302 >                for (i = 3; i--; )
303 >                        cureye.vpt[i] = 0.5*(cureye.vpt[i] + vn->vp[i]);
304 >                cureye.rng = 0.5*(cureye.rng + MEYERNG*hdgsiz + d);
305 >        }
306          return(1);
307   }
308  
# Line 280 | Line 311 | int
311   beam_sync(all)                  /* update beam list on server */
312   int     all;
313   {
314 +                                        /* set new eye position */
315 +        serv_request(DR_VIEWPOINT, sizeof(VIEWPOINT), (char *)&cureye);
316                                          /* sort list (put orphans at end) */
317          cbeamsort(all < 0);
318 +                                        /* send beam request */
319          if (all)
320                  cbeamop(DR_NEWSET, cbeam, ncbeams);
321          else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines