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.26 by gwlarson, Tue Nov 24 17:05:36 1998 UTC

# Line 19 | Line 19 | static char SCCSid[] = "$SunId$ SGI";
19   #ifndef NVSAMPS
20   #define NVSAMPS         4096    /* number of ray samples per view */
21   #endif
22 <
22 > #ifndef MEYERNG
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 */
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.; d = 1./3. / n;     /* compute mean grid size */
289 >        for (i = 0; i < n; i++) {
290 >                hp = hdlist[todo[i]];
291 >                hdgsiz += d * ( VLEN(hp->xv[0])/hp->grid[0] +
292 >                                VLEN(hp->xv[1])/hp->grid[1] +
293 >                                VLEN(hp->xv[2])/hp->grid[2] ) ;
294 >        }
295 >                                        /* add to current eye position */
296 >        if (cureye.rng <= FTINY) {
297 >                VCOPY(cureye.vpt, vn->vp);
298 >                cureye.rng = MEYERNG * hdgsiz;
299 >        } else if ((d = sqrt(dist2(vn->vp,cureye.vpt))) + MEYERNG*hdgsiz >
300 >                        cureye.rng) {
301 >                for (i = 3; i--; )
302 >                        cureye.vpt[i] = 0.5*(cureye.vpt[i] + vn->vp[i]);
303 >                cureye.rng = 0.5*(cureye.rng + MEYERNG*hdgsiz + d);
304 >        }
305          return(1);
306   }
307  
# Line 280 | Line 310 | int
310   beam_sync(all)                  /* update beam list on server */
311   int     all;
312   {
313 +                                        /* set new eye position */
314 +        serv_request(DR_VIEWPOINT, sizeof(VIEWPOINT), (char *)&cureye);
315                                          /* sort list (put orphans at end) */
316          cbeamsort(all < 0);
317 +                                        /* send beam request */
318          if (all)
319                  cbeamop(DR_NEWSET, cbeam, ncbeams);
320          else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines