| 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" |
| 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 |
|
|
| 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; |
| 229 |
– |
/* shadow ray not on source? */ |
| 230 |
– |
if (r->rsrc >= 0 && source[r->rsrc].so != r->ro) |
| 231 |
– |
return; |
| 237 |
|
|
| 238 |
< |
worldfunc(RCCONTEXT, r); /* else 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); /* compute coefficient */ |
| 334 |
|
lastray = lastdone = 0; |
| 335 |
|
++lastray; |
| 336 |
|
if (d == 0.0) { /* zero ==> flush */ |
| 337 |
< |
if ((yres <= 0) | (xres <= 0)) |
| 337 |
> |
if ((yres <= 0) | (xres <= 1)) |
| 338 |
|
waitflush = 1; /* flush after */ |
| 339 |
|
if (nchild == -1) |
| 340 |
|
account = 1; |