12 |
|
#include "view.h" |
13 |
|
#include "resolu.h" |
14 |
|
|
15 |
+ |
#ifndef BLOADSIZE |
16 |
+ |
#define BLOADSIZE 1024 /* number of input beams to load at a time */ |
17 |
+ |
#endif |
18 |
+ |
|
19 |
|
int checkdepth = 1; /* check depth (!-f option)? */ |
20 |
|
int checkrepeats = 0; /* check for repeats (-c option)? */ |
21 |
|
int frompicz; /* input from pictures & depth-buffers? */ |
35 |
|
frompicz = -1; |
36 |
|
for (i = 2; i < argc && argv[i][0] == '-'; i++) |
37 |
|
switch (argv[i][1]) { |
38 |
< |
case 'c': |
38 |
> |
case 'u': |
39 |
|
checkrepeats = 1; |
40 |
|
break; |
41 |
< |
case 'f': |
41 |
> |
case 'd': |
42 |
|
checkdepth = 0; |
43 |
|
break; |
44 |
|
case 'h': |
63 |
|
addholo(argv[i]); |
64 |
|
quit(0); |
65 |
|
userr: |
66 |
< |
fprintf(stderr, "Usage: %s output.hdk [-c][-f] -h inp1.hdk ..\n", |
66 |
> |
fprintf(stderr, "Usage: %s output.hdk [-u][-d] -h inp1.hdk ..\n", |
67 |
|
progname); |
68 |
< |
fprintf(stderr, " Or: %s output.hdk [-c][-f] -pz inp1.pic inp1.zbf ..\n", |
68 |
> |
fprintf(stderr, " Or: %s output.hdk [-u][-d] -pz inp1.pic inp1.zbf ..\n", |
69 |
|
progname); |
70 |
|
exit(1); |
71 |
|
} |
75 |
|
#define H_OBST 02 |
76 |
|
#define H_OBSF 04 |
77 |
|
|
78 |
+ |
int |
79 |
|
holheadline(s, hf) /* check holodeck header line */ |
80 |
|
register char *s; |
81 |
|
int *hf; |
87 |
|
*hf |= H_BADF; |
88 |
|
else |
89 |
|
*hf &= ~H_BADF; |
90 |
< |
return; |
90 |
> |
return(0); |
91 |
|
} |
92 |
|
if (!strncmp(s, "OBSTRUCTIONS=", 13)) { |
93 |
|
s += 13; |
98 |
|
*hf |= H_OBSF; |
99 |
|
else |
100 |
|
error(WARNING, "bad OBSTRUCTIONS value in holodeck"); |
101 |
< |
return; |
101 |
> |
return(0); |
102 |
|
} |
103 |
+ |
return(0); |
104 |
|
} |
105 |
|
|
106 |
|
int |
193 |
|
addholo(hdf) /* add a holodeck file */ |
194 |
|
char *hdf; |
195 |
|
{ |
196 |
+ |
HDBEAMI hbl[BLOADSIZE]; |
197 |
|
int fd; |
198 |
|
register HOLO *hp; |
199 |
|
register BEAM *bp; |
193 |
– |
register HDBEAMI *hbl; |
200 |
|
GCOORD gc[2]; |
201 |
|
FVECT ro, rd; |
202 |
|
double d; |
203 |
< |
int i, j; |
203 |
> |
int i, j, n, li; |
204 |
|
register int k; |
205 |
|
/* open the holodeck for reading */ |
206 |
|
openholo(hdf, 0); |
207 |
|
fd = hdlist[noutsects]->fd; /* remember the file handle */ |
208 |
|
while ((hp = hdlist[noutsects]) != NULL) { /* load each section */ |
209 |
< |
hbl = (HDBEAMI *)malloc(nbeams(hp)*sizeof(HDBEAMI)); |
210 |
< |
if (hbl == NULL) |
211 |
< |
error(SYSTEM, "out of memory in addholo"); |
212 |
< |
for (j = nbeams(hp); j > 0; j--) { /* sort the beams */ |
213 |
< |
hbl[j].h = hp; |
214 |
< |
hbl[j].b = j; |
215 |
< |
} |
216 |
< |
qsort((char *)hbl, nbeams(hp), sizeof(HDBEAMI), hdfilord); |
217 |
< |
for (j = 0; j < nbeams(hp); j++) /* load each beam */ |
218 |
< |
if ((bp = hdgetbeam(hp, hbl[j].b)) != NULL) { |
219 |
< |
hdbcoord(gc, hp, hbl[j].b); |
209 |
> |
for (j = 0; j < nbeams(hp); j++) { /* load each beam */ |
210 |
> |
if (!(li = j % BLOADSIZE)) { /* optimize order */ |
211 |
> |
if (j+BLOADSIZE > nbeams(hp)) |
212 |
> |
k = n = nbeams(hp) - j; |
213 |
> |
else |
214 |
> |
k = n = BLOADSIZE; |
215 |
> |
while (k--) { |
216 |
> |
hbl[k].h = hp; |
217 |
> |
hbl[k].b = j+k+1; |
218 |
> |
} |
219 |
> |
qsort((char *)hbl, n, |
220 |
> |
sizeof(HDBEAMI), hdfilord); |
221 |
> |
} |
222 |
> |
if ((bp = hdgetbeam(hp, hbl[li].b)) != NULL) { |
223 |
> |
hdbcoord(gc, hp, hbl[li].b); |
224 |
|
for (k = bp->nrm; k--; ) { |
225 |
|
d = hdray(ro, rd, |
226 |
|
hp, gc, hdbray(bp)[k].r); |
231 |
|
d = hddepth(hp, hdbray(bp)[k].d) - d; |
232 |
|
addray(ro, rd, d, hdbray(bp)[k].v); |
233 |
|
} |
234 |
< |
hdfreebeam(hp, hbl[j].b); /* free beam */ |
234 |
> |
hdfreebeam(hp, hbl[li].b); /* free beam */ |
235 |
|
} |
236 |
< |
free((char *)hbl); /* free beam list */ |
236 |
> |
} |
237 |
|
hddone(hp); /* free the section */ |
238 |
|
} |
239 |
|
close(fd); /* close the file */ |
249 |
|
}; |
250 |
|
|
251 |
|
|
252 |
+ |
int |
253 |
|
picheadline(s, ph) /* process picture header line */ |
254 |
|
char *s; |
255 |
|
struct phead *ph; |
258 |
|
|
259 |
|
if (formatval(fmt, s)) { |
260 |
|
ph->badfmt = strcmp(fmt, COLRFMT); |
261 |
< |
return; |
261 |
> |
return(0); |
262 |
|
} |
263 |
|
if (isprims(s)) { |
264 |
|
ph->altprims++; /* don't want to deal with this */ |
265 |
< |
return; |
265 |
> |
return(0); |
266 |
|
} |
267 |
|
if (isexpos(s)) { |
268 |
|
ph->expos *= exposval(s); |
269 |
< |
return; |
269 |
> |
return(0); |
270 |
|
} |
271 |
|
if (isview(s)) { |
272 |
|
ph->gotview += sscanview(&ph->vw, s); |
273 |
< |
return; |
273 |
> |
return(0); |
274 |
|
} |
275 |
+ |
return(0); |
276 |
|
} |
277 |
|
|
278 |
|
|