29 |
|
VSMATERIAL mirror_vs = {mir_proj, 1}; |
30 |
|
|
31 |
|
|
32 |
< |
extern int |
32 |
> |
int |
33 |
|
m_mirror( /* shade mirrored ray */ |
34 |
< |
register OBJREC *m, |
35 |
< |
register RAY *r |
34 |
> |
OBJREC *m, |
35 |
> |
RAY *r |
36 |
|
) |
37 |
|
{ |
38 |
|
COLOR mcolor; |
39 |
|
RAY nr; |
40 |
|
int rpure = 1; |
41 |
< |
register int i; |
41 |
> |
int i; |
42 |
|
/* check arguments */ |
43 |
|
if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1) |
44 |
|
objerror(m, USER, "bad number of arguments"); |
45 |
|
/* check for substitute material */ |
46 |
|
/* but avoid double-counting */ |
47 |
< |
if (m->oargs.nsargs > 0 && !(r->crtype & (AMBIENT|SPECULAR)) && |
48 |
< |
(r->rsrc < 0 || source[r->rsrc].so != r->ro)) { |
47 |
> |
if ( m->oargs.nsargs > 0 && |
48 |
> |
(r->rsrc < 0 || source[r->rsrc].so != r->ro) && |
49 |
> |
!(r->crtype & (AMBIENT|SPECULAR) && r->rod > 0.) ) { |
50 |
|
if (!strcmp(m->oargs.sarg[0], VOIDID)) { |
51 |
|
raytrans(r); |
52 |
|
return(1); |
57 |
|
if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) |
58 |
|
return(1); |
59 |
|
|
60 |
< |
if (r->rod < 0.) /* back is black */ |
60 |
> |
if (r->rod < 0.) { /* back is black */ |
61 |
> |
if (!backvis) |
62 |
> |
raytrans(r); /* unless back visibility is off */ |
63 |
|
return(1); |
64 |
+ |
} |
65 |
|
/* get modifiers */ |
66 |
|
raytexture(r, m->omod); |
67 |
|
/* assign material color */ |
83 |
|
|
84 |
|
if (rayorigin(&nr, REFLECTED, r, mcolor) < 0) |
85 |
|
return(1); |
86 |
< |
if (DOT(r->pert,r->pert) > FTINY*FTINY) { |
86 |
> |
if (!(r->crtype & AMBIENT) && |
87 |
> |
DOT(r->pert,r->pert) > FTINY*FTINY) { |
88 |
|
pdot = raynormal(pnorm, r); /* use textures */ |
89 |
|
for (i = 0; i < 3; i++) |
90 |
|
nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i]; |
108 |
|
static int |
109 |
|
mir_proj( /* compute a mirror's projection */ |
110 |
|
MAT4 pm, |
111 |
< |
register OBJREC *o, |
111 |
> |
OBJREC *o, |
112 |
|
SRCREC *s, |
113 |
|
int n |
114 |
|
) |
144 |
|
|
145 |
|
static void |
146 |
|
mirrorproj( /* get mirror projection for surface */ |
147 |
< |
register MAT4 m, |
147 |
> |
MAT4 m, |
148 |
|
FVECT nv, |
149 |
|
double offs |
150 |
|
) |
151 |
|
{ |
152 |
< |
register int i, j; |
152 |
> |
int i, j; |
153 |
|
/* assign matrix */ |
154 |
|
setident4(m); |
155 |
|
for (j = 0; j < 3; j++) { |