--- ray/src/rt/o_cone.c 2016/04/21 00:40:35 2.9 +++ ray/src/rt/o_cone.c 2021/01/31 18:08:04 2.10 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: o_cone.c,v 2.9 2016/04/21 00:40:35 greg Exp $"; +static const char RCSid[] = "$Id: o_cone.c,v 2.10 2021/01/31 18:08:04 greg Exp $"; #endif /* * o_cone.c - routine to determine ray intersection with cones. @@ -70,11 +70,11 @@ o_cone( /* intersect ray with cone */ } else { /* OBJ_RING */ - if (rdx[2] <= FTINY && rdx[2] >= -FTINY) + if ((rdx[2] <= FTINY) & (rdx[2] >= -FTINY)) return(0); /* parallel */ root[0] = -rox[2]/rdx[2]; - if (root[0] <= FTINY || root[0] >= r->rot) - return(0); /* distance check */ + if (rayreject(o, r, root[0])) + return(0); /* have better */ b = root[0]*rdx[0] + rox[0]; c = root[0]*rdx[1] + rox[1]; a = b*b + c*c; @@ -94,7 +94,7 @@ o_cone( /* intersect ray with cone */ for (rn = 0; rn < nroots; rn++) { /* check real roots */ if (root[rn] <= FTINY) continue; /* too small */ - if (root[rn] >= r->rot) + if (root[rn] > r->rot + FTINY) break; /* too big */ /* check endpoints */ VSUM(rox, r->rorg, r->rdir, root[rn]); @@ -104,6 +104,8 @@ o_cone( /* intersect ray with cone */ continue; /* before p0 */ if (b > co->al) continue; /* after p1 */ + if (rayreject(o, r, root[rn])) + break; /* previous hit better */ r->ro = o; r->rot = root[rn]; VCOPY(r->rop, rox);