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