--- ray/src/rt/m_mist.c 2003/03/10 17:26:26 2.12 +++ ray/src/rt/m_mist.c 2014/07/08 18:25:00 2.18 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id"; +static const char RCSid[] = "$Id: m_mist.c,v 2.18 2014/07/08 18:25:00 greg Exp $"; #endif /* * Mist volumetric material. @@ -7,9 +7,11 @@ static const char RCSid[] = "$Id"; #include "copyright.h" -#include "ray.h" +#include +#include "ray.h" #include "source.h" +#include "rtotypes.h" /* * A mist volume is used to specify a region in the scene where a certain @@ -49,13 +51,18 @@ static const char RCSid[] = "$Id"; #define RELAYDELIM '>' /* relay delimiter character */ +static int inslist(int *sl, int n); +static int srcmatch(SRCREC *sp, char *id); +static void add2slist(RAY *r, int *sl); + static int -inslist(sl, n) /* return index of source n if it's in list sl */ -register int *sl; -register int n; +inslist( /* return index of source n if it's in list sl */ + int *sl, + int n +) { - register int i; + int i; for (i = sl[0]; i > 0; i--) if (sl[i] == n) @@ -65,13 +72,14 @@ register int n; static int -srcmatch(sp, id) /* check for an id match on a light source */ -register SRCREC *sp; -register char *id; +srcmatch( /* check for an id match on a light source */ + SRCREC *sp, + char *id +) { - register char *cp; + char *cp; /* check for relay sources */ - while ((cp = index(id, RELAYDELIM)) != NULL) { + while ((cp = strchr(id, RELAYDELIM)) != NULL) { if (!(sp->sflags & SVIRTUAL) || sp->so == NULL) return(0); if (strncmp(id, sp->so->oname, cp-id) || sp->so->oname[cp-id]) @@ -86,12 +94,13 @@ register char *id; static void -add2slist(r, sl) /* add source list to ray's */ -register RAY *r; -register int *sl; +add2slist( /* add source list to ray's */ + RAY *r, + int *sl +) { static int slspare[MAXSLIST+1]; /* in case of emergence */ - register int i; + int i; if (sl == NULL || sl[0] == 0) /* nothing to add */ return; @@ -108,16 +117,17 @@ register int *sl; int -m_mist(m, r) /* process a ray entering or leaving some mist */ -OBJREC *m; -register RAY *r; +m_mist( /* process a ray entering or leaving some mist */ + OBJREC *m, + RAY *r +) { RAY p; int *myslist = NULL; int newslist[MAXSLIST+1]; COLOR mext; double re, ge, be; - register int i, j; + int i, j; /* check arguments */ if (m->oargs.nfargs > 7) objerror(m, USER, "bad arguments"); @@ -155,7 +165,7 @@ register RAY *r; } else setcolor(mext, 0., 0., 0.); /* start transmitted ray */ - if (rayorigin(&p, r, TRANS, 1.) < 0) + if (rayorigin(&p, TRANS, r, NULL) < 0) return(1); VCOPY(p.rdir, r->rdir); p.slights = newslist; @@ -175,7 +185,7 @@ register RAY *r; } else { /* leaving ray */ if (myslist != NULL) { /* delete from list */ for (j = myslist[0]; j > 0; j--) - if (i = inslist(p.slights, myslist[j])) + if ( (i = inslist(p.slights, myslist[j])) ) p.slights[i] = -1; for (i = 0, j = 1; j <= p.slights[0]; j++) if (p.slights[j] != -1) @@ -212,4 +222,5 @@ register RAY *r; return(1); memerr: error(SYSTEM, "out of memory in m_mist"); + return 0; /* pro forma return */ }