--- ray/src/hd/rholo2.c 1997/12/12 18:23:09 3.5 +++ ray/src/hd/rholo2.c 1997/12/18 09:33:35 3.10 @@ -34,8 +34,10 @@ register PACKET *p; p->ra[i].r[1][0] = sl[2] * 256.; p->ra[i].r[1][1] = sl[3] * 256.; d = hdray(ro, rd, hdlist[p->hd], gc, p->ra[i].r); + if (!vdef(OBSTRUCTIONS)) + d *= frandom(); /* random offset */ if (p->offset != NULL) { - VSUM(ro, ro, rd, d); /* exterior only */ + VSUM(ro, ro, rd, d); /* advance ray */ p->offset[i] = d; } VCOPY(rod, ro); @@ -72,15 +74,17 @@ done_rtrace() /* clean up and close rtrace calculati /* already closed? */ if (!nprocs) return; - /* report activity */ - wputs("closing rtrace process...\n"); /* flush beam queue */ done_packets(flush_queue()); + /* sync holodeck */ + hdsync(NULL, 1); /* close rtrace */ if ((status = end_rtrace())) error(WARNING, "bad exit status from rtrace"); - if (vdef(REPORT)) /* report time */ + if (vdef(REPORT)) { /* report time */ + eputs("rtrace process closed\n"); report(0); + } return(status); /* return status */ } @@ -91,7 +95,10 @@ new_rtrace() /* restart rtrace calculation */ if (nprocs > 0) /* already running? */ return; - wputs("restarting rtrace process...\n"); + starttime = time(NULL); /* reset start time and counts */ + npacksdone = nraysdone = 0L; + if (vdef(TIME)) /* reset end time */ + endtime = starttime + vflt(TIME)*3600. + .5; if (vdef(RIF)) { /* rerun rad to update octree */ sprintf(combuf, "rad -v 0 -s -w %s", vval(RIF)); if (system(combuf)) @@ -99,8 +106,10 @@ new_rtrace() /* restart rtrace calculation */ } if (start_rtrace() < 1) /* start rtrace */ error(WARNING, "cannot restart rtrace"); - else if (vdef(REPORT)) + else if (vdef(REPORT)) { + eputs("rtrace process restarted\n"); report(0); + } } @@ -141,7 +150,7 @@ getradfile() /* run rad and get needed variables */ if (system(combuf)) { unlink(tf2); /* clean up */ unlink(tf1); - error(SYSTEM, "cannot execute rad command"); + error(USER, "error executing rad command"); } if (pippt == NULL) { loadvars(tf2); /* load variables */ @@ -149,4 +158,21 @@ getradfile() /* run rad and get needed variables */ } rtargc += wordfile(rtargv+rtargc, tf1); /* get rtrace options */ unlink(tf1); /* clean up */ +} + + +report(t) /* report progress so far */ +time_t t; +{ + static time_t seconds2go = 1000000; + + if (t == 0L) + t = time(NULL); + sprintf(errmsg, "%ld packets (%ld rays) done after %.2f hours\n", + npacksdone, nraysdone, (t-starttime)/3600.); + eputs(errmsg); + if (seconds2go == 1000000) + seconds2go = vdef(REPORT) ? (long)(vflt(REPORT)*60. + .5) : 0L; + if (seconds2go) + reporttime = t + seconds2go; }