11 |
|
#include "otypes.h" |
12 |
|
#include "rtotypes.h" |
13 |
|
#include "source.h" |
14 |
– |
#include "pmapmat.h" |
14 |
|
|
15 |
|
/* |
16 |
|
* The real arguments for MAT_MIRROR are simply: |
35 |
|
RAY *r |
36 |
|
) |
37 |
|
{ |
38 |
< |
COLOR mcolor; |
38 |
> |
SCOLOR mcolor; |
39 |
|
RAY nr; |
40 |
|
int rpure = 1; |
41 |
|
int i; |
43 |
– |
|
44 |
– |
/* PMAP: skip specular refl via ambient bounce if already accounted for |
45 |
– |
* in photon map */ |
46 |
– |
if (ambRayInPmap(r)) |
47 |
– |
return(1); |
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); |
65 |
|
/* get modifiers */ |
66 |
|
raytexture(r, m->omod); |
67 |
|
/* assign material color */ |
68 |
< |
setcolor(mcolor, m->oargs.farg[0], |
68 |
> |
setscolor(mcolor, m->oargs.farg[0], |
69 |
|
m->oargs.farg[1], |
70 |
|
m->oargs.farg[2]); |
71 |
< |
multcolor(mcolor, r->pcol); |
71 |
> |
smultscolor(mcolor, r->pcol); |
72 |
|
/* compute reflected ray */ |
73 |
|
if (r->rsrc >= 0) { /* relayed light source */ |
74 |
|
rayorigin(&nr, REFLECTED, r, mcolor); |
97 |
|
} |
98 |
|
checknorm(nr.rdir); |
99 |
|
rayvalue(&nr); |
100 |
< |
multcolor(nr.rcol, nr.rcoef); |
101 |
< |
addcolor(r->rcol, nr.rcol); |
100 |
> |
smultscolor(nr.rcol, nr.rcoef); |
101 |
> |
copyscolor(r->mcol, nr.rcol); |
102 |
> |
saddscolor(r->rcol, nr.rcol); |
103 |
> |
r->rmt = r->rot; |
104 |
|
if (rpure && r->ro != NULL && isflat(r->ro->otype)) |
105 |
< |
r->rt = r->rot + nr.rt; |
105 |
> |
r->rmt += raydistance(&nr); |
106 |
|
return(1); |
107 |
|
} |
108 |
|
|