14 |
|
extern "C" { |
15 |
|
#endif |
16 |
|
|
17 |
+ |
#ifndef RNUMBER |
18 |
+ |
#define RNUMBER unsigned long /* ray counter (>= sizeof pointer) */ |
19 |
+ |
#endif |
20 |
+ |
|
21 |
|
#define MAXDIM 32 /* maximum number of dimensions */ |
22 |
|
|
23 |
|
/* ray type flags */ |
32 |
|
/* reflected ray types */ |
33 |
|
#define RAYREFL (SHADOW|REFLECTED|AMBIENT|SPECULAR) |
34 |
|
|
35 |
+ |
/* Arrange so double's come first for optimal alignment */ |
36 |
+ |
/* Pointers and long's come second for 64-bit mode */ |
37 |
+ |
/* Int's next (unknown length), then floats, followed by short's & char's */ |
38 |
|
typedef struct ray { |
32 |
– |
unsigned long rno; /* unique ray number */ |
33 |
– |
int rlvl; /* number of reflections for this ray */ |
34 |
– |
float rweight; /* cumulative weight (for termination) */ |
35 |
– |
COLOR rcoef; /* contribution coefficient w.r.t. parent */ |
36 |
– |
short rtype; /* ray type */ |
37 |
– |
short crtype; /* cumulative ray type */ |
38 |
– |
const struct ray *parent; /* ray this originated from */ |
39 |
|
FVECT rorg; /* origin of ray */ |
40 |
|
FVECT rdir; /* normalized direction of ray */ |
41 |
< |
double rmax; /* maximum distance (aft clipping plane) */ |
42 |
< |
int rsrc; /* source we're aiming for */ |
41 |
> |
RREAL rmax; /* maximum distance (aft clipping plane) */ |
42 |
> |
RREAL rot; /* distance to object */ |
43 |
> |
FVECT rop; /* intersection point */ |
44 |
> |
FVECT ron; /* intersection surface normal */ |
45 |
> |
RREAL rod; /* -DOT(rdir, ron) */ |
46 |
> |
RREAL uv[2]; /* local coordinates */ |
47 |
> |
FVECT pert; /* surface normal perturbation */ |
48 |
> |
RREAL rt; /* returned effective ray length */ |
49 |
> |
const struct ray *parent; /* ray this originated from */ |
50 |
|
OBJECT *clipset; /* set of objects currently clipped */ |
51 |
|
OBJECT *newcset; /* next clipset, used for transmission */ |
52 |
|
void (*revf)(struct ray *); /* ray evaluation function */ |
53 |
|
void (*hitf)(OBJECT *, struct ray *); /* custom hit test */ |
47 |
– |
OBJECT robj; /* intersected object number */ |
54 |
|
OBJREC *ro; /* intersected object (one with material) */ |
49 |
– |
double rot; /* distance to object */ |
50 |
– |
FVECT rop; /* intersection point */ |
51 |
– |
FVECT ron; /* intersection surface normal */ |
52 |
– |
double rod; /* -DOT(rdir, ron) */ |
55 |
|
FULLXF *rox; /* object transformation */ |
56 |
< |
RREAL uv[2]; /* local coordinates */ |
57 |
< |
FVECT pert; /* surface normal perturbation */ |
56 |
> |
int *slights; /* list of lights to test for scattering */ |
57 |
> |
RNUMBER rno; /* unique ray number */ |
58 |
> |
int rlvl; /* number of reflections for this ray */ |
59 |
> |
int rsrc; /* source we're aiming for */ |
60 |
> |
float rweight; /* cumulative weight (for termination) */ |
61 |
> |
COLOR rcoef; /* contribution coefficient w.r.t. parent */ |
62 |
|
COLOR pcol; /* pattern color */ |
63 |
|
COLOR rcol; /* returned radiance value */ |
58 |
– |
double rt; /* returned effective ray length */ |
64 |
|
COLOR cext; /* medium extinction coefficient */ |
65 |
|
COLOR albedo; /* medium scattering albedo */ |
66 |
|
float gecc; /* scattering eccentricity coefficient */ |
67 |
< |
int *slights; /* list of lights to test for scattering */ |
67 |
> |
OBJECT robj; /* intersected object number */ |
68 |
> |
short rtype; /* ray type */ |
69 |
> |
short crtype; /* cumulative ray type */ |
70 |
|
} RAY; |
71 |
|
|
72 |
|
#define rayvalue(r) (*(r)->revf)(r) |
212 |
|
extern void rayparticipate(RAY *r); |
213 |
|
extern void raytexture(RAY *r, OBJECT mod); |
214 |
|
extern int raymixture(RAY *r, OBJECT fore, OBJECT back, double coef); |
215 |
< |
extern void raycontrib(COLOR rc, const RAY *r, int flags); |
215 |
> |
extern void raycontrib(double rc[3], const RAY *r, int flags); |
216 |
|
extern double raydist(const RAY *r, int flags); |
217 |
|
extern double raynormal(FVECT norm, RAY *r); |
218 |
|
extern void newrayxf(RAY *r); |