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.21 by gwlarson, Thu May 14 13:23:00 1998 UTC vs.
Revision 3.24 by gwlarson, Tue Sep 15 15:59:31 1998 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ SGI";
16   #define MAXDIST         42      /* maximum distance outside section */
17   #endif
18  
19 < #define MAXVOXEL        16      /* maximum number of active voxels */
19 > #define MAXVOXEL        32      /* maximum number of active voxels */
20  
21   typedef struct {
22          int     hd;             /* holodeck section number (-1 if inactive) */
# Line 28 | Line 28 | static VOXL voxel[MAXVOXEL] = {{-1}};  /* current voxel
28   #define CBEAMBLK        1024    /* cbeam allocation block size */
29  
30   static struct beamcomp {
31 <        unsigned int2   wants;  /* flags telling which voxels want us */
32 <        unsigned int2   hd;     /* holodeck section number */
33 <        int4    bi;             /* beam index */
31 >        int     hd;             /* holodeck section number */
32 >        int     bi;             /* beam index */
33          int4    nr;             /* number of samples desired */
34   } *cbeam = NULL;        /* current beam list */
35  
# Line 40 | Line 39 | static int     maxcbeam = 0;   /* size of cbeam array */
39  
40   struct cellact {
41          short   vi;             /* voxel index */
43        short   add;            /* zero means delete */
42          short   rev;            /* reverse ray direction? */
43          VIEW    *vp;            /* view for image */
44          short   hr, vr;         /* image resolution */
# Line 90 | Line 88 | register struct beamcomp       *cb1, *cb2;
88   {
89          register int    c;
90  
91 <        if (!cb1->wants)                /* put orphans at the end, unsorted */
92 <                return(cb2->wants);
93 <        if (!cb2->wants)
91 >        if (!cb1->nr)                   /* put orphans at the end, unsorted */
92 >                return(cb2->nr);
93 >        if (!cb2->nr)
94                  return(-1);
95          if ((c = cb1->bi - cb2->bi))    /* sort on beam index first */
96                  return(c);
# Line 109 | Line 107 | int    hd, bi;
107  
108          if (ncbeams <= 0)
109                  return(-1);
110 <        cb.wants = 0; cb.hd = hd; cb.bi = bi; cb.nr = 0;
110 >        cb.hd = hd; cb.bi = bi; cb.nr = 0;
111          p = (struct beamcomp *)bsearch((char *)&cb, (char *)cbeam, ncbeams,
112                          sizeof(struct beamcomp), cbeamcmp);
113          if (p == NULL)
# Line 137 | Line 135 | int    bi;
135          if (bi < 1 | bi > nbeams(hdlist[hd]))
136                  error(INTERNAL, "illegal beam index in getcbeam");
137          n = newcbeam();         /* allocate and assign */
138 <        cbeam[n].wants = cbeam[n].nr = 0; cbeam[n].hd = hd; cbeam[n].bi = bi;
138 >        cbeam[n].nr = 0; cbeam[n].hd = hd; cbeam[n].bi = bi;
139          return(n);
140   }
141  
# Line 155 | Line 153 | int    adopt;
153          if (adopt)
154                  return;
155          for (i = ncbeams; i--; )        /* identify orphans */
156 <                if (cbeam[i].wants)
156 >                if (cbeam[i].nr)
157                          break;
158          xcbeams = ncbeams - ++i;        /* put orphans after ncbeams */
159          ncbeams = i;
# Line 186 | Line 184 | int    n;
184   }
185  
186  
187 + unsigned int4
188   add_voxels(vp)          /* add voxels corresponding to view point */
189   FVECT   vp;
190   {
# Line 246 | Line 245 | FVECT  vp;
245  
246  
247   int
248 < dobeam(gcp, bp)         /* express interest or disintrest in a beam */
248 > dobeam(gcp, bp)         /* express interest in a beam */
249   GCOORD  *gcp;
250   register struct beamact *bp;
251   {
# Line 262 | Line 261 | register struct beamact        *bp;
261          }
262          if ((bi = hdbindex(hdlist[voxel[bp->ca.vi].hd], gc)) <= 0)
263                  error(CONSISTENCY, "bad grid coordinate in dobeam");
264 <        if (bp->ca.add) {               /* add it in */
265 <                i = getcbeam(voxel[bp->ca.vi].hd, bi);
266 <                cbeam[i].wants |= 1<<bp->ca.vi; /* say we want it */
267 <                n = npixels(bp->ca.vp, bp->ca.hr, bp->ca.vr,
268 <                                hdlist[cbeam[i].hd], cbeam[i].bi);
269 <                if (n > cbeam[i].nr)
270 <                        cbeam[i].nr = n;
272 <                return(i == ncbeams+xcbeams-1); /* return 1 if totally new */
273 <        }
274 <                                        /* else delete it */
275 <        i = findcbeam(voxel[bp->ca.vi].hd, bi);
276 <        if (i >= 0 && cbeam[i].wants & 1<<bp->ca.vi) {
277 <                cbeam[i].wants &= ~(1<<bp->ca.vi);      /* we don't want it */
278 <                if (!cbeam[i].wants)
279 <                        cbeam[i].nr = 0;
280 <                return(1);                      /* indicate change */
281 <        }
282 <        return(0);
264 >                                        /* add it in */
265 >        i = getcbeam(voxel[bp->ca.vi].hd, bi);
266 >        n = npixels(bp->ca.vp, bp->ca.hr, bp->ca.vr,
267 >                        hdlist[cbeam[i].hd], cbeam[i].bi);
268 >        if (n > cbeam[i].nr)
269 >                cbeam[i].nr = n;
270 >        return(i == ncbeams+xcbeams-1); /* return 1 if totally new */
271   }
272  
273  
# Line 319 | Line 307 | register struct cellact        *cap;
307                  }
308          }
309   #ifdef DEBUG
310 <        if (axmax < 0.)
310 >        if (axmax < 0)
311                  error(CONSISTENCY, "botched axis computation in docell");
312   #endif
313                                  /* compute offset vectors */
# Line 361 | Line 349 | struct cellact *cap;
349   }
350  
351  
352 < beam_init()                     /* clear beam list for new view(s) */
352 > beam_init(fresh)                /* clear beam list for new view(s) */
353 > int     fresh;
354   {
355          register int    i;
356 <                                        /* clear desire flags */
357 <        for (i = ncbeams+xcbeams; i--; )
358 <                cbeam[i].wants = cbeam[i].nr = 0;
356 >
357 >        if (fresh)                      /* discard old beams? */
358 >                ncbeams = xcbeams = 0;
359 >        else                            /* else clear sample requests */
360 >                for (i = ncbeams+xcbeams; i--; )
361 >                        cbeam[i].nr = 0;
362          voxel[0].hd = -1;               /* clear voxel list */
363   }
364  
# Line 376 | Line 368 | VIEW   *vn;
368   int     hr, vr;
369   {
370          struct cellact  ca;
371 <        int     vfl;
371 >        unsigned int4   vfl;
372                                          /* sort our list */
373          cbeamsort(1);
374                                          /* add new voxels */
# Line 384 | Line 376 | int    hr, vr;
376          if (!vfl)
377                  return(0);
378          ca.vp = vn; ca.hr = hr; ca.vr = vr;
379 <        ca.add = 1;                     /* update our beam list */
379 >                                        /* update our beam list */
380          for (ca.vi = 0; vfl; vfl >>= 1, ca.vi++)
381                  if (vfl & 1)
382                          doview(&ca);
# Line 396 | Line 388 | int
388   beam_sync(all)                  /* update beam list on server */
389   int     all;
390   {
391 <                                        /* sort list to put orphans at end */
392 <        cbeamsort(0);
391 >                                        /* sort list (put orphans at end) */
392 >        cbeamsort(all < 0);
393          if (all)
394                  cbeamop(DR_NEWSET, cbeam, ncbeams);
395          else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines