--- ray/src/hd/rhdisp.c 1998/07/13 17:55:51 3.27 +++ ray/src/hd/rhdisp.c 1998/11/05 14:27:02 3.34 @@ -88,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(1) > 0; if (inp & DFL(DC_KILL)) { serv_request(DR_KILL, 0, NULL); pause = 0; @@ -106,10 +98,18 @@ 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); } - if (rdy & RDY_SIN) /* user input from sstdin */ + if (rdy & RDY_SIN && !imm_mode) /* user input from sstdin */ switch (usr_input()) { case DC_PAUSE: pause = 1; @@ -146,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); @@ -171,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)) @@ -234,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; @@ -282,8 +289,9 @@ again: } copystruct(v, viewhist + ((nhist-1)%VIEWHISTLEN)); goto again; - } - beam_sync(0); /* update server */ + } + /* update server */ + imm_mode = beam_sync(0) > 0; /* record new view */ if (v < viewhist || v >= viewhist+VIEWHISTLEN) { copystruct(viewhist + (nhist%VIEWHISTLEN), v); @@ -305,7 +313,7 @@ usr_input() /* get user input and process it */ sstdin = NULL; return(-1); } - if (!*cmd) + if (*cmd == '\n') return(DC_RESUME); for (args = cmd; *args && !isspace(*args); args++) ; @@ -406,7 +414,7 @@ serv_result() /* get next server result and process break; case DS_OUTSECT: do_outside = 1; - break; + goto noargs; case DS_EYESEP: if (msg.nbytes <= 1 || (eyesepdist = atof(buf)) <= FTINY) error(INTERNAL, "bad eye separation from server"); @@ -421,21 +429,23 @@ serv_result() /* get next server result and process tmodesw = tnow; } #endif - imm_mode = msg.type==DS_STARTIMM; - /* fall through */ + if (!(imm_mode = msg.type==DS_STARTIMM)) + dev_flush(); + 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"); @@ -449,6 +459,11 @@ char *p; { MSGHEAD msg; int m; + /* consistency checks */ +#ifdef DEBUG + if (nbytes < 0 || nbytes > 0 & p == NULL) + error(CONSISTENCY, "bad buffer handed to serv_request"); +#endif /* get server's attention for big request */ if (nbytes >= BIGREQSIZ-sizeof(MSGHEAD)) { serv_request(DR_ATTEN, 0, NULL);