1 |
– |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Mist volumetric material. |
6 |
|
*/ |
7 |
|
|
8 |
< |
#include "ray.h" |
8 |
> |
#include "copyright.h" |
9 |
|
|
10 |
+ |
#include <string.h> |
11 |
+ |
|
12 |
+ |
#include "ray.h" |
13 |
|
#include "source.h" |
14 |
|
|
15 |
|
/* |
50 |
|
|
51 |
|
#define RELAYDELIM '>' /* relay delimiter character */ |
52 |
|
|
53 |
– |
extern COLOR cextinction; /* global coefficient of extinction */ |
54 |
– |
extern COLOR salbedo; /* global scattering albedo */ |
55 |
– |
extern double seccg; /* global scattering eccentricity */ |
53 |
|
|
57 |
– |
|
54 |
|
static int |
55 |
|
inslist(sl, n) /* return index of source n if it's in list sl */ |
56 |
|
register int *sl; |
70 |
|
register SRCREC *sp; |
71 |
|
register char *id; |
72 |
|
{ |
77 |
– |
extern char *index(); |
73 |
|
register char *cp; |
74 |
|
/* check for relay sources */ |
75 |
< |
while ((cp = index(id, RELAYDELIM)) != NULL) { |
75 |
> |
while ((cp = strchr(id, RELAYDELIM)) != NULL) { |
76 |
|
if (!(sp->sflags & SVIRTUAL) || sp->so == NULL) |
77 |
|
return(0); |
78 |
|
if (strncmp(id, sp->so->oname, cp-id) || sp->so->oname[cp-id]) |
86 |
|
} |
87 |
|
|
88 |
|
|
89 |
< |
static |
89 |
> |
static void |
90 |
|
add2slist(r, sl) /* add source list to ray's */ |
91 |
|
register RAY *r; |
92 |
|
register int *sl; |
101 |
|
for (i = sl[0]; i > 0; i--) |
102 |
|
if (!inslist(r->slights, sl[i])) { |
103 |
|
if (r->slights[0] >= MAXSLIST) |
104 |
< |
error(USER, "scattering source list overflow"); |
104 |
> |
error(INTERNAL, |
105 |
> |
"scattering source list overflow"); |
106 |
|
r->slights[++r->slights[0]] = sl[i]; |
107 |
|
} |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
+ |
int |
112 |
|
m_mist(m, r) /* process a ray entering or leaving some mist */ |
113 |
|
OBJREC *m; |
114 |
|
register RAY *r; |
120 |
|
double re, ge, be; |
121 |
|
register int i, j; |
122 |
|
/* check arguments */ |
123 |
< |
if (m->oargs.nfargs > 5) |
123 |
> |
if (m->oargs.nfargs > 7) |
124 |
|
objerror(m, USER, "bad arguments"); |
125 |
|
/* get source indices */ |
126 |
|
if (m->oargs.nsargs > 0 && (myslist = (int *)m->os) == NULL) { |
127 |
|
if (m->oargs.nsargs > MAXSLIST) |
128 |
< |
objerror(m, USER, "too many sources in list"); |
128 |
> |
objerror(m, INTERNAL, "too many sources in list"); |
129 |
|
myslist = (int *)malloc((m->oargs.nsargs+1)*sizeof(int)); |
130 |
|
if (myslist == NULL) |
131 |
|
goto memerr; |