27 |
|
|
28 |
|
int rand_samp = 1; /* pure Monte Carlo sampling? */ |
29 |
|
|
30 |
< |
double dstrsrc = 0.0; /* square source distribution */ |
30 |
> |
double dstrsrc = 0.9; /* square source distribution */ |
31 |
|
double shadthresh = .03; /* shadow threshold */ |
32 |
|
double shadcert = .75; /* shadow certainty */ |
33 |
|
int directrelay = 3; /* number of source relays */ |
178 |
|
/* set shared memory boundary */ |
179 |
|
shm_boundary = strcpy((char *)malloc(16), "SHM_BOUNDARY"); |
180 |
|
} |
181 |
– |
if ((nproc > 1) & (accumulate <= 0)) |
182 |
– |
put_zero_record(0); /* prime our queue to accumulate */ |
183 |
– |
|
181 |
|
if (yres > 0) { /* set up flushing & ray counts */ |
182 |
|
if (xres > 0) |
183 |
|
raysleft = (RNUMBER)xres*yres; |
196 |
|
return; /* return to main processing loop */ |
197 |
|
|
198 |
|
if (recover) { /* recover previous output? */ |
199 |
< |
if (accumulate <= 0) { |
199 |
> |
if (accumulate <= 0) |
200 |
|
reload_output(); |
201 |
< |
if (nproc > 1) |
205 |
< |
queue_modifiers(); |
206 |
< |
} else |
201 |
> |
else |
202 |
|
recover_output(); |
203 |
|
} |
204 |
|
if (nproc == 1) /* single process? */ |
205 |
|
return; |
206 |
< |
|
207 |
< |
parental_loop(); /* else run controller */ |
206 |
> |
/* else run appropriate controller */ |
207 |
> |
if (accumulate <= 0) |
208 |
> |
feeder_loop(); |
209 |
> |
else |
210 |
> |
parental_loop(); |
211 |
|
quit(0); /* parent musn't return! */ |
212 |
|
} |
213 |
|
|
242 |
|
} |
243 |
|
|
244 |
|
|
245 |
+ |
/* Evaluate irradiance contributions */ |
246 |
|
static void |
247 |
< |
rayirrad( /* compute irradiance rather than radiance */ |
249 |
< |
RAY *r |
250 |
< |
) |
247 |
> |
eval_irrad(FVECT org, FVECT dir) |
248 |
|
{ |
249 |
< |
r->rot = 1e-5; /* pretend we hit surface */ |
250 |
< |
VSUM(r->rop, r->rorg, r->rdir, r->rot); |
251 |
< |
r->ron[0] = -r->rdir[0]; |
252 |
< |
r->ron[1] = -r->rdir[1]; |
253 |
< |
r->ron[2] = -r->rdir[2]; |
254 |
< |
r->rod = 1.0; |
255 |
< |
/* compute result */ |
256 |
< |
r->revf = raytrace; |
257 |
< |
(*ofun[Lamb.otype].funp)(&Lamb, r); |
258 |
< |
r->revf = rayirrad; |
249 |
> |
RAY thisray; |
250 |
> |
|
251 |
> |
VSUM(thisray.rorg, org, dir, 1.1e-4); |
252 |
> |
thisray.rdir[0] = -dir[0]; |
253 |
> |
thisray.rdir[1] = -dir[1]; |
254 |
> |
thisray.rdir[2] = -dir[2]; |
255 |
> |
thisray.rmax = 0.0; |
256 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
257 |
> |
thisray.rot = 1e-5; /* pretend we hit surface */ |
258 |
> |
thisray.rod = 1.0; |
259 |
> |
VSUM(thisray.rop, org, dir, 1e-4); |
260 |
> |
samplendx++; /* compute result */ |
261 |
> |
(*ofun[Lamb.otype].funp)(&Lamb, &thisray); |
262 |
|
} |
263 |
|
|
264 |
|
|
265 |
< |
/* Evaluate ray contributions */ |
265 |
> |
/* Evaluate radiance contributions */ |
266 |
|
static void |
267 |
< |
eval_ray(FVECT org, FVECT dir, double dmax) |
267 |
> |
eval_rad(FVECT org, FVECT dir, double dmax) |
268 |
|
{ |
269 |
|
RAY thisray; |
270 |
|
/* set up ray */ |
271 |
+ |
VCOPY(thisray.rorg, org); |
272 |
+ |
VCOPY(thisray.rdir, dir); |
273 |
+ |
thisray.rmax = dmax; |
274 |
|
rayorigin(&thisray, PRIMARY, NULL, NULL); |
272 |
– |
if (imm_irrad) { |
273 |
– |
VSUM(thisray.rorg, org, dir, 1.1e-4); |
274 |
– |
thisray.rdir[0] = -dir[0]; |
275 |
– |
thisray.rdir[1] = -dir[1]; |
276 |
– |
thisray.rdir[2] = -dir[2]; |
277 |
– |
thisray.rmax = 0.0; |
278 |
– |
thisray.revf = rayirrad; |
279 |
– |
} else { |
280 |
– |
VCOPY(thisray.rorg, org); |
281 |
– |
VCOPY(thisray.rdir, dir); |
282 |
– |
thisray.rmax = dmax; |
283 |
– |
} |
275 |
|
samplendx++; /* call ray evaluation */ |
276 |
|
rayvalue(&thisray); |
277 |
|
} |
326 |
|
if ((yres <= 0) | (xres <= 0)) |
327 |
|
waitflush = 1; /* flush right after */ |
328 |
|
account = 1; |
329 |
< |
} else { /* else compute */ |
330 |
< |
eval_ray(orig, direc, lim_dist ? d : 0.0); |
329 |
> |
} else if (imm_irrad) { /* else compute */ |
330 |
> |
eval_irrad(orig, direc); |
331 |
> |
} else { |
332 |
> |
eval_rad(orig, direc, lim_dist ? d : 0.0); |
333 |
|
} |
334 |
|
done_contrib(); /* accumulate/output */ |
335 |
|
++lastdone; |
336 |
|
if (raysleft && !--raysleft) |
337 |
|
break; /* preemptive EOI */ |
338 |
|
} |
339 |
< |
if (nchild != -1 && (accumulate <= 0) | (account < accumulate)) { |
339 |
> |
if ((accumulate <= 0) | (account < accumulate)) { |
340 |
|
if (account < accumulate) { |
341 |
|
error(WARNING, "partial accumulation in final record"); |
342 |
|
accumulate -= account; |
344 |
|
account = 1; /* output accumulated totals */ |
345 |
|
done_contrib(); |
346 |
|
} |
347 |
+ |
lu_done(&ofiletab); /* close output files */ |
348 |
|
if (raysleft) |
349 |
|
error(USER, "unexpected EOF on input"); |
356 |
– |
lu_done(&ofiletab); /* close output files */ |
350 |
|
} |