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.6 by gregl, Mon Nov 24 15:17:28 1997 UTC vs.
Revision 3.8 by gregl, Tue Dec 2 15:02:37 1997 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ SGI";
14  
15   extern GCOORD   *getviewcells();
16  
17 + static VIEW     dvw;            /* current view corresponding to beam list */
18 +
19   typedef struct {
20          int     hd;             /* holodeck section number (-1 if inactive) */
21          int     i[3];           /* voxel index (may be outside section) */
# Line 156 | Line 158 | int    adopt;
158   }
159  
160  
161 + cbeamadj(v, hr, vr)             /* adjust our beam list */
162 + VIEW    *v;
163 + int     hr, vr;
164 + {
165 +        register PACKHEAD       *pa;
166 +        register int    i;
167 +        int     n;
168 +                                        /* first handle additions */
169 +        pa = (PACKHEAD *)malloc(xcbeams*sizeof(PACKHEAD));
170 +        if (xcbeams && pa == NULL)
171 +                goto memerr;
172 +        for (i = xcbeams; i--; ) {
173 +                pa[i].hd = cbeam[ncbeams+i].hd;
174 +                pa[i].bi = cbeam[ncbeams+i].bi;
175 +                pa[i].nr = npixels(v, hr, vr, hdlist[pa[i].hd], pa[i].bi);
176 +        }
177 +        n = xcbeams;                    /* now sort list for deletions */
178 +        cbeamsort(0);
179 +        pa = (PACKHEAD *)realloc((char *)pa, (n+xcbeams)*sizeof(PACKHEAD));
180 +        if (n+xcbeams && pa == NULL)
181 +                goto memerr;
182 +        for (i = xcbeams; i--; ) {
183 +                pa[n+i].hd = cbeam[ncbeams+i].hd;
184 +                pa[n+i].bi = cbeam[ncbeams+i].bi;
185 +                pa[n+i].nr = 0;
186 +        }
187 +        n += xcbeams;
188 +        xcbeams = 0;                    /* delete orphans */
189 +        serv_request(DR_ADJSET, n*sizeof(PACKHEAD), (char *)pa);
190 +        free((char *)pa);
191 +        return;
192 + memerr:
193 +        error(SYSTEM, "out of memory in cbeamadj");
194 + }
195 +
196 +
197   cbeamop(op, bl, n, v, hr, vr)   /* update beams on server list */
198   int     op;
199   register struct beamcomp        *bl;
# Line 361 | Line 399 | VIEW   *vold, *vnew;
399          struct cellact  oca, nca;
400          int     ocnt, ncnt;
401          int     c;
402 +        GCOORD  *ogcl, *ngcl;
403          register GCOORD *ogcp, *ngcp;
404                                  /* get old and new cell lists */
405 <        ogcp = getviewcells(&ocnt, hdlist[voxel[voxi].hd], vold);
406 <        ngcp = getviewcells(&ncnt, hdlist[voxel[voxi].hd], vnew);
405 >        ogcp = ogcl = getviewcells(&ocnt, hdlist[voxel[voxi].hd], vold);
406 >        ngcp = ngcl = getviewcells(&ncnt, hdlist[voxel[voxi].hd], vnew);
407                                  /* set up actions */
408          oca.vi = nca.vi = voxi;
409          oca.rev = nca.rev = 0;
# Line 391 | Line 430 | VIEW   *vold, *vnew;
430          for ( ; ocnt > 0; ocnt--)
431                  netchange -= docell(ogcp++, &oca);
432                                  /* clean up */
433 <        if (ogcp != NULL) free((char *)ogcp);
434 <        if (ngcp != NULL) free((char *)ngcp);
433 >        if (ogcl != NULL) free((char *)ogcl);
434 >        if (ngcl != NULL) free((char *)ngcl);
435          return(netchange);
436   }
437  
# Line 403 | Line 442 | beam_sync()            /* synchronize beams on server */
442   }
443  
444  
445 < beam_view(vo, vn)       /* change beam view */
446 < VIEW    *vo, *vn;
445 > beam_view(vn)                   /* change beam view */
446 > VIEW    *vn;
447   {
448          struct cellact  ca;
449          VOXL    vlnew[8];
# Line 414 | Line 453 | VIEW   *vo, *vn;
453                  set_voxels(vlnew, 0);
454                  cbeamop(DR_DELSET, cbeam, ncbeams, NULL, 0, 0);
455                  ncbeams = 0;
456 +                copystruct(&dvw, vn);
457                  return;
458          }
459                                          /* find our new voxels */
460          n = get_voxels(vlnew, vn->vp);
461                                          /* set the new voxels */
462          comn = set_voxels(vlnew, n);
463 <        if (!vo->type)
463 >        if (!dvw.type)
464                  comn = 0;
465          ca.add = 1;                     /* update our beam list */
466          for (ca.vi = n; ca.vi--; )
467                  if (comn & 1<<ca.vi)    /* change which cells we see */
468 <                        mvview(ca.vi, vo, vn);
468 >                        mvview(ca.vi, &dvw, vn);
469                  else                    /* else add all new cells */
470                          doview(&ca, vn);
471 + #if 1
472 +        cbeamadj(vn, odev.hres, odev.vres);
473 + #else
474                                          /* inform server of new beams */
475          cbeamop(DR_ADDSET, cbeam+ncbeams, xcbeams, vn, odev.hres, odev.vres);
476                                          /* sort list to put orphans at end */
# Line 435 | Line 478 | VIEW   *vo, *vn;
478                                          /* tell server to delete orphans */
479          cbeamop(DR_DELSET, cbeam+ncbeams, xcbeams, NULL, 0, 0);
480          xcbeams = 0;                    /* truncate our list */
481 + #endif
482 +        copystruct(&dvw, vn);           /* record new view */
483   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines