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 2.2 by greg, Mon Nov 25 10:11:01 1991 UTC vs.
Revision 2.15 by greg, Fri Dec 8 18:49:24 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1987 Regents of the University of California */
1 > /* Copyright (c) 1995 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  directinvis = 0;                   /* sources invisible? */
39 < double  srcsizerat = 0.;                /* maximum ratio source size/dist. */
38 > int  directvis = 1;                     /* sources visible? */
39 > double  srcsizerat = 0.;                /* maximum ratio source size/dist. */
40  
41 + COLOR  cextinction = BLKCOLOR;          /* global extinction coefficient */
42 + double  salbedo = 0.;                   /* global scattering albedo */
43 + double  seccg = 0.;                     /* global scattering eccentricity */
44 + double  ssampdist = 0.;                 /* scatter sampling distance */
45 +
46 + double  specthresh = .3;                /* specular sampling threshold */
47 + double  specjitter = 1.;                /* specular sampling jitter */
48 +
49 + int  backvis = 1;                       /* back face visibility */
50 +
51   int  maxdepth = 4;                      /* maximum recursion depth */
52 < double  minweight = 1e-2;               /* minimum ray weight */
52 > double  minweight = 1e-2;               /* minimum ray weight */
53  
54   COLOR  ambval = BLKCOLOR;               /* ambient value */
55 < double  ambacc = 0.2;                   /* ambient accuracy */
55 > double  ambacc = 0.2;                   /* ambient accuracy */
56   int  ambres = 8;                        /* ambient resolution */
57   int  ambdiv = 32;                       /* ambient divisions */
58   int  ambssamp = 0;                      /* ambient super-samples */
# Line 55 | Line 65 | char  *devname = dev_default;          /* output device name *
65  
66   struct driver  *dev = NULL;             /* driver functions */
67  
68 + char  rifname[128];                     /* rad input file name */
69 +
70   VIEW  oldview;                          /* previous view parameters */
71  
72   PNODE  ptrunk;                          /* the base of our image */
# Line 65 | Line 77 | static char  *reserve_mem = NULL;      /* pre-allocated res
77  
78   #define RESERVE_AMT     32768           /* amount of memory to reserve */
79  
80 < #define  CTRL(c)        ('c'-'@')
80 > #define  CTRL(c)        ((c)-'@')
81  
82  
83   quit(code)                      /* quit program */
84   int  code;
85   {
86 + #ifdef MSTATS
87 +        if (code == 2 && errno == ENOMEM)
88 +                printmemstats(stderr);
89 + #endif
90          devclose();
91          exit(code);
92   }
# Line 92 | Line 108 | char  *dname;
108                                  error(USER, errmsg);
109                          } else
110                                  return;
111 + #ifndef NIX                                                
112                                                  /* not there, try exec */
113          if ((dev = comm_init(dname, id)) == NULL) {
114                  sprintf(errmsg, "cannot start device \"%s\"", dname);
115                  error(USER, errmsg);
116          }
117 + #endif
118   }
119  
120  
# Line 169 | Line 187 | freereserves()                 /* free memory reserves */
187   command(prompt)                 /* get/execute command */
188   char  *prompt;
189   {
190 < #define  badcom(s)      strncmp(s, inpbuf, args-inpbuf-1)
173 <        double  atof();
190 > #define  badcom(s)      strncmp(s, inpbuf, args-inpbuf-1)
191          char  inpbuf[256];
192          char  *args;
193   again:
# Line 181 | Line 198 | again:
198          else *++args = '\0';
199          
200          switch (inpbuf[0]) {
201 <        case 'f':                               /* new frame */
202 <                if (badcom("frame"))
203 <                        goto commerr;
201 >        case 'f':                               /* new frame (or free mem.) */
202 >                if (badcom("frame")) {
203 >                        if (badcom("free"))
204 >                                goto commerr;
205 >                        free_objmem();
206 >                        break;
207 >                }
208                  getframe(args);
209                  break;
210          case 'v':                               /* view */
# Line 196 | Line 217 | again:
217                          goto commerr;
218                  lastview(args);
219                  break;
220 +        case 'V':                               /* save view */
221 +                if (badcom("V"))
222 +                        goto commerr;
223 +                saveview(args);
224 +                break;
225 +        case 'L':                               /* load view */
226 +                if (badcom("L"))
227 +                        goto commerr;
228 +                loadview(args);
229 +                break;
230          case 'e':                               /* exposure */
231                  if (badcom("exposure"))
232                          goto commerr;
233                  getexposure(args);
234                  break;
235          case 's':                               /* set a parameter */
236 <                if (badcom("set"))
236 >                if (badcom("set")) {
237 > #ifdef  SIGTSTP
238 >                        if (!badcom("stop"))
239 >                                goto dostop;
240 > #endif
241                          goto commerr;
242 +                }
243                  setparam(args);
244                  break;
245          case 'n':                               /* new picture */
# Line 221 | Line 257 | again:
257                          goto commerr;
258                  getaim(args);
259                  break;
260 <        case 'm':                               /* move camera */
260 >        case 'm':                               /* move camera (or memstats) */
261                  if (badcom("move"))
262 < #ifdef  MSTATS
262 > #ifdef  MSTATS
263                  {
264                          if (badcom("memory"))
265                                  goto commerr;
# Line 237 | Line 273 | again:
273                  break;
274          case 'r':                               /* rotate/repaint */
275                  if (badcom("rotate")) {
276 <                        if (badcom("repaint"))
277 <                                goto commerr;
276 >                        if (badcom("repaint")) {
277 >                                if (badcom("redraw"))
278 >                                        goto commerr;
279 >                                redraw();
280 >                                break;
281 >                        }
282                          getrepaint(args);
283                          break;
284                  }
285                  getrotate(args);
286                  break;
287          case 'p':                               /* pivot view */
288 <                if (badcom("pivot"))
289 <                        goto commerr;
288 >                if (badcom("pivot")) {
289 >                        if (badcom("pause"))
290 >                                goto commerr;
291 >                        goto again;
292 >                }
293                  getpivot(args);
294                  break;
295 <        case CTRL(R):                           /* redraw */
295 >        case CTRL('R'):                         /* redraw */
296                  redraw();
297                  break;
298          case 'w':                               /* write */
# Line 261 | Line 304 | again:
304                  if (badcom("quit"))
305                          goto commerr;
306                  quit(0);
307 <        case CTRL(C):                           /* interrupt */
307 >        case CTRL('C'):                         /* interrupt */
308                  goto again;
309 < #ifdef  SIGTSTP
310 <        case CTRL(Z):                           /* stop */
309 > #ifdef  SIGTSTP
310 >        case CTRL('Z'):;                        /* stop */
311 > dostop:
312                  devclose();
313                  kill(0, SIGTSTP);
314                  /* pc stops here */
# Line 284 | Line 328 | commerr:
328                  error(COMMAND, errmsg);
329                  break;
330          }
331 < #undef  badcom
331 > #undef  badcom
332   }
333  
334  
# Line 294 | Line 338 | rsample()                      /* sample the image */
338          RECT  r;
339          PNODE  *p;
340          register RECT  *rl;
341 <        register PNODE  **pl;
341 >        register PNODE  **pl;
342          register int  x;
343          /*
344           *     We initialize the bottom row in the image at our current
345 <         * resolution.  During sampling, we check super-pixels to the
345 >         * resolution.  During sampling, we check super-pixels to the
346           * right and above by calling bigdiff().  If there is a significant
347           * difference, we subsample the super-pixels.  The testing process
348           * includes initialization of the next row.
349           */
350 <        xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
351 <        ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
350 >        xsiz = (((long)(pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
351 >        ysiz = (((long)(pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
352          rl = (RECT *)malloc(xsiz*sizeof(RECT));
353          if (rl == NULL)
354                  return;
355          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
356 <        if (pl == NULL)
356 >        if (pl == NULL) {
357 >                free((char *)rl);
358                  return;
359 +        }
360          /*
361           * Initialize the bottom row.
362           */
# Line 376 | Line 422 | escape:
422  
423   int
424   refine(p, xmin, ymin, xmax, ymax, pd)           /* refine a node */
425 < register PNODE  *p;
425 > register PNODE  *p;
426   int  xmin, ymin, xmax, ymax;
427   int  pd;
428   {
# Line 400 | Line 446 | int  pd;
446                          return(0);
447                  /*
448                   *  The following paint order can leave a black pixel
449 <                 *  when redraw() is called in (*dev->paintr)().
449 >                 *  if redraw() is called in (*dev->paintr)().
450                   */
451                  if (p->x >= mx && p->y >= my)
452                          pcopy(p, p->kid+UR);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines