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 1.8 by greg, Wed Nov 1 16:12:20 1989 UTC vs.
Revision 1.16 by greg, Tue Jun 26 09:00:19 1990 UTC

# Line 18 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
18  
19   #include  "random.h"
20  
21 + #ifndef WFLUSH
22 + #define WFLUSH          30              /* flush after this many rays */
23 + #endif
24  
25 +
26   getrect(s, r)                           /* get a box */
27   char  *s;
28   register RECT  *r;
# Line 27 | Line 31 | register RECT  *r;
31  
32          if (*s && !strncmp(s, "all", strlen(s))) {
33                  r->l = r->d = 0;
34 <                r->r = ourview.hresolu;
35 <                r->u = ourview.vresolu;
34 >                r->r = hresolu;
35 >                r->u = vresolu;
36                  return(0);
37          }
38          if (sscanf(s, "%d %d %d %d", &x0, &y0, &x1, &y1) != 4) {
# Line 57 | Line 61 | register RECT  *r;
61          }
62          if (r->l < 0) r->l = 0;
63          if (r->d < 0) r->d = 0;
64 <        if (r->r > ourview.hresolu) r->r = ourview.hresolu;
65 <        if (r->u > ourview.vresolu) r->u = ourview.vresolu;
64 >        if (r->r > hresolu) r->r = hresolu;
65 >        if (r->u > vresolu) r->u = vresolu;
66          if (r->l > r->r) r->l = r->r;
67          if (r->d > r->u) r->d = r->u;
68          return(0);
# Line 89 | Line 93 | double  *mp;
93                  (*dev->comout)("Pick view center\n");
94                  if ((*dev->getcur)(&x, &y) == ABORT)
95                          return(-1);
96 <                rayview(thisray.rorg, thisray.rdir, &ourview, x+.5, y+.5);
96 >                viewray(thisray.rorg, thisray.rdir, &ourview,
97 >                                (x+.5)/hresolu, (y+.5)/vresolu);
98                  if (!direc || ourview.type == VT_PAR) {
99                          rayorigin(&thisray, NULL, PRIMARY, 1.0);
100                          if (!localhit(&thisray, &thescene)) {
# Line 129 | Line 134 | paint(p, xmin, ymin, xmax, ymax)       /* compute and paint
134   register PNODE  *p;
135   int  xmin, ymin, xmax, ymax;
136   {
137 +        extern long  nrays;
138 +        static long  lastflush = 0;
139          static RAY  thisray;
140          double  h, v;
134        register int  i;
141  
142          if (xmax - xmin <= 0 || ymax - ymin <= 0) {     /* empty */
143                  p->x = xmin;
# Line 140 | Line 146 | int  xmin, ymin, xmax, ymax;
146                  return;
147          }
148                                                  /* jitter ray direction */
149 <        p->x = h = xmin + (xmax-xmin)*frandom();
150 <        p->y = v = ymin + (ymax-ymin)*frandom();
149 >        h = xmin + (xmax-xmin)*frandom();
150 >        v = ymin + (ymax-ymin)*frandom();
151          
152 <        rayview(thisray.rorg, thisray.rdir, &ourview, h, v);
147 <
152 >        viewray(thisray.rorg, thisray.rdir, &ourview, h/hresolu, v/vresolu);
153          rayorigin(&thisray, NULL, PRIMARY, 1.0);
149        
154          rayvalue(&thisray);
155  
156 +        p->x = h;
157 +        p->y = v;
158          copycolor(p->v, thisray.rcol);
153
159          scalecolor(p->v, exposure);
160  
161          (*dev->paintr)(greyscale?greyof(p->v):p->v, xmin, ymin, xmax, ymax);
162 +
163 +        if (dev->flush != NULL && nrays - lastflush >= WFLUSH) {
164 +                lastflush = nrays;
165 +                (*dev->flush)();
166 +        }
167   }
168  
169  
# Line 161 | Line 171 | newimage()                             /* start a new image */
171   {
172                                                  /* free old image */
173          freepkids(&ptrunk);
174 <                                                /* set up frame */
175 <        if (ourview.hresolu > dev->xsiz || ourview.vresolu > dev->ysiz)
176 <                newview(&ourview);              /* beware recursive loop! */
174 >                                                /* compute resolution */
175 >        hresolu = dev->xsiz;
176 >        vresolu = dev->ysiz;
177 >        normaspect(viewaspect(&ourview), &dev->pixaspect, &hresolu, &vresolu);
178          pframe.l = pframe.d = 0;
179 <        pframe.r = ourview.hresolu; pframe.u = ourview.vresolu;
179 >        pframe.r = hresolu; pframe.u = vresolu;
180          pdepth = 0;
181                                                  /* clear device */
182 <        (*dev->clear)(ourview.hresolu, ourview.vresolu);
182 >        (*dev->clear)(hresolu, vresolu);
183                                                  /* get first value */
184 <        paint(&ptrunk, 0, 0, ourview.hresolu, ourview.vresolu);
184 >        paint(&ptrunk, 0, 0, hresolu, vresolu);
185   }
186  
187  
188   redraw()                                /* redraw the image */
189   {
190 <        (*dev->clear)(ourview.hresolu, ourview.vresolu);
190 >        (*dev->clear)(hresolu, vresolu);
191          (*dev->comout)("redrawing...\n");
192 <        repaint(0, 0, ourview.hresolu, ourview.vresolu);
192 >        repaint(0, 0, hresolu, vresolu);
193          (*dev->comout)("\n");
194   }
195  
# Line 191 | Line 202 | int  xmin, ymin, xmax, ymax;
202          reg.l = xmin; reg.r = xmax;
203          reg.d = ymin; reg.u = ymax;
204  
205 <        paintrect(&ptrunk, 0, 0, ourview.hresolu, ourview.vresolu, &reg);
205 >        paintrect(&ptrunk, 0, 0, hresolu, vresolu, &reg);
206   }
207  
208  
# Line 339 | Line 350 | register VIEW  *vp;
350   {
351          char  *err;
352  
342        if (vp->hresolu > dev->xsiz || vp->vresolu > dev->ysiz) /* shrink */
343                if (vp->vresolu * dev->xsiz < vp->hresolu * dev->ysiz) {
344                        vp->vresolu = dev->xsiz * vp->vresolu / vp->hresolu;
345                        vp->hresolu = dev->xsiz;
346                } else {
347                        vp->hresolu = dev->ysiz * vp->hresolu / vp->vresolu;
348                        vp->vresolu = dev->ysiz;
349                }
353          if ((err = setview(vp)) != NULL) {
354                  sprintf(errmsg, "view not set - %s", err);
355                  error(COMMAND, errmsg);
356 <        } else if (bcmp(vp, &ourview, sizeof(VIEW))) {
357 <                bcopy(&ourview, &oldview, sizeof(VIEW));
358 <                bcopy(vp, &ourview, sizeof(VIEW));
359 <                newimage();             /* newimage() calls with vp=&ourview! */
356 >        } else if (bcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) {
357 >                copystruct(&oldview, &ourview);
358 >                copystruct(&ourview, vp);
359 >                newimage();
360          }
361   }
362  
# Line 369 | Line 372 | FVECT  vc;
372          register int  i;
373  
374          VCOPY(nv.vup, ourview.vup);
375 <        nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu;
375 >        nv.hoff = ourview.hoff; nv.voff = ourview.voff;
376          spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
377          if (elev != 0.0) {
378                  fcross(v1, ourview.vup, nv.vdir);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines