--- ray/src/hd/rhdisp.c 1998/01/08 21:19:05 3.23 +++ ray/src/hd/rhdisp.c 1998/08/26 13:06:09 3.32 @@ -26,6 +26,8 @@ int imm_mode = 0; /* bundles are being delivered imme int do_outside = 0; /* render from outside sections */ +double eyesepdist = 1; /* eye separation distance */ + char *progname; /* global argv[0] */ FILE *sstdin, *sstdout; /* server's standard input and output */ @@ -86,14 +88,6 @@ char *argv[]; printview(); if (inp & DFL(DC_LASTVIEW)) new_view(NULL); - if (inp & DFL(DC_RESUME)) { - serv_request(DR_NOOP, 0, NULL); - pause = 0; - } - if (inp & DFL(DC_PAUSE)) - pause = 1; - if (inp & DFL(DC_REDRAW)) - imm_mode = beam_sync() > 0; if (inp & DFL(DC_KILL)) { serv_request(DR_KILL, 0, NULL); pause = 0; @@ -104,6 +98,14 @@ char *argv[]; serv_request(DR_RESTART, 0, NULL); pause = 0; } + if (inp & DFL(DC_RESUME)) { + serv_request(DR_NOOP, 0, NULL); + pause = 0; + } + if (inp & DFL(DC_PAUSE)) + pause = 1; + if (inp & DFL(DC_REDRAW)) + imm_mode = beam_sync(1) > 0; if (inp & DFL(DC_QUIT)) serv_request(DR_SHUTDOWN, 0, NULL); } @@ -144,13 +146,18 @@ disp_wait() /* wait for more input */ int n; register int i; /* see if we can avoid select call */ + flgs = 0; /* flag what's ready already */ if (imm_mode || stdin->_cnt > 0) - return(RDY_SRV); + flgs |= RDY_SRV; if (sstdin != NULL && sstdin->_cnt > 0) - return(RDY_SIN); - if (dev_flush()) + flgs |= RDY_SIN; + if (odev.inpready) + flgs |= RDY_DEV; + if (flgs) /* got something? */ + return(flgs); + if (dev_flush()) /* else flush output & check keyboard+mouse */ return(RDY_DEV); - /* make the call */ + /* if nothing, we need to call select */ FD_ZERO(&readset); FD_ZERO(&errset); FD_SET(0, &readset); FD_SET(0, &errset); @@ -169,7 +176,6 @@ disp_wait() /* wait for more input */ return(0); error(SYSTEM, "select call failure in disp_wait"); } - flgs = 0; /* flag what's ready */ if (FD_ISSET(0, &readset) || FD_ISSET(0, &errset)) flgs |= RDY_SRV; if (FD_ISSET(odev.ifd, &readset) || FD_ISSET(odev.ifd, &errset)) @@ -232,8 +238,11 @@ register PACKHEAD *p; for (i = p->nr; i--; ) { hdray(ro, rd, hdlist[p->hd], gc, packra(p)[i].r); d = hddepth(hdlist[p->hd], packra(p)[i].d); - VSUM(wp, ro, rd, d); /* might be behind viewpoint */ - dev_value(packra(p)[i].v, wp, rd); + if (d < .99*FHUGE) { + VSUM(wp, ro, rd, d); /* might be behind viewpoint */ + dev_value(packra(p)[i].v, rd, wp); + } else + dev_value(packra(p)[i].v, rd, NULL); } #ifdef DEBUG if (imm_mode) nimmrays += p->nr; @@ -247,6 +256,8 @@ register VIEW *v; { static VIEW viewhist[VIEWHISTLEN]; static unsigned nhist; + VIEW *dv; + int i, res[2]; char *err; /* restore previous view? */ if (v == NULL) { @@ -266,11 +277,20 @@ again: error(COMMAND, "cannot handle parallel views"); return; } - if (!dev_view(v)) /* update display driver */ + if (!dev_view(v)) /* notify display driver */ goto again; dev_flush(); /* update screen */ - if (!beam_view(v)) /* update beam list */ - goto again; + beam_init(0); /* compute new beam set */ + for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++) + if (!beam_view(dv, res[0], res[1])) { + if (!nhist) { + error(COMMAND, "invalid starting view"); + return; + } + copystruct(v, viewhist + ((nhist-1)%VIEWHISTLEN)); + goto again; + } + beam_sync(0); /* update server */ /* record new view */ if (v < viewhist || v >= viewhist+VIEWHISTLEN) { copystruct(viewhist + (nhist%VIEWHISTLEN), v); @@ -290,22 +310,21 @@ usr_input() /* get user input and process it */ if (fgets(cmd, sizeof(cmd), sstdin) == NULL) { fclose(sstdin); sstdin = NULL; - return(0); + return(-1); } + if (*cmd == '\n') + return(DC_RESUME); for (args = cmd; *args && !isspace(*args); args++) ; while (isspace(*args)) *args++ = '\0'; - if (!*cmd) - return(DC_RESUME); if (*args && args[i=strlen(args)-1] == '\n') args[i] = '\0'; for (i = 0; i < DC_NCMDS; i++) if (!strcmp(cmd, cmdlist[i])) break; if (i >= DC_NCMDS) { - sprintf(errmsg, "unknown command: %s", cmd); - error(COMMAND, errmsg); + dev_auxcom(cmd, args); return(-1); } switch (i) { @@ -327,7 +346,7 @@ usr_input() /* get user input and process it */ /* handled in main() */ break; case DC_REDRAW: /* redraw from server */ - imm_mode = beam_sync() > 0; + imm_mode = beam_sync(1) > 0; dev_clear(); break; case DC_KILL: /* kill rtrace process(es) */ @@ -394,6 +413,10 @@ serv_result() /* get next server result and process break; case DS_OUTSECT: do_outside = 1; + goto noargs; + case DS_EYESEP: + if (msg.nbytes <= 1 || (eyesepdist = atof(buf)) <= FTINY) + error(INTERNAL, "bad eye separation from server"); break; case DS_STARTIMM: case DS_ENDIMM: @@ -406,20 +429,21 @@ serv_result() /* get next server result and process } #endif imm_mode = msg.type==DS_STARTIMM; - /* fall through */ + goto noargs; case DS_ACKNOW: case DS_SHUTDOWN: - if (msg.nbytes) { - sprintf(errmsg, - "unexpected body with server message %d", - msg.type); - error(INTERNAL, errmsg); - } - break; + goto noargs; default: error(INTERNAL, "unrecognized result from server process"); } return(msg.type); /* return message type */ +noargs: + if (msg.nbytes) { + sprintf(errmsg, "unexpected body with server message %d", + msg.type); + error(INTERNAL, errmsg); + } + return(msg.type); readerr: if (feof(stdin)) error(SYSTEM, "server process died");