40 |
|
/* check arguments */ |
41 |
|
if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1) |
42 |
|
objerror(m, USER, "bad number of arguments"); |
43 |
< |
/* check if source ray */ |
44 |
< |
if (r->rsrc >= 0) { /* aiming for somebody */ |
45 |
< |
if (source[r->rsrc].so != r->ro) |
46 |
< |
return; /* but not us */ |
47 |
< |
} else if (m->oargs.nsargs > 0) { /* else call substitute? */ |
48 |
< |
rayshade(r, modifier(m->oargs.sarg[0])); |
49 |
< |
return; |
43 |
> |
/* check for substitute material */ |
44 |
> |
if (m->oargs.nsargs > 0 && |
45 |
> |
(r->rsrc < 0 || source[r->rsrc].so != r->ro)) { |
46 |
> |
if (!strcmp(m->oargs.sarg[0], VOIDID)) { |
47 |
> |
raytrans(r); |
48 |
> |
return(1); |
49 |
> |
} |
50 |
> |
return(rayshade(r, modifier(m->oargs.sarg[0]))); |
51 |
|
} |
52 |
+ |
/* check for bad source ray */ |
53 |
+ |
if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) |
54 |
+ |
return(1); |
55 |
+ |
|
56 |
|
if (r->rod < 0.) /* back is black */ |
57 |
< |
return; |
57 |
> |
return(1); |
58 |
|
/* get modifiers */ |
59 |
|
raytexture(r, m->omod); |
60 |
|
/* assign material color */ |
69 |
|
for (i = 0; i < 3; i++) |
70 |
|
nr.rdir[i] = r->rdir[i] + 2.*r->rod*r->ron[i]; |
71 |
|
/* source we're aiming for next */ |
72 |
< |
nr.rsrc = source[r->rsrc].sa.svnext; |
72 |
> |
nr.rsrc = source[r->rsrc].sa.sv.sn; |
73 |
|
} else { /* ordinary reflection */ |
74 |
|
FVECT pnorm; |
75 |
|
double pdot; |
76 |
|
|
77 |
|
if (rayorigin(&nr, r, REFLECTED, bright(mcolor)) < 0) |
78 |
< |
return; |
78 |
> |
return(1); |
79 |
|
pdot = raynormal(pnorm, r); /* use textures */ |
80 |
|
for (i = 0; i < 3; i++) |
81 |
|
nr.rdir[i] = r->rdir[i] + 2.*pdot*pnorm[i]; |
82 |
+ |
/* check for penetration */ |
83 |
+ |
if (DOT(nr.rdir, r->ron) <= FTINY) |
84 |
+ |
for (i = 0; i < 3; i++) |
85 |
+ |
nr.rdir[i] = r->rdir[i] + 2.*r->rod*r->ron[i]; |
86 |
|
} |
87 |
|
rayvalue(&nr); |
88 |
|
multcolor(nr.rcol, mcolor); |
89 |
|
addcolor(r->rcol, nr.rcol); |
90 |
+ |
return(1); |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
mir_proj(pm, o, s, n) /* compute a mirror's projection */ |
95 |
|
MAT4 pm; |
96 |
|
register OBJREC *o; |
97 |
< |
register SRCREC *s; |
97 |
> |
SRCREC *s; |
98 |
|
int n; |
99 |
|
{ |
100 |
|
FVECT nv; |
101 |
|
double od; |
102 |
|
/* get surface normal and offset */ |
103 |
< |
if (sfun[o->otype].of->getpleq == NULL) |
94 |
< |
return(0); /* reject non-planar case */ |
95 |
< |
od = (*sfun[o->otype].of->getpleq)(nv, o); |
103 |
> |
od = getplaneq(nv, o); |
104 |
|
/* check for behind */ |
105 |
|
if (DOT(s->sloc, nv) <= (s->sflags & SDISTANT ? FTINY : od+FTINY)) |
106 |
|
return(0); |
118 |
|
register int i, j; |
119 |
|
/* assign matrix */ |
120 |
|
setident4(m); |
121 |
< |
for (i = 0; i < 3; i++) |
122 |
< |
for (j = 0; j < 3; j++) |
121 |
> |
for (j = 0; j < 3; j++) { |
122 |
> |
for (i = 0; i < 3; i++) |
123 |
|
m[i][j] -= 2.*nv[i]*nv[j]; |
116 |
– |
for (j = 0; j < 3; j++) |
124 |
|
m[3][j] = 2.*offs*nv[j]; |
125 |
+ |
} |
126 |
|
} |