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 |
|
|
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 |
|
|