| 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 |
|
* Holodeck beam support for display process |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
|
#include "rholo.h" |
| 9 |
|
#include "rhdisp.h" |
| 13 |
– |
#include "view.h" |
| 10 |
|
|
| 11 |
|
struct cellist { |
| 12 |
|
GCOORD *cl; |
| 16 |
|
|
| 17 |
|
int |
| 18 |
|
npixels(vp, hr, vr, hp, bi) /* compute appropriate nrays to evaluate */ |
| 19 |
< |
register VIEW *vp; |
| 19 |
> |
VIEW *vp; |
| 20 |
|
int hr, vr; |
| 21 |
|
HOLO *hp; |
| 22 |
|
int bi; |
| 25 |
|
GCOORD gc[2]; |
| 26 |
|
FVECT cp[4], ip[4], pf, pb; |
| 27 |
|
double af, ab, sf2, sb2, dfb2, df2, db2, penalty; |
| 28 |
< |
register int i; |
| 28 |
> |
int i; |
| 29 |
> |
/* special case */ |
| 30 |
> |
if (hr <= 0 | vr <= 0) |
| 31 |
> |
return(0); |
| 32 |
|
/* compute cell corners in image */ |
| 33 |
|
if (!hdbcoord(gc, hp, bi)) |
| 34 |
|
error(CONSISTENCY, "bad beam index in npixels"); |
| 37 |
|
pf[i] = 0.5*(cp[0][i] + cp[2][i]); |
| 38 |
|
sf2 = 0.25*dist2(cp[0], cp[2]); /* compute half diagonal length */ |
| 39 |
|
for (i = 0; i < 4; i++) { /* compute visible quad */ |
| 40 |
< |
viewloc(ip[i], vp, cp[i]); |
| 42 |
< |
if (ip[i][2] < 0.) { |
| 40 |
> |
if (viewloc(ip[i], vp, cp[i]) <= 0) { |
| 41 |
|
af = 0; |
| 42 |
|
goto getback; |
| 43 |
|
} |
| 51 |
|
(ip[1][0]-ip[3][0])*(ip[2][1]-ip[3][1]); |
| 52 |
|
af *= af >= 0 ? 0.5 : -0.5; |
| 53 |
|
getback: |
| 54 |
< |
copystruct(&vrev, vp); /* compute reverse view */ |
| 54 |
> |
vrev = *vp; /* compute reverse view */ |
| 55 |
|
for (i = 0; i < 3; i++) { |
| 56 |
|
vrev.vdir[i] = -vp->vdir[i]; |
| 57 |
|
vrev.vup[i] = -vp->vup[i]; |
| 63 |
|
pb[i] = 0.5*(cp[0][i] + cp[2][i]); |
| 64 |
|
sb2 = 0.25*dist2(cp[0], cp[2]); /* compute half diagonal length */ |
| 65 |
|
for (i = 0; i < 4; i++) { /* compute visible quad */ |
| 66 |
< |
viewloc(ip[i], &vrev, cp[i]); |
| 69 |
< |
if (ip[i][2] < 0.) { |
| 66 |
> |
if (viewloc(ip[i], &vrev, cp[i]) <= 0) { |
| 67 |
|
ab = 0; |
| 68 |
|
goto finish; |
| 69 |
|
} |
| 101 |
|
int |
| 102 |
|
visit_cells(orig, pyrd, hp, vf, dp) /* visit cells within a pyramid */ |
| 103 |
|
FVECT orig, pyrd[4]; /* pyramid ray directions in clockwise order */ |
| 104 |
< |
register HOLO *hp; |
| 104 |
> |
HOLO *hp; |
| 105 |
|
int (*vf)(); |
| 106 |
|
char *dp; |
| 107 |
|
{ |
| 110 |
|
FVECT gp, pn[4], lo, ld; |
| 111 |
|
double po[4], lbeg, lend, d, t; |
| 112 |
|
GCOORD gc, gc2[2]; |
| 113 |
< |
register int i; |
| 113 |
> |
int i; |
| 114 |
|
/* figure out whose side we're on */ |
| 115 |
|
hdgrid(gp, hp, orig); |
| 116 |
|
for (i = 0; i < 3; i++) { |
| 179 |
|
|
| 180 |
|
|
| 181 |
|
sect_behind(hp, vp) /* check if section is "behind" viewpoint */ |
| 182 |
< |
register HOLO *hp; |
| 183 |
< |
register VIEW *vp; |
| 182 |
> |
HOLO *hp; |
| 183 |
> |
VIEW *vp; |
| 184 |
|
{ |
| 185 |
|
FVECT hcent; |
| 186 |
|
/* compute holodeck section center */ |
| 197 |
|
HOLO *hp; |
| 198 |
|
VIEW *vp; |
| 199 |
|
{ |
| 200 |
< |
register int i; |
| 200 |
> |
int i; |
| 201 |
|
/* check view type */ |
| 202 |
|
if (vp->type == VT_PAR) |
| 203 |
|
return(0); |
| 234 |
|
int |
| 235 |
|
addcell(gcp, cl) /* add a cell to a list */ |
| 236 |
|
GCOORD *gcp; |
| 237 |
< |
register struct cellist *cl; |
| 237 |
> |
struct cellist *cl; |
| 238 |
|
{ |
| 239 |
< |
copystruct(cl->cl+cl->n, gcp); |
| 239 |
> |
*(cl->cl+cl->n) = *gcp; |
| 240 |
|
cl->n++; |
| 241 |
|
return(1); |
| 242 |
|
} |
| 244 |
|
|
| 245 |
|
int |
| 246 |
|
cellcmp(gcp1, gcp2) /* visit_cells() cell ordering */ |
| 247 |
< |
register GCOORD *gcp1, *gcp2; |
| 247 |
> |
GCOORD *gcp1, *gcp2; |
| 248 |
|
{ |
| 249 |
< |
register int c; |
| 249 |
> |
int c; |
| 250 |
|
|
| 251 |
|
if ((c = gcp1->w - gcp2->w)) |
| 252 |
|
return(c); |
| 259 |
|
GCOORD * |
| 260 |
|
getviewcells(np, hp, vp) /* get ordered cell list for section view */ |
| 261 |
|
int *np; /* returned number of cells (negative if reversed) */ |
| 262 |
< |
register HOLO *hp; |
| 262 |
> |
HOLO *hp; |
| 263 |
|
VIEW *vp; |
| 264 |
|
{ |
| 265 |
|
FVECT org, dir[4]; |
| 278 |
|
if (cl.cl == NULL) |
| 279 |
|
goto memerr; |
| 280 |
|
cl.n = 0; /* add cells within pyramid */ |
| 281 |
< |
visit_cells(org, dir, hp, addcell, &cl); |
| 281 |
> |
visit_cells(org, dir, hp, addcell, (char *)&cl); |
| 282 |
|
if (!cl.n) { |
| 283 |
< |
free((char *)cl.cl); |
| 283 |
> |
free((void *)cl.cl); |
| 284 |
|
return(NULL); |
| 285 |
|
} |
| 286 |
|
*np = cl.n * orient; |
| 289 |
|
* sorted automatically by visit_cells(), so we don't need this. |
| 290 |
|
*/ |
| 291 |
|
/* optimize memory use */ |
| 292 |
< |
cl.cl = (GCOORD *)realloc((char *)cl.cl, cl.n*sizeof(GCOORD)); |
| 292 |
> |
cl.cl = (GCOORD *)realloc((void *)cl.cl, cl.n*sizeof(GCOORD)); |
| 293 |
|
if (cl.cl == NULL) |
| 294 |
|
goto memerr; |
| 295 |
|
/* sort the list */ |
| 301 |
|
} |
| 302 |
|
|
| 303 |
|
|
| 304 |
< |
gridlines(f) /* run through holodeck section grid lines */ |
| 305 |
< |
int (*f)(); |
| 304 |
> |
void |
| 305 |
> |
gridlines( /* run through holodeck section grid lines */ |
| 306 |
> |
void (*f)(FVECT wp[2]) |
| 307 |
> |
) |
| 308 |
|
{ |
| 309 |
< |
register int hd, w, i; |
| 309 |
> |
int hd, w, i; |
| 310 |
|
int g0, g1; |
| 311 |
|
FVECT wp[2], mov; |
| 312 |
|
double d; |