9 |
|
|
10 |
|
#include "ray.h" |
11 |
|
#include "otypes.h" |
12 |
+ |
#include "otspecial.h" |
13 |
|
#include "rtotypes.h" |
14 |
|
#include "source.h" |
15 |
|
|
36 |
|
RAY *r |
37 |
|
) |
38 |
|
{ |
39 |
< |
COLOR mcolor; |
39 |
> |
SCOLOR mcolor; |
40 |
|
RAY nr; |
41 |
|
int rpure = 1; |
42 |
|
int i; |
45 |
|
objerror(m, USER, "bad number of arguments"); |
46 |
|
/* check for substitute material */ |
47 |
|
/* but avoid double-counting */ |
48 |
< |
if ( m->oargs.nsargs > 0 && |
49 |
< |
(r->rsrc < 0 || source[r->rsrc].so != r->ro) && |
50 |
< |
!(r->crtype & (AMBIENT|SPECULAR) && r->rod > 0.) ) { |
51 |
< |
if (!strcmp(m->oargs.sarg[0], VOIDID)) { |
52 |
< |
raytrans(r); |
48 |
> |
if (m->oargs.nsargs > 0 && |
49 |
> |
(r->rsrc < 0 || source[r->rsrc].so != r->ro)) { |
50 |
> |
int passOK = (r->rod < 0.) | |
51 |
> |
!(r->crtype & (AMBIENT|SPECULAR)); |
52 |
> |
if (strcmp(m->oargs.sarg[0], VOIDID)) { |
53 |
> |
OBJECT altmod = lastmod(objndx(m), m->oargs.sarg[0]); |
54 |
> |
OBJREC *altmat; |
55 |
> |
if (passOK) /* no double-count hazard? */ |
56 |
> |
return(rayshade(r, altmod)); |
57 |
> |
if (altmod == OVOID || /* else check alternate type */ |
58 |
> |
(altmat = findmaterial(objptr(altmod))) == NULL) |
59 |
> |
return(0); |
60 |
> |
if (istransp(altmat)) /* pass "transparent" materials */ |
61 |
> |
return(rayshade(r, altmod)); |
62 |
> |
} else if (passOK) { |
63 |
> |
raytrans(r); /* "safe" void passage */ |
64 |
|
return(1); |
65 |
|
} |
54 |
– |
return(rayshade(r, lastmod(objndx(m), m->oargs.sarg[0]))); |
66 |
|
} |
67 |
|
/* check for bad source ray */ |
68 |
|
if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) |
76 |
|
/* get modifiers */ |
77 |
|
raytexture(r, m->omod); |
78 |
|
/* assign material color */ |
79 |
< |
setcolor(mcolor, m->oargs.farg[0], |
79 |
> |
setscolor(mcolor, m->oargs.farg[0], |
80 |
|
m->oargs.farg[1], |
81 |
|
m->oargs.farg[2]); |
82 |
< |
multcolor(mcolor, r->pcol); |
82 |
> |
smultscolor(mcolor, r->pcol); |
83 |
|
/* compute reflected ray */ |
84 |
|
if (r->rsrc >= 0) { /* relayed light source */ |
85 |
|
rayorigin(&nr, REFLECTED, r, mcolor); |
108 |
|
} |
109 |
|
checknorm(nr.rdir); |
110 |
|
rayvalue(&nr); |
111 |
< |
multcolor(nr.rcol, nr.rcoef); |
112 |
< |
addcolor(r->rcol, nr.rcol); |
111 |
> |
smultscolor(nr.rcol, nr.rcoef); |
112 |
> |
copyscolor(r->mcol, nr.rcol); |
113 |
> |
saddscolor(r->rcol, nr.rcol); |
114 |
> |
r->rmt = r->rot; |
115 |
|
if (rpure && r->ro != NULL && isflat(r->ro->otype)) |
116 |
< |
r->rt = r->rot + nr.rt; |
116 |
> |
r->rmt += raydistance(&nr); |
117 |
|
return(1); |
118 |
|
} |
119 |
|
|