10 |
|
#include "copyright.h" |
11 |
|
|
12 |
|
#include "ray.h" |
13 |
– |
|
13 |
|
#include "ambient.h" |
15 |
– |
|
14 |
|
#include "random.h" |
15 |
|
|
16 |
+ |
#ifdef NEWAMB |
17 |
|
|
18 |
+ |
#else /* ! NEWAMB */ |
19 |
+ |
|
20 |
+ |
|
21 |
|
void |
22 |
|
inithemi( /* initialize sampling hemisphere */ |
23 |
< |
register AMBHEMI *hp, |
23 |
> |
AMBHEMI *hp, |
24 |
|
COLOR ac, |
25 |
|
RAY *r, |
26 |
|
double wt |
27 |
|
) |
28 |
|
{ |
29 |
|
double d; |
30 |
< |
register int i; |
30 |
> |
int i; |
31 |
|
/* set number of divisions */ |
32 |
|
if (ambacc <= FTINY && |
33 |
|
wt > (d = 0.8*intens(ac)*r->rweight/(ambdiv*minweight))) |
60 |
|
|
61 |
|
int |
62 |
|
divsample( /* sample a division */ |
63 |
< |
register AMBSAMP *dp, |
63 |
> |
AMBSAMP *dp, |
64 |
|
AMBHEMI *h, |
65 |
|
RAY *r |
66 |
|
) |
71 |
|
double xd, yd, zd; |
72 |
|
double b2; |
73 |
|
double phi; |
74 |
< |
register int i; |
74 |
> |
int i; |
75 |
|
/* ambient coefficient for weight */ |
76 |
|
if (ambacc > FTINY) |
77 |
|
setcolor(ar.rcoef, AVGREFL, AVGREFL, AVGREFL); |
141 |
|
{ |
142 |
|
const AMBSAMP *d1 = (const AMBSAMP *)p1; |
143 |
|
const AMBSAMP *d2 = (const AMBSAMP *)p2; |
144 |
< |
register int c; |
144 |
> |
int c; |
145 |
|
|
146 |
|
if ( (c = d1->t - d2->t) ) |
147 |
|
return(c); |
151 |
|
|
152 |
|
double |
153 |
|
doambient( /* compute ambient component */ |
154 |
< |
COLOR acol, |
154 |
> |
COLOR rcol, |
155 |
|
RAY *r, |
156 |
|
double wt, |
157 |
|
FVECT pg, |
158 |
|
FVECT dg |
159 |
|
) |
160 |
|
{ |
161 |
< |
double b, d; |
161 |
> |
double b, d=0; |
162 |
|
AMBHEMI hemi; |
163 |
|
AMBSAMP *div; |
164 |
|
AMBSAMP dnew; |
165 |
< |
register AMBSAMP *dp; |
165 |
> |
double acol[3]; |
166 |
> |
AMBSAMP *dp; |
167 |
|
double arad; |
168 |
|
int divcnt; |
169 |
< |
register int i, j; |
169 |
> |
int i, j; |
170 |
|
/* initialize hemisphere */ |
171 |
< |
inithemi(&hemi, acol, r, wt); |
171 |
> |
inithemi(&hemi, rcol, r, wt); |
172 |
|
divcnt = hemi.nt * hemi.np; |
173 |
|
/* initialize */ |
174 |
|
if (pg != NULL) |
175 |
|
pg[0] = pg[1] = pg[2] = 0.0; |
176 |
|
if (dg != NULL) |
177 |
|
dg[0] = dg[1] = dg[2] = 0.0; |
178 |
< |
setcolor(acol, 0.0, 0.0, 0.0); |
178 |
> |
setcolor(rcol, 0.0, 0.0, 0.0); |
179 |
|
if (divcnt == 0) |
180 |
|
return(0.0); |
181 |
|
/* allocate super-samples */ |
187 |
|
div = NULL; |
188 |
|
/* sample the divisions */ |
189 |
|
arad = 0.0; |
190 |
+ |
acol[0] = acol[1] = acol[2] = 0.0; |
191 |
|
if ((dp = div) == NULL) |
192 |
|
dp = &dnew; |
193 |
|
divcnt = 0; |
269 |
|
} |
270 |
|
free((void *)div); |
271 |
|
} |
272 |
+ |
copycolor(rcol, acol); |
273 |
|
if (arad <= FTINY) |
274 |
|
arad = maxarad; |
275 |
|
else |
296 |
|
void |
297 |
|
comperrs( /* compute initial error estimates */ |
298 |
|
AMBSAMP *da, /* assumes standard ordering */ |
299 |
< |
register AMBHEMI *hp |
299 |
> |
AMBHEMI *hp |
300 |
|
) |
301 |
|
{ |
302 |
|
double b, b2; |
303 |
|
int i, j; |
304 |
< |
register AMBSAMP *dp; |
304 |
> |
AMBSAMP *dp; |
305 |
|
/* sum differences from neighbors */ |
306 |
|
dp = da; |
307 |
|
for (i = 0; i < hp->nt; i++) |
349 |
|
posgradient( /* compute position gradient */ |
350 |
|
FVECT gv, |
351 |
|
AMBSAMP *da, /* assumes standard ordering */ |
352 |
< |
register AMBHEMI *hp |
352 |
> |
AMBHEMI *hp |
353 |
|
) |
354 |
|
{ |
355 |
< |
register int i, j; |
355 |
> |
int i, j; |
356 |
|
double nextsine, lastsine, b, d; |
357 |
|
double mag0, mag1; |
358 |
|
double phi, cosp, sinp, xd, yd; |
359 |
< |
register AMBSAMP *dp; |
359 |
> |
AMBSAMP *dp; |
360 |
|
|
361 |
|
xd = yd = 0.0; |
362 |
|
for (j = 0; j < hp->np; j++) { |
407 |
|
dirgradient( /* compute direction gradient */ |
408 |
|
FVECT gv, |
409 |
|
AMBSAMP *da, /* assumes standard ordering */ |
410 |
< |
register AMBHEMI *hp |
410 |
> |
AMBHEMI *hp |
411 |
|
) |
412 |
|
{ |
413 |
< |
register int i, j; |
413 |
> |
int i, j; |
414 |
|
double mag; |
415 |
|
double phi, xd, yd; |
416 |
< |
register AMBSAMP *dp; |
416 |
> |
AMBSAMP *dp; |
417 |
|
|
418 |
|
xd = yd = 0.0; |
419 |
|
for (j = 0; j < hp->np; j++) { |
436 |
|
for (i = 0; i < 3; i++) |
437 |
|
gv[i] = xd*hp->ux[i] + yd*hp->uy[i]; |
438 |
|
} |
439 |
+ |
|
440 |
+ |
#endif /* ! NEWAMB */ |