172 |
|
} |
173 |
|
|
174 |
|
|
175 |
+ |
/* Check if we have any more rays left (and report progress) */ |
176 |
+ |
int |
177 |
+ |
morays(void) |
178 |
+ |
{ |
179 |
+ |
static RNUMBER total_rays; |
180 |
+ |
static time_t tstart, last_report; |
181 |
+ |
time_t tnow; |
182 |
+ |
|
183 |
+ |
if (!raysleft) |
184 |
+ |
return(1); /* unknown total, so nothing to do or say */ |
185 |
+ |
|
186 |
+ |
if (report_intvl > 0 && (tnow = time(0)) >= last_report+report_intvl) { |
187 |
+ |
if (!total_rays) { |
188 |
+ |
total_rays = raysleft; |
189 |
+ |
tstart = tnow; |
190 |
+ |
} else { |
191 |
+ |
sprintf(errmsg, "%.2f%% done after %.3f hours\n", |
192 |
+ |
100.-100.*raysleft/total_rays, |
193 |
+ |
(1./3600.)*(tnow - tstart)); |
194 |
+ |
eputs(errmsg); |
195 |
+ |
} |
196 |
+ |
last_report = tnow; |
197 |
+ |
} |
198 |
+ |
return(--raysleft); |
199 |
+ |
} |
200 |
+ |
|
201 |
+ |
|
202 |
+ |
/* Quit program */ |
203 |
|
void |
204 |
< |
quit( /* quit program */ |
204 |
> |
quit( |
205 |
|
int code |
206 |
|
) |
207 |
|
{ |
208 |
|
if (nchild > 0) /* close children if any */ |
209 |
|
end_children(code != 0); |
210 |
+ |
else if (nchild < 0) |
211 |
+ |
_exit(code); /* avoid flush() in child */ |
212 |
|
exit(code); |
213 |
|
} |
214 |
|
|
311 |
|
thisray.rmax = 0.0; |
312 |
|
rayorigin(&thisray, PRIMARY, NULL, NULL); |
313 |
|
/* pretend we hit surface */ |
314 |
< |
thisray.rxt = thisray.rmt = thisray.rot = 1e-5; |
314 |
> |
thisray.rxt = thisray.rot = 1e-5; |
315 |
|
thisray.rod = 1.0; |
316 |
|
VCOPY(thisray.ron, dir); |
317 |
|
VSUM(thisray.rop, org, dir, 1e-4); |
392 |
|
} |
393 |
|
done_contrib(); /* accumulate/output */ |
394 |
|
++lastdone; |
395 |
< |
if (raysleft && !--raysleft) |
395 |
> |
if (!morays()) |
396 |
|
break; /* preemptive EOI */ |
397 |
|
} |
398 |
|
if (nchild != -1 && (accumulate <= 0) | (account < accumulate)) { |