--- ray/src/rt/rv3.c 1990/01/19 00:00:31 1.12 +++ ray/src/rt/rv3.c 1990/06/26 09:00:19 1.16 @@ -18,7 +18,11 @@ static char SCCSid[] = "$SunId$ LBL"; #include "random.h" +#ifndef WFLUSH +#define WFLUSH 30 /* flush after this many rays */ +#endif + getrect(s, r) /* get a box */ char *s; register RECT *r; @@ -130,9 +134,10 @@ paint(p, xmin, ymin, xmax, ymax) /* compute and paint register PNODE *p; int xmin, ymin, xmax, ymax; { + extern long nrays; + static long lastflush = 0; static RAY thisray; double h, v; - register int i; if (xmax - xmin <= 0 || ymax - ymin <= 0) { /* empty */ p->x = xmin; @@ -141,22 +146,24 @@ int xmin, ymin, xmax, ymax; return; } /* jitter ray direction */ - p->x = h = xmin + (xmax-xmin)*frandom(); - h /= hresolu; - p->y = v = ymin + (ymax-ymin)*frandom(); - v /= vresolu; + h = xmin + (xmax-xmin)*frandom(); + v = ymin + (ymax-ymin)*frandom(); - viewray(thisray.rorg, thisray.rdir, &ourview, h, v); - + viewray(thisray.rorg, thisray.rdir, &ourview, h/hresolu, v/vresolu); rayorigin(&thisray, NULL, PRIMARY, 1.0); - rayvalue(&thisray); + p->x = h; + p->y = v; copycolor(p->v, thisray.rcol); - scalecolor(p->v, exposure); (*dev->paintr)(greyscale?greyof(p->v):p->v, xmin, ymin, xmax, ymax); + + if (dev->flush != NULL && nrays - lastflush >= WFLUSH) { + lastflush = nrays; + (*dev->flush)(); + } } @@ -349,7 +356,7 @@ register VIEW *vp; } else if (bcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) { copystruct(&oldview, &ourview); copystruct(&ourview, vp); - newimage(); /* newimage() calls with vp=&ourview! */ + newimage(); } }