63 |
|
RNUMBER raysleft; /* number of rays left to trace */ |
64 |
|
long waitflush; /* how long until next flush */ |
65 |
|
|
66 |
< |
int lastray = 0; /* last ray number sent */ |
67 |
< |
int lastdone = 0; /* last ray output */ |
66 |
> |
RNUMBER lastray = 0; /* last ray number sent */ |
67 |
> |
RNUMBER lastdone = 0; /* last ray output */ |
68 |
|
|
69 |
|
static void mcfree(void *p) { epfree((*(MODCONT *)p).binv); free(p); } |
70 |
|
|
71 |
|
LUTAB modconttab = LU_SINIT(NULL,mcfree); /* modifier lookup table */ |
72 |
|
|
73 |
– |
static OBJECT traset[MAXTSET+1]={0}; /* trace include set */ |
74 |
– |
|
73 |
|
/************************** INITIALIZATION ROUTINES ***********************/ |
74 |
|
|
77 |
– |
void |
78 |
– |
tranotify( /* record new modifier */ |
79 |
– |
OBJECT obj |
80 |
– |
) |
81 |
– |
{ |
82 |
– |
static int hitlimit = 0; |
83 |
– |
OBJREC *o = objptr(obj); |
84 |
– |
int i; |
85 |
– |
|
86 |
– |
if (obj == OVOID) { /* starting over */ |
87 |
– |
traset[0] = 0; |
88 |
– |
hitlimit = 0; |
89 |
– |
return; |
90 |
– |
} |
91 |
– |
if (hitlimit || !ismodifier(o->otype)) |
92 |
– |
return; |
93 |
– |
for (i = nmods; i-- > 0; ) |
94 |
– |
if (!strcmp(o->oname, modname[i])) { |
95 |
– |
if (traset[0] >= MAXTSET) { |
96 |
– |
error(WARNING, "too many same-named modifiers"); |
97 |
– |
hitlimit++; |
98 |
– |
return; /* should this be fatal? */ |
99 |
– |
} |
100 |
– |
insertelem(traset, obj); |
101 |
– |
break; |
102 |
– |
} |
103 |
– |
} |
104 |
– |
|
105 |
– |
|
75 |
|
char * |
76 |
|
formstr( /* return format identifier */ |
77 |
|
int f |
181 |
|
if ((nproc > 1) & (accumulate <= 0)) |
182 |
|
put_zero_record(0); /* prime our queue to accumulate */ |
183 |
|
|
215 |
– |
if (recover) { /* recover previous output? */ |
216 |
– |
if (accumulate <= 0) { |
217 |
– |
reload_output(); |
218 |
– |
if (nproc > 1) |
219 |
– |
queue_modifiers(); |
220 |
– |
} else |
221 |
– |
recover_output(); |
222 |
– |
} |
184 |
|
if (yres > 0) { /* set up flushing & ray counts */ |
185 |
|
if (xres > 0) |
186 |
|
raysleft = (RNUMBER)xres*yres; |
195 |
|
for (i = 0; i < nsources; i++) |
196 |
|
source[i].sflags |= SFOLLOW; |
197 |
|
|
198 |
< |
if (nproc == 1 || in_rchild()) /* single process or child */ |
198 |
> |
if (nproc > 1 && in_rchild()) /* forked child? */ |
199 |
|
return; /* return to main processing loop */ |
200 |
|
|
201 |
+ |
if (recover) { /* recover previous output? */ |
202 |
+ |
if (accumulate <= 0) { |
203 |
+ |
reload_output(); |
204 |
+ |
if (nproc > 1) |
205 |
+ |
queue_modifiers(); |
206 |
+ |
} else |
207 |
+ |
recover_output(); |
208 |
+ |
} |
209 |
+ |
if (nproc == 1) /* single process? */ |
210 |
+ |
return; |
211 |
+ |
|
212 |
|
parental_loop(); /* else run controller */ |
213 |
|
quit(0); /* parent musn't return! */ |
214 |
|
} |
223 |
|
int bn; |
224 |
|
RREAL contr[3]; |
225 |
|
|
226 |
< |
if (r->ro == NULL || !inset(traset, r->ro->omod)) |
226 |
> |
if (r->ro == NULL || r->ro->omod == OVOID) |
227 |
|
return; |
228 |
|
|
229 |
|
mp = (MODCONT *)lu_find(&modconttab,objptr(r->ro->omod)->oname)->data; |
230 |
|
|
231 |
< |
if (mp == NULL) |
232 |
< |
error(CONSISTENCY, "unexpected modifier in trace_contrib()"); |
231 |
> |
if (mp == NULL) /* not in our list? */ |
232 |
> |
return; |
233 |
|
|
234 |
|
worldfunc(RCCONTEXT, r); /* get bin number */ |
235 |
|
bn = (int)(evalue(mp->binv) + .5); |
322 |
|
#endif |
323 |
|
while (getvec(orig) == 0 && getvec(direc) == 0) { |
324 |
|
d = normalize(direc); |
325 |
< |
if ((d == 0.0) & (accumulate != 1)) { |
325 |
> |
if (nchild != -1 && (d == 0.0) & (accumulate != 1)) { |
326 |
|
if (!ignore_warning_given++) |
327 |
|
error(WARNING, |
328 |
|
"dummy ray(s) ignored during accumulation\n"); |
334 |
|
if (d == 0.0) { /* zero ==> flush */ |
335 |
|
if ((yres <= 0) | (xres <= 0)) |
336 |
|
waitflush = 1; /* flush right after */ |
337 |
+ |
account = 1; |
338 |
|
} else { /* else compute */ |
339 |
|
eval_ray(orig, direc, lim_dist ? d : 0.0); |
340 |
|
} |
343 |
|
if (raysleft && !--raysleft) |
344 |
|
break; /* preemptive EOI */ |
345 |
|
} |
346 |
< |
if (accumulate <= 0 || account < accumulate) { |
346 |
> |
if (nchild != -1 && (accumulate <= 0) | (account < accumulate)) { |
347 |
|
if (account < accumulate) { |
348 |
|
error(WARNING, "partial accumulation in final record"); |
349 |
|
accumulate -= account; |