| 161 |
|
static float * |
| 162 |
|
getambdiffs(AMBHEMI *hp) |
| 163 |
|
{ |
| 164 |
< |
float *earr = calloc(hp->ns*hp->ns, sizeof(float)); |
| 164 |
> |
float *earr = (float *)calloc(hp->ns*hp->ns, sizeof(float)); |
| 165 |
|
float *ep; |
| 166 |
|
AMBSAMP *ap; |
| 167 |
|
double b, d2; |
| 606 |
|
) |
| 607 |
|
{ |
| 608 |
|
AMBHEMI *hp = inithemi(rcol, r, wt); |
| 609 |
< |
int cnt = 0; |
| 609 |
> |
int cnt; |
| 610 |
|
FVECT my_uv[2]; |
| 611 |
|
double d, K, acol[3]; |
| 612 |
|
AMBSAMP *ap; |
| 624 |
|
dg[0] = dg[1] = 0.0; |
| 625 |
|
/* sample the hemisphere */ |
| 626 |
|
acol[0] = acol[1] = acol[2] = 0.0; |
| 627 |
+ |
cnt = 0; |
| 628 |
|
for (i = hp->ns; i--; ) |
| 629 |
|
for (j = hp->ns; j--; ) |
| 630 |
|
if ((ap = ambsample(hp, i, j)) != NULL) { |
| 649 |
|
free(hp); |
| 650 |
|
return(-1); /* no radius or gradient calc. */ |
| 651 |
|
} |
| 652 |
< |
if (bright(acol) > FTINY) { /* normalize Y values */ |
| 653 |
< |
d = 0.99*cnt/bright(acol); |
| 652 |
> |
if ((d = bright(acol)) > FTINY) { /* normalize Y values */ |
| 653 |
> |
d = 0.99*(hp->ns*hp->ns)/d; |
| 654 |
|
K = 0.01; |
| 655 |
< |
} else { /* geometric Hessian fall-back */ |
| 655 |
< |
d = 0.0; |
| 655 |
> |
} else { /* or fall back on geometric Hessian */ |
| 656 |
|
K = 1.0; |
| 657 |
|
pg = NULL; |
| 658 |
|
dg = NULL; |