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.11 by gregl, Tue Dec 9 13:53:21 1997 UTC vs.
Revision 3.17 by gregl, Thu Jan 1 13:00:16 1998 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 13 | Line 13 | static char SCCSid[] = "$SunId$ SGI";
13   #include "rhdriver.h"
14  
15   #ifndef MAXDIST
16 < #define MAXDIST         13      /* maximum distance outside section */
16 > #define MAXDIST         42      /* maximum distance outside section */
17   #endif
18  
19   extern GCOORD   *getviewcells();
# Line 94 | Line 94 | register struct beamcomp       *cb1, *cb2;
94  
95          if (!cb1->wants)                /* put orphans at the end, unsorted */
96                  return(cb2->wants);
97 +        if (!cb2->wants)
98 +                return(-1);
99          if ((c = cb1->bi - cb2->bi))    /* sort on beam index first */
100                  return(c);
101          return(cb1->hd - cb2->hd);      /* use hd to resolve matches */
# Line 162 | Line 164 | int    adopt;
164   }
165  
166  
165 cbeamadj(v, hr, vr)             /* adjust our beam list */
166 VIEW    *v;
167 int     hr, vr;
168 {
169        register PACKHEAD       *pa;
170        register int    i;
171        int     n;
172                                        /* first handle additions */
173        pa = (PACKHEAD *)malloc(xcbeams*sizeof(PACKHEAD));
174        if (xcbeams && pa == NULL)
175                goto memerr;
176        for (i = xcbeams; i--; ) {
177                pa[i].hd = cbeam[ncbeams+i].hd;
178                pa[i].bi = cbeam[ncbeams+i].bi;
179                pa[i].nr = npixels(v, hr, vr, hdlist[pa[i].hd], pa[i].bi) + 1;
180        }
181        n = xcbeams;                    /* now sort list for deletions */
182        cbeamsort(0);
183        pa = (PACKHEAD *)realloc((char *)pa, (n+xcbeams)*sizeof(PACKHEAD));
184        if (n+xcbeams && pa == NULL)
185                goto memerr;
186        for (i = xcbeams; i--; ) {
187                pa[n+i].hd = cbeam[ncbeams+i].hd;
188                pa[n+i].bi = cbeam[ncbeams+i].bi;
189                pa[n+i].nr = 0;
190        }
191        n += xcbeams;
192        xcbeams = 0;                    /* delete orphans */
193        serv_request(DR_ADJSET, n*sizeof(PACKHEAD), (char *)pa);
194        free((char *)pa);
195        return;
196 memerr:
197        error(SYSTEM, "out of memory in cbeamadj");
198 }
199
200
167   cbeamop(op, bl, n, v, hr, vr)   /* update beams on server list */
168   int     op;
169   register struct beamcomp        *bl;
# Line 218 | Line 184 | int    hr, vr;
184                  pa[i].bi = bl[i].bi;
185                  pa[i].nr = v==NULL ? 0 :
186                                  npixels(v, hr, vr, hdlist[bl[i].hd], bl[i].bi);
187 +                pa[i].nc = 0;
188          }
189          serv_request(op, n*sizeof(PACKHEAD), (char *)pa);
190          free((char *)pa);
# Line 268 | Line 235 | get_voxels(vl, vp)     /* find voxels corresponding to vie
235   VOXL    vl[8];
236   FVECT   vp;
237   {
271        static int      lastn = 0, lastd = -1;
238          int     n = 0;
239          FVECT   gp;
240          double  d;
# Line 304 | Line 270 | FVECT  vp;
270                  error(COMMAND, "move past outer limits");
271                  return(0);
272          }
273 <                                        /* warn of dangerous moves */
308 <        if (n < lastn && bestd >= lastd)
309 <                error(WARNING, "moving outside holodeck section");
310 <        else if (n > lastn && bestd <= lastd)
311 <                error(WARNING, "moving inside holodeck section");
312 <        lastd = bestd;
313 <        return(lastn = n);
273 >        return(n);
274   }
275  
276  
# Line 375 | Line 335 | register struct cellact        *cap;
335          axmax = -1; avmax = 0;
336          for (i = 3; i--; ) {
337                  d = vgp[i] - cgp[i];
338 <                if (d < 0) d = -d;
338 >                if (d < 0.) d = -d;
339                  if (d > avmax) {
340                          avmax = d;
341                          axmax = i;
342                  }
343          }
344   #ifdef DEBUG
345 <        if (axmax < 0)
345 >        if (axmax < 0.)
346                  error(CONSISTENCY, "botched axis computation in docell");
347   #endif
348                                  /* compute offset vectors */
# Line 390 | Line 350 | register struct cellact        *cap;
350          for (i = 3; i--; )
351                  v1[i] = hp->xv[j][i] * d;
352          d = 0.5/hp->grid[j=(axmax+2)%3];
353 <        if (DOT(hp->wn[axmax], vc) < 0)
353 >        if (DOT(hp->wn[axmax], vc) < 0.)
354                  d = -d; /* reverse vertex ordering */
355          for (i = 3; i--; )
356                  v2[i] = hp->xv[j][i] * d;
# Line 469 | Line 429 | VIEW   *vold, *vnew;
429   }
430  
431  
432 + int
433   beam_sync()             /* synchronize beams on server */
434   {
435          cbeamop(DR_NEWSET, cbeam, ncbeams, &odev.v, odev.hres, odev.vres);
436 +        return(ncbeams);
437   }
438  
439  
# Line 482 | Line 444 | VIEW   *vn;
444          VOXL    vlnew[8];
445          int     n, comn;
446  
447 <        if (!vn->type) {                /* clear our beam list */
447 >        if (vn == NULL || !vn->type) {  /* clear our beam list */
448                  set_voxels(vlnew, 0);
449                  cbeamop(DR_DELSET, cbeam, ncbeams, NULL, 0, 0);
450                  ncbeams = 0;
451 <                copystruct(&dvw, vn);
451 >                dvw.type = 0;
452                  return(1);
453          }
454                                          /* find our new voxels */
# Line 505 | Line 467 | VIEW   *vn;
467                          mvview(ca.vi, &dvw, vn);
468                  else                    /* else add all new cells */
469                          doview(&ca, vn);
508 #if 1
509        cbeamadj(vn, odev.hres, odev.vres);
510 #else
470                                          /* inform server of new beams */
471          cbeamop(DR_ADDSET, cbeam+ncbeams, xcbeams, vn, odev.hres, odev.vres);
472                                          /* sort list to put orphans at end */
# Line 515 | Line 474 | VIEW   *vn;
474                                          /* tell server to delete orphans */
475          cbeamop(DR_DELSET, cbeam+ncbeams, xcbeams, NULL, 0, 0);
476          xcbeams = 0;                    /* truncate our list */
518 #endif
477          copystruct(&dvw, vn);           /* record new view */
478          return(1);
479   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines