26 |
|
|
27 |
|
int do_outside = 0; /* render from outside sections */ |
28 |
|
|
29 |
+ |
double eyesepdist = 1; /* eye separation distance */ |
30 |
+ |
|
31 |
|
char *progname; /* global argv[0] */ |
32 |
|
|
33 |
|
FILE *sstdin, *sstdout; /* server's standard input and output */ |
88 |
|
printview(); |
89 |
|
if (inp & DFL(DC_LASTVIEW)) |
90 |
|
new_view(NULL); |
89 |
– |
if (inp & DFL(DC_RESUME)) { |
90 |
– |
serv_request(DR_NOOP, 0, NULL); |
91 |
– |
pause = 0; |
92 |
– |
} |
93 |
– |
if (inp & DFL(DC_PAUSE)) |
94 |
– |
pause = 1; |
95 |
– |
if (inp & DFL(DC_REDRAW)) |
96 |
– |
imm_mode = beam_sync(1) > 0; |
91 |
|
if (inp & DFL(DC_KILL)) { |
92 |
|
serv_request(DR_KILL, 0, NULL); |
93 |
|
pause = 0; |
98 |
|
serv_request(DR_RESTART, 0, NULL); |
99 |
|
pause = 0; |
100 |
|
} |
101 |
+ |
if (inp & DFL(DC_RESUME)) { |
102 |
+ |
serv_request(DR_NOOP, 0, NULL); |
103 |
+ |
pause = 0; |
104 |
+ |
} |
105 |
+ |
if (inp & DFL(DC_PAUSE)) |
106 |
+ |
pause = 1; |
107 |
+ |
if (inp & DFL(DC_REDRAW)) |
108 |
+ |
imm_mode = beam_sync(1) > 0; |
109 |
|
if (inp & DFL(DC_QUIT)) |
110 |
|
serv_request(DR_SHUTDOWN, 0, NULL); |
111 |
|
} |
112 |
< |
if (rdy & RDY_SIN) /* user input from sstdin */ |
112 |
> |
if (rdy & RDY_SIN && !imm_mode) /* user input from sstdin */ |
113 |
|
switch (usr_input()) { |
114 |
|
case DC_PAUSE: |
115 |
|
pause = 1; |
146 |
|
int n; |
147 |
|
register int i; |
148 |
|
/* see if we can avoid select call */ |
149 |
+ |
flgs = 0; /* flag what's ready already */ |
150 |
|
if (imm_mode || stdin->_cnt > 0) |
151 |
< |
return(RDY_SRV); |
151 |
> |
flgs |= RDY_SRV; |
152 |
|
if (sstdin != NULL && sstdin->_cnt > 0) |
153 |
< |
return(RDY_SIN); |
154 |
< |
if (dev_flush()) |
153 |
> |
flgs |= RDY_SIN; |
154 |
> |
if (odev.inpready) |
155 |
> |
flgs |= RDY_DEV; |
156 |
> |
if (flgs) /* got something? */ |
157 |
> |
return(flgs); |
158 |
> |
if (dev_flush()) /* else flush output & check keyboard+mouse */ |
159 |
|
return(RDY_DEV); |
160 |
< |
/* make the call */ |
160 |
> |
/* if nothing, we need to call select */ |
161 |
|
FD_ZERO(&readset); FD_ZERO(&errset); |
162 |
|
FD_SET(0, &readset); |
163 |
|
FD_SET(0, &errset); |
176 |
|
return(0); |
177 |
|
error(SYSTEM, "select call failure in disp_wait"); |
178 |
|
} |
172 |
– |
flgs = 0; /* flag what's ready */ |
179 |
|
if (FD_ISSET(0, &readset) || FD_ISSET(0, &errset)) |
180 |
|
flgs |= RDY_SRV; |
181 |
|
if (FD_ISSET(odev.ifd, &readset) || FD_ISSET(odev.ifd, &errset)) |
238 |
|
for (i = p->nr; i--; ) { |
239 |
|
hdray(ro, rd, hdlist[p->hd], gc, packra(p)[i].r); |
240 |
|
d = hddepth(hdlist[p->hd], packra(p)[i].d); |
241 |
< |
VSUM(wp, ro, rd, d); /* might be behind viewpoint */ |
242 |
< |
dev_value(packra(p)[i].v, wp, rd); |
241 |
> |
if (d < .99*FHUGE) { |
242 |
> |
VSUM(wp, ro, rd, d); /* might be behind viewpoint */ |
243 |
> |
dev_value(packra(p)[i].v, rd, wp); |
244 |
> |
} else |
245 |
> |
dev_value(packra(p)[i].v, rd, NULL); |
246 |
|
} |
247 |
|
#ifdef DEBUG |
248 |
|
if (imm_mode) nimmrays += p->nr; |
280 |
|
if (!dev_view(v)) /* notify display driver */ |
281 |
|
goto again; |
282 |
|
dev_flush(); /* update screen */ |
283 |
< |
beam_init(); /* compute new beam set */ |
283 |
> |
beam_init(0); /* compute new beam set */ |
284 |
|
for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++) |
285 |
|
if (!beam_view(dv, res[0], res[1])) { |
286 |
|
if (!nhist) { |
289 |
|
} |
290 |
|
copystruct(v, viewhist + ((nhist-1)%VIEWHISTLEN)); |
291 |
|
goto again; |
292 |
< |
} |
293 |
< |
beam_sync(0); /* update server */ |
292 |
> |
} |
293 |
> |
/* update server */ |
294 |
> |
imm_mode = beam_sync(0) > 0; |
295 |
|
/* record new view */ |
296 |
|
if (v < viewhist || v >= viewhist+VIEWHISTLEN) { |
297 |
|
copystruct(viewhist + (nhist%VIEWHISTLEN), v); |
311 |
|
if (fgets(cmd, sizeof(cmd), sstdin) == NULL) { |
312 |
|
fclose(sstdin); |
313 |
|
sstdin = NULL; |
314 |
< |
return(0); |
314 |
> |
return(-1); |
315 |
|
} |
316 |
+ |
if (*cmd == '\n') |
317 |
+ |
return(DC_RESUME); |
318 |
|
for (args = cmd; *args && !isspace(*args); args++) |
319 |
|
; |
320 |
|
while (isspace(*args)) |
321 |
|
*args++ = '\0'; |
310 |
– |
if (!*cmd) |
311 |
– |
return(DC_RESUME); |
322 |
|
if (*args && args[i=strlen(args)-1] == '\n') |
323 |
|
args[i] = '\0'; |
324 |
|
for (i = 0; i < DC_NCMDS; i++) |
325 |
|
if (!strcmp(cmd, cmdlist[i])) |
326 |
|
break; |
327 |
|
if (i >= DC_NCMDS) { |
328 |
< |
sprintf(errmsg, "unknown command: %s", cmd); |
319 |
< |
error(COMMAND, errmsg); |
328 |
> |
dev_auxcom(cmd, args); |
329 |
|
return(-1); |
330 |
|
} |
331 |
|
switch (i) { |
414 |
|
break; |
415 |
|
case DS_OUTSECT: |
416 |
|
do_outside = 1; |
417 |
+ |
goto noargs; |
418 |
+ |
case DS_EYESEP: |
419 |
+ |
if (msg.nbytes <= 1 || (eyesepdist = atof(buf)) <= FTINY) |
420 |
+ |
error(INTERNAL, "bad eye separation from server"); |
421 |
|
break; |
422 |
|
case DS_STARTIMM: |
423 |
|
case DS_ENDIMM: |
429 |
|
tmodesw = tnow; |
430 |
|
} |
431 |
|
#endif |
432 |
< |
imm_mode = msg.type==DS_STARTIMM; |
433 |
< |
/* fall through */ |
432 |
> |
if (!(imm_mode = msg.type==DS_STARTIMM)) |
433 |
> |
dev_flush(); |
434 |
> |
goto noargs; |
435 |
|
case DS_ACKNOW: |
436 |
|
case DS_SHUTDOWN: |
437 |
< |
if (msg.nbytes) { |
424 |
< |
sprintf(errmsg, |
425 |
< |
"unexpected body with server message %d", |
426 |
< |
msg.type); |
427 |
< |
error(INTERNAL, errmsg); |
428 |
< |
} |
429 |
< |
break; |
437 |
> |
goto noargs; |
438 |
|
default: |
439 |
|
error(INTERNAL, "unrecognized result from server process"); |
440 |
|
} |
441 |
|
return(msg.type); /* return message type */ |
442 |
+ |
noargs: |
443 |
+ |
if (msg.nbytes) { |
444 |
+ |
sprintf(errmsg, "unexpected body with server message %d", |
445 |
+ |
msg.type); |
446 |
+ |
error(INTERNAL, errmsg); |
447 |
+ |
} |
448 |
+ |
return(msg.type); |
449 |
|
readerr: |
450 |
|
if (feof(stdin)) |
451 |
|
error(SYSTEM, "server process died"); |
459 |
|
{ |
460 |
|
MSGHEAD msg; |
461 |
|
int m; |
462 |
+ |
/* consistency checks */ |
463 |
+ |
#ifdef DEBUG |
464 |
+ |
if (nbytes < 0 || nbytes > 0 & p == NULL) |
465 |
+ |
error(CONSISTENCY, "bad buffer handed to serv_request"); |
466 |
+ |
#endif |
467 |
|
/* get server's attention for big request */ |
468 |
|
if (nbytes >= BIGREQSIZ-sizeof(MSGHEAD)) { |
469 |
|
serv_request(DR_ATTEN, 0, NULL); |