--- ray/src/rt/rv3.c 2008/09/16 18:35:56 2.29 +++ ray/src/rt/rv3.c 2010/10/08 20:41:04 2.33 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rv3.c,v 2.29 2008/09/16 18:35:56 greg Exp $"; +static const char RCSid[] = "$Id: rv3.c,v 2.33 2010/10/08 20:41:04 greg Exp $"; #endif /* * rv3.c - miscellaneous routines for rview. @@ -29,7 +29,7 @@ static const char RCSid[] = "$Id: rv3.c,v 2.29 2008/09 #define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) #endif -static unsigned long niflush; /* flushes since newimage() */ +static RNUMBER niflush; /* flushes since newimage() */ int getrect( /* get a box */ @@ -197,12 +197,15 @@ paint( /* compute and paint a rectangle */ } else { /* queuing mode */ int rval; rayorigin(&thisray, PRIMARY, NULL, NULL); - thisray.rno = (unsigned long)p; + thisray.rno = (RNUMBER)p; rval = ray_pqueue(&thisray); if (!rval) return(0); if (rval < 0) return(-1); + /* random color place holder */ + setcolor(p->v, frandom(), frandom(), frandom()); + /* get node for returned ray */ p = (PNODE *)thisray.rno; } @@ -212,9 +215,9 @@ paint( /* compute and paint a rectangle */ recolor(p); /* paint it */ if (dev->flush != NULL) { /* shall we check for input? */ - static unsigned long lastflush = 0; - unsigned long counter = raynum; - int flushintvl; + static RNUMBER lastflush = 0; + RNUMBER counter = raynum; + int flushintvl; if (nproc == 1) { counter = nrays; flushintvl = WFLUSH1; @@ -224,6 +227,8 @@ paint( /* compute and paint a rectangle */ flushintvl = nproc*niflush/(ambounce+1); else flushintvl = nproc*WFLUSH/(ambounce+1); + if (lastflush > counter) + lastflush = 0; /* counter wrapped */ if (counter - lastflush >= flushintvl) { lastflush = counter; @@ -242,7 +247,7 @@ waitrays(void) /* finish up pending rays */ int rval; RAY raydone; - if (nproc == 1) /* immediate mode? */ + if (nproc <= 1) /* immediate mode? */ return(0); while ((rval = ray_presult(&raydone, 0)) > 0) { PNODE *p = (PNODE *)raydone.rno; @@ -265,16 +270,15 @@ newimage( /* start a new image */ extern int ray_pnprocs; int newnp; /* change in nproc? */ - if (s != NULL && sscanf(s, "%d", &newnp) == 1 && newnp > 0) { + if (s != NULL && sscanf(s, "%d", &newnp) == 1 && + (newnp > 0) & (newnp != nproc)) { if (!newparam) { - if (nproc == 1) - nproc = 0; /* actually running */ if (newnp == 1) ray_pclose(0); - else if (newnp < nproc) - ray_pclose(nproc - newnp); + else if (newnp < ray_pnprocs) + ray_pclose(ray_pnprocs - newnp); else - ray_popen(newnp - nproc); + ray_popen(newnp - ray_pnprocs); } nproc = newnp; }