16 |
|
#define MAXDIST 42 /* maximum distance outside section */ |
17 |
|
#endif |
18 |
|
|
19 |
< |
#define MAXVOXEL 16 /* maximum number of active voxels */ |
19 |
> |
#define MAXVOXEL 32 /* maximum number of active voxels */ |
20 |
|
|
21 |
|
typedef struct { |
22 |
|
int hd; /* holodeck section number (-1 if inactive) */ |
28 |
|
#define CBEAMBLK 1024 /* cbeam allocation block size */ |
29 |
|
|
30 |
|
static struct beamcomp { |
31 |
< |
unsigned int2 wants; /* flags telling which voxels want us */ |
32 |
< |
unsigned int2 hd; /* holodeck section number */ |
31 |
> |
int hd; /* holodeck section number */ |
32 |
|
int4 bi; /* beam index */ |
33 |
|
int4 nr; /* number of samples desired */ |
34 |
|
} *cbeam = NULL; /* current beam list */ |
39 |
|
|
40 |
|
struct cellact { |
41 |
|
short vi; /* voxel index */ |
43 |
– |
short add; /* zero means delete */ |
42 |
|
short rev; /* reverse ray direction? */ |
43 |
|
VIEW *vp; /* view for image */ |
44 |
|
short hr, vr; /* image resolution */ |
88 |
|
{ |
89 |
|
register int c; |
90 |
|
|
91 |
< |
if (!cb1->wants) /* put orphans at the end, unsorted */ |
92 |
< |
return(cb2->wants); |
93 |
< |
if (!cb2->wants) |
91 |
> |
if (!cb1->nr) /* put orphans at the end, unsorted */ |
92 |
> |
return(cb2->nr); |
93 |
> |
if (!cb2->nr) |
94 |
|
return(-1); |
95 |
|
if ((c = cb1->bi - cb2->bi)) /* sort on beam index first */ |
96 |
|
return(c); |
107 |
|
|
108 |
|
if (ncbeams <= 0) |
109 |
|
return(-1); |
110 |
< |
cb.wants = 0; cb.hd = hd; cb.bi = bi; cb.nr = 0; |
110 |
> |
cb.hd = hd; cb.bi = bi; cb.nr = 0; |
111 |
|
p = (struct beamcomp *)bsearch((char *)&cb, (char *)cbeam, ncbeams, |
112 |
|
sizeof(struct beamcomp), cbeamcmp); |
113 |
|
if (p == NULL) |
135 |
|
if (bi < 1 | bi > nbeams(hdlist[hd])) |
136 |
|
error(INTERNAL, "illegal beam index in getcbeam"); |
137 |
|
n = newcbeam(); /* allocate and assign */ |
138 |
< |
cbeam[n].wants = cbeam[n].nr = 0; cbeam[n].hd = hd; cbeam[n].bi = bi; |
138 |
> |
cbeam[n].nr = 0; cbeam[n].hd = hd; cbeam[n].bi = bi; |
139 |
|
return(n); |
140 |
|
} |
141 |
|
|
153 |
|
if (adopt) |
154 |
|
return; |
155 |
|
for (i = ncbeams; i--; ) /* identify orphans */ |
156 |
< |
if (cbeam[i].wants) |
156 |
> |
if (cbeam[i].nr) |
157 |
|
break; |
158 |
|
xcbeams = ncbeams - ++i; /* put orphans after ncbeams */ |
159 |
|
ncbeams = i; |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
+ |
unsigned int4 |
188 |
|
add_voxels(vp) /* add voxels corresponding to view point */ |
189 |
|
FVECT vp; |
190 |
|
{ |
261 |
|
} |
262 |
|
if ((bi = hdbindex(hdlist[voxel[bp->ca.vi].hd], gc)) <= 0) |
263 |
|
error(CONSISTENCY, "bad grid coordinate in dobeam"); |
264 |
< |
if (bp->ca.add) { /* add it in */ |
265 |
< |
i = getcbeam(voxel[bp->ca.vi].hd, bi); |
266 |
< |
cbeam[i].wants |= 1<<bp->ca.vi; /* say we want it */ |
267 |
< |
n = npixels(bp->ca.vp, bp->ca.hr, bp->ca.vr, |
268 |
< |
hdlist[cbeam[i].hd], cbeam[i].bi); |
269 |
< |
if (n > cbeam[i].nr) |
270 |
< |
cbeam[i].nr = n; |
272 |
< |
return(i == ncbeams+xcbeams-1); /* return 1 if totally new */ |
273 |
< |
} |
274 |
< |
/* else delete it */ |
275 |
< |
i = findcbeam(voxel[bp->ca.vi].hd, bi); |
276 |
< |
if (i >= 0 && cbeam[i].wants & 1<<bp->ca.vi) { |
277 |
< |
cbeam[i].wants &= ~(1<<bp->ca.vi); /* we don't want it */ |
278 |
< |
if (!cbeam[i].wants) |
279 |
< |
cbeam[i].nr = 0; |
280 |
< |
return(1); /* indicate change */ |
281 |
< |
} |
282 |
< |
return(0); |
264 |
> |
/* add it in */ |
265 |
> |
i = getcbeam(voxel[bp->ca.vi].hd, bi); |
266 |
> |
n = npixels(bp->ca.vp, bp->ca.hr, bp->ca.vr, |
267 |
> |
hdlist[cbeam[i].hd], cbeam[i].bi); |
268 |
> |
if (n > cbeam[i].nr) |
269 |
> |
cbeam[i].nr = n; |
270 |
> |
return(i == ncbeams+xcbeams-1); /* return 1 if totally new */ |
271 |
|
} |
272 |
|
|
273 |
|
|
354 |
|
register int i; |
355 |
|
/* clear desire flags */ |
356 |
|
for (i = ncbeams+xcbeams; i--; ) |
357 |
< |
cbeam[i].wants = cbeam[i].nr = 0; |
357 |
> |
cbeam[i].nr = 0; |
358 |
|
voxel[0].hd = -1; /* clear voxel list */ |
359 |
|
} |
360 |
|
|
364 |
|
int hr, vr; |
365 |
|
{ |
366 |
|
struct cellact ca; |
367 |
< |
int vfl; |
367 |
> |
unsigned int4 vfl; |
368 |
|
/* sort our list */ |
369 |
|
cbeamsort(1); |
370 |
|
/* add new voxels */ |
372 |
|
if (!vfl) |
373 |
|
return(0); |
374 |
|
ca.vp = vn; ca.hr = hr; ca.vr = vr; |
375 |
< |
ca.add = 1; /* update our beam list */ |
375 |
> |
/* update our beam list */ |
376 |
|
for (ca.vi = 0; vfl; vfl >>= 1, ca.vi++) |
377 |
|
if (vfl & 1) |
378 |
|
doview(&ca); |