21 |
|
#ifndef OCTSCALE |
22 |
|
#define OCTSCALE 1.0 /* ceil((valid rad.)/(cube size)) */ |
23 |
|
#endif |
24 |
– |
#ifndef AMBVWT |
25 |
– |
#define AMBVWT 250 /* relative ambient value weight (# calcs) */ |
26 |
– |
#endif |
24 |
|
|
25 |
|
typedef struct ambtree { |
26 |
|
AMBVAL *alist; /* ambient value list */ |
57 |
|
#endif |
58 |
|
|
59 |
|
static COLOR avsum = BLKCOLOR; /* computed ambient value sum */ |
60 |
< |
static unsigned int nambvals = 0; /* number of computed ambient values */ |
60 |
> |
static unsigned int nambvals = 0; /* total number of indirect values */ |
61 |
> |
static unsigned int nambshare = 0; /* number of values from file */ |
62 |
|
static unsigned long ambclock = 0; /* ambient access clock */ |
63 |
|
static unsigned long lastsort = 0; /* time of last value sort */ |
64 |
|
static long sortintvl = SORT_INTVL; /* time until next sort */ |
67 |
|
/* |
68 |
|
* Track access times unless we are sharing ambient values |
69 |
|
* through memory on a multiprocessor, when we want to avoid |
70 |
< |
* claiming our own memory (copy on write). |
70 |
> |
* claiming our own memory (copy on write). Go ahead anyway |
71 |
> |
* if more than two thirds of our values are unshared. |
72 |
|
*/ |
73 |
< |
#define tracktime (shm_boundary == NULL || ambfp == NULL) |
73 |
> |
#define tracktime (shm_boundary == NULL || nambvals > 3*nambshare) |
74 |
|
|
75 |
|
#define AMBFLUSH (BUFSIZ/AMBVALSIZ) |
76 |
|
|
142 |
|
avinsert(avstore(&amb)); |
143 |
|
/* align */ |
144 |
|
fseek(ambfp, -((ftell(ambfp)-headlen)%AMBVALSIZ), 1); |
145 |
+ |
nambshare = nambvals; |
146 |
|
} else if ((ambfp = fopen(afile, "w+")) != NULL) |
147 |
|
initambfile(1); |
148 |
|
else { |
219 |
|
return; |
220 |
|
dumbamb: /* return global value */ |
221 |
|
copycolor(acol, ambval); |
222 |
< |
#if AMBVWT |
223 |
< |
if (nambvals == 0) |
222 |
> |
if (ambvwt <= 0 | nambvals == 0) |
223 |
|
return; |
224 |
< |
scalecolor(acol, (double)AMBVWT); |
224 |
> |
scalecolor(acol, (double)ambvwt); |
225 |
|
addcolor(acol, avsum); /* average in computations */ |
226 |
< |
d = 1.0/(AMBVWT+nambvals); |
226 |
> |
d = 1.0/(ambvwt+nambvals); |
227 |
|
scalecolor(acol, d); |
229 |
– |
#endif |
228 |
|
} |
229 |
|
|
230 |
|
|