| 34 |
|
extern char *amblist[]; /* ambient include/exclude list */ |
| 35 |
|
extern int ambincl; /* include == 1, exclude == 0 */ |
| 36 |
|
|
| 37 |
< |
OBJECT ambset[256]={0}; /* ambient include/exclude set */ |
| 37 |
> |
#define MAXASET 511 /* maximum number of elements in ambient set */ |
| 38 |
> |
OBJECT ambset[MAXASET+1]={0}; /* ambient include/exclude set */ |
| 39 |
|
|
| 40 |
|
double maxarad; /* maximum ambient radius */ |
| 41 |
|
double minarad; /* minimum ambient radius */ |
| 102 |
|
ambnotify(obj) /* record new modifier */ |
| 103 |
|
OBJECT obj; |
| 104 |
|
{ |
| 105 |
+ |
static int hitlimit = 0; |
| 106 |
|
register OBJREC *o = objptr(obj); |
| 107 |
|
register char **amblp; |
| 108 |
|
|
| 109 |
< |
if (!ismodifier(o->otype)) |
| 109 |
> |
if (hitlimit || !ismodifier(o->otype)) |
| 110 |
|
return; |
| 111 |
|
for (amblp = amblist; *amblp != NULL; amblp++) |
| 112 |
|
if (!strcmp(o->oname, *amblp)) { |
| 113 |
+ |
if (ambset[0] >= MAXASET) { |
| 114 |
+ |
error(WARNING, "too many modifiers in ambient list"); |
| 115 |
+ |
hitlimit++; |
| 116 |
+ |
return; /* should this be fatal? */ |
| 117 |
+ |
} |
| 118 |
|
insertelem(ambset, obj); |
| 119 |
|
return; |
| 120 |
|
} |
| 278 |
|
{ |
| 279 |
|
extern int ambcmp(); |
| 280 |
|
extern double sin(), cos(), sqrt(); |
| 281 |
+ |
int hlist[4]; |
| 282 |
|
double phi, xd, yd, zd; |
| 283 |
|
double b, b2; |
| 284 |
|
register AMBSAMP *div; |
| 313 |
|
fcross(ux, r->ron, uy); |
| 314 |
|
normalize(ux); |
| 315 |
|
fcross(uy, ux, r->ron); |
| 316 |
+ |
/* set up urand */ |
| 317 |
+ |
hlist[0] = r->rno; |
| 318 |
|
/* sample divisions */ |
| 319 |
|
arad = 0.0; |
| 320 |
|
ne = 0; |
| 321 |
< |
for (i = 0; i < nt; i++) |
| 321 |
> |
for (i = 0; i < nt; i++) { |
| 322 |
> |
hlist[1] = i; |
| 323 |
|
for (j = 0; j < np; j++) { |
| 324 |
|
rayorigin(&ar, r, AMBIENT, 0.5); /* pretested */ |
| 325 |
< |
zd = sqrt((i+frandom())/nt); |
| 326 |
< |
phi = 2.0*PI * (j+frandom())/np; |
| 325 |
> |
hlist[2] = j; |
| 326 |
> |
hlist[3] = 0; |
| 327 |
> |
zd = sqrt((i+urand(ilhash(hlist,4)))/nt); |
| 328 |
> |
hlist[3] = 1; |
| 329 |
> |
phi = 2.0*PI * (j+urand(ilhash(hlist,4)))/np; |
| 330 |
|
xd = cos(phi) * zd; |
| 331 |
|
yd = sin(phi) * zd; |
| 332 |
|
zd = sqrt(1.0 - zd*zd); |
| 333 |
|
for (k = 0; k < 3; k++) |
| 334 |
|
ar.rdir[k] = xd*ux[k]+yd*uy[k]+zd*r->ron[k]; |
| 335 |
+ |
dimlist[ndims++] = i*np + j + 38813; |
| 336 |
|
rayvalue(&ar); |
| 337 |
+ |
ndims--; |
| 338 |
|
if (ar.rot < FHUGE) |
| 339 |
|
arad += 1.0 / ar.rot; |
| 340 |
|
if (ns > 0) { /* save division */ |
| 372 |
|
} else |
| 373 |
|
addcolor(acol, ar.rcol); |
| 374 |
|
} |
| 375 |
+ |
} |
| 376 |
|
for (k = 0; k < ne; k++) { /* compute errors */ |
| 377 |
|
if (div[k].n > 1) |
| 378 |
|
div[k].k /= div[k].n; |
| 388 |
|
/* super-sample */ |
| 389 |
|
for (i = ns; i > 0; i--) { |
| 390 |
|
rayorigin(&ar, r, AMBIENT, 0.5); /* pretested */ |
| 391 |
< |
zd = sqrt((div[0].t+frandom())/nt); |
| 392 |
< |
phi = 2.0*PI * (div[0].p+frandom())/np; |
| 391 |
> |
hlist[1] = div[0].t; |
| 392 |
> |
hlist[2] = div[0].p; |
| 393 |
> |
hlist[3] = 0; |
| 394 |
> |
zd = sqrt((div[0].t+urand(ilhash(hlist,4)+div[0].n))/nt); |
| 395 |
> |
hlist[3] = 1; |
| 396 |
> |
phi = 2.0*PI * (div[0].p+urand(ilhash(hlist,4)+div[0].n))/np; |
| 397 |
|
xd = cos(phi) * zd; |
| 398 |
|
yd = sin(phi) * zd; |
| 399 |
|
zd = sqrt(1.0 - zd*zd); |
| 400 |
|
for (k = 0; k < 3; k++) |
| 401 |
|
ar.rdir[k] = xd*ux[k]+yd*uy[k]+zd*r->ron[k]; |
| 402 |
+ |
dimlist[ndims++] = div[0].t*np + div[0].p + 38813; |
| 403 |
+ |
rayvalue(&ar); |
| 404 |
+ |
ndims--; |
| 405 |
|
rayvalue(&ar); |
| 406 |
|
if (ar.rot < FHUGE) |
| 407 |
|
arad += 1.0 / ar.rot; |