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