10 |
|
#include "copyright.h" |
11 |
|
|
12 |
|
#include "ray.h" |
13 |
< |
|
13 |
> |
#include "source.h" |
14 |
|
#include "otypes.h" |
15 |
– |
|
15 |
|
#include "otspecial.h" |
16 |
|
|
17 |
|
#define MAXCSET ((MAXSET+1)*2-1) /* maximum check set size */ |
27 |
|
|
28 |
|
OBJREC Aftplane; /* aft clipping plane object */ |
29 |
|
|
31 |
– |
static int raymove(), checkhit(); |
32 |
– |
static void checkset(); |
33 |
– |
|
30 |
|
#define RAYHIT (-1) /* return value for intercepted ray */ |
31 |
|
|
32 |
+ |
static int raymove(FVECT pos, OBJECT *cxs, int dirf, RAY *r, CUBE *cu); |
33 |
+ |
static int checkhit(RAY *r, CUBE *cu, OBJECT *cxs); |
34 |
+ |
static void checkset(OBJECT *os, OBJECT *cs); |
35 |
|
|
36 |
< |
int |
37 |
< |
rayorigin(r, ro, rt, rw) /* start new ray from old one */ |
38 |
< |
register RAY *r, *ro; |
39 |
< |
int rt; |
40 |
< |
double rw; |
36 |
> |
|
37 |
> |
extern int |
38 |
> |
rayorigin( /* start new ray from old one */ |
39 |
> |
register RAY *r, |
40 |
> |
register RAY *ro, |
41 |
> |
int rt, |
42 |
> |
double rw |
43 |
> |
) |
44 |
|
{ |
45 |
|
double re; |
46 |
|
|
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
< |
void |
91 |
< |
rayclear(r) /* clear a ray for (re)evaluation */ |
92 |
< |
register RAY *r; |
90 |
> |
extern void |
91 |
> |
rayclear( /* clear a ray for (re)evaluation */ |
92 |
> |
register RAY *r |
93 |
> |
) |
94 |
|
{ |
95 |
|
r->rno = raynum++; |
96 |
|
r->newcset = r->clipset; |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
< |
void |
110 |
< |
raytrace(r) /* trace a ray and compute its value */ |
111 |
< |
RAY *r; |
109 |
> |
extern void |
110 |
> |
raytrace( /* trace a ray and compute its value */ |
111 |
> |
RAY *r |
112 |
> |
) |
113 |
|
{ |
114 |
|
if (localhit(r, &thescene)) |
115 |
|
raycont(r); /* hit local surface, evaluate */ |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
< |
void |
130 |
< |
raycont(r) /* check for clipped object and continue */ |
131 |
< |
register RAY *r; |
129 |
> |
extern void |
130 |
> |
raycont( /* check for clipped object and continue */ |
131 |
> |
register RAY *r |
132 |
> |
) |
133 |
|
{ |
134 |
|
if ((r->clipset != NULL && inset(r->clipset, r->ro->omod)) || |
135 |
|
!rayshade(r, r->ro->omod)) |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
< |
void |
141 |
< |
raytrans(r) /* transmit ray as is */ |
142 |
< |
register RAY *r; |
140 |
> |
extern void |
141 |
> |
raytrans( /* transmit ray as is */ |
142 |
> |
register RAY *r |
143 |
> |
) |
144 |
|
{ |
145 |
|
RAY tr; |
146 |
|
|
153 |
|
} |
154 |
|
|
155 |
|
|
156 |
< |
int |
157 |
< |
rayshade(r, mod) /* shade ray r with material mod */ |
158 |
< |
register RAY *r; |
159 |
< |
int mod; |
156 |
> |
extern int |
157 |
> |
rayshade( /* shade ray r with material mod */ |
158 |
> |
register RAY *r, |
159 |
> |
int mod |
160 |
> |
) |
161 |
|
{ |
162 |
|
int gotmat; |
163 |
|
register OBJREC *m; |
188 |
|
} |
189 |
|
|
190 |
|
|
191 |
< |
void |
192 |
< |
rayparticipate(r) /* compute ray medium participation */ |
193 |
< |
register RAY *r; |
191 |
> |
extern void |
192 |
> |
rayparticipate( /* compute ray medium participation */ |
193 |
> |
register RAY *r |
194 |
> |
) |
195 |
|
{ |
196 |
|
COLOR ce, ca; |
197 |
|
double re, ge, be; |
221 |
|
} |
222 |
|
|
223 |
|
|
224 |
< |
void |
225 |
< |
raytexture(r, mod) /* get material modifiers */ |
226 |
< |
RAY *r; |
227 |
< |
OBJECT mod; |
224 |
> |
extern void |
225 |
> |
raytexture( /* get material modifiers */ |
226 |
> |
RAY *r, |
227 |
> |
OBJECT mod |
228 |
> |
) |
229 |
|
{ |
230 |
|
register OBJREC *m; |
231 |
|
/* execute textures and patterns */ |
246 |
|
} |
247 |
|
|
248 |
|
|
249 |
< |
int |
250 |
< |
raymixture(r, fore, back, coef) /* mix modifiers */ |
251 |
< |
register RAY *r; |
252 |
< |
OBJECT fore, back; |
253 |
< |
double coef; |
249 |
> |
extern int |
250 |
> |
raymixture( /* mix modifiers */ |
251 |
> |
register RAY *r, |
252 |
> |
OBJECT fore, |
253 |
> |
OBJECT back, |
254 |
> |
double coef |
255 |
> |
) |
256 |
|
{ |
257 |
|
RAY fr, br; |
258 |
|
int foremat, backmat; |
300 |
|
} |
301 |
|
|
302 |
|
|
303 |
< |
double |
304 |
< |
raydist(r, flags) /* compute (cumulative) ray distance */ |
305 |
< |
register RAY *r; |
306 |
< |
register int flags; |
303 |
> |
extern double |
304 |
> |
raydist( /* compute (cumulative) ray distance */ |
305 |
> |
register RAY *r, |
306 |
> |
register int flags |
307 |
> |
) |
308 |
|
{ |
309 |
|
double sum = 0.0; |
310 |
|
|
316 |
|
} |
317 |
|
|
318 |
|
|
319 |
< |
double |
320 |
< |
raynormal(norm, r) /* compute perturbed normal for ray */ |
321 |
< |
FVECT norm; |
322 |
< |
register RAY *r; |
319 |
> |
extern double |
320 |
> |
raynormal( /* compute perturbed normal for ray */ |
321 |
> |
FVECT norm, |
322 |
> |
register RAY *r |
323 |
> |
) |
324 |
|
{ |
325 |
|
double newdot; |
326 |
|
register int i; |
352 |
|
} |
353 |
|
|
354 |
|
|
355 |
< |
void |
356 |
< |
newrayxf(r) /* get new tranformation matrix for ray */ |
357 |
< |
RAY *r; |
355 |
> |
extern void |
356 |
> |
newrayxf( /* get new tranformation matrix for ray */ |
357 |
> |
RAY *r |
358 |
> |
) |
359 |
|
{ |
360 |
|
static struct xfn { |
361 |
|
struct xfn *next; |
390 |
|
} |
391 |
|
|
392 |
|
|
393 |
< |
void |
394 |
< |
flipsurface(r) /* reverse surface orientation */ |
395 |
< |
register RAY *r; |
393 |
> |
extern void |
394 |
> |
flipsurface( /* reverse surface orientation */ |
395 |
> |
register RAY *r |
396 |
> |
) |
397 |
|
{ |
398 |
|
r->rod = -r->rod; |
399 |
|
r->ron[0] = -r->ron[0]; |
405 |
|
} |
406 |
|
|
407 |
|
|
408 |
< |
void |
409 |
< |
rayhit(oset, r) /* standard ray hit test */ |
410 |
< |
OBJECT *oset; |
411 |
< |
RAY *r; |
408 |
> |
extern void |
409 |
> |
rayhit( /* standard ray hit test */ |
410 |
> |
OBJECT *oset, |
411 |
> |
RAY *r |
412 |
> |
) |
413 |
|
{ |
414 |
|
OBJREC *o; |
415 |
|
int i; |
422 |
|
} |
423 |
|
|
424 |
|
|
425 |
< |
int |
426 |
< |
localhit(r, scene) /* check for hit in the octree */ |
427 |
< |
register RAY *r; |
428 |
< |
register CUBE *scene; |
425 |
> |
extern int |
426 |
> |
localhit( /* check for hit in the octree */ |
427 |
> |
register RAY *r, |
428 |
> |
register CUBE *scene |
429 |
> |
) |
430 |
|
{ |
431 |
|
OBJECT cxset[MAXCSET+1]; /* set of checked objects */ |
432 |
|
FVECT curpos; /* current cube position */ |
486 |
|
|
487 |
|
|
488 |
|
static int |
489 |
< |
raymove(pos, cxs, dirf, r, cu) /* check for hit as we move */ |
490 |
< |
FVECT pos; /* current position, modified herein */ |
491 |
< |
OBJECT *cxs; /* checked objects, modified by checkhit */ |
492 |
< |
int dirf; /* direction indicators to speed tests */ |
493 |
< |
register RAY *r; |
494 |
< |
register CUBE *cu; |
489 |
> |
raymove( /* check for hit as we move */ |
490 |
> |
FVECT pos, /* current position, modified herein */ |
491 |
> |
OBJECT *cxs, /* checked objects, modified by checkhit */ |
492 |
> |
int dirf, /* direction indicators to speed tests */ |
493 |
> |
register RAY *r, |
494 |
> |
register CUBE *cu |
495 |
> |
) |
496 |
|
{ |
497 |
|
int ax; |
498 |
|
double dt, t; |
573 |
|
|
574 |
|
|
575 |
|
static int |
576 |
< |
checkhit(r, cu, cxs) /* check for hit in full cube */ |
577 |
< |
register RAY *r; |
578 |
< |
CUBE *cu; |
579 |
< |
OBJECT *cxs; |
576 |
> |
checkhit( /* check for hit in full cube */ |
577 |
> |
register RAY *r, |
578 |
> |
CUBE *cu, |
579 |
> |
OBJECT *cxs |
580 |
> |
) |
581 |
|
{ |
582 |
|
OBJECT oset[MAXSET+1]; |
583 |
|
|
594 |
|
|
595 |
|
|
596 |
|
static void |
597 |
< |
checkset(os, cs) /* modify checked set and set to check */ |
598 |
< |
register OBJECT *os; /* os' = os - cs */ |
599 |
< |
register OBJECT *cs; /* cs' = cs + os */ |
597 |
> |
checkset( /* modify checked set and set to check */ |
598 |
> |
register OBJECT *os, /* os' = os - cs */ |
599 |
> |
register OBJECT *cs /* cs' = cs + os */ |
600 |
> |
) |
601 |
|
{ |
602 |
|
OBJECT cset[MAXCSET+MAXSET+1]; |
603 |
|
register int i, j; |