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 */ |
77 |
|
char *afile; |
78 |
|
{ |
79 |
|
long ftell(); |
79 |
– |
OBJECT obj; |
80 |
|
AMBVAL amb; |
81 |
|
|
82 |
|
maxarad = thescene.cusize / 2.0; /* maximum radius */ |
86 |
|
/* open ambient file */ |
87 |
|
if (afile != NULL) |
88 |
|
if ((ambfp = fopen(afile, "r+")) != NULL) { |
89 |
< |
while (fread(&amb, sizeof(AMBVAL), 1, ambfp) == 1) |
89 |
> |
while (fread((char *)&amb,sizeof(AMBVAL),1,ambfp) == 1) |
90 |
|
avinsert(&amb, &atrunk, thescene.cuorg, |
91 |
|
thescene.cusize); |
92 |
|
/* align */ |
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 |
|
} |
398 |
|
dnew.k = b2/(dnew.n*dnew.n); |
399 |
|
/* reinsert */ |
400 |
|
for (k = 0; k < ne-1 && dnew.k < div[k+1].k; k++) |
401 |
< |
bcopy(&div[k+1], &div[k], sizeof(AMBSAMP)); |
402 |
< |
bcopy(&dnew, &div[k], sizeof(AMBSAMP)); |
401 |
> |
copystruct(&div[k], &div[k+1]); |
402 |
> |
copystruct(&div[k], &dnew); |
403 |
|
|
404 |
|
if (ne >= i) { /* extract darkest division */ |
405 |
|
ne--; |
444 |
|
#endif |
445 |
|
if (ambfp == NULL) |
446 |
|
return; |
447 |
< |
if (fwrite(av, sizeof(AMBVAL), 1, ambfp) != 1) |
447 |
> |
if (fwrite((char *)av, sizeof(AMBVAL), 1, ambfp) != 1) |
448 |
|
goto writerr; |
449 |
|
#ifdef AMBFLUSH |
450 |
|
if (++nunflshed >= AMBFLUSH) { |
473 |
|
|
474 |
|
if ((av = newambval()) == NULL) |
475 |
|
goto memerr; |
476 |
< |
bcopy(aval, av, sizeof(AMBVAL)); |
476 |
> |
copystruct(av, aval); |
477 |
|
VCOPY(ck0, c0); |
478 |
|
while (s*(OCTSCALE/2) > av->rad*ambacc) { |
479 |
|
if (at->kid == NULL) |