ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/holo.c
(Generate patch)

Comparing ray/src/hd/holo.c (file contents):
Revision 3.16 by gwlarson, Fri Mar 12 09:37:47 1999 UTC vs.
Revision 3.23 by greg, Wed Mar 29 01:10:23 2017 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Routines for converting holodeck coordinates, etc.
6   *
# Line 20 | Line 17 | int    hdwg1[6] = {2,2,0,0,1,1};
17   static double   logstep;
18  
19  
20 < hdcompgrid(hp)                  /* compute derived grid vector and index */
21 < register HOLO   *hp;
20 > void
21 > hdcompgrid(                     /* compute derived grid vector and index */
22 >        HOLO    *hp
23 > )
24   {
25          double  d;
26 <        register int    i, j;
26 >        int     i, j;
27                                  /* initialize depth map */
28          if (hd_depthmap[0] < 1.) {
29                  d = 1. + .5/DCLIN;
# Line 38 | Line 37 | register HOLO  *hp;
37          for (i = 0; i < 3; i++) {
38                  fcross(hp->wg[i], hp->xv[(i+1)%3], hp->xv[(i+2)%3]);
39                  d = DOT(hp->wg[i],hp->xv[i]);
40 <                if (d <= FTINY & d >= -FTINY)
40 >                if ((d <= FTINY) & (d >= -FTINY))
41                          error(USER, "degenerate holodeck section");
42                  d = hp->grid[i] / d;
43                  hp->wg[i][0] *= d; hp->wg[i][1] *= d; hp->wg[i][2] *= d;
# Line 57 | Line 56 | register HOLO  *hp;
56   }
57  
58  
59 < hdbcoord(gc, hp, i)             /* compute beam coordinates from index */
60 < GCOORD  gc[2];          /* returned */
61 < register HOLO   *hp;
62 < register int    i;
59 > int
60 > hdbcoord(               /* compute beam coordinates from index */
61 >        GCOORD  gc[2],          /* returned */
62 >        HOLO    *hp,
63 >        int     i
64 > )
65   {
66 <        register int    j, n;
66 >        int     j, n;
67          int     n2, reverse;
68          GCOORD  g2[2];
69                                          /* check range */
70 <        if (i < 1 | i > nbeams(hp))
70 >        if ((i < 1) | (i > nbeams(hp)))
71                  return(0);
72 <        if (reverse = i >= hp->wi[5])
72 >        if ( (reverse = i >= hp->wi[5]) )
73                  i -= hp->wi[5] - 1;
74          for (j = 0; j < 5; j++)         /* find w0 */
75                  if (hp->wi[j+1] > i)
# Line 93 | Line 94 | register int   i;
94          gc[1].i[1] = i / hp->grid[hdwg0[gc[1].w]];
95          gc[1].i[0] = i - gc[1].i[1]*hp->grid[hdwg0[gc[1].w]];
96          if (reverse) {
97 <                copystruct(g2, gc+1);
98 <                copystruct(gc+1, gc);
99 <                copystruct(gc, g2);
97 >                *g2 = *(gc+1);
98 >                *(gc+1) = *gc;
99 >                *gc = *g2;
100          }
101          return(1);                      /* we're done */
102   }
103  
104  
105   int
106 < hdbindex(hp, gc)                /* compute index from beam coordinates */
107 < register HOLO   *hp;
108 < register GCOORD gc[2];
106 > hdbindex(               /* compute index from beam coordinates */
107 >        HOLO    *hp,
108 >        GCOORD  gc[2]
109 > )
110   {
111          GCOORD  g2[2];
112          int     reverse;
113 <        register int    i, j;
113 >        int     i, j;
114                                          /* check ordering and limits */
115 <        if (reverse = gc[0].w > gc[1].w) {
116 <                copystruct(g2, gc+1);
117 <                copystruct(g2+1, gc);
115 >        if ( (reverse = gc[0].w > gc[1].w) ) {
116 >                *g2 = *(gc+1);
117 >                *(g2+1) = *gc;
118                  gc = g2;
119          } else if (gc[0].w == gc[1].w)
120                  return(0);
121 <        if (gc[0].w < 0 | gc[1].w > 5)
121 >        if ((gc[0].w < 0) | (gc[1].w > 5))
122                  return(0);
123          i = 0;                          /* compute index */
124          for (j = gc[0].w+1; j < gc[1].w; j++)
# Line 132 | Line 134 | register GCOORD        gc[2];
134   }
135  
136  
137 < hdcell(cp, hp, gc)              /* compute cell coordinates */
138 < register FVECT  cp[4];  /* returned (may be passed as FVECT cp[2][2]) */
139 < register HOLO   *hp;
140 < register GCOORD *gc;
137 > void
138 > hdcell(         /* compute cell coordinates */
139 >        FVECT   cp[4],  /* returned (may be passed as FVECT cp[2][2]) */
140 >        HOLO    *hp,
141 >        GCOORD  *gc
142 > )
143   {
144 <        register FLOAT  *v;
144 >        RREAL   *v;
145          double  d;
146                                          /* compute common component */
147          VCOPY(cp[0], hp->orig);
# Line 164 | Line 168 | register GCOORD        *gc;
168   }
169  
170  
171 < hdlseg(lseg, hp, gc)                    /* compute line segment for beam */
172 < register int    lseg[2][3];
173 < register HOLO   *hp;
174 < GCOORD  gc[2];
171 > int
172 > hdlseg(                 /* compute line segment for beam */
173 >        int     lseg[2][3],
174 >        HOLO    *hp,
175 >        GCOORD  gc[2]
176 > )
177   {
178 <        register int    k;
178 >        int     k;
179  
180          for (k = 0; k < 2; k++) {               /* compute end points */
181                  lseg[k][gc[k].w>>1] = gc[k].w&1 ? hp->grid[gc[k].w>>1]-1 : 0 ;
# Line 180 | Line 186 | GCOORD gc[2];
186   }
187  
188  
189 < unsigned
190 < hdcode(hp, d)                   /* compute depth code for d */
191 < HOLO    *hp;
192 < double  d;
189 > unsigned int
190 > hdcode(                 /* compute depth code for d */
191 >        HOLO    *hp,
192 >        double  d
193 > )
194   {
195          double  tl = hp->tlin;
196 <        register long   c;
196 >        long    c;
197  
198          if (d <= 0.)
199                  return(0);
# Line 199 | Line 206 | double d;
206   }
207  
208  
209 < hdgrid(gp, hp, wp)              /* compute grid coordinates */
210 < FVECT   gp;             /* returned */
211 < register HOLO   *hp;
212 < FVECT   wp;
209 > void
210 > hdgrid(         /* compute grid coordinates */
211 >        FVECT   gp,             /* returned */
212 >        HOLO    *hp,
213 >        FVECT   wp
214 > )
215   {
216          FVECT   vt;
217  
# Line 213 | Line 222 | FVECT  wp;
222   }
223  
224  
225 < hdworld(wp, hp, gp)             /* compute world coordinates */
226 < register FVECT  wp;
227 < register HOLO   *hp;
228 < FVECT   gp;
225 > void
226 > hdworld(                /* compute world coordinates */
227 >        FVECT   wp,
228 >        HOLO    *hp,
229 >        FVECT   gp
230 > )
231   {
232 <        register double d;
232 >        double  d;
233  
234          d = gp[0]/hp->grid[0];
235          VSUM(wp, hp->orig, hp->xv[0], d);
# Line 232 | Line 243 | FVECT  gp;
243  
244  
245   double
246 < hdray(ro, rd, hp, gc, r)        /* compute ray within a beam */
247 < FVECT   ro, rd;         /* returned */
248 < HOLO    *hp;
249 < GCOORD  gc[2];
250 < BYTE    r[2][2];
246 > hdray(  /* compute ray within a beam */
247 >        FVECT   ro,
248 >        FVECT   rd,             /* returned */
249 >        HOLO    *hp,
250 >        GCOORD  gc[2],
251 >        uby8    r[2][2]
252 > )
253   {
254          FVECT   cp[4], p[2];
255 <        register int    i, j;
255 >        int     i, j;
256          double  d0, d1;
257                                          /* compute entry and exit points */
258          for (i = 0; i < 2; i++) {
# Line 257 | Line 270 | BYTE   r[2][2];
270  
271  
272   double
273 < hdinter(gc, r, ed, hp, ro, rd)  /* compute ray intersection with section */
274 < register GCOORD gc[2];  /* returned */
275 < BYTE    r[2][2];        /* returned (optional) */
276 < double  *ed;            /* returned (optional) */
277 < register HOLO   *hp;
278 < FVECT   ro, rd;         /* normalization of rd affects distances */
273 > hdinter(        /* compute ray intersection with section */
274 >        GCOORD  gc[2],  /* returned */
275 >        uby8    r[2][2],        /* returned (optional) */
276 >        double  *ed,            /* returned (optional) */
277 >        HOLO    *hp,
278 >        FVECT   ro,
279 >        FVECT   rd              /* normalization of rd affects distances */
280 > )
281   {
282          FVECT   p[2], vt;
283          double  d, t0, t1, d0, d1;
284 <        register FLOAT  *v;
285 <        register int    i;
284 >        RREAL   *v;
285 >        int     i;
286                                          /* first, intersect walls */
287          gc[0].w = gc[1].w = -1;
288          t0 = -FHUGE; t1 = FHUGE;
# Line 299 | Line 314 | FVECT  ro, rd;         /* normalization of rd affects distance
314                          }
315                  }
316          }
317 <        if (gc[0].w < 0 | gc[1].w < 0)          /* paranoid check */
317 >        if ((gc[0].w < 0) | (gc[1].w < 0))              /* paranoid check */
318                  return(FHUGE);
319                                                  /* compute intersections */
320          VSUM(p[0], ro, rd, t0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines