ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rv3.c
(Generate patch)

Comparing ray/src/rt/rv3.c (file contents):
Revision 2.29 by greg, Tue Sep 16 18:35:56 2008 UTC vs.
Revision 2.38 by greg, Thu Sep 6 00:07:43 2012 UTC

# Line 29 | Line 29 | static const char      RCSid[] = "$Id$";
29   #define  sscanvec(s,v)  (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3)
30   #endif
31  
32 < static unsigned long  niflush;          /* flushes since newimage() */
32 > extern int      ray_pnprocs;
33  
34 + static RNUMBER  niflush;                /* flushes since newimage() */
35 +
36   int
37   getrect(                                /* get a box */
38          char  *s,
# Line 192 | Line 194 | paint(                 /* compute and paint a rectangle */
194          if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview,
195                          h/hresolu, v/vresolu)) < -FTINY) {
196                  setcolor(thisray.rcol, 0.0, 0.0, 0.0);
197 <        } else if (nproc == 1) {                /* immediate mode */
197 >        } else if (!ray_pnprocs) {              /* immediate mode */
198                  ray_trace(&thisray);
199          } else {                                /* queuing mode */
200                  int     rval;
201                  rayorigin(&thisray, PRIMARY, NULL, NULL);
202 <                thisray.rno = (unsigned long)p;
202 >                thisray.rno = (RNUMBER)p;
203                  rval = ray_pqueue(&thisray);
204                  if (!rval)
205                          return(0);
206                  if (rval < 0)
207                          return(-1);
208 +                                                /* get node for returned ray */
209                  p = (PNODE *)thisray.rno;
210          }
211  
# Line 212 | Line 215 | paint(                 /* compute and paint a rectangle */
215          recolor(p);                             /* paint it */
216  
217          if (dev->flush != NULL) {               /* shall we check for input? */
218 <                static unsigned long    lastflush = 0;
219 <                unsigned long           counter = raynum;
220 <                int                     flushintvl;
221 <                if (nproc == 1) {
218 >                static RNUMBER  lastflush = 0;
219 >                RNUMBER         counter = raynum;
220 >                int             flushintvl;
221 >                if (!ray_pnprocs) {
222                          counter = nrays;
223                          flushintvl = WFLUSH1;
224                  } else if (ambounce == 0)
225 <                        flushintvl = nproc*WFLUSH;
225 >                        flushintvl = ray_pnprocs*WFLUSH;
226                  else if (niflush < WFLUSH)
227 <                        flushintvl = nproc*niflush/(ambounce+1);
227 >                        flushintvl = ray_pnprocs*niflush/(ambounce+1);
228                  else
229 <                        flushintvl = nproc*WFLUSH/(ambounce+1);
229 >                        flushintvl = ray_pnprocs*WFLUSH/(ambounce+1);
230 >                if (lastflush > counter)
231 >                        lastflush = 0;          /* counter wrapped */
232  
233                  if (counter - lastflush >= flushintvl) {
234                          lastflush = counter;
# Line 242 | Line 247 | waitrays(void)                                 /* finish up pending rays */
247          int     rval;
248          RAY     raydone;
249  
250 <        if (nproc == 1)                         /* immediate mode? */
250 >        if (!ray_pnprocs)                       /* immediate mode? */
251                  return(0);
252          while ((rval = ray_presult(&raydone, 0)) > 0) {
253                  PNODE  *p = (PNODE *)raydone.rno;
# Line 262 | Line 267 | newimage(                                      /* start a new image */
267          char *s
268   )
269   {
270 <        extern int      ray_pnprocs;
271 <        int             newnp;
272 <                                                /* change in nproc? */
273 <        if (s != NULL && sscanf(s, "%d", &newnp) == 1 && newnp > 0) {
269 <                if (!newparam) {
270 <                        if (nproc == 1)
271 <                                nproc = 0;      /* actually running */
272 <                        if (newnp == 1)
273 <                                ray_pclose(0);
274 <                        else if (newnp < nproc)
275 <                                ray_pclose(nproc - newnp);
276 <                        else
277 <                                ray_popen(newnp - nproc);
278 <                }
279 <                nproc = newnp;
280 <        }
270 >        int             newnp = 0;
271 >                                                /* # rendering procs arg? */
272 >        if (s != NULL)
273 >                sscanf(s, "%d", &newnp);
274                                                  /* free old image */
275          freepkids(&ptrunk);
276                                                  /* compute resolution */
# Line 292 | Line 285 | newimage(                                      /* start a new image */
285          (*dev->clear)(hresolu, vresolu);
286  
287          if (newparam) {                         /* (re)start rendering procs */
288 <                if (ray_pnprocs > 0)
289 <                        ray_pclose(0);
288 >                if (ray_pnprocs)
289 >                        ray_pclose(0);          /* should already be closed */
290 >                if (newnp > 0)
291 >                        nproc = newnp;
292                  if (nproc > 1)
293                          ray_popen(nproc);
294                  newparam = 0;
295 +        } else if ((newnp > 0) & (newnp != nproc)) {
296 +                if (newnp == 1)                 /* change # rendering procs */
297 +                        ray_pclose(0);
298 +                else if (newnp < ray_pnprocs)
299 +                        ray_pclose(ray_pnprocs - newnp);
300 +                else
301 +                        ray_popen(newnp - ray_pnprocs);
302 +                nproc = newnp;
303          }
304          niflush = 0;                            /* get first value */
305          paint(&ptrunk);
# Line 514 | Line 517 | moveview(                                      /* move viewpoint */
517   )
518   {
519          double  d;
517        FVECT  v1;
520          VIEW  nv = ourview;
521          int  i;
522  
523          spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
524 <        if (elev != 0.0) {
525 <                fcross(v1, ourview.vup, nv.vdir);
526 <                normalize(v1);
525 <                spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
526 <        }
524 >        if (elev != 0.0)
525 >                geodesic(nv.vdir, nv.vdir, nv.vup, elev*(-PI/180.), GEOD_RAD);
526 >
527          if (nv.type == VT_PAR) {
528                  nv.horiz /= mag;
529                  nv.vert /= mag;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines