--- ray/src/rt/rtrace.c 2009/12/13 19:13:04 2.59 +++ ray/src/rt/rtrace.c 2009/12/16 03:30:50 2.63 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rtrace.c,v 2.59 2009/12/13 19:13:04 greg Exp $"; +static const char RCSid[] = "$Id: rtrace.c,v 2.63 2009/12/16 03:30:50 greg Exp $"; #endif /* * rtrace.c - program and variables for individual ray tracing. @@ -160,13 +160,14 @@ rtrace( /* trace rays from file */ d = normalize(direc); if (d == 0.0) { /* zero ==> flush */ - if (nproc > 1 && ray_fifo_flush() < 0) - error(USER, "lost children"); - bogusray(); if (--nextflush <= 0 || !vcount) { + if (nproc > 1 && ray_fifo_flush() < 0) + error(USER, "lost children"); + bogusray(); fflush(stdout); nextflush = hresolu; - } + } else + bogusray(); } else { /* compute and print */ rtcompute(orig, direc, lim_dist ? d : 0.0); /* flush if time */ @@ -320,6 +321,8 @@ rayirrad( /* compute irradiance rather than radiance RAY *r ) { + void (*old_revf)(RAY *) = r->revf; + r->rot = 1e-5; /* pretend we hit surface */ VSUM(r->rop, r->rorg, r->rdir, r->rot); r->ron[0] = -r->rdir[0]; @@ -327,7 +330,9 @@ rayirrad( /* compute irradiance rather than radiance r->ron[2] = -r->rdir[2]; r->rod = 1.0; /* compute result */ + r->revf = raytrace; (*ofun[Lamb.otype].funp)(&Lamb, r); + r->revf = old_revf; } @@ -338,24 +343,22 @@ rtcompute( /* compute and print ray value(s) */ double dmax ) { - if (imm_irrad) { /* set up ray */ + /* set up ray */ + rayorigin(&thisray, PRIMARY, NULL, NULL); + if (imm_irrad) { VSUM(thisray.rorg, org, dir, 1.1e-4); thisray.rdir[0] = -dir[0]; thisray.rdir[1] = -dir[1]; thisray.rdir[2] = -dir[2]; thisray.rmax = 0.0; + thisray.revf = rayirrad; } else { VCOPY(thisray.rorg, org); VCOPY(thisray.rdir, dir); thisray.rmax = dmax; + if (castonly) + thisray.revf = raycast; } - rayorigin(&thisray, PRIMARY, NULL, NULL); - /* special case evaluators */ - if (castonly) - thisray.revf = raycast; - else if (imm_irrad) - thisray.revf = rayirrad; - if (ray_pnprocs > 1) { /* multiprocessing FIFO? */ if (ray_fifo_in(&thisray) < 0) error(USER, "lost children");