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

Comparing ray/src/hd/rhdisp.c (file contents):
Revision 3.10 by gregl, Mon Dec 8 18:51:15 1997 UTC vs.
Revision 3.20 by gregl, Sun Jan 4 18:37:10 1998 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ SGI";
14   #include "selcall.h"
15   #include <ctype.h>
16  
17 + #ifndef VIEWHISTLEN
18 + #define VIEWHISTLEN     4       /* number of remembered views */
19 + #endif
20 +
21   HOLO    *hdlist[HDMAX+1];       /* global holodeck list */
22  
23   char    cmdlist[DC_NCMDS][8] = DC_INIT;
24  
25   int     imm_mode = 0;           /* bundles are being delivered immediately */
26  
27 + int     do_outside = 0;         /* render from outside sections */
28 +
29   char    *progname;              /* global argv[0] */
30  
31   FILE    *sstdin, *sstdout;      /* server's standard input and output */
# Line 52 | Line 58 | char   *argv[];
58                                          /* enter main loop */
59          do {
60                  rdy = disp_wait();
61 +                if (rdy & RDY_SRV) {            /* process server result */
62 +                        res = serv_result();
63 +                        if (pause && res != DS_SHUTDOWN) {
64 +                                serv_request(DR_ATTEN, 0, NULL);
65 +                                while ((res = serv_result()) != DS_ACKNOW &&
66 +                                                res != DS_SHUTDOWN)
67 +                                        ;
68 +                        }
69 +                }
70                  if (rdy & RDY_DEV) {            /* user input from driver */
71                          inp = dev_input();
72 <                        if (inp & DEV_PUTVIEW)
58 <                                printview();
59 <                        if (inp & DEV_NEWVIEW)
72 >                        if (inp & DFL(DC_SETVIEW))
73                                  new_view(&odev.v);
74 <                        if (inp & DEV_SHUTDOWN)
75 <                                serv_request(DR_SHUTDOWN, 0, NULL);
76 <                        if (inp & DEV_REDRAW) {
77 <                                imm_mode = 1;   /* preempt updates */
78 <                                beam_sync();
74 >                        if (inp & DFL(DC_GETVIEW))
75 >                                printview();
76 >                        if (inp & DFL(DC_LASTVIEW))
77 >                                new_view(NULL);
78 >                        if (inp & DFL(DC_RESUME)) {
79 >                                serv_request(DR_NOOP, 0, NULL);
80 >                                pause = 0;
81                          }
82 <                        if (inp & DEV_WAIT)
82 >                        if (inp & DFL(DC_PAUSE))
83                                  pause = 1;
84 <                        if (inp & DEV_RESUME) {
85 <                                serv_request(DR_NOOP, 0, NULL);
84 >                        if (inp & DFL(DC_REDRAW))
85 >                                imm_mode = beam_sync() > 0;
86 >                        if (inp & DFL(DC_KILL)) {
87 >                                serv_request(DR_KILL, 0, NULL);
88                                  pause = 0;
89                          }
90 +                        if (inp & DFL(DC_CLOBBER))
91 +                                serv_request(DR_CLOBBER, 0, NULL);
92 +                        if (inp & DFL(DC_RESTART)) {
93 +                                serv_request(DR_RESTART, 0, NULL);
94 +                                pause = 0;
95 +                        }
96 +                        if (inp & DFL(DC_QUIT))
97 +                                serv_request(DR_SHUTDOWN, 0, NULL);
98                  }
99                  if (rdy & RDY_SIN)              /* user input from sstdin */
100                          switch (usr_input()) {
# Line 78 | Line 103 | char   *argv[];
103                                  break;
104                          case DC_RESUME:
105                                  serv_request(DR_NOOP, 0, NULL);
106 +                                /* fall through */
107 +                        case DC_KILL:
108 +                        case DC_RESTART:
109                                  pause = 0;
110                                  break;
111                          }
84                if (rdy & RDY_SRV) {            /* process server result */
85                        res = serv_result();
86                        if (pause && res != DS_SHUTDOWN) {
87                                serv_request(DR_ATTEN, 0, NULL);
88                                while ((res = serv_result()) != DS_ACKNOW &&
89                                                res != DS_SHUTDOWN)
90                                        ;
91                        }
92                }
112          } while (res != DS_SHUTDOWN);
113                                          /* all done */
114          quit(0);
# Line 143 | Line 162 | add_holo(hdg)                  /* register a new holodeck section */
162   HDGRID  *hdg;
163   {
164          VIEW    nv;
165 +        double  d;
166          register int    hd;
167  
168          for (hd = 0; hd < HDMAX && hdlist[hd] != NULL; hd++)
# Line 163 | Line 183 | HDGRID *hdg;
183          VSUM(nv.vp, nv.vp, hdlist[0]->xv[2], 0.5);
184          fcross(nv.vdir, hdlist[0]->xv[1], hdlist[0]->xv[2]);
185          VCOPY(nv.vup, hdlist[0]->xv[2]);
186 +        if (do_outside) {
187 +                normalize(nv.vdir);
188 +                d = VLEN(hdlist[0]->xv[1]);
189 +                d += VLEN(hdlist[0]->xv[2]);
190 +                VSUM(nv.vp, nv.vp, nv.vdir, -d);
191 +        }
192          new_view(&nv);
193   }
194  
# Line 190 | Line 216 | register PACKHEAD      *p;
216  
217  
218   new_view(v)                     /* change view parameters */
219 < VIEW    *v;
219 > register VIEW   *v;
220   {
221 +        static VIEW     viewhist[VIEWHISTLEN];
222 +        static unsigned nhist;
223          char    *err;
224 <
225 <        do {
226 <                if ((err = setview(v)) != NULL) {
227 <                        error(COMMAND, err);
228 <                        return;
229 <                }
230 <                if (v->type == VT_PAR) {
231 <                        error(COMMAND, "cannot handle parallel views");
232 <                        return;
233 <                }
234 <                dev_view(v);            /* update display driver */
235 <                dev_flush();            /* update screen */
236 <        } while (!beam_view(v));        /* update beam list */
224 >                                /* restore previous view? */
225 >        if (v == NULL) {
226 >                if (nhist > 1)          /* get one before last setting */
227 >                        nhist--;
228 >                else                    /* else go to end of list */
229 >                        while (nhist < VIEWHISTLEN && viewhist[nhist].type)
230 >                                nhist++;
231 >                v = viewhist + ((nhist-1)%VIEWHISTLEN);
232 >        } else
233 > again:
234 >        if ((err = setview(v)) != NULL) {
235 >                error(COMMAND, err);
236 >                return;
237 >        }
238 >        if (v->type == VT_PAR) {
239 >                error(COMMAND, "cannot handle parallel views");
240 >                return;
241 >        }
242 >        if (!dev_view(v))       /* update display driver */
243 >                goto again;
244 >        dev_flush();            /* update screen */
245 >        if (!beam_view(v))      /* update beam list */
246 >                goto again;
247 >                                /* record new view */
248 >        if (v < viewhist || v >= viewhist+VIEWHISTLEN) {
249 >                copystruct(viewhist + (nhist%VIEWHISTLEN), v);
250 >                nhist++;
251 >        }
252   }
253  
254  
# Line 215 | Line 258 | usr_input()                    /* get user input and process it */
258          VIEW    vparams;
259          char    cmd[128];
260          register char   *args;
261 <        register int    cmdno;
261 >        register int    i;
262  
263          if (fgets(cmd, sizeof(cmd), sstdin) == NULL)
264                  return(DC_QUIT);
# Line 225 | Line 268 | usr_input()                    /* get user input and process it */
268                  *args++ = '\0';
269          if (!*cmd)
270                  return(DC_RESUME);
271 <        for (cmdno = 0; cmdno < DC_NCMDS; cmdno++)
272 <                if (!strcmp(cmd, cmdlist[cmdno]))
271 >        if (*args && args[i=strlen(args)-1] == '\n')
272 >                args[i] = '\0';
273 >        for (i = 0; i < DC_NCMDS; i++)
274 >                if (!strcmp(cmd, cmdlist[i]))
275                          break;
276 <        if (cmdno >= DC_NCMDS) {
276 >        if (i >= DC_NCMDS) {
277                  sprintf(errmsg, "unknown command: %s", cmd);
278                  error(COMMAND, errmsg);
279                  return(-1);
280          }
281 <        switch (cmdno) {
281 >        switch (i) {
282          case DC_SETVIEW:                /* set the view */
283                  copystruct(&vparams, &odev.v);
284                  if (!sscanview(&vparams, args))
# Line 244 | Line 289 | usr_input()                    /* get user input and process it */
289          case DC_GETVIEW:                /* print the current view */
290                  printview();
291                  break;
292 +        case DC_LASTVIEW:               /* restore previous view */
293 +                new_view(NULL);
294 +                break;
295          case DC_PAUSE:                  /* pause the current calculation */
296          case DC_RESUME:                 /* resume the calculation */
297                  /* handled in main() */
298                  break;
299 +        case DC_REDRAW:                 /* redraw from server */
300 +                imm_mode = beam_sync() > 0;
301 +                break;
302 +        case DC_KILL:                   /* kill rtrace process(es) */
303 +                serv_request(DR_KILL, 0, NULL);
304 +                break;
305 +        case DC_CLOBBER:                /* clobber holodeck */
306 +                serv_request(DR_CLOBBER, 0, NULL);
307 +                break;
308 +        case DC_RESTART:                /* restart rtrace */
309 +                serv_request(DR_RESTART, 0, NULL);
310 +                break;
311          case DC_QUIT:                   /* quit request */
312                  serv_request(DR_SHUTDOWN, 0, NULL);
313                  break;
314          default:
315                  error(CONSISTENCY, "bad command id in usr_input");
316          }
317 <        return(cmdno);
258 <                
317 >        return(i);
318   }
319  
320  
# Line 302 | Line 361 | serv_result()                  /* get next server result and process
361                          error(INTERNAL, "bad holodeck record from server");
362                  add_holo((HDGRID *)buf);
363                  break;
364 +        case DS_OUTSECT:
365 +                do_outside = 1;
366 +                break;
367          case DS_STARTIMM:
368          case DS_ENDIMM:
369                  imm_mode = msg.type==DS_STARTIMM;
308                if (msg.type == DS_ENDIMM)
309                        dev_flush();            /* update display NOW */
370                  /* fall through */
371          case DS_ACKNOW:
372          case DS_SHUTDOWN:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines