--- ray/src/rt/m_mist.c 1996/03/21 10:24:59 2.5 +++ ray/src/rt/m_mist.c 2003/06/30 14:59:12 2.13 @@ -1,15 +1,15 @@ -/* Copyright (c) 1995 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id"; #endif - /* * Mist volumetric material. */ -#include "ray.h" +#include "copyright.h" +#include + +#include "ray.h" #include "source.h" /* @@ -33,7 +33,7 @@ static char SCCSid[] = "$SunId$ LBL"; * * Up to five real arguments may be given for MAT_MIST: * - * [ext_r ext_g ext_b [albedo [gecc]]] + * [ext_r ext_g ext_b [albedo_r albedo_g albedo_b [gecc]]] * * The primaries indicate medium extinction per unit length (absorption * plus scattering), which is added to the global extinction coefficient, set @@ -44,13 +44,13 @@ 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 double salbedo; /* global scattering albedo */ -extern double seccg; /* global scattering eccentricity */ - static int inslist(sl, n) /* return index of source n if it's in list sl */ register int *sl; @@ -70,10 +70,9 @@ srcmatch(sp, id) /* check for an id match on a light s 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,7 +86,7 @@ register char *id; } -static +static void add2slist(r, sl) /* add source list to ray's */ register RAY *r; register int *sl; @@ -102,12 +101,14 @@ 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]; } } +int m_mist(m, r) /* process a ray entering or leaving some mist */ OBJREC *m; register RAY *r; @@ -119,12 +120,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; @@ -166,10 +167,11 @@ register RAY *r; p.slights[0] = 0; if (r->rod > 0.) { /* entering ray */ addcolor(p.cext, mext); - if (m->oargs.nfargs > 3) - p.albedo = m->oargs.farg[3]; - if (m->oargs.nfargs > 4) - p.gecc = m->oargs.farg[4]; + if (m->oargs.nfargs > 5) + setcolor(p.albedo, m->oargs.farg[3], + m->oargs.farg[4], m->oargs.farg[5]); + if (m->oargs.nfargs > 6) + p.gecc = m->oargs.farg[6]; add2slist(&p, myslist); /* add to list */ } else { /* leaving ray */ if (myslist != NULL) { /* delete from list */ @@ -181,10 +183,11 @@ register RAY *r; p.slights[++i] = p.slights[j]; if (p.slights[0] - i < myslist[0]) { /* fix old */ addcolor(r->cext, mext); - if (m->oargs.nfargs > 3) - r->albedo = m->oargs.farg[3]; - if (m->oargs.nfargs > 4) - r->gecc = m->oargs.farg[4]; + if (m->oargs.nfargs > 5) + setcolor(r->albedo, m->oargs.farg[3], + m->oargs.farg[4], m->oargs.farg[5]); + if (m->oargs.nfargs > 6) + r->gecc = m->oargs.farg[6]; add2slist(r, myslist); } p.slights[0] = i; @@ -199,9 +202,9 @@ register RAY *r; colval(cextinction,BLU)) be = colval(cextinction,BLU); setcolor(p.cext, re, ge, be); - if (m->oargs.nfargs > 3) - p.albedo = salbedo; - if (m->oargs.nfargs > 4) + if (m->oargs.nfargs > 5) + copycolor(p.albedo, salbedo); + if (m->oargs.nfargs > 6) p.gecc = seccg; } rayvalue(&p); /* calls rayparticipate() */