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

Comparing ray/src/rt/rview.c (file contents):
Revision 1.18 by greg, Tue Jun 25 14:06:15 1991 UTC vs.
Revision 2.14 by greg, Wed Dec 21 09:52:07 1994 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1987 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 26 | Line 26 | int  ndims = 0;                                /* number of sampling dimensions */
26   int  samplendx = 0;                     /* index for this sample */
27  
28   int  psample = 8;                       /* pixel sample size */
29 < double  maxdiff = .15;                  /* max. sample difference */
29 > double  maxdiff = .15;                  /* max. sample difference */
30  
31 < double  exposure = 1.0;                 /* exposure for scene */
31 > double  exposure = 1.0;                 /* exposure for scene */
32  
33 < double  dstrsrc = 0.0;                  /* square source distribution */
34 < double  shadthresh = .1;                /* shadow threshold */
35 < double  shadcert = .25;                 /* shadow certainty */
33 > double  dstrsrc = 0.0;                  /* square source distribution */
34 > double  shadthresh = .1;                /* shadow threshold */
35 > double  shadcert = .25;                 /* shadow certainty */
36   int  directrelay = 0;                   /* number of source relays */
37   int  vspretest = 128;                   /* virtual source pretest density */
38 + int  directvis = 1;                     /* sources visible? */
39 + double  srcsizerat = 0.;                /* maximum ratio source size/dist. */
40  
41 + double  specthresh = .3;                /* specular sampling threshold */
42 + double  specjitter = 1.;                /* specular sampling jitter */
43 +
44 + int  backvis = 1;                       /* back face visibility */
45 +
46   int  maxdepth = 4;                      /* maximum recursion depth */
47 < double  minweight = 1e-2;               /* minimum ray weight */
47 > double  minweight = 1e-2;               /* minimum ray weight */
48  
49   COLOR  ambval = BLKCOLOR;               /* ambient value */
50 < double  ambacc = 0.2;                   /* ambient accuracy */
50 > double  ambacc = 0.2;                   /* ambient accuracy */
51   int  ambres = 8;                        /* ambient resolution */
52   int  ambdiv = 32;                       /* ambient divisions */
53   int  ambssamp = 0;                      /* ambient super-samples */
# Line 53 | Line 60 | char  *devname = dev_default;          /* output device name *
60  
61   struct driver  *dev = NULL;             /* driver functions */
62  
63 + char  rifname[128];                     /* rad input file name */
64 +
65   VIEW  oldview;                          /* previous view parameters */
66  
67   PNODE  ptrunk;                          /* the base of our image */
# Line 61 | Line 70 | int  pdepth;                           /* image depth in current frame */
70  
71   static char  *reserve_mem = NULL;       /* pre-allocated reserve memory */
72  
73 < #define RESERVE_AMT     8192            /* amount of memory to reserve */
73 > #define RESERVE_AMT     32768           /* amount of memory to reserve */
74  
75 < #define  CTRL(c)        ('c'-'@')
75 > #define  CTRL(c)        ((c)-'@')
76  
77  
78   quit(code)                      /* quit program */
79   int  code;
80   {
81 + #ifdef MSTATS
82 +        if (code == 2 && errno == ENOMEM)
83 +                printmemstats(stderr);
84 + #endif
85          devclose();
86          exit(code);
87   }
# Line 90 | Line 103 | char  *dname;
103                                  error(USER, errmsg);
104                          } else
105                                  return;
106 + #ifndef NIX                                                
107                                                  /* not there, try exec */
108          if ((dev = comm_init(dname, id)) == NULL) {
109                  sprintf(errmsg, "cannot start device \"%s\"", dname);
110                  error(USER, errmsg);
111          }
112 + #endif
113   }
114  
115  
# Line 167 | Line 182 | freereserves()                 /* free memory reserves */
182   command(prompt)                 /* get/execute command */
183   char  *prompt;
184   {
185 < #define  badcom(s)      strncmp(s, inpbuf, args-inpbuf-1)
171 <        double  atof();
185 > #define  badcom(s)      strncmp(s, inpbuf, args-inpbuf-1)
186          char  inpbuf[256];
187          char  *args;
188   again:
# Line 179 | Line 193 | again:
193          else *++args = '\0';
194          
195          switch (inpbuf[0]) {
196 <        case 'f':                               /* new frame */
197 <                if (badcom("frame"))
198 <                        goto commerr;
196 >        case 'f':                               /* new frame (or free mem.) */
197 >                if (badcom("frame")) {
198 >                        if (badcom("free"))
199 >                                goto commerr;
200 >                        free_objmem();
201 >                        break;
202 >                }
203                  getframe(args);
204                  break;
205          case 'v':                               /* view */
# Line 194 | Line 212 | again:
212                          goto commerr;
213                  lastview(args);
214                  break;
215 +        case 'V':                               /* save view */
216 +                if (badcom("V"))
217 +                        goto commerr;
218 +                saveview(args);
219 +                break;
220 +        case 'L':                               /* load view */
221 +                if (badcom("L"))
222 +                        goto commerr;
223 +                loadview(args);
224 +                break;
225          case 'e':                               /* exposure */
226                  if (badcom("exposure"))
227                          goto commerr;
228                  getexposure(args);
229                  break;
230          case 's':                               /* set a parameter */
231 <                if (badcom("set"))
231 >                if (badcom("set")) {
232 > #ifdef  SIGTSTP
233 >                        if (!badcom("stop"))
234 >                                goto dostop;
235 > #endif
236                          goto commerr;
237 +                }
238                  setparam(args);
239                  break;
240          case 'n':                               /* new picture */
# Line 219 | Line 252 | again:
252                          goto commerr;
253                  getaim(args);
254                  break;
255 <        case 'm':                               /* move camera */
255 >        case 'm':                               /* move camera (or memstats) */
256                  if (badcom("move"))
257 + #ifdef  MSTATS
258 +                {
259 +                        if (badcom("memory"))
260 +                                goto commerr;
261 +                        printmemstats(stderr);
262 +                        break;
263 +                }
264 + #else
265                          goto commerr;
266 + #endif
267                  getmove(args);
268                  break;
269          case 'r':                               /* rotate/repaint */
270                  if (badcom("rotate")) {
271 <                        if (badcom("repaint"))
272 <                                goto commerr;
271 >                        if (badcom("repaint")) {
272 >                                if (badcom("redraw"))
273 >                                        goto commerr;
274 >                                redraw();
275 >                                break;
276 >                        }
277                          getrepaint(args);
278                          break;
279                  }
280                  getrotate(args);
281                  break;
282          case 'p':                               /* pivot view */
283 <                if (badcom("pivot"))
284 <                        goto commerr;
283 >                if (badcom("pivot")) {
284 >                        if (badcom("pause"))
285 >                                goto commerr;
286 >                        goto again;
287 >                }
288                  getpivot(args);
289                  break;
290 <        case CTRL(R):                           /* redraw */
290 >        case CTRL('R'):                         /* redraw */
291                  redraw();
292                  break;
293          case 'w':                               /* write */
# Line 250 | Line 299 | again:
299                  if (badcom("quit"))
300                          goto commerr;
301                  quit(0);
302 <        case CTRL(C):                           /* interrupt */
302 >        case CTRL('C'):                         /* interrupt */
303                  goto again;
304 < #ifdef  SIGTSTP
305 <        case CTRL(Z):                           /* stop */
304 > #ifdef  SIGTSTP
305 >        case CTRL('Z'):;                        /* stop */
306 > dostop:
307                  devclose();
308                  kill(0, SIGTSTP);
309                  /* pc stops here */
# Line 273 | Line 323 | commerr:
323                  error(COMMAND, errmsg);
324                  break;
325          }
326 < #undef  badcom
326 > #undef  badcom
327   }
328  
329  
# Line 283 | Line 333 | rsample()                      /* sample the image */
333          RECT  r;
334          PNODE  *p;
335          register RECT  *rl;
336 <        register PNODE  **pl;
336 >        register PNODE  **pl;
337          register int  x;
338          /*
339           *     We initialize the bottom row in the image at our current
340 <         * resolution.  During sampling, we check super-pixels to the
340 >         * resolution.  During sampling, we check super-pixels to the
341           * right and above by calling bigdiff().  If there is a significant
342           * difference, we subsample the super-pixels.  The testing process
343           * includes initialization of the next row.
344           */
345 <        xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
346 <        ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
345 >        xsiz = (((long)(pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
346 >        ysiz = (((long)(pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
347          rl = (RECT *)malloc(xsiz*sizeof(RECT));
348          if (rl == NULL)
349                  return;
350          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
351 <        if (pl == NULL)
351 >        if (pl == NULL) {
352 >                free((char *)rl);
353                  return;
354 +        }
355          /*
356           * Initialize the bottom row.
357           */
# Line 315 | Line 367 | rsample()                      /* sample the image */
367                                                  /* sample the image */
368          for (y = 0; /* y < ysiz */ ; y++) {
369                  for (x = 0; x < xsiz-1; x++) {
370 <                        if (dev->inpready)
370 >                        if (dev->inpready || errno == ENOMEM)
371                                  goto escape;
372                          /*
373                           * Test super-pixel to the right.
# Line 331 | Line 383 | rsample()                      /* sample the image */
383                  if (y >= ysiz-1)
384                          break;
385                  for (x = 0; x < xsiz; x++) {
386 <                        if (dev->inpready)
386 >                        if (dev->inpready || errno == ENOMEM)
387                                  goto escape;
388                          /*
389                           * Find super-pixel at this position in next row.
# Line 365 | Line 417 | escape:
417  
418   int
419   refine(p, xmin, ymin, xmax, ymax, pd)           /* refine a node */
420 < register PNODE  *p;
420 > register PNODE  *p;
421   int  xmin, ymin, xmax, ymax;
422   int  pd;
423   {
# Line 386 | Line 438 | int  pd;
438          if (p->kid == NULL) {                   /* subdivide */
439  
440                  if ((p->kid = newptree()) == NULL)
441 <                        return(growth);
441 >                        return(0);
442                  /*
443                   *  The following paint order can leave a black pixel
444 <                 *  when redraw() is called in (*dev->paintr)().
444 >                 *  if redraw() is called in (*dev->paintr)().
445                   */
446                  if (p->x >= mx && p->y >= my)
447                          pcopy(p, p->kid+UR);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines