13 |
|
#include "source.h" |
14 |
|
#include "otypes.h" |
15 |
|
#include "otspecial.h" |
16 |
+ |
#include "random.h" |
17 |
|
|
18 |
|
#define MAXCSET ((MAXSET+1)*2-1) /* maximum check set size */ |
19 |
|
|
59 |
|
r->crtype = r->rtype = rt; |
60 |
|
r->rsrc = -1; |
61 |
|
r->clipset = NULL; |
62 |
+ |
r->revf = raytrace; |
63 |
|
copycolor(r->cext, cextinction); |
64 |
|
copycolor(r->albedo, salbedo); |
65 |
|
r->gecc = seccg; |
80 |
|
r->clipset = ro->newcset; |
81 |
|
r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot; |
82 |
|
} |
83 |
+ |
r->revf = ro->revf; |
84 |
|
copycolor(r->cext, ro->cext); |
85 |
|
copycolor(r->albedo, ro->albedo); |
86 |
|
r->gecc = ro->gecc; |
97 |
|
r->rweight *= exp(-re); |
98 |
|
} |
99 |
|
rayclear(r); |
100 |
+ |
if (maxdepth <= 0 && rc != NULL) { /* Russian roulette */ |
101 |
+ |
if (minweight <= 0.0) |
102 |
+ |
error(USER, "zero ray weight in Russian roulette"); |
103 |
+ |
if (maxdepth < 0 && r->rlvl > -maxdepth) |
104 |
+ |
return(-1); /* upper reflection limit */ |
105 |
+ |
if (r->rweight >= minweight) |
106 |
+ |
return(0); |
107 |
+ |
if (frandom() < r->rweight/minweight) |
108 |
+ |
return(-1); |
109 |
+ |
rw = minweight/r->rweight; /* promote survivor */ |
110 |
+ |
scalecolor(r->rcoef, rw); |
111 |
+ |
r->rweight = minweight; |
112 |
+ |
return(0); |
113 |
+ |
} |
114 |
|
return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1); |
115 |
|
} |
116 |
|
|
135 |
|
|
136 |
|
|
137 |
|
extern void |
138 |
< |
rayvalue( /* trace a ray and compute its value */ |
138 |
> |
raytrace( /* trace a ray and compute its value */ |
139 |
|
RAY *r |
140 |
|
) |
141 |
|
{ |