41 |
|
#define RINDEX 1.52 /* refractive index of glass */ |
42 |
|
|
43 |
|
|
44 |
< |
extern int |
44 |
> |
int |
45 |
|
m_glass( /* color a ray which hit a thin glass surface */ |
46 |
|
OBJREC *m, |
47 |
< |
register RAY *r |
47 |
> |
RAY *r |
48 |
|
) |
49 |
|
{ |
50 |
|
COLOR mcolor; |
57 |
|
double transtest, transdist; |
58 |
|
double mirtest, mirdist; |
59 |
|
RAY p; |
60 |
< |
register int i; |
60 |
> |
int i; |
61 |
|
/* check arguments */ |
62 |
|
if (m->oargs.nfargs == 3) |
63 |
|
rindex = RINDEX; /* default value of n */ |
65 |
|
rindex = m->oargs.farg[3]; /* use their value */ |
66 |
|
else |
67 |
|
objerror(m, USER, "bad arguments"); |
68 |
+ |
/* check back face visibility */ |
69 |
+ |
if (!backvis && r->rod <= 0.0) { |
70 |
+ |
raytrans(r); |
71 |
+ |
return(1); |
72 |
+ |
} |
73 |
|
/* check transmission */ |
74 |
|
setcolor(mcolor, m->oargs.farg[0], m->oargs.farg[1], m->oargs.farg[2]); |
75 |
|
if ((hastrans = (intens(mcolor) > 1e-15))) { |
116 |
|
multcolor(trans, r->pcol); /* modify by pattern */ |
117 |
|
/* transmitted ray */ |
118 |
|
if (rayorigin(&p, TRANS, r, trans) == 0) { |
119 |
< |
if (!(r->crtype & SHADOW) && hastexture) { |
119 |
> |
if (!(r->crtype & (SHADOW|AMBIENT)) && hastexture) { |
120 |
|
VSUM(p.rdir, r->rdir, r->pert, 2.*(1.-rindex)); |
121 |
|
if (normalize(p.rdir) == 0.0) { |
122 |
|
objerror(m, WARNING, "bad perturbation"); |
151 |
|
rayvalue(&p); |
152 |
|
multcolor(p.rcol, p.rcoef); |
153 |
|
addcolor(r->rcol, p.rcol); |
154 |
< |
if (!hastexture && r->ro != NULL && isflat(r->ro->otype)) { |
154 |
> |
if (r->ro != NULL && isflat(r->ro->otype) && |
155 |
> |
!hastexture | (r->crtype & AMBIENT)) { |
156 |
|
mirtest = 2.0*bright(p.rcol); |
157 |
|
mirdist = r->rot + p.rt; |
158 |
|
} |