27 |
|
short nt, np; /* number of theta and phi directions */ |
28 |
|
} AMBHEMI; /* ambient sample hemisphere */ |
29 |
|
|
30 |
– |
extern double sin(), cos(), sqrt(); |
30 |
|
|
32 |
– |
|
31 |
|
static int |
32 |
|
ambcmp(d1, d2) /* decreasing order */ |
33 |
|
AMBSAMP *d1, *d2; |
84 |
|
rayvalue(&ar); |
85 |
|
ndims--; |
86 |
|
addcolor(dp->v, ar.rcol); |
87 |
< |
if (ar.rt > FTINY && ar.rt < FHUGE) |
88 |
< |
dp->r += 1.0/ar.rt; |
87 |
> |
/* be conservative and use rot */ |
88 |
> |
if (ar.rot > FTINY && ar.rot < FHUGE) |
89 |
> |
dp->r += 1.0/ar.rot; |
90 |
|
/* (re)initialize error */ |
91 |
|
if (dp->n++) { |
92 |
|
b2 = bright(dp->v)/dp->n - bright(ar.rcol); |
140 |
|
dp->n = 0; |
141 |
|
if (divsample(dp, &hemi, r) < 0) |
142 |
|
goto oopsy; |
143 |
+ |
arad += dp->r; |
144 |
|
if (div != NULL) |
145 |
|
dp++; |
146 |
< |
else { |
146 |
> |
else |
147 |
|
addcolor(acol, dp->v); |
148 |
– |
arad += dp->r; |
149 |
– |
} |
148 |
|
} |
149 |
< |
if (ns > 0) { /* perform super-sampling */ |
149 |
> |
if (ns > 0 && arad > FTINY && ndivs/arad < minarad) |
150 |
> |
ns = 0; /* close enough */ |
151 |
> |
else if (ns > 0) { /* else perform super-sampling */ |
152 |
|
comperrs(div, &hemi); /* compute errors */ |
153 |
|
qsort(div, ndivs, sizeof(AMBSAMP), ambcmp); /* sort divs */ |
154 |
|
/* super-sample */ |
170 |
|
} |
171 |
|
/* compute returned values */ |
172 |
|
if (div != NULL) { |
173 |
+ |
arad = 0.0; |
174 |
|
for (i = ndivs, dp = div; i-- > 0; dp++) { |
175 |
|
arad += dp->r; |
176 |
|
if (dp->n > 1) { |