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.5 by gregl, Fri Nov 21 18:17:37 1997 UTC vs.
Revision 3.7 by gregl, Tue Nov 25 10:48:38 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 361 | Line 363 | VIEW   *vold, *vnew;
363          struct cellact  oca, nca;
364          int     ocnt, ncnt;
365          int     c;
366 +        GCOORD  *ogcl, *ngcl;
367          register GCOORD *ogcp, *ngcp;
368                                  /* get old and new cell lists */
369 <        ogcp = getviewcells(&ocnt, hdlist[voxel[voxi].hd], vold);
370 <        ngcp = getviewcells(&ncnt, hdlist[voxel[voxi].hd], vnew);
369 >        ogcp = ogcl = getviewcells(&ocnt, hdlist[voxel[voxi].hd], vold);
370 >        ngcp = ngcl = getviewcells(&ncnt, hdlist[voxel[voxi].hd], vnew);
371                                  /* set up actions */
372          oca.vi = nca.vi = voxi;
373          oca.rev = nca.rev = 0;
# Line 373 | Line 376 | VIEW   *vold, *vnew;
376                  ocnt = -ocnt;
377          if ((nca.rev = ncnt < 0))
378                  ncnt = -ncnt;
379 <                                /* add and delete cells in order */
380 <        while (ocnt > 0 & ncnt > 0)
381 <                if ((c = cellcmp(ogcp, ngcp)) > 0) {    /* new cell */
382 <                        netchange += docell(ngcp++, &nca);
383 <                        ncnt--;
384 <                } else if (c < 0) {                     /* obsolete cell */
385 <                        netchange -= docell(ogcp++, &oca);
386 <                        ocnt--;
387 <                } else {                                /* same cell? */
388 <                        if (oca.rev != nca.rev)         /* not */
389 <                                netchange += docell(ngcp, &nca) -
390 <                                                docell(ogcp, &oca);
388 <                        ogcp++; ocnt--;
389 <                        ngcp++; ncnt--;
390 <                }
379 >        if (nca.rev == oca.rev)         /* add and delete cells in order */
380 >                while (ocnt > 0 & ncnt > 0)
381 >                        if ((c = cellcmp(ogcp, ngcp)) > 0) {    /* new cell */
382 >                                netchange += docell(ngcp++, &nca);
383 >                                ncnt--;
384 >                        } else if (c < 0) {                     /* old cell */
385 >                                netchange -= docell(ogcp++, &oca);
386 >                                ocnt--;
387 >                        } else {                                /* same cell */
388 >                                ogcp++; ocnt--;
389 >                                ngcp++; ncnt--;
390 >                        }
391                                  /* take care of list tails */
392          for ( ; ncnt > 0; ncnt--)
393                  netchange += docell(ngcp++, &nca);
394          for ( ; ocnt > 0; ocnt--)
395                  netchange -= docell(ogcp++, &oca);
396                                  /* clean up */
397 <        if (ogcp != NULL) free((char *)ogcp);
398 <        if (ngcp != NULL) free((char *)ngcp);
397 >        if (ogcl != NULL) free((char *)ogcl);
398 >        if (ngcl != NULL) free((char *)ngcl);
399          return(netchange);
400   }
401  
# Line 406 | Line 406 | beam_sync()            /* synchronize beams on server */
406   }
407  
408  
409 < beam_view(vo, vn)       /* change beam view */
410 < VIEW    *vo, *vn;
409 > beam_view(vn)                   /* change beam view */
410 > VIEW    *vn;
411   {
412          struct cellact  ca;
413          VOXL    vlnew[8];
# Line 417 | Line 417 | VIEW   *vo, *vn;
417                  set_voxels(vlnew, 0);
418                  cbeamop(DR_DELSET, cbeam, ncbeams, NULL, 0, 0);
419                  ncbeams = 0;
420 +                copystruct(&dvw, vn);
421                  return;
422          }
423                                          /* find our new voxels */
424          n = get_voxels(vlnew, vn->vp);
425                                          /* set the new voxels */
426          comn = set_voxels(vlnew, n);
427 <        if (!vo->type)
427 >        if (!dvw.type)
428                  comn = 0;
429          ca.add = 1;                     /* update our beam list */
430          for (ca.vi = n; ca.vi--; )
431                  if (comn & 1<<ca.vi)    /* change which cells we see */
432 <                        mvview(ca.vi, vo, vn);
432 >                        mvview(ca.vi, &dvw, vn);
433                  else                    /* else add all new cells */
434                          doview(&ca, vn);
435                                          /* inform server of new beams */
# Line 438 | Line 439 | VIEW   *vo, *vn;
439                                          /* tell server to delete orphans */
440          cbeamop(DR_DELSET, cbeam+ncbeams, xcbeams, NULL, 0, 0);
441          xcbeams = 0;                    /* truncate our list */
442 +        copystruct(&dvw, vn);           /* record new view */
443   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines