--- ray/src/rt/rtrace.c 2009/12/13 19:13:04 2.59 +++ ray/src/rt/rtrace.c 2009/12/14 07:31:37 2.62 @@ -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.62 2009/12/14 07:31:37 greg Exp $"; #endif /* * rtrace.c - program and variables for individual ray tracing. @@ -320,6 +320,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 +329,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 +342,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");