--- ray/src/rt/rv3.c 2008/12/03 06:57:48 2.31 +++ ray/src/rt/rv3.c 2012/03/20 02:56:08 2.36 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rv3.c,v 2.31 2008/12/03 06:57:48 greg Exp $"; +static const char RCSid[] = "$Id: rv3.c,v 2.36 2012/03/20 02:56:08 greg Exp $"; #endif /* * rv3.c - miscellaneous routines for rview. @@ -29,7 +29,7 @@ static const char RCSid[] = "$Id: rv3.c,v 2.31 2008/12 #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 */ @@ -192,17 +192,18 @@ paint( /* compute and paint a rectangle */ if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview, h/hresolu, v/vresolu)) < -FTINY) { setcolor(thisray.rcol, 0.0, 0.0, 0.0); - } else if (nproc == 1) { /* immediate mode */ + } else if (nproc == 1 || newparam) { /* immediate mode */ ray_trace(&thisray); } 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); + /* get node for returned ray */ p = (PNODE *)thisray.rno; } @@ -212,9 +213,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; @@ -265,20 +266,10 @@ newimage( /* start a new image */ ) { extern int ray_pnprocs; - int newnp; - /* change in nproc? */ - if (s != NULL && sscanf(s, "%d", &newnp) == 1 && - (newnp > 0) & (newnp != nproc)) { - if (!newparam) { - if (newnp == 1) - ray_pclose(0); - else if (newnp < ray_pnprocs) - ray_pclose(ray_pnprocs - newnp); - else - ray_popen(newnp - ray_pnprocs); - } - nproc = newnp; - } + int newnp = 0; + /* # rendering procs arg? */ + if (s != NULL) + sscanf(s, "%d", &newnp); /* free old image */ freepkids(&ptrunk); /* compute resolution */ @@ -295,9 +286,19 @@ newimage( /* start a new image */ if (newparam) { /* (re)start rendering procs */ if (ray_pnprocs > 0) ray_pclose(0); + if (newnp > 0) + nproc = newnp; if (nproc > 1) ray_popen(nproc); newparam = 0; + } else if ((newnp > 0) & (newnp != nproc)) { + if (newnp == 1) /* change # rendering procs */ + ray_pclose(0); + else if (newnp < ray_pnprocs) + ray_pclose(ray_pnprocs - newnp); + else + ray_popen(newnp - ray_pnprocs); + nproc = newnp; } niflush = 0; /* get first value */ paint(&ptrunk);