1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
40 |
|
d = DOT(hp->wg[i],hp->xv[i]); |
41 |
|
if (d <= FTINY & d >= -FTINY) |
42 |
|
error(USER, "degenerate holodeck section"); |
43 |
< |
d = (double)hp->grid[i] / d; |
43 |
> |
d = hp->grid[i] / d; |
44 |
|
hp->wg[i][0] *= d; hp->wg[i][1] *= d; hp->wg[i][2] *= d; |
45 |
– |
hp->wo[i<<1] = DOT(hp->wg[i],hp->orig); |
46 |
– |
d = DOT(hp->wg[i],hp->xv[i]); |
47 |
– |
hp->wo[i<<1|1] = hp->wo[i<<1] + d; |
45 |
|
} |
46 |
|
/* compute linear depth range */ |
47 |
|
hp->tlin = VLEN(hp->xv[0]) + VLEN(hp->xv[1]) + VLEN(hp->xv[2]); |
57 |
|
} |
58 |
|
|
59 |
|
|
63 |
– |
HOLO * |
64 |
– |
hdalloc(hproto) /* allocate and set holodeck section based on grid */ |
65 |
– |
HDGRID *hproto; |
66 |
– |
{ |
67 |
– |
HOLO hdhead; |
68 |
– |
register HOLO *hp; |
69 |
– |
int n; |
70 |
– |
/* copy grid to temporary header */ |
71 |
– |
bcopy((char *)hproto, (char *)&hdhead, sizeof(HDGRID)); |
72 |
– |
/* compute grid vectors and sizes */ |
73 |
– |
hdcompgrid(&hdhead); |
74 |
– |
/* allocate header with directory */ |
75 |
– |
n = sizeof(HOLO)+nbeams(&hdhead)*sizeof(BEAMI); |
76 |
– |
if ((hp = (HOLO *)malloc(n)) == NULL) |
77 |
– |
return(NULL); |
78 |
– |
/* copy header information */ |
79 |
– |
copystruct(hp, &hdhead); |
80 |
– |
/* allocate and clear beam list */ |
81 |
– |
hp->bl = (BEAM **)malloc((nbeams(hp)+1)*sizeof(BEAM *)+sizeof(BEAM)); |
82 |
– |
if (hp->bl == NULL) { |
83 |
– |
free((char *)hp); |
84 |
– |
return(NULL); |
85 |
– |
} |
86 |
– |
bzero((char *)hp->bl, (nbeams(hp)+1)*sizeof(BEAM *)+sizeof(BEAM)); |
87 |
– |
hp->bl[0] = (BEAM *)(hp->bl+nbeams(hp)+1); /* set blglob(hp) */ |
88 |
– |
hp->fd = -1; |
89 |
– |
hp->dirty = 0; |
90 |
– |
hp->priv = NULL; |
91 |
– |
/* clear beam directory */ |
92 |
– |
bzero((char *)hp->bi, (nbeams(hp)+1)*sizeof(BEAMI)); |
93 |
– |
return(hp); /* all is well */ |
94 |
– |
} |
95 |
– |
|
96 |
– |
|
60 |
|
hdbcoord(gc, hp, i) /* compute beam coordinates from index */ |
61 |
|
GCOORD gc[2]; /* returned */ |
62 |
|
register HOLO *hp; |
271 |
|
/* first, intersect walls */ |
272 |
|
gc[0].w = gc[1].w = -1; |
273 |
|
t0 = -FHUGE; t1 = FHUGE; |
274 |
+ |
VSUB(vt, ro, hp->orig); |
275 |
|
for (i = 0; i < 3; i++) { /* for each wall pair */ |
276 |
|
d = -DOT(rd, hp->wg[i]); /* plane distance */ |
277 |
|
if (d <= FTINY && d >= -FTINY) /* check for parallel */ |
278 |
|
continue; |
279 |
< |
d1 = DOT(ro, hp->wg[i]); /* ray distances */ |
280 |
< |
d0 = (d1 - hp->wo[i<<1]) / d; |
281 |
< |
d1 = (d1 - hp->wo[i<<1|1]) / d; |
282 |
< |
if (d0 < d1) { /* check against best */ |
279 |
> |
d1 = DOT(vt, hp->wg[i]); /* ray distances */ |
280 |
> |
d0 = d1 / d; |
281 |
> |
d1 = (d1 - hp->grid[i]) / d; |
282 |
> |
if (d < 0) { /* check against best */ |
283 |
|
if (d0 > t0) { |
284 |
|
t0 = d0; |
285 |
|
gc[0].w = i<<1; |
309 |
|
VSUB(vt, p[i], hp->orig); |
310 |
|
v = hp->wg[hdwg0[gc[i].w]]; |
311 |
|
d = DOT(vt, v); |
312 |
< |
if (d < 0. || (gc[i].i[0] = d) >= hp->grid[hdwg0[gc[i].w]]) |
312 |
> |
if (d < 0 || d >= hp->grid[hdwg0[gc[i].w]]) |
313 |
|
return(FHUGE); /* outside wall */ |
314 |
+ |
gc[i].i[0] = d; |
315 |
|
if (r != NULL) |
316 |
|
r[i][0] = 256. * (d - gc[i].i[0]); |
317 |
|
v = hp->wg[hdwg1[gc[i].w]]; |
318 |
|
d = DOT(vt, v); |
319 |
< |
if (d < 0. || (gc[i].i[1] = d) >= hp->grid[hdwg1[gc[i].w]]) |
319 |
> |
if (d < 0 || d >= hp->grid[hdwg1[gc[i].w]]) |
320 |
|
return(FHUGE); /* outside wall */ |
321 |
+ |
gc[i].i[1] = d; |
322 |
|
if (r != NULL) |
323 |
|
r[i][1] = 256. * (d - gc[i].i[1]); |
324 |
|
} |