--- ray/src/rt/ambcomp.c 2014/04/25 18:39:22 2.35 +++ ray/src/rt/ambcomp.c 2014/04/26 04:37:48 2.36 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ambcomp.c,v 2.35 2014/04/25 18:39:22 greg Exp $"; +static const char RCSid[] = "$Id: ambcomp.c,v 2.36 2014/04/26 04:37:48 greg Exp $"; #endif /* * Routines to compute "ambient" values using Monte Carlo @@ -70,15 +70,12 @@ inithemi( /* initialize sampling hemisphere */ d = 1.0/(n*n); scalecolor(hp->acoef, d); /* make tangent plane axes */ - hp->uy[0] = 0.1 - 0.2*frandom(); - hp->uy[1] = 0.1 - 0.2*frandom(); - hp->uy[2] = 0.1 - 0.2*frandom(); - for (i = 0; i < 3; i++) - if (r->ron[i] < 0.6 && r->ron[i] > -0.6) - break; - if (i >= 3) + hp->uy[0] = hp->uy[1] = hp->uy[2] = 0; + for (i = 3; i--; ) + if ((0.6 < r->ron[i]) & (r->ron[i] < 0.6)) + hp->uy[i] = 0.1+frandom(); + if (DOT(hp->uy,hp->uy) <= FTINY) error(CONSISTENCY, "bad ray direction in inithemi()"); - hp->uy[i] = 1.0; VCROSS(hp->ux, hp->uy, r->ron); normalize(hp->ux); VCROSS(hp->uy, r->ron, hp->ux);