5 |
|
* Rtrace support routines for holodeck rendering |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include <time.h> |
9 |
+ |
|
10 |
|
#include "rholo.h" |
11 |
|
#include "paths.h" |
12 |
|
#include "random.h" |
22 |
|
double gmin[2], gmax[2]; /* grid coordinate limits */ |
23 |
|
}; /* a grid coordinate range */ |
24 |
|
|
25 |
+ |
static void initeyelim(struct gclim *gcl, HOLO *hp, GCOORD *gc); |
26 |
+ |
static void groweyelim(struct gclim *gcl, GCOORD *gc, |
27 |
+ |
double r0, double r1, int tight); |
28 |
+ |
static int clipeyelim(short rrng[2][2], struct gclim *gcl); |
29 |
|
|
30 |
< |
static |
31 |
< |
initeyelim(gcl, hp, gc) /* initialize grid coordinate limits */ |
32 |
< |
register struct gclim *gcl; |
33 |
< |
register HOLO *hp; |
34 |
< |
GCOORD *gc; |
30 |
> |
|
31 |
> |
static void |
32 |
> |
initeyelim( /* initialize grid coordinate limits */ |
33 |
> |
register struct gclim *gcl, |
34 |
> |
register HOLO *hp, |
35 |
> |
GCOORD *gc |
36 |
> |
) |
37 |
|
{ |
38 |
|
register RREAL *v; |
39 |
|
register int i; |
52 |
|
} |
53 |
|
|
54 |
|
|
55 |
< |
static |
56 |
< |
groweyelim(gcl, gc, r0, r1, tight) /* grow grid limits about eye point */ |
57 |
< |
register struct gclim *gcl; |
58 |
< |
GCOORD *gc; |
59 |
< |
double r0, r1; |
60 |
< |
int tight; |
55 |
> |
static void |
56 |
> |
groweyelim( /* grow grid limits about eye point */ |
57 |
> |
register struct gclim *gcl, |
58 |
> |
GCOORD *gc, |
59 |
> |
double r0, |
60 |
> |
double r1, |
61 |
> |
int tight |
62 |
> |
) |
63 |
|
{ |
64 |
|
FVECT gp, ab; |
65 |
|
double ab2, od, cfact; |
116 |
|
d*(c*d-b*e) + f*b*b); |
117 |
|
while (n-- > 0) { |
118 |
|
if (gc->w>>1 == gi[i] && |
119 |
< |
(gc->w&1) ^ root[n] < gp[gc->w>>1]) { |
119 |
> |
(gc->w&1) ^ (root[n] < gp[gc->w>>1])) { |
120 |
|
if (gc->w&1) |
121 |
|
gcl->gmin[i] = -FHUGE; |
122 |
|
else |
142 |
|
n = quadratic(root, a, b*yex+d, yex*(yex*c+e)+f); |
143 |
|
while (n-- > 0) { |
144 |
|
if (gc->w>>1 == gi[i] && |
145 |
< |
(gc->w&1) ^ root[n] < gp[gc->w>>1]) |
145 |
> |
(gc->w&1) ^ (root[n] < gp[gc->w>>1])) |
146 |
|
continue; |
147 |
|
if (root[n] < gcl->gmin[i]) |
148 |
|
gcl->gmin[i] = root[n]; |
155 |
|
|
156 |
|
|
157 |
|
static int |
158 |
< |
clipeyelim(rrng, gcl) /* clip eye limits to grid cell */ |
159 |
< |
register short rrng[2][2]; |
160 |
< |
register struct gclim *gcl; |
158 |
> |
clipeyelim( /* clip eye limits to grid cell */ |
159 |
> |
register short rrng[2][2], |
160 |
> |
register struct gclim *gcl |
161 |
> |
) |
162 |
|
{ |
163 |
|
int incell = 1; |
164 |
|
register int i; |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
< |
packrays(rod, p) /* pack ray origins and directions */ |
185 |
< |
register float *rod; |
186 |
< |
register PACKET *p; |
184 |
> |
extern void |
185 |
> |
packrays( /* pack ray origins and directions */ |
186 |
> |
register float *rod, |
187 |
> |
register PACKET *p |
188 |
> |
) |
189 |
|
{ |
190 |
|
#if 0 |
191 |
|
double dist2sum = 0.; |
265 |
|
} |
266 |
|
|
267 |
|
|
268 |
< |
donerays(p, rvl) /* encode finished ray computations */ |
269 |
< |
register PACKET *p; |
270 |
< |
register float *rvl; |
268 |
> |
extern void |
269 |
> |
donerays( /* encode finished ray computations */ |
270 |
> |
register PACKET *p, |
271 |
> |
register float *rvl |
272 |
> |
) |
273 |
|
{ |
274 |
|
double d; |
275 |
|
register int i; |
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
< |
int |
290 |
< |
done_rtrace() /* clean up and close rtrace calculation */ |
289 |
> |
extern int |
290 |
> |
done_rtrace(void) /* clean up and close rtrace calculation */ |
291 |
|
{ |
292 |
|
int status; |
293 |
|
/* already closed? */ |
308 |
|
} |
309 |
|
|
310 |
|
|
311 |
< |
new_rtrace() /* restart rtrace calculation */ |
311 |
> |
extern void |
312 |
> |
new_rtrace(void) /* restart rtrace calculation */ |
313 |
|
{ |
314 |
|
char combuf[128]; |
315 |
|
|
333 |
|
} |
334 |
|
|
335 |
|
|
336 |
< |
getradfile() /* run rad and get needed variables */ |
336 |
> |
extern int |
337 |
> |
getradfile(void) /* run rad and get needed variables */ |
338 |
|
{ |
339 |
|
static short mvar[] = {OCTREE,EYESEP,-1}; |
340 |
|
static char tf1[] = TEMPLATE; |
341 |
|
char tf2[64]; |
342 |
|
char combuf[256]; |
343 |
< |
char *pippt; |
343 |
> |
char *pippt = NULL; |
344 |
|
register int i; |
345 |
|
register char *cp; |
346 |
|
/* check if rad file specified */ |
376 |
|
loadvars(tf2); /* load variables */ |
377 |
|
unlink(tf2); |
378 |
|
} |
379 |
< |
rtargc += wordfile(rtargv+rtargc, tf1); /* get rtrace options */ |
379 |
> |
/* get rtrace options */ |
380 |
> |
rtargc += wordfile(rtargv+rtargc, MAXRTARGC-rtargc, tf1); |
381 |
|
unlink(tf1); /* clean up */ |
382 |
|
return(1); |
383 |
|
} |
384 |
|
|
385 |
|
|
386 |
< |
report(t) /* report progress so far */ |
387 |
< |
time_t t; |
386 |
> |
extern void |
387 |
> |
report( /* report progress so far */ |
388 |
> |
time_t t |
389 |
> |
) |
390 |
|
{ |
391 |
|
static time_t seconds2go = 1000000; |
392 |
|
|