| 156 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
| 157 |
|
|
| 158 |
|
|
| 159 |
+ |
static void |
| 160 |
+ |
reset_random(void) /* re-initialize random number generator */ |
| 161 |
+ |
{ |
| 162 |
+ |
if (rand_samp) { |
| 163 |
+ |
srandom((long)time(0)); |
| 164 |
+ |
initurand(0); |
| 165 |
+ |
} else { |
| 166 |
+ |
srandom(0L); |
| 167 |
+ |
initurand(2048); |
| 168 |
+ |
} |
| 169 |
+ |
} |
| 170 |
+ |
|
| 171 |
+ |
|
| 172 |
|
void |
| 173 |
|
ray_init( /* initialize ray-tracing calculation */ |
| 174 |
|
char *otnm |
| 180 |
|
if (ofun[OBJ_SPHERE].funp == o_default) |
| 181 |
|
initotypes(); |
| 182 |
|
/* initialize urand */ |
| 183 |
< |
if (rand_samp) { |
| 171 |
< |
srandom((long)time(0)); |
| 172 |
< |
initurand(0); |
| 173 |
< |
} else { |
| 174 |
< |
srandom(0L); |
| 175 |
< |
initurand(2048); |
| 176 |
< |
} |
| 183 |
> |
reset_random(); |
| 184 |
|
/* read scene octree */ |
| 185 |
|
readoct(octname = otnm, ~(IO_FILES|IO_INFO), &thescene, NULL); |
| 186 |
|
nsceneobjs = nobjects; |
| 193 |
|
/* ready to go... (almost) */ |
| 194 |
|
} |
| 195 |
|
|
| 196 |
+ |
|
| 197 |
|
void |
| 198 |
|
ray_trace( /* trace a primary ray */ |
| 199 |
|
RAY *r |
| 298 |
|
RAYPARAMS *rp |
| 299 |
|
) |
| 300 |
|
{ |
| 301 |
< |
register int i; |
| 301 |
> |
int i; |
| 302 |
|
|
| 303 |
|
if (rp == NULL) { /* restore defaults */ |
| 304 |
|
RAYPARAMS dflt; |
| 308 |
|
} |
| 309 |
|
/* restore saved settings */ |
| 310 |
|
do_irrad = rp->do_irrad; |
| 311 |
< |
rand_samp = rp->rand_samp; |
| 311 |
> |
if (!rand_samp != !rp->rand_samp) { |
| 312 |
> |
rand_samp = rp->rand_samp; |
| 313 |
> |
reset_random(); |
| 314 |
> |
} |
| 315 |
|
dstrsrc = rp->dstrsrc; |
| 316 |
|
shadthresh = rp->shadthresh; |
| 317 |
|
shadcert = rp->shadcert; |
| 333 |
|
ambdiv = rp->ambdiv; |
| 334 |
|
ambssamp = rp->ambssamp; |
| 335 |
|
ambounce = rp->ambounce; |
| 336 |
+ |
/* a bit dangerous if not static */ |
| 337 |
|
for (i = 0; rp->amblndx[i] >= 0; i++) |
| 338 |
|
amblist[i] = rp->amblval + rp->amblndx[i]; |
| 339 |
|
while (i <= AMBLLEN) |