17 |
|
|
18 |
|
#include "octree.h" |
19 |
|
|
20 |
+ |
#include "otypes.h" |
21 |
+ |
|
22 |
|
#include "random.h" |
23 |
|
|
24 |
|
#define OCTSCALE 0.5 /* ceil((valid rad.)/(cube size)) */ |
34 |
|
extern char *amblist[]; /* ambient include/exclude list */ |
35 |
|
extern int ambincl; /* include == 1, exclude == 0 */ |
36 |
|
|
37 |
< |
OBJECT ambset[128]; /* ambient include/exclude set */ |
37 |
> |
OBJECT ambset[256]={0}; /* ambient include/exclude set */ |
38 |
|
|
39 |
|
double maxarad; /* maximum ambient radius */ |
40 |
|
double minarad; /* minimum ambient radius */ |
76 |
|
char *afile; |
77 |
|
{ |
78 |
|
long ftell(); |
77 |
– |
char **amblp; |
78 |
– |
OBJECT obj; |
79 |
|
AMBVAL amb; |
80 |
< |
/* set up ambient set */ |
81 |
< |
ambset[0] = 0; |
82 |
< |
for (amblp = amblist; *amblp != NULL; amblp++) { |
83 |
< |
if ((obj = modifier(*amblp)) == OVOID) { |
84 |
< |
sprintf(errmsg, "unknown %s modifier \"%s\"", |
85 |
< |
ambincl ? "include" : "exclude", *amblp); |
86 |
< |
error(WARNING, errmsg); |
87 |
< |
continue; |
88 |
< |
} |
89 |
< |
if (!inset(ambset, obj)) |
90 |
< |
insertelem(ambset, obj); |
91 |
< |
} |
80 |
> |
|
81 |
|
maxarad = thescene.cusize / 2.0; /* maximum radius */ |
82 |
|
/* minimum radius */ |
83 |
|
minarad = ambres > 0 ? thescene.cusize/ambres : 0.0; |
85 |
|
/* open ambient file */ |
86 |
|
if (afile != NULL) |
87 |
|
if ((ambfp = fopen(afile, "r+")) != NULL) { |
88 |
< |
while (fread(&amb, sizeof(AMBVAL), 1, ambfp) == 1) |
88 |
> |
while (fread((char *)&amb,sizeof(AMBVAL),1,ambfp) == 1) |
89 |
|
avinsert(&amb, &atrunk, thescene.cuorg, |
90 |
|
thescene.cusize); |
91 |
|
/* align */ |
98 |
|
} |
99 |
|
|
100 |
|
|
101 |
+ |
ambnotify(obj) /* record new modifier */ |
102 |
+ |
OBJECT obj; |
103 |
+ |
{ |
104 |
+ |
register OBJREC *o = objptr(obj); |
105 |
+ |
register char **amblp; |
106 |
+ |
|
107 |
+ |
if (!ismodifier(o->otype)) |
108 |
+ |
return; |
109 |
+ |
for (amblp = amblist; *amblp != NULL; amblp++) |
110 |
+ |
if (!strcmp(o->oname, *amblp)) { |
111 |
+ |
insertelem(ambset, obj); |
112 |
+ |
return; |
113 |
+ |
} |
114 |
+ |
} |
115 |
+ |
|
116 |
+ |
|
117 |
|
ambient(acol, r) /* compute ambient component for ray */ |
118 |
|
COLOR acol; |
119 |
|
register RAY *r; |
391 |
|
dnew.k = b2/(dnew.n*dnew.n); |
392 |
|
/* reinsert */ |
393 |
|
for (k = 0; k < ne-1 && dnew.k < div[k+1].k; k++) |
394 |
< |
bcopy(&div[k+1], &div[k], sizeof(AMBSAMP)); |
395 |
< |
bcopy(&dnew, &div[k], sizeof(AMBSAMP)); |
394 |
> |
copystruct(&div[k], &div[k+1]); |
395 |
> |
copystruct(&div[k], &dnew); |
396 |
|
|
397 |
|
if (ne >= i) { /* extract darkest division */ |
398 |
|
ne--; |
437 |
|
#endif |
438 |
|
if (ambfp == NULL) |
439 |
|
return; |
440 |
< |
if (fwrite(av, sizeof(AMBVAL), 1, ambfp) != 1) |
440 |
> |
if (fwrite((char *)av, sizeof(AMBVAL), 1, ambfp) != 1) |
441 |
|
goto writerr; |
442 |
|
#ifdef AMBFLUSH |
443 |
|
if (++nunflshed >= AMBFLUSH) { |
466 |
|
|
467 |
|
if ((av = newambval()) == NULL) |
468 |
|
goto memerr; |
469 |
< |
bcopy(aval, av, sizeof(AMBVAL)); |
469 |
> |
copystruct(av, aval); |
470 |
|
VCOPY(ck0, c0); |
471 |
|
while (s*(OCTSCALE/2) > av->rad*ambacc) { |
472 |
|
if (at->kid == NULL) |