--- ray/src/rt/m_clip.c 2003/02/25 02:47:22 2.6 +++ ray/src/rt/m_clip.c 2007/07/25 04:12:36 2.10 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: m_clip.c,v 2.6 2003/02/25 02:47:22 greg Exp $"; +static const char RCSid[] = "$Id: m_clip.c,v 2.10 2007/07/25 04:12:36 greg Exp $"; #endif /* * m_clip.c - routine for clipped (cut) objects. @@ -8,6 +8,7 @@ static const char RCSid[] = "$Id: m_clip.c,v 2.6 2003/ #include "copyright.h" #include "ray.h" +#include "rtotypes.h" /* * Clipping objects permit holes and sections to be taken out @@ -18,10 +19,11 @@ static const char RCSid[] = "$Id: m_clip.c,v 2.6 2003/ */ -int -m_clip(m, r) /* clip objects from ray */ -register OBJREC *m; -register RAY *r; +extern int +m_clip( /* clip objects from ray */ + register OBJREC *m, + register RAY *r +) { OBJECT cset[MAXSET+1], *modset; OBJECT obj, mod; @@ -53,6 +55,8 @@ register RAY *r; } m->os = (char *)modset; } + if (r == NULL) + return(0); /* just initializing */ if (r->clipset != NULL) setcopy(cset, r->clipset); else @@ -76,15 +80,16 @@ register RAY *r; r->newcset = cset; if (strcmp(m->oargs.sarg[0], VOIDID)) { int inside = 0; - register RAY *rp; + register const RAY *rp; /* check for penetration */ for (rp = r; rp->parent != NULL; rp = rp->parent) if (!(rp->rtype & RAYREFL) && rp->parent->ro != NULL - && inset(modset, rp->parent->ro->omod)) + && inset(modset, rp->parent->ro->omod)) { if (rp->parent->rod > 0.0) inside++; else inside--; + } if (inside > 0) { /* we just hit the object */ flipsurface(r); return(rayshade(r, lastmod(obj, m->oargs.sarg[0])));