--- ray/src/rt/sphere.c 1989/02/02 10:41:42 1.1 +++ ray/src/rt/sphere.c 1990/12/15 15:03:37 1.3 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1990 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -57,18 +57,21 @@ register RAY *r; if (i >= nroots) return(0); /* no positive root */ - if (t < r->rot) { /* found closer intersection */ - r->ro = so; - r->rot = t; - /* compute normal */ - a = ap[3]; - if (so->otype == OBJ_BUBBLE) - a = -a; /* reverse */ - for (i = 0; i < 3; i++) { - r->rop[i] = r->rorg[i] + r->rdir[i]*t; - r->ron[i] = (r->rop[i] - ap[i]) / a; - } - r->rod = -DOT(r->rdir, r->ron); + if (t >= r->rot) + return(0); /* other is closer */ + + r->ro = so; + r->rot = t; + /* compute normal */ + a = ap[3]; + if (so->otype == OBJ_BUBBLE) + a = -a; /* reverse */ + for (i = 0; i < 3; i++) { + r->rop[i] = r->rorg[i] + r->rdir[i]*t; + r->ron[i] = (r->rop[i] - ap[i]) / a; } - return(1); + r->rod = -DOT(r->rdir, r->ron); + r->rox = NULL; + + return(1); /* hit */ }