| 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 |
+ |
} |
| 191 |
+ |
sprintf(errmsg, "%.2f%% done after %.3f hours\n", |
| 192 |
+ |
100.-100.*raysleft/total_rays, |
| 193 |
+ |
(1./3600.)*(tnow - tstart)); |
| 194 |
+ |
eputs(errmsg); |
| 195 |
+ |
last_report = tnow; |
| 196 |
+ |
} |
| 197 |
+ |
return(--raysleft); |
| 198 |
+ |
} |
| 199 |
+ |
|
| 200 |
+ |
|
| 201 |
+ |
/* Quit program */ |
| 202 |
|
void |
| 203 |
< |
quit( /* quit program */ |
| 203 |
> |
quit( |
| 204 |
|
int code |
| 205 |
|
) |
| 206 |
|
{ |
| 207 |
|
if (nchild > 0) /* close children if any */ |
| 208 |
|
end_children(code != 0); |
| 209 |
+ |
else if (nchild < 0) |
| 210 |
+ |
_exit(code); /* avoid flush() in child */ |
| 211 |
|
exit(code); |
| 212 |
|
} |
| 213 |
|
|
| 310 |
|
thisray.rmax = 0.0; |
| 311 |
|
rayorigin(&thisray, PRIMARY, NULL, NULL); |
| 312 |
|
/* pretend we hit surface */ |
| 313 |
< |
thisray.rt = thisray.rot = 1e-5; |
| 313 |
> |
thisray.rxt = thisray.rot = 1e-5; |
| 314 |
|
thisray.rod = 1.0; |
| 315 |
|
VCOPY(thisray.ron, dir); |
| 316 |
|
VSUM(thisray.rop, org, dir, 1e-4); |
| 391 |
|
} |
| 392 |
|
done_contrib(); /* accumulate/output */ |
| 393 |
|
++lastdone; |
| 394 |
< |
if (raysleft && !--raysleft) |
| 394 |
> |
if (!morays()) |
| 395 |
|
break; /* preemptive EOI */ |
| 396 |
|
} |
| 397 |
|
if (nchild != -1 && (accumulate <= 0) | (account < accumulate)) { |