--- ray/src/rt/m_clip.c 2003/07/21 22:30:19 2.7 +++ ray/src/rt/m_clip.c 2013/08/20 21:37:46 2.11 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: m_clip.c,v 2.7 2003/07/21 22:30:19 schorsch Exp $"; +static const char RCSid[] = "$Id: m_clip.c,v 2.11 2013/08/20 21:37:46 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.7 2003/ #include "copyright.h" #include "ray.h" +#include "rtotypes.h" /* * Clipping objects permit holes and sections to be taken out @@ -19,14 +20,15 @@ static const char RCSid[] = "$Id: m_clip.c,v 2.7 2003/ int -m_clip(m, r) /* clip objects from ray */ -register OBJREC *m; -register RAY *r; +m_clip( /* clip objects from ray */ + OBJREC *m, + RAY *r +) { OBJECT cset[MAXSET+1], *modset; OBJECT obj, mod; int entering; - register int i; + int i; obj = objndx(m); if ((modset = (OBJECT *)m->os) == NULL) { @@ -53,30 +55,30 @@ register RAY *r; } m->os = (char *)modset; } + if (r == NULL) + return(0); /* just initializing */ if (r->clipset != NULL) setcopy(cset, r->clipset); else cset[0] = 0; - entering = r->rod > 0.0; /* entering clipped region? */ + entering = (r->rod > 0.0); /* entering clipped region? */ - for (i = modset[0]; i > 0; i--) { + for (i = modset[0]; i > 0; i--) if (entering) { if (!inset(cset, modset[i])) { if (cset[0] >= MAXSET) error(INTERNAL, "set overflow in m_clip"); insertelem(cset, modset[i]); } - } else { - if (inset(cset, modset[i])) - deletelem(cset, modset[i]); - } - } + } else if (inset(cset, modset[i])) + deletelem(cset, modset[i]); + /* compute ray value */ r->newcset = cset; if (strcmp(m->oargs.sarg[0], VOIDID)) { int inside = 0; - register RAY *rp; + const RAY *rp; /* check for penetration */ for (rp = r; rp->parent != NULL; rp = rp->parent) if (!(rp->rtype & RAYREFL) && rp->parent->ro != NULL