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.1 by gregl, Wed Nov 19 18:01:03 1997 UTC vs.
Revision 3.4 by gregl, Fri Nov 21 16:10:17 1997 UTC

# Line 5 | Line 5 | static char SCCSid[] = "$SunId$ SGI";
5   #endif
6  
7   /*
8 < * Holodeck beam tracking
8 > * Holodeck beam tracking for display process
9   */
10  
11   #include "rholo.h"
# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ SGI";
15   extern int      *getviewcells();
16  
17   typedef struct {
18 <        int     hd;             /* holodeck section number */
18 >        int     hd;             /* holodeck section number (-1 if inactive) */
19          int     i[3];           /* voxel index (may be outside section) */
20   } VOXL;                 /* a voxel */
21  
# Line 36 | Line 36 | static int     ncbeams = 0;    /* number of sorted beams in c
36   static int      xcbeams = 0;    /* extra (unregistered) beams past ncbeams */
37   static int      maxcbeam = 0;   /* size of cbeam array */
38  
39
39   struct cellact {
40          short   vi;             /* voxel index */
41          short   add;            /* zero means delete */
42   };              /* action for cell */
43  
45
44   struct beamact {
45          struct cellact  ca;     /* cell action */
46          GCOORD  gc;             /* grid coordinate */
# Line 157 | Line 155 | int    adopt;
155   }
156  
157  
158 < cbeamadd(bl, n, v, hr, vr)      /* add beams to server list */
158 > cbeamop(op, bl, n, v, hr, vr)   /* update beams on server list */
159 > int     op;
160   register struct beamcomp        *bl;
161   int     n;
162   VIEW    *v;
# Line 171 | Line 170 | int    hr, vr;
170          pa = (PACKHEAD *)malloc(n*sizeof(PACKHEAD));
171          if (pa == NULL)
172                  error(SYSTEM, "out of memory in cbeamadd");
174        for (i = 0; i < n; i++)
175                pa[i].nr = npixels(v, hr, vr,
176                                hdlist[pa[i].hd=bl[i].hd],
177                                pa[i].bi=bl[i].bi) / 8;
178
179        serv_request(DR_ADDSET, n*sizeof(PACKHEAD), (char *)pa);
180        free((char *)pa);
181 }
182
183
184 cbeamdel(bl, n)         /* delete unwanted beam requests */
185 register struct beamcomp        *bl;
186 int     n;
187 {
188        register PACKHEAD       *pa;
189        register int    i;
190
191        if (n <= 0)
192                return;
193        pa = (PACKHEAD *)malloc(n*sizeof(PACKHEAD));
194        if (pa == NULL)
195                error(SYSTEM, "out of memory in cbeamdel");
173          for (i = 0; i < n; i++) {
174                  pa[i].hd = bl[i].hd;
175                  pa[i].bi = bl[i].bi;
176 <                pa[i].nr = 0;           /* removes any request */
176 >                pa[i].nr = v==NULL ? 0 :
177 >                                npixels(v, hr, vr, hdlist[bl[i].hd], bl[i].bi);
178          }
179 <        serv_request(DR_DELSET, n*sizeof(PACKHEAD), (char *)pa);
179 >        serv_request(op, n*sizeof(PACKHEAD), (char *)pa);
180          free((char *)pa);
181   }
182  
# Line 247 | Line 225 | get_voxels(vl, vp)     /* find voxels corresponding to vie
225   VOXL    vl[8];
226   FVECT   vp;
227   {
228 +        static int      lastn = 0, lastd = -1;
229          int     n = 0;
230          FVECT   gp;
231          double  d;
# Line 277 | Line 256 | FVECT  vp;
256                          n++;
257                  }
258          }
259 <        return(n);
259 >                                        /* warn of dangerous moves */
260 >        if (n < lastn && bestd >= lastd)
261 >                error(WARNING, "moving outside holodeck section");
262 >        else if (n > lastn && bestd <= lastd)
263 >                error(WARNING, "moving inside holodeck section");
264 >        lastd = bestd;
265 >        return(lastn = n);
266   }
267  
268  
# Line 292 | Line 277 | register struct beamact        *bp;
277          copystruct(gc, gcp);
278          copystruct(gc+1, &bp->gc);
279          if ((bi = hdbindex(hdlist[voxel[bp->ca.vi].hd], gc)) <= 0)
280 <                return(0);              /* should report an error? */
280 >                error(CONSISTENCY, "bad grid coordinate in dobeam");
281          if (bp->ca.add) {               /* add it in */
282                  i = getcbeam(voxel[bp->ca.vi].hd, bi);
283                  cbeam[i].wants |= 1<<bp->ca.vi; /* say we want it */
# Line 403 | Line 388 | VIEW   *vold, *vnew;
388                  }
389                                  /* take care of list tails */
390          for (ca.add = 1; ncnt > 0; ncnt--)
391 <                docell(ngcp++, &ca);
391 >                netchange += docell(ngcp++, &ca);
392          for (ca.add = 0; ocnt > 0; ocnt--)
393 <                docell(ogcp++, &ca);
393 >                netchange -= docell(ogcp++, &ca);
394                                  /* clean up */
395          if (ocl != NULL) free((char *)ocl);
396          if (ncl != NULL) free((char *)ncl);
# Line 413 | Line 398 | VIEW   *vold, *vnew;
398   }
399  
400  
401 + beam_sync()             /* synchronize beams on server */
402 + {
403 +        cbeamop(DR_NEWSET, cbeam, ncbeams, &odev.v, odev.hres, odev.vres);
404 + }
405 +
406 +
407   beam_view(vo, vn)       /* change beam view */
408   VIEW    *vo, *vn;
409   {
# Line 422 | Line 413 | VIEW   *vo, *vn;
413  
414          if (!vn->type) {                /* clear our beam list */
415                  set_voxels(vlnew, 0);
416 <                cbeamdel(cbeam, ncbeams);
416 >                cbeamop(DR_DELSET, cbeam, ncbeams, NULL, 0, 0);
417                  ncbeams = 0;
418                  return;
419          }
# Line 439 | Line 430 | VIEW   *vo, *vn;
430                  else                    /* else add all new cells */
431                          doview(&ca, vn);
432                                          /* inform server of new beams */
433 <        cbeamadd(cbeam+ncbeams, xcbeams, vn, odev.hres, odev.vres);
433 >        cbeamop(DR_ADDSET, cbeam+ncbeams, xcbeams, vn, odev.hres, odev.vres);
434                                          /* sort list to put orphans at end */
435          cbeamsort(0);
436                                          /* tell server to delete orphans */
437 <        cbeamdel(cbeam+ncbeams, xcbeams);
437 >        cbeamop(DR_DELSET, cbeam+ncbeams, xcbeams, NULL, 0, 0);
438          xcbeams = 0;                    /* truncate our list */
439   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines