--- ray/src/rt/rv3.c 2008/08/21 07:05:59 2.22 +++ ray/src/rt/rv3.c 2008/08/29 05:46:03 2.26 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rv3.c,v 2.22 2008/08/21 07:05:59 greg Exp $"; +static const char RCSid[] = "$Id: rv3.c,v 2.26 2008/08/29 05:46:03 greg Exp $"; #endif /* * rv3.c - miscellaneous routines for rview. @@ -25,6 +25,7 @@ static const char RCSid[] = "$Id: rv3.c,v 2.22 2008/08 #define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) #endif +static unsigned long niflush; /* flushes since newimage() */ int getrect( /* get a box */ @@ -145,7 +146,27 @@ greyof( /* convert color to greyscale */ return(gcol); } +static void +recolor( /* recolor the given node */ + PNODE *p +) +{ + while (p->kid != NULL) { /* need to propogate down */ + int mx = (p->xmin + p->xmax) >> 1; + int my = (p->ymin + p->ymax) >> 1; + int ki; + if (p->x >= mx) + ki = (p->y >= my) ? UR : DR; + else + ki = (p->y >= my) ? UL : DL; + pcopy(p, p->kid+ki); + p = p->kid + ki; + } + (*dev->paintr)(greyscale?greyof(p->v):p->v, + p->xmin, p->ymin, p->xmax, p->ymax); +} + int paint( /* compute and paint a rectangle */ PNODE *p @@ -154,6 +175,7 @@ paint( /* compute and paint a rectangle */ extern int ray_pnprocs; static unsigned long lastflush = 0; static RAY thisray; + int flushintvl; double h, v; if (p->xmax - p->xmin <= 0 || p->ymax - p->ymin <= 0) { /* empty */ @@ -184,18 +206,26 @@ paint( /* compute and paint a rectangle */ copycolor(p->v, thisray.rcol); scalecolor(p->v, exposure); - (*dev->paintr)(greyscale?greyof(p->v):p->v, p->xmin, p->ymin, p->xmax, p->ymax); + recolor(p); /* paint it */ - if (dev->flush != NULL && raynum - lastflush >= WFLUSH*ray_pnprocs) { + if (ambounce <= 0) /* shall we check for input? */ + flushintvl = ray_pnprocs*WFLUSH; + else if (niflush < WFLUSH) + flushintvl = ray_pnprocs*niflush/(ambounce+1); + else + flushintvl = ray_pnprocs*WFLUSH/(ambounce+1); + + if (dev->flush != NULL && raynum - lastflush >= flushintvl) { lastflush = raynum; (*dev->flush)(); + niflush++; } return(1); } int -waitrays(void) /* finish up pending rays */ +waitrays(void) /* finish up pending rays */ { int nwaited = 0; int rval; @@ -205,8 +235,7 @@ waitrays(void) /* finish up pending rays */ PNODE *p = (PNODE *)raydone.rno; copycolor(p->v, raydone.rcol); scalecolor(p->v, exposure); - (*dev->paintr)(greyscale?greyof(p->v):p->v, - p->xmin, p->ymin, p->xmax, p->ymax); + recolor(p); nwaited++; } if (rval < 0) @@ -249,7 +278,7 @@ newimage( /* start a new image */ ray_popen(nproc); newparam = 0; } - /* get first value */ + niflush = 0; /* get first value */ paint(&ptrunk); }