1 |
< |
/* Copyright (c) 1996 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
4 |
> |
static char SCCSid[] = "$SunId$ SGI"; |
5 |
|
#endif |
6 |
|
|
7 |
|
/* |
44 |
|
|
45 |
|
static int raymove(), checkset(), checkhit(); |
46 |
|
|
47 |
< |
#define MAXLOOP 128 /* modifier loop detection */ |
47 |
> |
#ifndef MAXLOOP |
48 |
> |
#define MAXLOOP 0 /* modifier loop detection */ |
49 |
> |
#endif |
50 |
|
|
51 |
|
#define RAYHIT (-1) /* return value for intercepted ray */ |
52 |
|
|
56 |
|
int rt; |
57 |
|
double rw; |
58 |
|
{ |
59 |
+ |
double re; |
60 |
+ |
|
61 |
|
if ((r->parent = ro) == NULL) { /* primary ray */ |
62 |
|
r->rlvl = 0; |
63 |
|
r->rweight = rw; |
86 |
|
copycolor(r->albedo, ro->albedo); |
87 |
|
r->gecc = ro->gecc; |
88 |
|
r->slights = ro->slights; |
85 |
– |
r->rweight = ro->rweight * rw; |
89 |
|
r->crtype = ro->crtype | (r->rtype = rt); |
90 |
|
VCOPY(r->rorg, ro->rop); |
91 |
+ |
r->rweight = ro->rweight * rw; |
92 |
+ |
/* estimate absorption */ |
93 |
+ |
re = colval(ro->cext,RED) < colval(ro->cext,GRN) ? |
94 |
+ |
colval(ro->cext,RED) : colval(ro->cext,GRN); |
95 |
+ |
if (colval(ro->cext,BLU) < re) re = colval(ro->cext,BLU); |
96 |
+ |
if (re > 0.) |
97 |
+ |
r->rweight *= exp(-re*ro->rot); |
98 |
|
} |
99 |
|
rayclear(r); |
100 |
|
return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1); |
162 |
|
register RAY *r; |
163 |
|
int mod; |
164 |
|
{ |
155 |
– |
static int depth = 0; |
165 |
|
int gotmat; |
166 |
|
register OBJREC *m; |
167 |
+ |
#if MAXLOOP |
168 |
+ |
static int depth = 0; |
169 |
|
/* check for infinite loop */ |
170 |
|
if (depth++ >= MAXLOOP) |
171 |
|
objerror(r->ro, USER, "possible modifier loop"); |
172 |
+ |
#endif |
173 |
|
r->rt = r->rot; /* set effective ray length */ |
174 |
|
for (gotmat = 0; !gotmat && mod != OVOID; mod = m->omod) { |
175 |
|
m = objptr(mod); |
182 |
|
/* hack for irradiance calculation */ |
183 |
|
if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) { |
184 |
|
if (irr_ignore(m->otype)) { |
185 |
+ |
#if MAXLOOP |
186 |
|
depth--; |
187 |
+ |
#endif |
188 |
|
raytrans(r); |
189 |
|
return(1); |
190 |
|
} |
194 |
|
/* materials call raytexture */ |
195 |
|
gotmat = (*ofun[m->otype].funp)(m, r); |
196 |
|
} |
197 |
+ |
#if MAXLOOP |
198 |
|
depth--; |
199 |
+ |
#endif |
200 |
|
return(gotmat); |
201 |
|
} |
202 |
|
|
236 |
|
RAY *r; |
237 |
|
int mod; |
238 |
|
{ |
223 |
– |
static int depth = 0; |
239 |
|
register OBJREC *m; |
240 |
+ |
#if MAXLOOP |
241 |
+ |
static int depth = 0; |
242 |
|
/* check for infinite loop */ |
243 |
|
if (depth++ >= MAXLOOP) |
244 |
|
objerror(r->ro, USER, "modifier loop"); |
245 |
+ |
#endif |
246 |
|
/* execute textures and patterns */ |
247 |
|
for ( ; mod != OVOID; mod = m->omod) { |
248 |
|
m = objptr(mod); |
258 |
|
objerror(r->ro, USER, errmsg); |
259 |
|
} |
260 |
|
} |
261 |
+ |
#if MAXLOOP |
262 |
|
depth--; /* end here */ |
263 |
+ |
#endif |
264 |
|
} |
265 |
|
|
266 |
|
|