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.15 by gregl, Mon Dec 15 20:40:46 1997 UTC vs.
Revision 3.31 by gwlarson, Wed Mar 3 10:25:27 1999 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1997 Silicon Graphics, Inc. */
1 > /* Copyright (c) 1998 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ SGI";
# Line 11 | Line 11 | static char SCCSid[] = "$SunId$ SGI";
11   #include "rholo.h"
12   #include "rhdisp.h"
13   #include "rhdriver.h"
14 + #include "random.h"
15  
16   #ifndef MAXDIST
17   #define MAXDIST         42      /* maximum distance outside section */
18   #endif
19 + #ifndef NVSAMPS
20 + #define NVSAMPS         16384   /* number of ray samples per view */
21 + #endif
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 + #endif
28 + #ifndef MAXDRAT
29 + #define MAXDRAT         3.0     /* maximum distance ratio btwn. cand. sect. */
30 + #endif
31  
19 extern GCOORD   *getviewcells();
20
21 static VIEW     dvw;            /* current view corresponding to beam list */
22
23 typedef struct {
24        int     hd;             /* holodeck section number (-1 if inactive) */
25        int     i[3];           /* voxel index (may be outside section) */
26 } VOXL;                 /* a voxel */
27
28 static VOXL voxel[8] = {        /* current voxel list */
29        {-1}, {-1}, {-1}, {-1},
30        {-1}, {-1}, {-1}, {-1}
31 };
32
32   #define CBEAMBLK        1024    /* cbeam allocation block size */
33  
34   static struct beamcomp {
35 <        short   wants;          /* flags telling which voxels want us */
37 <        short   hd;             /* holodeck section number */
35 >        int     hd;             /* holodeck section number */
36          int     bi;             /* beam index */
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 */
45  
45 struct cellact {
46        short   vi;             /* voxel index */
47        short   add;            /* zero means delete */
48        short   rev;            /* reverse ray direction? */
49 };              /* action for cell */
46  
51 struct beamact {
52        struct cellact  ca;     /* cell action */
53        GCOORD  gc;             /* grid coordinate */
54 };              /* beam origin and action */
55
56
47   int
48   newcbeam()              /* allocate new entry at end of cbeam array */
49   {
# Line 92 | Line 82 | register struct beamcomp       *cb1, *cb2;
82   {
83          register int    c;
84  
85 <        if (!cb1->wants)                /* put orphans at the end, unsorted */
86 <                return(cb2->wants);
87 <        if (!cb2->wants)
85 >        if (!cb1->nr)                   /* put orphans at the end, unsorted */
86 >                return(cb2->nr);
87 >        if (!cb2->nr)
88                  return(-1);
89          if ((c = cb1->bi - cb2->bi))    /* sort on beam index first */
90                  return(c);
# Line 111 | Line 101 | int    hd, bi;
101  
102          if (ncbeams <= 0)
103                  return(-1);
104 <        cb.wants = 0; cb.hd = hd; cb.bi = bi;
104 >        cb.hd = hd; cb.bi = bi; cb.nr = 0;
105          p = (struct beamcomp *)bsearch((char *)&cb, (char *)cbeam, ncbeams,
106                          sizeof(struct beamcomp), cbeamcmp);
107          if (p == NULL)
# Line 139 | Line 129 | int    bi;
129          if (bi < 1 | bi > nbeams(hdlist[hd]))
130                  error(INTERNAL, "illegal beam index in getcbeam");
131          n = newcbeam();         /* allocate and assign */
132 <        cbeam[n].wants = 0; cbeam[n].hd = hd; cbeam[n].bi = bi;
132 >        cbeam[n].nr = 0; cbeam[n].hd = hd; cbeam[n].bi = bi;
133          return(n);
134   }
135  
# Line 157 | Line 147 | int    adopt;
147          if (adopt)
148                  return;
149          for (i = ncbeams; i--; )        /* identify orphans */
150 <                if (cbeam[i].wants)
150 >                if (cbeam[i].nr)
151                          break;
152          xcbeams = ncbeams - ++i;        /* put orphans after ncbeams */
153          ncbeams = i;
154   }
155  
156  
157 < cbeamadj(v, hr, vr)             /* adjust our beam list */
168 < VIEW    *v;
169 < int     hr, vr;
170 < {
171 <        register PACKHEAD       *pa;
172 <        register int    i;
173 <        int     n;
174 <                                        /* first handle additions */
175 <        pa = (PACKHEAD *)malloc(xcbeams*sizeof(PACKHEAD));
176 <        if (xcbeams && pa == NULL)
177 <                goto memerr;
178 <        for (i = xcbeams; i--; ) {
179 <                pa[i].hd = cbeam[ncbeams+i].hd;
180 <                pa[i].bi = cbeam[ncbeams+i].bi;
181 <                pa[i].nr = npixels(v, hr, vr, hdlist[pa[i].hd], pa[i].bi) + 1;
182 <        }
183 <        n = xcbeams;                    /* now sort list for deletions */
184 <        cbeamsort(0);
185 <        pa = (PACKHEAD *)realloc((char *)pa, (n+xcbeams)*sizeof(PACKHEAD));
186 <        if (n+xcbeams && pa == NULL)
187 <                goto memerr;
188 <        for (i = xcbeams; i--; ) {
189 <                pa[n+i].hd = cbeam[ncbeams+i].hd;
190 <                pa[n+i].bi = cbeam[ncbeams+i].bi;
191 <                pa[n+i].nr = 0;
192 <        }
193 <        n += xcbeams;
194 <        xcbeams = 0;                    /* delete orphans */
195 <        serv_request(DR_ADJSET, n*sizeof(PACKHEAD), (char *)pa);
196 <        free((char *)pa);
197 <        return;
198 < memerr:
199 <        error(SYSTEM, "out of memory in cbeamadj");
200 < }
201 <
202 <
203 < cbeamop(op, bl, n, v, hr, vr)   /* update beams on server list */
157 > cbeamop(op, bl, n)              /* update beams on server list */
158   int     op;
159   register struct beamcomp        *bl;
160   int     n;
207 VIEW    *v;
208 int     hr, vr;
161   {
162          register PACKHEAD       *pa;
163          register int    i;
# Line 214 | Line 166 | int    hr, vr;
166                  return;
167          pa = (PACKHEAD *)malloc(n*sizeof(PACKHEAD));
168          if (pa == NULL)
169 <                error(SYSTEM, "out of memory in cbeamadd");
169 >                error(SYSTEM, "out of memory in cbeamop");
170          for (i = 0; i < n; i++) {
171                  pa[i].hd = bl[i].hd;
172                  pa[i].bi = bl[i].bi;
173 <                pa[i].nr = v==NULL ? 0 :
174 <                                npixels(v, hr, vr, hdlist[bl[i].hd], bl[i].bi);
173 >                pa[i].nr = bl[i].nr;
174 >                pa[i].nc = 0;
175          }
176          serv_request(op, n*sizeof(PACKHEAD), (char *)pa);
177          free((char *)pa);
178   }
179  
180  
181 < int
182 < set_voxels(vl, n)       /* set new voxel array */
183 < VOXL    vl[8];
184 < int     n;
181 > static int
182 > comptodo(tdl, vw)               /* compute holodeck sections in view */
183 > int     tdl[MAXTODO+1];
184 > VIEW    *vw;
185   {
234        short   wmap[256];
235        int     vmap[8];
236        int     comn = 0;
237        int     no;
238        register int    i, j;
239                                        /* find common voxels */
240        for (j = 0; j < 8 && voxel[j].hd >= 0; j++) {
241                vmap[j] = -1;
242                for (i = n; i--; )
243                        if (!bcmp((char *)(vl+i), (char *)(voxel+j),
244                                        sizeof(VOXL))) {
245                                vmap[j] = i;
246                                comn |= 1<<i;
247                                break;
248                        }
249        }
250        no = comn ? j : 0;              /* compute flag mapping */
251        for (i = 256; i--; ) {
252                wmap[i] = 0;
253                for (j = no; j--; )
254                        if (vmap[j] >= 0 && i & 1<<j)
255                                wmap[i] |= 1<<vmap[j];
256        }
257                                        /* fix cbeam flags */
258        for (i = ncbeams; i--; )
259                cbeam[i].wants = wmap[cbeam[i].wants];
260                                        /* update our voxel list */
261        bcopy((char *)vl, (char *)voxel, n*sizeof(VOXL));
262        for (j = n; j < 8; j++)
263                voxel[j].hd = -1;
264        return(comn);                   /* return bit array of common voxels */
265 }
266
267
268 int
269 get_voxels(vl, vp)      /* find voxels corresponding to view point */
270 VOXL    vl[8];
271 FVECT   vp;
272 {
273        static int      lastn = 0, lastd = -1;
186          int     n = 0;
187 <        FVECT   gp;
188 <        double  d;
189 <        int     dist, bestd = 0x7fff;
190 <        VOXL    vox;
191 <        register int    i, j, k;
192 <                                        /* find closest voxels */
193 <        for (i = 0; n < 8 && hdlist[i]; i++) {
194 <                hdgrid(gp, hdlist[i], vp);
195 <                for (j = 0; n < 8 && j < 8; j++) {
196 <                        dist = 0;
197 <                        for (k = 0; k < 3; k++) {
198 <                                d = gp[k] - .5 + (j>>k & 1);
199 <                                if (d < 0.)
200 <                                        dist += -(vox.i[k] = (int)d - 1);
201 <                                else if ((vox.i[k] = d) >= hdlist[i]->grid[k])
202 <                                        dist += vox.i[k] -
203 <                                                        hdlist[i]->grid[k] + 1;
292 <                        }
293 <                        if (dist > bestd)       /* others were closer */
294 <                                continue;
295 <                        if (dist < bestd) {     /* start closer list */
296 <                                n = 0;
297 <                                bestd = dist;
298 <                        }
299 <                        vox.hd = i;             /* add this voxel */
300 <                        copystruct(&vl[n], &vox);
301 <                        n++;
187 >        FVECT   gp, dv;
188 >        double  dist2[MAXTODO+1], thisdist2;
189 >        register int    i, j;
190 >                                        /* find closest MAXTODO sections */
191 >        for (i = 0; hdlist[i]; i++) {
192 >                hdgrid(gp, hdlist[i], vw->vp);
193 >                for (j = 0; j < 3; j++)
194 >                        if (gp[j] < 0.)
195 >                                dv[j] = -gp[j];
196 >                        else if (gp[j] > hdlist[i]->grid[j])
197 >                                dv[j] = gp[j] - hdlist[i]->grid[j];
198 >                        else
199 >                                dv[j] = 0.;
200 >                thisdist2 = DOT(dv,dv);
201 >                for (j = n; j > 0 && thisdist2 < dist2[j-1]; j--) {
202 >                        tdl[j] = tdl[j-1];
203 >                        dist2[j] = dist2[j-1];
204                  }
205 +                tdl[j] = i;
206 +                dist2[j] = thisdist2;
207 +                if (n < MAXTODO)
208 +                        n++;
209          }
210 <                                        /* check for really stupid move */
211 <        if (bestd > MAXDIST) {
210 >                                        /* watch for bad move */
211 >        if (n && dist2[0] > MAXDIST*MAXDIST) {
212                  error(COMMAND, "move past outer limits");
213                  return(0);
214          }
215 <                                        /* warn of dangerous moves */
216 <        if (n < lastn && bestd >= lastd)
217 <                error(WARNING, "moving outside holodeck section");
218 <        else if (n > lastn && bestd <= lastd)
219 <                error(WARNING, "moving inside holodeck section");
220 <        lastd = bestd;
315 <        return(lastn = n);
215 >                                        /* avoid big differences */
216 >        for (j = 1; j < n; j++)
217 >                if (dist2[j] > MAXDRAT*MAXDRAT*dist2[j-1])
218 >                        n = j;
219 >        tdl[n] = -1;
220 >        return(n);
221   }
222  
223  
224   int
225 < dobeam(gcp, bp)         /* express interest or disintrest in a beam */
226 < GCOORD  *gcp;
227 < register struct beamact *bp;
225 > addview(hd, vw, rad, hres, vres)        /* add view for section */
226 > int     hd;
227 > VIEW    *vw;
228 > double  rad;
229 > int     hres, vres;
230   {
231 +        int     sampquant, samptot = 0;
232 +        int     h, v, shr, svr;
233          GCOORD  gc[2];
234 <        int     bi, i;
235 <                                        /* compute beam index */
236 <        if (bp->ca.rev) {
237 <                copystruct(gc, &bp->gc);
238 <                copystruct(gc+1, gcp);
234 >        FVECT   rorg, rdir;
235 >                                /* compute sampling grid */
236 >        if (hres|vres && hres*vres <= NVSAMPS) {
237 >                shr = hres; svr = vres;
238 >                sampquant = 1;
239          } else {
240 <                copystruct(gc, gcp);
241 <                copystruct(gc+1, &bp->gc);
240 >                shr = sqrt(NVSAMPS/viewaspect(vw)) + .5;
241 >                svr = (NVSAMPS + shr/2)/shr;
242 >                sampquant = (hres*vres + shr*svr/2)/(shr*svr);
243          }
244 <        if ((bi = hdbindex(hdlist[voxel[bp->ca.vi].hd], gc)) <= 0)
245 <                error(CONSISTENCY, "bad grid coordinate in dobeam");
246 <        if (bp->ca.add) {               /* add it in */
247 <                i = getcbeam(voxel[bp->ca.vi].hd, bi);
248 <                cbeam[i].wants |= 1<<bp->ca.vi; /* say we want it */
249 <                return(i == ncbeams+xcbeams-1); /* return 1 if totally new */
250 <        }
251 <                                        /* else delete it */
252 <        i = findcbeam(voxel[bp->ca.vi].hd, bi);
253 <        if (i >= 0 && cbeam[i].wants & 1<<bp->ca.vi) {
254 <                cbeam[i].wants &= ~(1<<bp->ca.vi);      /* we don't want it */
255 <                return(1);                      /* indicate change */
256 <        }
257 <        return(0);
244 >                                /* intersect sample rays with section */
245 >        for (v = svr; v--; )
246 >                for (h = shr; h--; ) {
247 >                        if (viewray(rorg, rdir, vw, (h+frandom())/shr,
248 >                                                (v+frandom())/svr) < -FTINY)
249 >                                continue;
250 >                        if (rad > FTINY) {
251 >                                rorg[0] += (1.-2.*frandom())*rad;
252 >                                rorg[1] += (1.-2.*frandom())*rad;
253 >                                rorg[2] += (1.-2.*frandom())*rad;
254 >                        }
255 >                        if (hdinter(gc, NULL, NULL, hdlist[hd], rorg, rdir)
256 >                                                >= 0.99*FHUGE)
257 >                                continue;
258 >                        cbeam[getcbeam(hd,hdbindex(hdlist[hd],gc))].nr +=
259 >                                        sampquant;
260 >                        samptot += sampquant;
261 >                }
262 >        return(samptot);
263   }
264  
265  
266 <
267 < int
353 < docell(gcp, cap)        /* find beams corresponding to cell and voxel */
354 < GCOORD  *gcp;
355 < register struct cellact *cap;
266 > beam_init(fresh)                /* clear beam list for new view(s) */
267 > int     fresh;
268   {
357        register HOLO   *hp = hdlist[voxel[cap->vi].hd];
358        FVECT   org, dir[4];
359        FVECT   vgp, cgp, vc;
360        FVECT   v1, v2;
361        struct beamact  bo;
362        int     axmax, j;
363        double  d, avmax;
269          register int    i;
365                                /* compute cell center */
366        cgp[gcp->w>>1] = gcp->w&1 ? hp->grid[gcp->w>>1] : 0 ;
367        cgp[((gcp->w>>1)+1)%3] = gcp->i[0] + .5;
368        cgp[((gcp->w>>1)+2)%3] = gcp->i[1] + .5;
369        hdworld(org, hp, cgp);
370                                /* compute direction to voxel center */
371        for (i = 3; i--; )
372                vgp[i] = voxel[cap->vi].i[i] + .5;
373        hdworld(vc, hp, vgp);
374        for (i = 3; i--; )
375                vc[i] -= org[i];
376                                /* compute maximum area axis */
377        axmax = -1; avmax = 0;
378        for (i = 3; i--; ) {
379                d = vgp[i] - cgp[i];
380                if (d < 0.) d = -d;
381                if (d > avmax) {
382                        avmax = d;
383                        axmax = i;
384                }
385        }
386 #ifdef DEBUG
387        if (axmax < 0.)
388                error(CONSISTENCY, "botched axis computation in docell");
389 #endif
390                                /* compute offset vectors */
391        d = 0.5/hp->grid[j=(axmax+1)%3];
392        for (i = 3; i--; )
393                v1[i] = hp->xv[j][i] * d;
394        d = 0.5/hp->grid[j=(axmax+2)%3];
395        if (DOT(hp->wn[axmax], vc) < 0.)
396                d = -d; /* reverse vertex ordering */
397        for (i = 3; i--; )
398                v2[i] = hp->xv[j][i] * d;
399                                /* compute voxel pyramid */
400        for (i = 3; i--; ) {
401                dir[0][i] = vc[i] - v1[i] - v2[i];
402                dir[1][i] = vc[i] + v1[i] - v2[i];
403                dir[2][i] = vc[i] + v1[i] + v2[i];
404                dir[3][i] = vc[i] - v1[i] + v2[i];
405        }
406                                /* visit beams for opposite cells */
407        copystruct(&bo.ca, cap);
408        copystruct(&bo.gc, gcp);
409        return(visit_cells(org, dir, hp, dobeam, &bo));
410 }
270  
271 <
272 < int
273 < doview(cap, vp)                 /* visit cells for a given view */
274 < struct cellact  *cap;
275 < VIEW    *vp;
276 < {
418 <        int     orient;
419 <        FVECT   org, dir[4];
420 <                                        /* compute view pyramid */
421 <        orient = viewpyramid(org, dir, hdlist[voxel[cap->vi].hd], vp);
422 <        if (!orient)
423 <                error(INTERNAL, "unusable view in doview");
424 <        cap->rev = orient < 0;
425 <                                        /* visit cells within pyramid */
426 <        return(visit_cells(org, dir, hdlist[voxel[cap->vi].hd], docell, cap));
271 >        if (fresh)                      /* discard old beams? */
272 >                ncbeams = xcbeams = 0;
273 >        else                            /* else clear sample requests */
274 >                for (i = ncbeams+xcbeams; i--; )
275 >                        cbeam[i].nr = 0;
276 >        cureye.rng = 0.;
277   }
278  
279  
280 < mvview(voxi, vold, vnew)        /* move view for a voxel */
281 < int     voxi;
282 < VIEW    *vold, *vnew;
280 > int *
281 > beam_view(vn, hr, vr)           /* add beam view (if advisable) */
282 > VIEW    *vn;
283 > int     hr, vr;
284   {
285 <        int     netchange = 0;
286 <        struct cellact  oca, nca;
287 <        int     ocnt, ncnt;
288 <        int     c;
289 <        GCOORD  *ogcl, *ngcl;
290 <        register GCOORD *ogcp, *ngcp;
291 <                                /* get old and new cell lists */
292 <        ogcp = ogcl = getviewcells(&ocnt, hdlist[voxel[voxi].hd], vold);
293 <        ngcp = ngcl = getviewcells(&ncnt, hdlist[voxel[voxi].hd], vnew);
294 <                                /* set up actions */
295 <        oca.vi = nca.vi = voxi;
296 <        oca.add = 0; nca.add = 1;
297 <        if ((oca.rev = ocnt < 0))
298 <                ocnt = -ocnt;
299 <        if ((nca.rev = ncnt < 0))
300 <                ncnt = -ncnt;
301 <        if (nca.rev == oca.rev)         /* add and delete cells in order */
302 <                while (ocnt > 0 & ncnt > 0)
303 <                        if ((c = cellcmp(ogcp, ngcp)) > 0) {    /* new cell */
304 <                                netchange += docell(ngcp++, &nca);
305 <                                ncnt--;
306 <                        } else if (c < 0) {                     /* old cell */
307 <                                netchange -= docell(ogcp++, &oca);
308 <                                ocnt--;
309 <                        } else {                                /* same cell */
310 <                                ogcp++; ocnt--;
311 <                                ngcp++; ncnt--;
312 <                        }
313 <                                /* take care of list tails */
314 <        for ( ; ncnt > 0; ncnt--)
315 <                netchange += docell(ngcp++, &nca);
316 <        for ( ; ocnt > 0; ocnt--)
317 <                netchange -= docell(ogcp++, &oca);
318 <                                /* clean up */
319 <        if (ogcl != NULL) free((char *)ogcl);
320 <        if (ngcl != NULL) free((char *)ngcl);
321 <        return(netchange);
285 >        static int      todo[MAXTODO+1];
286 >        int     n;
287 >        double  er, eravg, d;
288 >        register HOLO   *hp;
289 >        register int    i;
290 >                                        /* find nearby sections */
291 >        if (!(n = comptodo(todo, vn)))
292 >                return(NULL);
293 >                                        /* sort current beam list */
294 >        cbeamsort(1);
295 >                                        /* add view to nearby sections */
296 >        eravg = 0.;
297 >        for (i = 0; i < n; i++) {
298 >                hp = hdlist[todo[i]];
299 >                if (MEYERNG > FTINY)
300 >                        er =    MEYERNG/3. / VLEN(hp->wg[0]) +
301 >                                MEYERNG/3. / VLEN(hp->wg[1]) +
302 >                                MEYERNG/3. / VLEN(hp->wg[2]) ;
303 >                else
304 >                        er = 0.;
305 >                if (!addview(todo[i], vn, 0.25*er, hr, vr)) {
306 >                        register int    j;              /* whoops! */
307 >                        n--;                            /* delete from list */
308 >                        for (j = i--; j <= n; j++)
309 >                                todo[j] = todo[j+1];
310 >                } else
311 >                        eravg += er;
312 >        }
313 >        if (eravg <= FTINY)
314 >                return(todo);
315 >                                        /* compute average eye range */
316 >        eravg /= (double)n;
317 >                                        /* add to current eye position */
318 >        if (cureye.rng <= FTINY) {
319 >                VCOPY(cureye.vpt, vn->vp);
320 >                cureye.rng = eravg;
321 >        } else if ((d = sqrt(dist2(vn->vp,cureye.vpt))) + eravg > cureye.rng) {
322 >                for (i = 3; i--; )
323 >                        cureye.vpt[i] = 0.5*(cureye.vpt[i] + vn->vp[i]);
324 >                cureye.rng = 0.5*(cureye.rng + eravg + d);
325 >        }
326 >        return(todo);
327   }
328  
329  
330   int
331 < beam_sync()             /* synchronize beams on server */
331 > beam_sync(all)                  /* update beam list on server */
332 > int     all;
333   {
334 <        cbeamop(DR_NEWSET, cbeam, ncbeams, &odev.v, odev.hres, odev.vres);
335 <        return(ncbeams);
336 < }
337 <
338 <
339 < beam_view(vn)                   /* change beam view (if advisable) */
340 < VIEW    *vn;
341 < {
342 <        struct cellact  ca;
486 <        VOXL    vlnew[8];
487 <        int     n, comn;
488 <
489 <        if (vn == NULL || !vn->type) {  /* clear our beam list */
490 <                set_voxels(vlnew, 0);
491 <                cbeamop(DR_DELSET, cbeam, ncbeams, NULL, 0, 0);
492 <                ncbeams = 0;
493 <                dvw.type = 0;
494 <                return(1);
495 <        }
496 <                                        /* find our new voxels */
497 <        n = get_voxels(vlnew, vn->vp);
498 <        if (dvw.type && !n) {
499 <                copystruct(vn, &dvw);           /* cancel move */
500 <                return(0);
501 <        }
502 <                                        /* set the new voxels */
503 <        comn = set_voxels(vlnew, n);
504 <        if (!dvw.type)
505 <                comn = 0;
506 <        ca.add = 1;                     /* update our beam list */
507 <        for (ca.vi = n; ca.vi--; )
508 <                if (comn & 1<<ca.vi)    /* change which cells we see */
509 <                        mvview(ca.vi, &dvw, vn);
510 <                else                    /* else add all new cells */
511 <                        doview(&ca, vn);
512 < #if 1
513 <        cbeamadj(vn, odev.hres, odev.vres);
514 < #else
515 <                                        /* inform server of new beams */
516 <        cbeamop(DR_ADDSET, cbeam+ncbeams, xcbeams, vn, odev.hres, odev.vres);
517 <                                        /* sort list to put orphans at end */
518 <        cbeamsort(0);
519 <                                        /* tell server to delete orphans */
520 <        cbeamop(DR_DELSET, cbeam+ncbeams, xcbeams, NULL, 0, 0);
334 >                                        /* set new eye position */
335 >        serv_request(DR_VIEWPOINT, sizeof(VIEWPOINT), (char *)&cureye);
336 >                                        /* sort list (put orphans at end) */
337 >        cbeamsort(all < 0);
338 >                                        /* send beam request */
339 >        if (all)
340 >                cbeamop(DR_NEWSET, cbeam, ncbeams);
341 >        else
342 >                cbeamop(DR_ADJSET, cbeam, ncbeams+xcbeams);
343          xcbeams = 0;                    /* truncate our list */
344 < #endif
523 <        copystruct(&dvw, vn);           /* record new view */
524 <        return(1);
344 >        return(ncbeams);
345   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines