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); |
106 |
|
{ |
107 |
|
r->rno = raynum++; |
108 |
|
r->newcset = r->clipset; |
109 |
+ |
r->robj = OVOID; |
110 |
|
r->ro = NULL; |
111 |
< |
r->rot = FHUGE; |
111 |
> |
r->rt = r->rot = FHUGE; |
112 |
|
r->pert[0] = r->pert[1] = r->pert[2] = 0.0; |
113 |
|
setcolor(r->pcol, 1.0, 1.0, 1.0); |
114 |
|
setcolor(r->rcol, 0.0, 0.0, 0.0); |
104 |
– |
r->rt = 0.0; |
115 |
|
} |
116 |
|
|
117 |
|
|
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 |
|
|
289 |
|
backmat = rayshade(&br, back); |
290 |
|
/* check for transparency */ |
291 |
|
if (backmat ^ foremat) |
292 |
< |
if (backmat) |
292 |
> |
if (backmat && coef > FTINY) |
293 |
|
raytrans(&fr); |
294 |
< |
else |
294 |
> |
else if (foremat && coef < 1.0-FTINY) |
295 |
|
raytrans(&br); |
296 |
|
/* mix perturbations */ |
297 |
|
for (i = 0; i < 3; i++) |
574 |
|
checkset(oset, cxs); /* eliminate double-checking */ |
575 |
|
for (i = oset[0]; i > 0; i--) { |
576 |
|
o = objptr(oset[i]); |
577 |
< |
(*ofun[o->otype].funp)(o, r); |
577 |
> |
if ((*ofun[o->otype].funp)(o, r)) |
578 |
> |
r->robj = oset[i]; |
579 |
|
} |
580 |
|
if (r->ro == NULL) |
581 |
|
return(0); /* no scores yet */ |