--- ray/src/rt/m_mist.c 1996/04/17 14:10:23 2.6 +++ ray/src/rt/m_mist.c 2005/04/19 01:15:06 2.17 @@ -1,16 +1,17 @@ -/* Copyright (c) 1995 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: m_mist.c,v 2.17 2005/04/19 01:15:06 greg Exp $"; #endif - /* * Mist volumetric material. */ -#include "ray.h" +#include "copyright.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 @@ -44,17 +45,22 @@ static char SCCSid[] = "$SunId$ LBL"; * scattering. A value approaching 1 indicates strong forward scattering. */ +#ifndef MAXSLIST +#define MAXSLIST 32 /* maximum sources to check */ +#endif + #define RELAYDELIM '>' /* relay delimiter character */ -extern COLOR cextinction; /* global coefficient of extinction */ -extern COLOR salbedo; /* global scattering albedo */ -extern double seccg; /* global scattering eccentricity */ +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 */ + register int *sl, + register int n +) { register int i; @@ -66,14 +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 */ + register SRCREC *sp, + register char *id +) { - extern char *index(); register 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]) @@ -87,10 +93,11 @@ register char *id; } -static -add2slist(r, sl) /* add source list to ray's */ -register RAY *r; -register int *sl; +static void +add2slist( /* add source list to ray's */ + register RAY *r, + register int *sl +) { static int slspare[MAXSLIST+1]; /* in case of emergence */ register int i; @@ -102,15 +109,18 @@ register int *sl; for (i = sl[0]; i > 0; i--) if (!inslist(r->slights, sl[i])) { if (r->slights[0] >= MAXSLIST) - error(USER, "scattering source list overflow"); + error(INTERNAL, + "scattering source list overflow"); r->slights[++r->slights[0]] = sl[i]; } } -m_mist(m, r) /* process a ray entering or leaving some mist */ -OBJREC *m; -register RAY *r; +extern int +m_mist( /* process a ray entering or leaving some mist */ + OBJREC *m, + register RAY *r +) { RAY p; int *myslist = NULL; @@ -119,12 +129,12 @@ register RAY *r; double re, ge, be; register int i, j; /* check arguments */ - if (m->oargs.nfargs > 5) + if (m->oargs.nfargs > 7) objerror(m, USER, "bad arguments"); /* get source indices */ if (m->oargs.nsargs > 0 && (myslist = (int *)m->os) == NULL) { if (m->oargs.nsargs > MAXSLIST) - objerror(m, USER, "too many sources in list"); + objerror(m, INTERNAL, "too many sources in list"); myslist = (int *)malloc((m->oargs.nsargs+1)*sizeof(int)); if (myslist == NULL) goto memerr; @@ -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 */ }