| 21 |
|
#include "ambient.h" |
| 22 |
|
#include "random.h" |
| 23 |
|
|
| 24 |
+ |
#ifndef MINADIV |
| 25 |
+ |
#define MINADIV 7 /* minimum # divisions in each dimension */ |
| 26 |
+ |
#endif |
| 27 |
+ |
|
| 28 |
|
extern void SDsquare2disk(double ds[2], double seedx, double seedy); |
| 29 |
|
|
| 30 |
|
typedef struct { |
| 262 |
|
wt > (d = 0.8*intens(rcol)*r->rweight/(ambdiv*minweight))) |
| 263 |
|
wt = d; /* avoid ray termination */ |
| 264 |
|
n = sqrt(ambdiv * wt) + 0.5; |
| 265 |
< |
i = 1 + 5*(ambacc > FTINY); /* minimum number of samples */ |
| 266 |
< |
if (n < i) |
| 265 |
> |
i = 1 + (MINADIV-1)*(ambacc > FTINY); |
| 266 |
> |
if (n < i) /* use minimum number of samples? */ |
| 267 |
|
n = i; |
| 268 |
|
/* allocate sampling array */ |
| 269 |
|
hp = (AMBHEMI *)malloc(sizeof(AMBHEMI) + sizeof(AMBSAMP)*(n*n - 1)); |
| 295 |
|
hp->sampOK *= -1; /* soft failure */ |
| 296 |
|
return(hp); |
| 297 |
|
} |
| 298 |
< |
if (hp->sampOK < 64) |
| 299 |
< |
return(hp); /* insufficient for super-sampling */ |
| 298 |
> |
if (hp->sampOK <= MINADIV*MINADIV) |
| 299 |
> |
return(hp); /* don't bother super-sampling */ |
| 300 |
|
n = ambssamp*wt + 0.5; |
| 301 |
|
if (n > 8) { /* perform super-sampling? */ |
| 302 |
|
ambsupersamp(hp, n); |
| 717 |
|
return(0); |
| 718 |
|
|
| 719 |
|
if ((ra == NULL) & (pg == NULL) & (dg == NULL) || |
| 720 |
< |
(hp->sampOK < 0) | (hp->ns < 6)) { |
| 720 |
> |
(hp->sampOK < 0) | (hp->ns < MINADIV)) { |
| 721 |
|
free(hp); /* Hessian not requested/possible */ |
| 722 |
|
return(-1); /* value-only return value */ |
| 723 |
|
} |
| 765 |
|
ra[0] = maxarad; |
| 766 |
|
} |
| 767 |
|
/* flag encroached directions */ |
| 768 |
< |
if (crlp != NULL) |
| 768 |
> |
if (crlp != NULL) /* XXX doesn't update with changes to ambacc */ |
| 769 |
|
*crlp = ambcorral(hp, uv, ra[0]*ambacc, ra[1]*ambacc); |
| 770 |
|
if (pg != NULL) { /* cap gradient if necessary */ |
| 771 |
|
d = pg[0]*pg[0]*ra[0]*ra[0] + pg[1]*pg[1]*ra[1]*ra[1]; |
| 779 |
|
free(hp); /* clean up and return */ |
| 780 |
|
return(1); |
| 781 |
|
} |
| 778 |
– |
|