26 |
|
|
27 |
|
#include "ray.h" |
28 |
|
|
29 |
+ |
#include "octree.h" |
30 |
+ |
|
31 |
|
#include "otypes.h" |
32 |
|
|
33 |
|
int inform = 'a'; /* input format */ |
55 |
|
|
56 |
|
static RAY thisray; /* for our convenience */ |
57 |
|
|
58 |
< |
extern int oputo(), oputd(), oputv(), oputl(), |
58 |
> |
static int oputo(), oputd(), oputv(), oputl(), |
59 |
|
oputp(), oputn(), oputs(), oputw(), oputm(); |
60 |
|
|
61 |
|
static int (*ray_out[10])(), (*every_out[10])(); |
62 |
+ |
static int castonly; |
63 |
|
|
64 |
< |
extern int puta(), putf(), putd(); |
64 |
> |
static int puta(), putf(), putd(); |
65 |
|
|
66 |
|
static int (*putreal)(); |
67 |
|
|
129 |
|
extern int ourtrace(), (*trace)(); |
130 |
|
register int (**table)() = ray_out; |
131 |
|
|
132 |
+ |
castonly = 1; |
133 |
|
while (*vs) |
134 |
|
switch (*vs++) { |
135 |
|
case 't': /* trace */ |
136 |
|
*table = NULL; |
137 |
|
table = every_out; |
138 |
|
trace = ourtrace; |
139 |
+ |
castonly = 0; |
140 |
|
break; |
141 |
|
case 'o': /* origin */ |
142 |
|
*table++ = oputo; |
146 |
|
break; |
147 |
|
case 'v': /* value */ |
148 |
|
*table++ = oputv; |
149 |
+ |
castonly = 0; |
150 |
|
break; |
151 |
|
case 'l': /* length */ |
152 |
|
*table++ = oputl; |
153 |
+ |
castonly = 0; |
154 |
|
break; |
155 |
|
case 'p': /* point */ |
156 |
|
*table++ = oputp; |
180 |
|
VCOPY(thisray.rorg, org); |
181 |
|
VCOPY(thisray.rdir, dir); |
182 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
183 |
< |
rayvalue(&thisray); |
183 |
> |
if (castonly) |
184 |
> |
localhit(&thisray, &thescene) || sourcehit(&thisray); |
185 |
> |
else |
186 |
> |
rayvalue(&thisray); |
187 |
|
|
188 |
|
if (ray_out[0] == NULL) |
189 |
|
return; |
236 |
|
return(-1); |
237 |
|
break; |
238 |
|
case 'f': /* binary float */ |
239 |
< |
if (fread(vf, sizeof(float), 3, fp) != 3) |
239 |
> |
if (fread((char *)vf, sizeof(float), 3, fp) != 3) |
240 |
|
return(-1); |
241 |
|
vec[0] = vf[0]; vec[1] = vf[1]; vec[2] = vf[2]; |
242 |
|
break; |
243 |
|
case 'd': /* binary double */ |
244 |
< |
if (fread(vec, sizeof(double), 3, fp) != 3) |
244 |
> |
if (fread((char *)vec, sizeof(double), 3, fp) != 3) |
245 |
|
return(-1); |
246 |
|
break; |
247 |
|
} |
309 |
|
oputl(r) /* print length */ |
310 |
|
register RAY *r; |
311 |
|
{ |
312 |
< |
if (r->rot < FHUGE) |
303 |
< |
(*putreal)(r->rot); |
304 |
< |
else |
305 |
< |
(*putreal)(0.0); |
312 |
> |
(*putreal)(r->rt); |
313 |
|
} |
314 |
|
|
315 |
|
|
389 |
|
putd(v) /* print binary double */ |
390 |
|
double v; |
391 |
|
{ |
392 |
< |
fwrite(&v, sizeof(v), 1, stdout); |
392 |
> |
fwrite((char *)&v, sizeof(v), 1, stdout); |
393 |
|
} |
394 |
|
|
395 |
|
|
399 |
|
{ |
400 |
|
float f = v; |
401 |
|
|
402 |
< |
fwrite(&f, sizeof(f), 1, stdout); |
402 |
> |
fwrite((char *)&f, sizeof(f), 1, stdout); |
403 |
|
} |