--- ray/src/rt/m_clip.c 1996/02/12 17:04:08 2.3 +++ ray/src/rt/m_clip.c 2003/07/21 22:30:19 2.7 @@ -1,15 +1,12 @@ -/* Copyright (c) 1986 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: m_clip.c,v 2.7 2003/07/21 22:30:19 schorsch Exp $"; #endif - /* * m_clip.c - routine for clipped (cut) objects. - * - * 3/17/86 */ +#include "copyright.h" + #include "ray.h" /* @@ -21,20 +18,20 @@ static char SCCSid[] = "$SunId$ LBL"; */ +int m_clip(m, r) /* clip objects from ray */ register OBJREC *m; register RAY *r; { OBJECT cset[MAXSET+1], *modset; + OBJECT obj, mod; int entering; register int i; + obj = objndx(m); if ((modset = (OBJECT *)m->os) == NULL) { - OBJECT obj, mod; - if (m->oargs.nsargs < 1 || m->oargs.nsargs > MAXSET) objerror(m, USER, "bad # arguments"); - obj = objndx(m); modset = (OBJECT *)malloc((m->oargs.nsargs+1)*sizeof(OBJECT)); if (modset == NULL) error(SYSTEM, "out of memory in m_clip"); @@ -83,14 +80,15 @@ register RAY *r; /* 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, modifier(m->oargs.sarg[0]))); + return(rayshade(r, lastmod(obj, m->oargs.sarg[0]))); } } raytrans(r); /* else transfer ray */