| 43 |
|
if (m->oargs.nfargs != 3 || m->oargs.nsargs > 1) |
| 44 |
|
objerror(m, USER, "bad number of arguments"); |
| 45 |
|
/* check for substitute material */ |
| 46 |
< |
if (m->oargs.nsargs > 0 && |
| 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)) { |
| 49 |
|
if (!strcmp(m->oargs.sarg[0], VOIDID)) { |
| 50 |
|
raytrans(r); |
| 56 |
|
if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) |
| 57 |
|
return(1); |
| 58 |
|
|
| 59 |
< |
if (r->rod < 0.) /* back is black */ |
| 59 |
> |
if (r->rod < 0.) { /* back is black */ |
| 60 |
> |
if (!backvis) |
| 61 |
> |
raytrans(r); /* unless back visibility is off */ |
| 62 |
|
return(1); |
| 63 |
+ |
} |
| 64 |
|
/* get modifiers */ |
| 65 |
|
raytexture(r, m->omod); |
| 66 |
|
/* assign material color */ |
| 70 |
|
multcolor(mcolor, r->pcol); |
| 71 |
|
/* compute reflected ray */ |
| 72 |
|
if (r->rsrc >= 0) { /* relayed light source */ |
| 73 |
< |
rayorigin(&nr, r, REFLECTED, 1.); |
| 73 |
> |
rayorigin(&nr, REFLECTED, r, mcolor); |
| 74 |
|
/* ignore textures */ |
| 75 |
|
for (i = 0; i < 3; i++) |
| 76 |
|
nr.rdir[i] = r->rdir[i] + 2.*r->rod*r->ron[i]; |
| 80 |
|
FVECT pnorm; |
| 81 |
|
double pdot; |
| 82 |
|
|
| 83 |
< |
if (rayorigin(&nr, r, REFLECTED, bright(mcolor)) < 0) |
| 83 |
> |
if (rayorigin(&nr, REFLECTED, r, mcolor) < 0) |
| 84 |
|
return(1); |
| 85 |
|
if (DOT(r->pert,r->pert) > FTINY*FTINY) { |
| 86 |
|
pdot = raynormal(pnorm, r); /* use textures */ |
| 93 |
|
for (i = 0; i < 3; i++) |
| 94 |
|
nr.rdir[i] = r->rdir[i] + 2.*r->rod*r->ron[i]; |
| 95 |
|
} |
| 96 |
+ |
checknorm(nr.rdir); |
| 97 |
|
rayvalue(&nr); |
| 98 |
< |
multcolor(nr.rcol, mcolor); |
| 98 |
> |
multcolor(nr.rcol, nr.rcoef); |
| 99 |
|
addcolor(r->rcol, nr.rcol); |
| 100 |
|
if (rpure && r->ro != NULL && isflat(r->ro->otype)) |
| 101 |
|
r->rt = r->rot + nr.rt; |
| 111 |
|
int n |
| 112 |
|
) |
| 113 |
|
{ |
| 114 |
+ |
double corr = 1.; |
| 115 |
|
FVECT nv, sc; |
| 116 |
< |
double od; |
| 117 |
< |
register int i, j; |
| 116 |
> |
double od, offs; |
| 117 |
> |
int i; |
| 118 |
|
/* get surface normal and offset */ |
| 119 |
< |
od = getplaneq(nv, o); |
| 120 |
< |
/* check for extreme point for behind */ |
| 119 |
> |
offs = od = getplaneq(nv, o); |
| 120 |
> |
if (s->sflags & SDISTANT) |
| 121 |
> |
offs = 0.; |
| 122 |
> |
/* check for extreme point behind */ |
| 123 |
> |
if (s->sflags & SCIR) { |
| 124 |
> |
if (s->sflags & (SFLAT|SDISTANT)) |
| 125 |
> |
corr = 1.12837917; /* correct setflatss() */ |
| 126 |
> |
else |
| 127 |
> |
corr = 1.0/0.7236; /* correct sphsetsrc() */ |
| 128 |
> |
} |
| 129 |
|
VCOPY(sc, s->sloc); |
| 130 |
|
for (i = s->sflags & SFLAT ? SV : SW; i >= 0; i--) |
| 131 |
< |
if (DOT(nv, s->ss[i]) > 0.) |
| 132 |
< |
for (j = 0; j < 3; j++) |
| 119 |
< |
sc[j] += s->ss[i][j]; |
| 131 |
> |
if (DOT(nv, s->ss[i]) > offs) |
| 132 |
> |
VSUM(sc, sc, s->ss[i], corr); |
| 133 |
|
else |
| 134 |
< |
for (j = 0; j < 3; j++) |
| 135 |
< |
sc[j] -= s->ss[i][j]; |
| 123 |
< |
if (DOT(sc, nv) <= (s->sflags & SDISTANT ? FTINY : od+FTINY)) |
| 134 |
> |
VSUM(sc, sc, s->ss[i], -corr); |
| 135 |
> |
if (DOT(sc, nv) <= offs+FTINY) |
| 136 |
|
return(0); |
| 137 |
|
/* everything OK -- compute projection */ |
| 138 |
|
mirrorproj(pm, nv, od); |