--- ray/src/rt/o_face.c 1990/12/15 15:03:29 1.4 +++ ray/src/rt/o_face.c 2014/07/08 18:25:00 2.7 @@ -1,29 +1,27 @@ -/* Copyright (c) 1990 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: o_face.c,v 2.7 2014/07/08 18:25:00 greg Exp $"; #endif - /* * o_face.c - compute ray intersection with faces. - * - * 8/29/85 */ -#include "ray.h" +#include "copyright.h" +#include "ray.h" #include "face.h" +#include "rtotypes.h" -o_face(o, r) /* compute intersection with polygonal face */ -OBJREC *o; -register RAY *r; +int +o_face( /* compute intersection with polygonal face */ + OBJREC *o, + RAY *r +) { double rdot; /* direction . normal */ double t; /* distance to intersection */ FVECT pisect; /* intersection point */ - register FACE *f; /* face record */ - register int i; + FACE *f; /* face record */ f = getface(o); @@ -46,8 +44,7 @@ register RAY *r; if (t <= FTINY || t >= r->rot) /* not good enough */ return(0); /* compute intersection */ - for (i = 0; i < 3; i++) - pisect[i] = r->rorg[i] + r->rdir[i]*t; + VSUM(pisect, r->rorg, r->rdir, t); if (!inface(pisect, f)) /* ray intersects face? */ return(0); @@ -57,6 +54,8 @@ register RAY *r; VCOPY(r->rop, pisect); VCOPY(r->ron, f->norm); r->rod = rdot; + r->pert[0] = r->pert[1] = r->pert[2] = 0.0; + r->uv[0] = r->uv[1] = 0.0; r->rox = NULL; return(1); /* hit */