--- ray/src/rt/rpict.c 1990/10/13 21:32:25 1.22 +++ ray/src/rt/rpict.c 1991/06/25 14:06:12 1.29 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -24,6 +24,10 @@ static char SCCSid[] = "$SunId$ LBL"; #include "random.h" +int dimlist[MAXDIM]; /* sampling dimensions */ +int ndims = 0; /* number of sampling dimensions */ +int samplendx; /* sample index number */ + VIEW ourview = STDVIEW; /* view parameters */ int hresolu = 512; /* horizontal resolution */ int vresolu = 512; /* vertical resolution */ @@ -36,6 +40,8 @@ double dstrpix = 0.67; /* square pixel distribution double dstrsrc = 0.0; /* square source distribution */ double shadthresh = .05; /* shadow threshold */ double shadcert = .5; /* shadow certainty */ +int directrelay = 0; /* number of source relays */ +int vspretest = 512; /* virtual source pretest density */ int maxdepth = 6; /* maximum recursion depth */ double minweight = 5e-3; /* minimum ray weight */ @@ -53,9 +59,14 @@ int ralrm = 0; /* seconds between reports */ double pctdone = 0.0; /* percentage done */ +long tlastrept = 0L; /* time at last report */ + +extern long time(); +extern long tstart; /* starting time */ + extern long nrays; /* number of rays traced */ -#define MAXDIV 32 /* maximum sample size */ +#define MAXDIV 15 /* maximum sample size */ #define pixjitter() (.5+dstrpix*(.5-frandom())) @@ -72,9 +83,9 @@ int code; } +#ifdef BSD report() /* report progress */ { -#ifdef BSD struct rusage rubuf; double t; @@ -87,15 +98,19 @@ report() /* report progress */ sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n", nrays, pctdone, t/3600.0); + eputs(errmsg); + tlastrept = time((long *)0); +} #else +report() /* report progress */ +{ signal(SIGALRM, report); - sprintf(errmsg, "%ld rays, %4.2f%% done\n", nrays, pctdone); -#endif + tlastrept = time((long *)0); + sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n", + nrays, pctdone, (tlastrept-tstart)/3600.0); eputs(errmsg); - - if (ralrm > 0) - alarm(ralrm); } +#endif render(zfile, oldfile) /* render the scene */ @@ -113,8 +128,12 @@ char *zfile, *oldfile; /* check sampling */ if (psample < 1) psample = 1; - else if (psample > MAXDIV) + else if (psample > MAXDIV) { + sprintf(errmsg, "pixel sampling reduced from %d to %d", + psample, MAXDIV); + error(WARNING, errmsg); psample = MAXDIV; + } /* allocate scanlines */ for (i = 0; i <= psample; i++) { scanbar[i] = (COLOR *)malloc(hresolu*sizeof(COLOR)); @@ -141,15 +160,17 @@ char *zfile, *oldfile; fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout); /* recover file and compute first */ i = salvage(oldfile); - if (zfd != -1 && lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1) + if (zfd != -1 && i > 0 && + lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1) error(SYSTEM, "z file seek error in render"); + pctdone = 100.0*i/vresolu; + if (ralrm > 0) /* report init stats */ + report(); ypos = vresolu-1 - i; fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample); ystep = psample; /* compute scanlines */ for (ypos -= ystep; ypos > -ystep; ypos -= ystep) { - /* record progress */ - pctdone = 100.0*(vresolu-1-ypos-ystep)/vresolu; /* bottom adjust? */ if (ypos < 0) { ystep += ypos; @@ -176,6 +197,10 @@ char *zfile, *oldfile; } if (fflush(stdout) == EOF) goto writerr; + /* record progress */ + pctdone = 100.0*(vresolu-1-ypos)/vresolu; + if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm) + report(); } /* clean up */ if (zfd != -1) { @@ -318,7 +343,7 @@ pixvalue(col, x, y) /* compute pixel value */ COLOR col; /* returned color */ int x, y; /* pixel position */ { - static RAY thisray; /* our ray for this pixel */ + static RAY thisray; if (viewray(thisray.rorg, thisray.rdir, &ourview, (x+pixjitter())/hresolu, (y+pixjitter())/vresolu) < 0) { @@ -327,7 +352,9 @@ int x, y; /* pixel position */ } rayorigin(&thisray, NULL, PRIMARY, 1.0); - + + samplendx = 3*y + x; /* set pixel index */ + rayvalue(&thisray); /* trace ray */ copycolor(col, thisray.rcol); /* return color */