12 |
|
#include "view.h" |
13 |
|
#include "resolu.h" |
14 |
|
|
15 |
+ |
int checkdepth = 1; /* check depth (!-f option)? */ |
16 |
+ |
int checkrepeats = 0; /* check for repeats (-c option)? */ |
17 |
|
int frompicz; /* input from pictures & depth-buffers? */ |
18 |
|
int noutsects; /* number of output sections */ |
19 |
|
char obstr, unobstr; /* flag pointer values */ |
28 |
|
int i; |
29 |
|
|
30 |
|
progname = argv[0]; |
31 |
< |
if (argc < 4) |
31 |
> |
frompicz = -1; |
32 |
> |
for (i = 2; i < argc && argv[i][0] == '-'; i++) |
33 |
> |
switch (argv[i][1]) { |
34 |
> |
case 'c': |
35 |
> |
checkrepeats = 1; |
36 |
> |
break; |
37 |
> |
case 'f': |
38 |
> |
checkdepth = 0; |
39 |
> |
break; |
40 |
> |
case 'h': |
41 |
> |
frompicz = 0; |
42 |
> |
break; |
43 |
> |
case 'p': |
44 |
> |
frompicz = 1; |
45 |
> |
break; |
46 |
> |
default: |
47 |
> |
goto userr; |
48 |
> |
} |
49 |
> |
if (i >= argc || frompicz < 0) |
50 |
|
goto userr; |
51 |
< |
if (!strcmp(argv[2], "-h")) |
32 |
< |
frompicz = 0; |
33 |
< |
else if (!strcmp(argv[2], "-pz")) |
34 |
< |
frompicz = 1; |
35 |
< |
else |
51 |
> |
if (frompicz && (argc-i)%2) |
52 |
|
goto userr; |
37 |
– |
if (frompicz && (argc-3)%2) |
38 |
– |
goto userr; |
53 |
|
noutsects = openholo(argv[1], 1); |
54 |
|
if (frompicz) |
55 |
< |
for (i = 3; i < argc; i += 2) |
55 |
> |
for ( ; i < argc; i += 2) |
56 |
|
addpicz(argv[i], argv[i+1]); |
57 |
|
else |
58 |
< |
for (i = 3; i < argc; i++) |
58 |
> |
for ( ; i < argc; i++) |
59 |
|
addholo(argv[i]); |
60 |
|
quit(0); |
61 |
|
userr: |
62 |
< |
fprintf(stderr, "Usage: %s output.hdk -h inp1.hdk ..\n", progname); |
49 |
< |
fprintf(stderr, " Or: %s output.hdk -pz inp1.pic inp1.zbf ..\n", |
62 |
> |
fprintf(stderr, "Usage: %s output.hdk [-c][-f] -h inp1.hdk ..\n", |
63 |
|
progname); |
64 |
+ |
fprintf(stderr, " Or: %s output.hdk [-c][-f] -pz inp1.pic inp1.zbf ..\n", |
65 |
+ |
progname); |
66 |
|
exit(1); |
67 |
|
} |
68 |
|
|
142 |
|
double d; |
143 |
|
COLR cv; |
144 |
|
{ |
145 |
< |
int sn; |
145 |
> |
int sn, bi, n; |
146 |
|
register HOLO *hp; |
147 |
|
GCOORD gc[2]; |
148 |
|
BYTE rr[2][2]; |
149 |
+ |
BEAM *bp; |
150 |
|
double d0, d1; |
151 |
+ |
unsigned dc; |
152 |
|
register RAYVAL *rv; |
153 |
|
/* check each output section */ |
154 |
|
for (sn = noutsects; sn--; ) { |
156 |
|
d0 = hdinter(gc, rr, &d1, hp, ro, rd); |
157 |
|
if (d <= d0 || d1 < -0.001) |
158 |
|
continue; /* missed section */ |
159 |
< |
if (hp->priv == &obstr && d0 < -0.001) |
160 |
< |
continue; /* ray starts too late */ |
161 |
< |
if (hp->priv == &unobstr && d < 0.999*d1) |
162 |
< |
continue; /* ray ends too soon */ |
163 |
< |
/* should we check for duplicates? */ |
164 |
< |
rv = hdnewrays(hp, hdbindex(hp, gc), 1); |
159 |
> |
if (checkdepth) { /* check depth */ |
160 |
> |
if (hp->priv == &obstr && d0 < -0.001) |
161 |
> |
continue; /* ray starts too late */ |
162 |
> |
if (hp->priv == &unobstr && d < 0.999*d1) |
163 |
> |
continue; /* ray ends too soon */ |
164 |
> |
} |
165 |
> |
dc = hdcode(hp, d-d0); |
166 |
> |
bi = hdbindex(hp, gc); /* check for duplicates */ |
167 |
> |
if (checkrepeats && (bp = hdgetbeam(hp, bi)) != NULL) { |
168 |
> |
for (n = bp->nrm, rv = hdbray(bp); n--; rv++) |
169 |
> |
if (rv->d == dc && |
170 |
> |
rv->r[0][0] == rr[0][0] && |
171 |
> |
rv->r[0][1] == rr[0][1] && |
172 |
> |
rv->r[1][0] == rr[1][0] && |
173 |
> |
rv->r[1][1] == rr[1][1]) |
174 |
> |
break; |
175 |
> |
if (n >= 0) |
176 |
> |
continue; /* found a matching ray */ |
177 |
> |
} |
178 |
> |
rv = hdnewrays(hp, bi, 1); |
179 |
> |
rv->d = dc; |
180 |
|
rv->r[0][0] = rr[0][0]; rv->r[0][1] = rr[0][1]; |
181 |
|
rv->r[1][0] = rr[1][0]; rv->r[1][1] = rr[1][1]; |
182 |
|
copycolr(rv->v, cv); |
151 |
– |
rv->d = hdcode(hp, d-d0); |
183 |
|
} |
184 |
|
} |
185 |
|
|