40 |
|
double maxarad; /* maximum ambient radius */ |
41 |
|
double minarad; /* minimum ambient radius */ |
42 |
|
|
43 |
+ |
/* |
44 |
+ |
* Since we've defined our vectors as float below to save space, |
45 |
+ |
* watch out for changes in the definitions of VCOPY() and DOT(). |
46 |
+ |
*/ |
47 |
|
typedef struct ambval { |
48 |
< |
FVECT pos; /* position in space */ |
49 |
< |
FVECT dir; /* normal direction */ |
48 |
> |
float pos[3]; /* position in space */ |
49 |
> |
float dir[3]; /* normal direction */ |
50 |
|
int lvl; /* recursion level of parent ray */ |
51 |
|
float weight; /* weight of parent ray */ |
52 |
|
COLOR val; /* computed ambient value */ |
213 |
|
for (j = 0; j < 3; j++) |
214 |
|
d += (r->rop[j] - av->pos[j]) * |
215 |
|
(av->dir[j] + r->ron[j]); |
216 |
< |
if (d < -minarad) |
216 |
> |
if (d*0.5 < -minarad*ambacc) |
217 |
|
continue; |
218 |
|
/* |
219 |
|
* Jittering final test reduces image artifacts. |
307 |
|
div = (AMBSAMP *)malloc(ndivs*sizeof(AMBSAMP)); |
308 |
|
if (div == NULL) |
309 |
|
error(SYSTEM, "out of memory in doambient"); |
310 |
< |
} |
310 |
> |
} else |
311 |
> |
div = NULL; |
312 |
|
/* make axes */ |
313 |
|
uy[0] = uy[1] = uy[2] = 0.0; |
314 |
|
for (k = 0; k < 3; k++) |
342 |
|
ndims--; |
343 |
|
if (ar.rot < FHUGE) |
344 |
|
arad += 1.0 / ar.rot; |
345 |
< |
if (ns > 0) { /* save division */ |
345 |
> |
if (div != NULL) { /* save division */ |
346 |
|
div[ne].k = 0.0; |
347 |
|
copycolor(div[ne].v, ar.rcol); |
348 |
|
div[ne].n = 0; |
425 |
|
|
426 |
|
if (ne >= i) { /* extract darkest division */ |
427 |
|
ne--; |
428 |
< |
if (div[ne].n > 1) |
429 |
< |
scalecolor(div[ne].v, 1.0/div[ne].n); |
428 |
> |
if (div[ne].n > 1) { |
429 |
> |
b = 1.0/div[ne].n; |
430 |
> |
scalecolor(div[ne].v, b); |
431 |
> |
div[ne].n = 1; |
432 |
> |
} |
433 |
|
addcolor(acol, div[ne].v); |
434 |
|
} |
435 |
|
} |
442 |
|
arad = maxarad; |
443 |
|
else if (arad < minarad) |
444 |
|
arad = minarad; |
445 |
< |
if (ns > 0) |
445 |
> |
if (div != NULL) |
446 |
|
free((char *)div); |
447 |
|
return(arad); |
448 |
|
} |