6 |
|
* Initialization and calculation routines |
7 |
|
*/ |
8 |
|
|
9 |
+ |
#include "copyright.h" |
10 |
+ |
|
11 |
|
#include "rcontrib.h" |
12 |
|
#include "otypes.h" |
13 |
+ |
#include "source.h" |
14 |
|
|
15 |
|
char *shm_boundary = NULL; /* boundary of shared memory */ |
16 |
|
|
90 |
|
|
91 |
|
/* Add modifier to our list to track */ |
92 |
|
MODCONT * |
93 |
< |
addmodifier(char *modn, char *outf, char *binv, int bincnt) |
93 |
> |
addmodifier(char *modn, char *outf, char *prms, char *binv, int bincnt) |
94 |
|
{ |
95 |
|
LUENT *lep = lu_find(&modconttab,modn); |
96 |
|
MODCONT *mp; |
103 |
|
} |
104 |
|
if (nmods >= MAXMODLIST) |
105 |
|
error(INTERNAL, "too many modifiers"); |
106 |
+ |
if (!strcmp(modn, VOIDID)) { |
107 |
+ |
sprintf(errmsg, "cannot track '%s' modifier", VOIDID); |
108 |
+ |
error(USER, errmsg); |
109 |
+ |
} |
110 |
|
modname[nmods++] = modn; /* XXX assumes static string */ |
111 |
|
lep->key = modn; /* XXX assumes static string */ |
112 |
|
if (binv == NULL) |
131 |
|
error(SYSTEM, "out of memory in addmodifier"); |
132 |
|
mp->outspec = outf; /* XXX assumes static string */ |
133 |
|
mp->modname = modn; /* XXX assumes static string */ |
134 |
+ |
mp->params = prms; |
135 |
|
mp->binv = ebinv; |
136 |
|
mp->nbins = bincnt; |
137 |
|
memset(mp->cbin, 0, sizeof(DCOLOR)*bincnt); |
145 |
|
|
146 |
|
/* Add modifiers from a file list */ |
147 |
|
void |
148 |
< |
addmodfile(char *fname, char *outf, char *binv, int bincnt) |
148 |
> |
addmodfile(char *fname, char *outf, char *prms, char *binv, int bincnt) |
149 |
|
{ |
150 |
|
char *mname[MAXMODLIST]; |
151 |
|
int i; |
155 |
|
error(SYSTEM, errmsg); |
156 |
|
} |
157 |
|
for (i = 0; mname[i]; i++) /* add each one */ |
158 |
< |
addmodifier(mname[i], outf, binv, bincnt); |
158 |
> |
addmodifier(mname[i], outf, prms, binv, bincnt); |
159 |
|
} |
160 |
|
|
161 |
|
|
184 |
|
/* set shared memory boundary */ |
185 |
|
shm_boundary = strcpy((char *)malloc(16), "SHM_BOUNDARY"); |
186 |
|
} |
187 |
+ |
for (i = 0; i < nsources; i++) /* tracing to sources as well */ |
188 |
+ |
source[i].sflags |= SFOLLOW; |
189 |
|
if (yres > 0) { /* set up flushing & ray counts */ |
190 |
|
if (xres > 0) |
191 |
|
raysleft = (RNUMBER)xres*yres; |
223 |
|
trace_contrib(RAY *r) |
224 |
|
{ |
225 |
|
MODCONT *mp; |
226 |
+ |
double bval; |
227 |
|
int bn; |
228 |
|
RREAL contr[3]; |
229 |
|
|
230 |
|
if (r->ro == NULL || r->ro->omod == OVOID) |
231 |
|
return; |
232 |
+ |
/* shadow ray not on source? */ |
233 |
+ |
if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) |
234 |
+ |
return; |
235 |
|
|
236 |
|
mp = (MODCONT *)lu_find(&modconttab,objptr(r->ro->omod)->oname)->data; |
237 |
|
|
238 |
|
if (mp == NULL) /* not in our list? */ |
239 |
|
return; |
240 |
|
|
241 |
< |
worldfunc(RCCONTEXT, r); /* get bin number */ |
242 |
< |
bn = (int)(evalue(mp->binv) + .5); |
243 |
< |
if ((bn < 0) | (bn >= mp->nbins)) { |
244 |
< |
error(WARNING, "bad bin number (ignored)"); |
241 |
> |
worldfunc(RCCONTEXT, r); /* else set context */ |
242 |
> |
set_eparams((char *)mp->params); |
243 |
> |
if ((bval = evalue(mp->binv)) <= -.5) /* and get bin number */ |
244 |
> |
return; /* silently ignore negatives */ |
245 |
> |
if ((bn = (int)(bval + .5)) >= mp->nbins) { |
246 |
> |
sprintf(errmsg, "bad bin number (%d ignored)", bn); |
247 |
> |
error(WARNING, errmsg); |
248 |
|
return; |
249 |
|
} |
250 |
< |
raycontrib(contr, r, PRIMARY); |
250 |
> |
raycontrib(contr, r, PRIMARY); /* compute coefficient */ |
251 |
|
if (contrib) |
252 |
< |
multcolor(contr, r->rcol); |
252 |
> |
multcolor(contr, r->rcol); /* -> contribution */ |
253 |
|
addcolor(mp->cbin[bn], contr); |
254 |
|
} |
255 |
|
|
266 |
|
thisray.rdir[2] = -dir[2]; |
267 |
|
thisray.rmax = 0.0; |
268 |
|
rayorigin(&thisray, PRIMARY, NULL, NULL); |
269 |
< |
thisray.rot = 1e-5; /* pretend we hit surface */ |
269 |
> |
/* pretend we hit surface */ |
270 |
> |
thisray.rt = thisray.rot = 1e-5; |
271 |
|
thisray.rod = 1.0; |
272 |
+ |
VCOPY(thisray.ron, dir); |
273 |
|
VSUM(thisray.rop, org, dir, 1e-4); |
274 |
|
samplendx++; /* compute result */ |
275 |
|
(*ofun[Lamb.otype].funp)(&Lamb, &thisray); |
327 |
|
#endif |
328 |
|
while (getvec(orig) == 0 && getvec(direc) == 0) { |
329 |
|
d = normalize(direc); |
330 |
< |
if (nchild != -1 && (d == 0.0) & (accumulate != 1)) { |
330 |
> |
if (nchild != -1 && (d == 0.0) & (accumulate == 0)) { |
331 |
|
if (!ignore_warning_given++) |
332 |
|
error(WARNING, |
333 |
|
"dummy ray(s) ignored during accumulation\n"); |
337 |
|
lastray = lastdone = 0; |
338 |
|
++lastray; |
339 |
|
if (d == 0.0) { /* zero ==> flush */ |
340 |
< |
if ((yres <= 0) | (xres <= 0)) |
341 |
< |
waitflush = 1; /* flush right after */ |
342 |
< |
account = 1; |
340 |
> |
if ((yres <= 0) | (xres <= 1)) |
341 |
> |
waitflush = 1; /* flush after */ |
342 |
> |
if (nchild == -1) |
343 |
> |
account = 1; |
344 |
|
} else if (imm_irrad) { /* else compute */ |
345 |
|
eval_irrad(orig, direc); |
346 |
|
} else { |