--- ray/src/rt/sphere.c 2003/03/12 04:59:05 2.5 +++ ray/src/rt/sphere.c 2021/01/31 18:08:04 2.9 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: sphere.c,v 2.5 2003/03/12 04:59:05 greg Exp $"; +static const char RCSid[] = "$Id: sphere.c,v 2.9 2021/01/31 18:08:04 greg Exp $"; #endif /* * sphere.c - compute ray intersection with spheres. @@ -8,20 +8,22 @@ static const char RCSid[] = "$Id: sphere.c,v 2.5 2003/ #include "copyright.h" #include "ray.h" - #include "otypes.h" +#include "rtotypes.h" -o_sphere(so, r) /* compute intersection with sphere */ -OBJREC *so; -register RAY *r; +int +o_sphere( /* compute intersection with sphere */ + OBJREC *so, + RAY *r +) { double a, b, c; /* coefficients for quadratic equation */ double root[2]; /* quadratic roots */ int nroots; double t; - register FLOAT *ap; - register int i; + RREAL *ap; + int i; if (so->oargs.nfargs != 4) objerror(so, USER, "bad # arguments"); @@ -61,9 +63,8 @@ register RAY *r; break; if (i >= nroots) return(0); /* no positive root */ - - if (t >= r->rot) - return(0); /* other is closer */ + if (rayreject(so, r, t)) + return(0); /* previous hit better */ r->ro = so; r->rot = t;